From 6f62905b6a96b1b532ad23de5f17d9af7678e2b4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 18 Oct 2022 18:42:42 +0200 Subject: [PATCH 001/144] Move ObjectWriter and ObjectWritingOptions into its own namespace --- .../LlvmObjectWriter.cs} | 19 ++++++------------- .../ObjectWriter/ObjectWritingOptions.cs | 15 +++++++++++++++ .../ILCompiler.Compiler.csproj | 3 ++- .../Compiler/RyuJitCompilation.cs | 3 ++- 4 files changed, 25 insertions(+), 15 deletions(-) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/{DependencyAnalysis/ObjectWriter.cs => ObjectWriter/LlvmObjectWriter.cs} (99%) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWritingOptions.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs similarity index 99% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs index 2a7fbfda344050..8d148d4db930f9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; +using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.Text; @@ -15,12 +16,12 @@ using Internal.JitInterface; using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; -namespace ILCompiler.DependencyAnalysis +namespace ILCompiler.ObjectWriter { /// /// Object writer using src/Native/ObjWriter /// - public class ObjectWriter : IDisposable, ITypesDebugInfoWriter + public class LlvmObjectWriter : IDisposable, ITypesDebugInfoWriter { private readonly ObjectWritingOptions _options; @@ -906,7 +907,7 @@ public void EmitSymbolDefinition(int currentOffset) private IntPtr _nativeObjectWriter = IntPtr.Zero; - public ObjectWriter(string objectFilePath, NodeFactory factory, ObjectWritingOptions options) + public LlvmObjectWriter(string objectFilePath, NodeFactory factory, ObjectWritingOptions options) { var triple = GetLLVMTripleFromTarget(factory.Target); @@ -949,7 +950,7 @@ public virtual void Dispose(bool bDisposing) } } - ~ObjectWriter() + ~LlvmObjectWriter() { Dispose(false); } @@ -1004,7 +1005,7 @@ public void ResetByteRunInterruptionOffsets(ObjectData nodeContents) public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { - ObjectWriter objectWriter = new ObjectWriter(objectFilePath, factory, options); + LlvmObjectWriter objectWriter = new LlvmObjectWriter(objectFilePath, factory, options); bool succeeded = false; try @@ -1418,12 +1419,4 @@ public void LogProgress() } } } - - [Flags] - public enum ObjectWritingOptions - { - GenerateDebugInfo = 0x01, - ControlFlowGuard = 0x02, - UseDwarf5 = 0x4, - } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWritingOptions.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWritingOptions.cs new file mode 100644 index 00000000000000..a3b76e220cde2a --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWritingOptions.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +namespace ILCompiler.ObjectWriter +{ + [Flags] + public enum ObjectWritingOptions + { + GenerateDebugInfo = 0x01, + ControlFlowGuard = 0x02, + UseDwarf5 = 0x4, + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 2060c0cea69549..11090daf397298 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -556,7 +556,6 @@ - @@ -586,6 +585,8 @@ + + diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 885f2ce2026c50..e6ed38a4b83d4f 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -9,6 +9,7 @@ using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; +using ILCompiler.ObjectWriter; using ILLink.Shared; using Internal.IL; @@ -106,7 +107,7 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) if ((_compilationOptions & RyuJitCompilationOptions.ControlFlowGuardAnnotations) != 0) options |= ObjectWritingOptions.ControlFlowGuard; - ObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); } protected override void ComputeDependencyNodeDependencies(List> obj) From b3a219887c77c75dcb14e9a97b8c55e4e8676737 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 18 Oct 2022 18:58:58 +0200 Subject: [PATCH 002/144] Add external sources for Melanzana.MachO and LibObjectFile Melanzana is commit ef829f2a7ec22999bab8e07c04bf65ec1474d381 from https://github.com/filipnavara/CodeSign LibObjectFile is commit c483288f58ed7776ad0700314f62545053513086 from https://github.com/filipnavara/LibObjectFile/tree/loclist-wip --- .../tools/aot/external/Directory.Build.props | 5 + .../aot/external/Directory.Build.targets | 1 + .../aot/external/LibObjectFile/changelog.md | 32 + .../LibObjectFile/doc/ar_class_diagram.png | Bin 0 -> 37660 bytes .../LibObjectFile/doc/elf_class_diagram.png | Bin 0 -> 119276 bytes .../aot/external/LibObjectFile/doc/readme.md | 242 + .../LibObjectFile/img/libobjectfile.png | Bin 0 -> 6489 bytes .../aot/external/LibObjectFile/license.txt | 23 + .../aot/external/LibObjectFile/readme.md | 110 + .../external/LibObjectFile/src/.dockerignore | 4 + .../LibObjectFile/src/Directory.Build.props | 7 + .../aot/external/LibObjectFile/src/Dockerfile | 17 + .../LibObjectFile.CodeGen.csproj | 23 + .../LibObjectFile.CodeGen/Program.Dwarf.cs | 787 + .../src/LibObjectFile.CodeGen/Program.cs | 327 + .../src/LibObjectFile.CodeGen/dwarf.h | 1432 ++ .../src/LibObjectFile.CodeGen/elf.h | 3367 ++++ .../src/LibObjectFile.Tests/Ar/ArTestBase.cs | 42 + .../src/LibObjectFile.Tests/Ar/ArTests.cs | 431 + .../LibObjectFile.Tests/Dwarf/DwarfTests.cs | 546 + .../LibObjectFile.Tests/Elf/ElfSimpleTests.cs | 425 + .../LibObjectFile.Tests/Elf/ElfTestBase.cs | 98 + .../LibObjectFile.Tests.csproj | 50 + .../src/LibObjectFile.Tests/LinuxUtil.cs | 101 + .../LibObjectFile.Tests/TestFiles/cmnlib.b00 | Bin 0 -> 180 bytes .../src/LibObjectFile.Tests/helloworld.cpp | 5 + .../src/LibObjectFile.Tests/lib_a.cpp | 4 + .../src/LibObjectFile.Tests/lib_b.cpp | 4 + .../multiple_functions.cpp | 14 + .../src/LibObjectFile.Tests/small.cpp | 22 + .../LibObjectFile/src/LibObjectFile.sln | 59 + .../src/LibObjectFile.sln.DotSettings | 16 + .../LibObjectFile/src/LibObjectFile/Ar/Ar.cd | 65 + .../src/LibObjectFile/Ar/ArArchiveFile.cs | 381 + .../LibObjectFile/Ar/ArArchiveFileReader.cs | 352 + .../Ar/ArArchiveFileReaderOptions.cs | 41 + .../LibObjectFile/Ar/ArArchiveFileWriter.cs | 203 + .../src/LibObjectFile/Ar/ArArchiveKind.cs | 32 + .../src/LibObjectFile/Ar/ArBinaryFile.cs | 39 + .../src/LibObjectFile/Ar/ArElfFile.cs | 62 + .../src/LibObjectFile/Ar/ArFile.cs | 148 + .../LibObjectFile/Ar/ArFileEntry.Constants.cs | 84 + .../src/LibObjectFile/Ar/ArLongNamesTable.cs | 148 + .../src/LibObjectFile/Ar/ArObject.cs | 35 + .../src/LibObjectFile/Ar/ArSymbol.cs | 48 + .../src/LibObjectFile/Ar/ArSymbolTable.cs | 242 + .../src/LibObjectFile/DiagnosticBag.cs | 106 + .../src/LibObjectFile/DiagnosticId.cs | 115 + .../src/LibObjectFile/DiagnosticKind.cs | 22 + .../src/LibObjectFile/DiagnosticMessage.cs | 53 + .../LibObjectFile/Dwarf/DwarfAbbreviation.cs | 241 + .../Dwarf/DwarfAbbreviationItem.cs | 125 + .../Dwarf/DwarfAbbreviationItemKey.cs | 61 + .../Dwarf/DwarfAbbreviationTable.cs | 86 + .../LibObjectFile/Dwarf/DwarfAccessibility.cs | 15 + .../LibObjectFile/Dwarf/DwarfAddressRange.cs | 27 + .../Dwarf/DwarfAddressRangeTable.cs | 277 + .../LibObjectFile/Dwarf/DwarfAddressSize.cs | 19 + .../Dwarf/DwarfArrayOrderingKind.cs | 13 + .../src/LibObjectFile/Dwarf/DwarfAttribute.cs | 991 + .../Dwarf/DwarfAttributeDescriptor.cs | 55 + .../Dwarf/DwarfAttributeDescriptors.cs | 82 + .../Dwarf/DwarfAttributeEncoding.cs | 50 + .../Dwarf/DwarfAttributeFormEx.cs | 64 + .../Dwarf/DwarfAttributeKindEx.cs | 66 + .../Dwarf/DwarfAttributeValue.cs | 21 + .../Dwarf/DwarfCallingConventionEx.cs | 59 + .../Dwarf/DwarfCompilationUnit.cs | 81 + .../src/LibObjectFile/Dwarf/DwarfConstant.cs | 71 + .../src/LibObjectFile/Dwarf/DwarfContainer.cs | 16 + .../src/LibObjectFile/Dwarf/DwarfDIE.cs | 516 + .../Dwarf/DwarfDIEDeclaration.cs | 28 + .../Dwarf/DwarfDiscriminantListKind.cs | 13 + .../LibObjectFile/Dwarf/DwarfElfContext.cs | 341 + .../LibObjectFile/Dwarf/DwarfExpression.cs | 132 + .../src/LibObjectFile/Dwarf/DwarfFile.cs | 456 + .../src/LibObjectFile/Dwarf/DwarfFileName.cs | 30 + .../src/LibObjectFile/Dwarf/DwarfHelper.cs | 127 + .../Dwarf/DwarfIdentifierCaseKind.cs | 17 + .../LibObjectFile/Dwarf/DwarfInfoSection.cs | 105 + .../LibObjectFile/Dwarf/DwarfInlineKind.cs | 17 + .../src/LibObjectFile/Dwarf/DwarfInteger.cs | 41 + .../Dwarf/DwarfLanguageKindEx.cs | 59 + .../LibObjectFile/Dwarf/DwarfLayoutConfig.cs | 37 + .../LibObjectFile/Dwarf/DwarfLayoutContext.cs | 26 + .../src/LibObjectFile/Dwarf/DwarfLine.cs | 184 + .../Dwarf/DwarfLineProgramTable.cs | 1368 ++ .../LibObjectFile/Dwarf/DwarfLineSection.cs | 90 + .../LibObjectFile/Dwarf/DwarfLineSequence.cs | 71 + .../src/LibObjectFile/Dwarf/DwarfLineState.cs | 157 + .../src/LibObjectFile/Dwarf/DwarfLocation.cs | 55 + .../LibObjectFile/Dwarf/DwarfLocationList.cs | 84 + .../Dwarf/DwarfLocationListEntry.cs | 69 + .../Dwarf/DwarfLocationSection.cs | 89 + .../src/LibObjectFile/Dwarf/DwarfObject.cs | 92 + .../src/LibObjectFile/Dwarf/DwarfOperation.cs | 1172 ++ .../Dwarf/DwarfOperationKindEx.cs | 59 + .../src/LibObjectFile/Dwarf/DwarfPrinter.cs | 234 + .../src/LibObjectFile/Dwarf/DwarfReader.cs | 170 + .../LibObjectFile/Dwarf/DwarfReaderContext.cs | 30 + .../LibObjectFile/Dwarf/DwarfReaderWriter.cs | 173 + .../Dwarf/DwarfReaderWriterContext.cs | 29 + .../Dwarf/DwarfRelocatableSection.cs | 67 + .../LibObjectFile/Dwarf/DwarfRelocation.cs | 33 + .../Dwarf/DwarfRelocationTarget.cs | 17 + .../src/LibObjectFile/Dwarf/DwarfSection.cs | 31 + .../LibObjectFile/Dwarf/DwarfSectionLink.cs | 48 + .../Dwarf/DwarfStreamExtensions.cs | 97 + .../LibObjectFile/Dwarf/DwarfStringTable.cs | 89 + .../src/LibObjectFile/Dwarf/DwarfTagEx.cs | 62 + .../src/LibObjectFile/Dwarf/DwarfUnit.cs | 241 + .../src/LibObjectFile/Dwarf/DwarfUnitKind.cs | 63 + .../LibObjectFile/Dwarf/DwarfVirtuality.cs | 15 + .../LibObjectFile/Dwarf/DwarfVisibility.cs | 15 + .../src/LibObjectFile/Dwarf/DwarfWriter.cs | 45 + .../LibObjectFile/Dwarf/DwarfWriterContext.cs | 26 + .../src/LibObjectFile/Elf/Elf.cd | 154 + .../src/LibObjectFile/Elf/ElfArch.cs | 67 + .../src/LibObjectFile/Elf/ElfDecoderDirect.cs | 102 + .../src/LibObjectFile/Elf/ElfDecoderSwap.cs | 104 + .../src/LibObjectFile/Elf/ElfEncoderDirect.cs | 102 + .../src/LibObjectFile/Elf/ElfEncoderSwap.cs | 104 + .../src/LibObjectFile/Elf/ElfEncoding.cs | 29 + .../src/LibObjectFile/Elf/ElfFileClass.cs | 30 + .../src/LibObjectFile/Elf/ElfFilePart.cs | 93 + .../src/LibObjectFile/Elf/ElfFilePartList.cs | 82 + .../src/LibObjectFile/Elf/ElfFileType.cs | 39 + .../src/LibObjectFile/Elf/ElfHeaderFlags.cs | 58 + .../LibObjectFile/Elf/ElfNativeExtensions.cs | 104 + .../src/LibObjectFile/Elf/ElfOSAbi2.cs | 64 + .../src/LibObjectFile/Elf/ElfObject.cs | 37 + .../src/LibObjectFile/Elf/ElfObjectFile.cs | 761 + .../Elf/ElfObjectFileExtensions.cs | 83 + .../src/LibObjectFile/Elf/ElfPrinter.cs | 810 + .../src/LibObjectFile/Elf/ElfReader.cs | 60 + .../src/LibObjectFile/Elf/ElfReaderDirect.cs | 18 + .../src/LibObjectFile/Elf/ElfReaderOptions.cs | 47 + .../src/LibObjectFile/Elf/ElfReaderSwap.cs | 18 + .../LibObjectFile/Elf/ElfReader{TDecoder}.cs | 764 + .../src/LibObjectFile/Elf/ElfSection.cs | 198 + .../LibObjectFile/Elf/ElfSectionExtension.cs | 154 + .../src/LibObjectFile/Elf/ElfSectionFlags.cs | 72 + .../src/LibObjectFile/Elf/ElfSectionLink.cs | 147 + .../Elf/ElfSectionSpecialType.cs | 38 + .../src/LibObjectFile/Elf/ElfSectionType.cs | 132 + .../src/LibObjectFile/Elf/ElfSegment.cs | 140 + .../src/LibObjectFile/Elf/ElfSegmentFlags.cs | 61 + .../LibObjectFile/Elf/ElfSegmentFlagsCore.cs | 35 + .../src/LibObjectFile/Elf/ElfSegmentRange.cs | 156 + .../src/LibObjectFile/Elf/ElfSegmentType.cs | 61 + .../LibObjectFile/Elf/ElfSegmentTypeCore.cs | 52 + .../src/LibObjectFile/Elf/ElfString.cs | 111 + .../src/LibObjectFile/Elf/ElfWriter.cs | 52 + .../src/LibObjectFile/Elf/ElfWriterDirect.cs | 18 + .../src/LibObjectFile/Elf/ElfWriterSwap.cs | 18 + .../LibObjectFile/Elf/ElfWriter{TEncoder}.cs | 289 + .../src/LibObjectFile/Elf/IElfDecoder.cs | 49 + .../src/LibObjectFile/Elf/IElfEncoder.cs | 49 + .../Elf/Sections/ElfAlignedShadowSection.cs | 68 + .../Elf/Sections/ElfBinarySection.cs | 82 + .../Elf/Sections/ElfBinaryShadowSection.cs | 39 + .../Elf/Sections/ElfCustomNote.cs | 107 + .../LibObjectFile/Elf/Sections/ElfGnuNote.cs | 14 + .../Elf/Sections/ElfGnuNoteABITag.cs | 83 + .../Elf/Sections/ElfGnuNoteBuildId.cs | 58 + .../Elf/Sections/ElfGnuNoteOSKind.cs | 32 + .../src/LibObjectFile/Elf/Sections/ElfNote.cs | 48 + .../Elf/Sections/ElfNoteTable.cs | 175 + .../LibObjectFile/Elf/Sections/ElfNoteType.cs | 65 + .../Elf/Sections/ElfNullSection.cs | 45 + .../Elf/Sections/ElfProgramHeaderTable.cs | 93 + .../Elf/Sections/ElfRelocation.cs | 58 + .../Elf/Sections/ElfRelocationContext.cs | 20 + .../Elf/Sections/ElfRelocationTable.cs | 314 + .../Sections/ElfRelocationTableExtensions.cs | 235 + .../Elf/Sections/ElfRelocationType.cs | 66 + .../Sections/ElfSectionHeaderStringTable.cs | 19 + .../Elf/Sections/ElfShadowSection.cs | 19 + .../Elf/Sections/ElfStringTable.cs | 199 + .../LibObjectFile/Elf/Sections/ElfSymbol.cs | 92 + .../Elf/Sections/ElfSymbolBind.cs | 64 + .../Elf/Sections/ElfSymbolTable.cs | 256 + .../Elf/Sections/ElfSymbolType.cs | 84 + .../Elf/Sections/ElfSymbolVisibility.cs | 34 + .../src/LibObjectFile/IObjectFileNodeLink.cs | 13 + .../src/LibObjectFile/LibObjectFile.csproj | 41 + .../LibObjectFile.csproj.DotSettings | 2 + .../src/LibObjectFile/ObjectFileException.cs | 27 + .../src/LibObjectFile/ObjectFileExtensions.cs | 141 + .../src/LibObjectFile/ObjectFileNode.cs | 152 + .../LibObjectFile/ObjectFileReaderWriter.cs | 341 + .../ObjectFileStreamExtensions.cs | 234 + .../src/LibObjectFile/RelocationSize.cs | 14 + .../src/LibObjectFile/Utils/AlignHelper.cs | 41 + .../src/LibObjectFile/Utils/SliceStream.cs | 148 + .../src/LibObjectFile/Utils/ThrowHelper.cs | 84 + .../src/LibObjectFile/ValueKind.cs | 22 + .../LibObjectFile.Dwarf.generated.cs | 15181 ++++++++++++++++ .../generated/LibObjectFile.Elf.generated.cs | 14546 +++++++++++++++ .../LibObjectFile/src/dotnet-releaser.toml | 9 + .../LibObjectFile/src/objdasm/ObjDisasmApp.cs | 180 + .../LibObjectFile/src/objdasm/Program.cs | 87 + .../LibObjectFile/src/objdasm/objdasm.csproj | 19 + .../LibObjectFile/src/test-with-docker.sh | 14 + .../tools/aot/external/Melanzana/CodeSign.sln | 49 + .../external/Melanzana/Directory.Build.props | 13 + .../tools/aot/external/Melanzana/LICENSE | 21 + .../DataMemberSymbol.cs | 35 + .../Generator.Attribute.cs | 37 + .../Generator.ReadWrite.cs | 367 + .../Generator.cs | 54 + .../Melanzana.BinaryFormat.Generator.csproj | 12 + .../Melanzana.CodeSign.Tests/Data/a.out | Bin 0 -> 34976 bytes .../Melanzana.CodeSign.Tests.csproj | 31 + .../RequirementTest.cs | 27 + .../Melanzana.CodeSign.Tests/ResignTest.cs | 44 + .../AppleCertificateExtensions.cs | 74 + .../Melanzana.CodeSign/Blobs/BlobMagic.cs | 14 + .../Blobs/CmsWrapperBlob.cs | 121 + .../Blobs/CodeDirectoryBaselineHeader.cs | 22 + .../Blobs/CodeDirectoryBuilder.cs | 205 + .../Blobs/CodeDirectoryCodeLimit64Header.cs | 10 + .../Blobs/CodeDirectoryExecSegmentHeader.cs | 11 + .../Blobs/CodeDirectoryFlags.cs | 7 + .../Blobs/CodeDirectoryPreencryptHeader.cs | 10 + .../Blobs/CodeDirectoryScatterHeader.cs | 9 + .../Blobs/CodeDirectorySpecialSlot.cs | 18 + .../Blobs/CodeDirectoryTeamIdHeader.cs | 9 + .../Blobs/CodeDirectoryVersion.cs | 13 + .../Blobs/EntitlementsBlob.cs | 21 + .../Blobs/EntitlementsDerBlob.cs | 21 + .../Blobs/ExecutableSegmentFlags.cs | 13 + .../Melanzana.CodeSign/Blobs/HashType.cs | 12 + .../Blobs/HashTypeExtensions.cs | 47 + .../Melanzana/Melanzana.CodeSign/Bundle.cs | 130 + .../IntermediateG1Certificate.cer | Bin 0 -> 1062 bytes .../IntermediateG3Certificate.cer | Bin 0 -> 1109 bytes .../Certificates/RootCertificate.cer | Bin 0 -> 1215 bytes .../Melanzana.CodeSign/CodeSignAllocate.cs | 50 + .../Melanzana.CodeSign/CodeSignOptions.cs | 37 + .../Melanzana.CodeSign/Entitlements.cs | 31 + .../Melanzana.CodeSign.csproj | 26 + .../PropertyList/DerPropertyListWriter.cs | 86 + .../Melanzana.CodeSign/ProvisioningProfile.cs | 29 + .../Expression.ConversionHelpers.cs | 89 + .../Requirements/Expression.Derived.cs | 470 + .../Requirements/Expression.FromBlob.cs | 157 + .../Requirements/Expression.Static.cs | 42 + .../Requirements/Expression.cs | 9 + .../Requirements/ExpressionMatchType.cs | 21 + .../Requirements/ExpressionOperation.cs | 30 + .../Requirements/Requirement.cs | 41 + .../Requirements/RequirementSet.cs | 73 + .../Requirements/RequirementType.cs | 12 + .../Melanzana.CodeSign/ResourceBuilder.cs | 98 + .../Melanzana.CodeSign/ResourceRule.cs | 32 + .../Melanzana/Melanzana.CodeSign/Signer.cs | 459 + .../Melanzana.MachO.Tests/CreateTests.cs | 176 + .../Melanzana.MachO.Tests/Data/a.fat.out | Bin 0 -> 84128 bytes .../Melanzana.MachO.Tests/Data/a.out | Bin 0 -> 34976 bytes .../Melanzana.MachO.Tests.csproj | 31 + .../Melanzana.MachO.Tests/ReadTests.cs | 82 + .../Melanzana.MachO.Tests/RoundtripTests.cs | 48 + .../BinaryFormat/BuildToolVersionHeader.cs | 9 + .../BinaryFormat/BuildVersionCommandHeader.cs | 11 + .../BinaryFormat/DyldInfoHeader.cs | 17 + .../BinaryFormat/DylibCommandHeader.cs | 11 + .../DynamicSymbolTableCommandHeader.cs | 25 + .../BinaryFormat/FatArchHeader.cs | 12 + .../Melanzana.MachO/BinaryFormat/FatHeader.cs | 8 + .../BinaryFormat/IMachHeader.cs | 12 + .../BinaryFormat/LinkEditHeader.cs | 9 + .../BinaryFormat/LoadCommandHeader.cs | 9 + .../BinaryFormat/MachFixedName.cs | 52 + .../BinaryFormat/MachHeader.cs | 13 + .../BinaryFormat/MachHeader64.cs | 14 + .../BinaryFormat/MainCommandHeader.cs | 9 + .../BinaryFormat/Section64Header.cs | 19 + .../BinaryFormat/SectionHeader.cs | 18 + .../BinaryFormat/Segment64Header.cs | 16 + .../BinaryFormat/SegmentHeader.cs | 16 + .../BinaryFormat/SymbolHeader.cs | 11 + .../BinaryFormat/SymbolTableCommandHeader.cs | 11 + .../BinaryFormat/TwoLevelHintsHeader.cs | 9 + .../BinaryFormat/VersionMinCommandHeader.cs | 9 + .../LoadCommands/MachBuildTool.cs | 9 + .../LoadCommands/MachBuildToolVersion.cs | 9 + .../LoadCommands/MachBuildVersion.cs | 11 + .../LoadCommands/MachBuildVersionBase.cs | 13 + .../LoadCommands/MachCodeSignature.cs | 15 + .../LoadCommands/MachCustomLoadCommand.cs | 17 + .../LoadCommands/MachDataInCode.cs | 15 + .../LoadCommands/MachDyldChainedFixups.cs | 15 + .../LoadCommands/MachDyldExportsTrie.cs | 15 + .../LoadCommands/MachDyldInfo.cs | 56 + .../LoadCommands/MachDyldInfoOnly.cs | 21 + .../LoadCommands/MachDylibCodeSigningDirs.cs | 15 + .../LoadCommands/MachDylibCommand.cs | 16 + .../MachDynamicLinkEditSymbolTable.cs | 180 + .../LoadCommands/MachEntrypointCommand.cs | 12 + .../LoadCommands/MachFunctionStarts.cs | 15 + .../LoadCommands/MachLinkEdit.cs | 38 + .../MachLinkerOptimizationHint.cs | 15 + .../LoadCommands/MachLoadDylibCommand.cs | 6 + .../LoadCommands/MachLoadWeakDylibCommand.cs | 6 + .../LoadCommands/MachReexportDylibCommand.cs | 6 + .../LoadCommands/MachSection.cs | 163 + .../LoadCommands/MachSectionAttributes.cs | 17 + .../LoadCommands/MachSectionType.cs | 28 + .../LoadCommands/MachSegment.cs | 189 + .../LoadCommands/MachSegmentFlags.cs | 9 + .../LoadCommands/MachSegmentSplitInfo.cs | 15 + .../LoadCommands/MachSymbolTable.cs | 82 + .../LoadCommands/MachTwoLevelHints.cs | 26 + .../LoadCommands/MachVersionMinIOS.cs | 7 + .../LoadCommands/MachVersionMinMacOS.cs | 7 + .../LoadCommands/MachVersionMinTvOS.cs | 7 + .../LoadCommands/MachVersionMinWatchOS.cs | 7 + .../Melanzana.MachO/MachArm64CpuSubType.cs | 34 + .../Melanzana.MachO/MachArmCpuSubType.cs | 83 + .../Melanzana.MachO/MachCpuSubType.cs | 19 + .../Melanzana/Melanzana.MachO/MachCpuType.cs | 20 + .../Melanzana/Melanzana.MachO/MachFileType.cs | 17 + .../Melanzana.MachO/MachHeaderFlags.cs | 32 + .../Melanzana.MachO/MachI386CpuSubType.cs | 118 + .../Melanzana.MachO/MachLayoutOptions.cs | 32 + .../Melanzana.MachO/MachLinkEditData.cs | 67 + .../Melanzana.MachO/MachLoadCommand.cs | 11 + .../Melanzana.MachO/MachLoadCommandType.cs | 63 + .../Melanzana/Melanzana.MachO/MachMagic.cs | 12 + .../Melanzana.MachO/MachObjectFile.cs | 321 + .../Melanzana/Melanzana.MachO/MachPlatform.cs | 16 + .../Melanzana/Melanzana.MachO/MachReader.cs | 371 + .../Melanzana.MachO/MachRelocation.cs | 41 + .../MachRelocationCollection.cs | 146 + .../Melanzana.MachO/MachRelocationType.cs | 35 + .../Melanzana/Melanzana.MachO/MachSymbol.cs | 16 + .../Melanzana.MachO/MachSymbolDescriptor.cs | 19 + .../MachSymbolTableCollection.cs | 222 + .../Melanzana.MachO/MachSymbolType.cs | 17 + .../Melanzana.MachO/MachVmProtection.cs | 11 + .../Melanzana/Melanzana.MachO/MachWriter.cs | 562 + .../Melanzana.MachO/MachX8664CpuSubType.cs | 23 + .../Melanzana.MachO/Melanzana.MachO.csproj | 17 + .../Melanzana/Melanzana.MachO/README.md | 18 + .../Melanzana.Streams.csproj | 9 + .../Melanzana.Streams/SliceStream.cs | 152 + .../Melanzana.Streams/StreamExtensions.cs | 34 + .../UnclosableMemoryStream.cs | 9 + .../tools/aot/external/Melanzana/README.md | 9 + .../external/Melanzana/codesign/Program.cs | 103 + .../Melanzana/codesign/codesign.csproj | 23 + .../tools/aot/external/Melanzana/version.json | 8 + 353 files changed, 66595 insertions(+) create mode 100644 src/coreclr/tools/aot/external/Directory.Build.props create mode 100644 src/coreclr/tools/aot/external/Directory.Build.targets create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/changelog.md create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/readme.md create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/license.txt create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/readme.md create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/helloworld.cpp create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj create mode 100755 src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh create mode 100644 src/coreclr/tools/aot/external/Melanzana/CodeSign.sln create mode 100644 src/coreclr/tools/aot/external/Melanzana/Directory.Build.props create mode 100644 src/coreclr/tools/aot/external/Melanzana/LICENSE create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj create mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/RootCertificate.cer create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs create mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out create mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/README.md create mode 100644 src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs create mode 100644 src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj create mode 100644 src/coreclr/tools/aot/external/Melanzana/version.json diff --git a/src/coreclr/tools/aot/external/Directory.Build.props b/src/coreclr/tools/aot/external/Directory.Build.props new file mode 100644 index 00000000000000..fe6c0d71e74a72 --- /dev/null +++ b/src/coreclr/tools/aot/external/Directory.Build.props @@ -0,0 +1,5 @@ + + + true + + diff --git a/src/coreclr/tools/aot/external/Directory.Build.targets b/src/coreclr/tools/aot/external/Directory.Build.targets new file mode 100644 index 00000000000000..058246e4086204 --- /dev/null +++ b/src/coreclr/tools/aot/external/Directory.Build.targets @@ -0,0 +1 @@ + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/changelog.md b/src/coreclr/tools/aot/external/LibObjectFile/changelog.md new file mode 100644 index 00000000000000..5eba39943b6e2f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/changelog.md @@ -0,0 +1,32 @@ +# Changelog + +## 0.3.5 (11 Feb 2020) +- Fix a bug with bss sections not being correctly handled when trying to write them to a stream +- Add shadow sections between sections even when no-program headers are in the file. + +## 0.3.4 (4 Jan 2020) +- Fix a bug if a program header has an invalid shadow section that does not correspond to a region in the file + +## 0.3.3 (24 Dec 2019) +- Fix an invalid error when a program header size is bigger than expected + +## 0.3.2 (22 Dec 2019) +- Fix a bug when reading ElfObjectFile from an existing ELF where ObjectFile.FileClass/Encoding/Version/OSABI/AbiVersion was not actually deserialized. + +## 0.3.1 (18 Dec 2019) +- Fix creation of DWARF sections from scratch + +## 0.3.0 (18 Dec 2019) +- Add support for DWARF Version 4 (missing only .debug_frame) +- Add support for layouting sections independently of the order defined sections header + +## 0.2.1 (17 Nov 2019) +- Add verify for PT_LOAD segment align requirements + +## 0.2.0 (17 Nov 2019) +- Add support for ElfNoteTable +- Add XML documentation and user manual +- Removed some accessors that should not have been public + +## 0.1.0 (16 Nov 2019) +- Initial version with support for ELF file format \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png b/src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..94017777fbbce96643f6a82b2b37709511591cb7 GIT binary patch literal 37660 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 literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png b/src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..c57837fe14afa74cee85b47345fce7643d987dd1 GIT binary patch literal 119276 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�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≤yZ1A7 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

YL7u9*yk*NZ??3?c3`@d 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 vB%`-(TlBqz-Z+5;|Kg9|zE=F^ Note: The `ArSymbolTable` instance must be the first entry in the `ArArchiveFile.Files` before other file entries + +```c# +var arFile = new ArArchiveFile(); +// Create Symbol table, added 1st to ArArchiveFile +var symbolTable = new ArSymbolTable(); +arFile.AddFile(symbolTable); +// Create an ELF +var elf = new ElfObjectFile(); +// ... fill elf, add symbols +arFile.AddFile(elf); +// Add a symbol entry +symbolTable.Symbols.Add(new ArSymbol("my_symbol", elf)); +``` +### Links + +- [Archive ar file format (Wikipedia)](https://en.wikipedia.org/wiki/Ar_(Unix)) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png b/src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png new file mode 100644 index 0000000000000000000000000000000000000000..13a891acfcaf4f2c77f4024fb956f4cd22961b70 GIT binary patch literal 6489 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 + +LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...) + +> NOTE: Currently LibObjectFile supports only the following file format: +> +> - **ELF** object-file format +> - **DWARF** debugging format (version 4) +> - **Archive `ar`** file format (Common, GNU and BSD variants) +> +> There is a longer term plan to support other file formats (e.g COFF, MACH-O, .lib) but as I don't +> have a need for them right now, it is left as an exercise for PR contributors! ;) + +## Usage + +```C# +// Reads an ELF file +using var inStream = File.OpenRead("helloworld"); +var elf = ElfObjectFile.Read(inStream); +foreach(var section in elf.Sections) +{ + Console.WriteLine(section.Name); +} +// Print the content of the ELF as readelf output +elf.Print(Console.Out); +// Write the ElfObjectFile to another file on the disk +using var outStream = File.OpenWrite("helloworld2"); +elf.Write(outStream); +``` + +## Features +- Full support of Archive `ar` file format including Common, GNU and BSD variants. +- Good support for the ELF file format: + - Read and write from/to a `System.IO.Stream` + - Handling of LSB/MSB + - Support the following sections: + - String Table + - Symbol Table + - Relocation Table: supported I386, X86_64, ARM and AARCH64 relocations (others can be exposed by adding some mappings) + - Note Table + - Other sections fallback to `ElfCustomSection` + - Program headers with or without sections + - Print with `readelf` similar output +- Support for DWARF debugging format: + - Partial support of Version 4 (currently still the default for GCC) + - Support for the sections: `.debug_info`, `.debug_line`, `.debug_aranges`, `.debug_abbrev` and `.debug_str` + - Support for Dwarf expressions + - High level interface, automatic layout/offsets between sections. + - Integration with ELF to support easy reading/writing back + - Support for relocatable sections +- Use of a Diagnostics API to validate file format (on read/before write) +- Library requiring .NET `netstandard2.1`+ and compatible with `netcoreapp3.0`+ + +## Documentation + +The [doc/readme.md](doc/readme.md) explains how the library is designed and can be used. + +## Known Issues + +PR Welcome if you are willing to contribute to one of these issues: + +- [ ] Add more unit tests + +### ELF +There are still a few missing implementation of `ElfSection` for completeness: + +- [ ] Dynamic Linking Table (`SHT_DYNAMIC`) +- [ ] Version Symbol Table (`SHT_VERSYM`) +- [ ] Version Needs Table (`SHT_VERNEED`) + +These sections are currently loaded as `ElfCustomSection` but should have their own ElfXXXTable (e.g `ElfDynamicLinkingTable`, `ElfVersionSymbolTable`...) + +### DWARF + +- [ ] Version 4: support for `.debug_types`, `.debug_frame`, `.debug_loc`, `.debug_ranges`, `.debug_pubnames`, `.debug_pubtypes`, `.debug_macinfo` section +- [ ] Version 5 + +### Other file formats +In a future version I would like to implement the following file format: + +- [ ] COFF +- [ ] Mach-O +- [ ] Portable in Memory file format to easily convert between ELF/COFF/Mach-O file formats. + +## Download + +LibObjectFile is available as a NuGet package: [![NuGet](https://img.shields.io/nuget/v/LibObjectFile.svg)](https://www.nuget.org/packages/LibObjectFile/) + +## Build + +In order to build LibObjectFile, you need to have installed the [.NET Core 3.0 SDK](https://www.microsoft.com/net/core). + +Running the tests require Ubuntu 18.04. `dotnet test` will work on Windows (via WSL) and on that version of Ubuntu. +If you're using macOS or another Linux, there's a Dockerfile and a helper script under `src` to run tests in the right OS version. + +## License + +This software is released under the [BSD-Clause 2 license](https://github.com/xoofx/LibObjectFile/blob/master/license.txt). + +## Author + +Alexandre MUTEL aka [xoofx](http://xoofx.com) + +## Supporters + +Supports this project with a monthly donation and help me continue improving it. \[[Become a supporter](https://github.com/sponsors/xoofx)\] + +[bruno-garcia](https://github.com/bruno-garcia) \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore b/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore new file mode 100644 index 00000000000000..ac752d15f985a8 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +.dockerignore +**/bin/ +**/obj/ \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props b/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props new file mode 100644 index 00000000000000..2755547fe39a5d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + True + True + $(NoWarn);CS1591;CS1573;CS1574;CS1734;CS0419 + + \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile b/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile new file mode 100644 index 00000000000000..4ae896b1e7059c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get -y install \ + # .NET Core SDK needs: https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?pivots=os-linux&tabs=netcore31#supported-operating-systems + curl libcurl4 libssl1.0.0 zlib1g libicu60 libkrb5-3 liblttng-ust0 \ + # Tests need: + build-essential gcc + +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 +RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.0.100 + +ENV PATH="/root/.dotnet:${PATH}" +RUN dotnet --info + +WORKDIR /src + +CMD dotnet test \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj new file mode 100644 index 00000000000000..0e8fa3e0eae47b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj @@ -0,0 +1,23 @@ + + + net6.0 + Exe + false + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs new file mode 100644 index 00000000000000..f7a143908e07e9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs @@ -0,0 +1,787 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using CppAst.CodeGen.CSharp; + +namespace LibObjectFile.CodeGen +{ + partial class Program + { + private static void GenerateDwarf() + { + var cppOptions = new CSharpConverterOptions() + { + DefaultClassLib = "DwarfNative", + DefaultNamespace = "LibObjectFile.Dwarf", + DefaultOutputFilePath = "/LibObjectFile.Dwarf.generated.cs", + DefaultDllImportNameAndArguments = "NotUsed", + MappingRules = + { + map => map.MapMacroToConst("^DW_TAG_.*", "unsigned short"), + map => map.MapMacroToConst("^DW_FORM_.*", "unsigned short"), + map => map.MapMacroToConst("^DW_AT_.*", "unsigned short"), + map => map.MapMacroToConst("^DW_LN[ES]_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_IDX_.*", "unsigned short"), + map => map.MapMacroToConst("^DW_LANG_.*", "unsigned short"), + map => map.MapMacroToConst("^DW_ID_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_CC_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_ISA_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_CHILDREN_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_OP_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_ACCESS_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_VIS_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_VIRTUALITY_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_INL_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_ORD_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_DSC_.*", "unsigned char"), + map => map.MapMacroToConst("^DW_UT_.*", "unsigned char"), + } + }; + + cppOptions.GenerateEnumItemAsFields = false; + cppOptions.IncludeFolders.Add(Environment.CurrentDirectory); + + var csCompilation = CSharpConverter.Convert(@"#include ""dwarf.h""", cppOptions); + + AssertCompilation(csCompilation); + + // Add pragma + var csFile = csCompilation.Members.OfType().First(); + var ns = csFile.Members.OfType().First(); + csFile.Members.Insert(csFile.Members.IndexOf(ns), new CSharpLineElement("#pragma warning disable 1591") ); + + ProcessEnum(cppOptions, csCompilation, "DW_AT_", "DwarfAttributeKind"); + ProcessEnum(cppOptions, csCompilation, "DW_FORM_", "DwarfAttributeForm"); + ProcessEnum(cppOptions, csCompilation, "DW_TAG_", "DwarfTag"); + ProcessEnum(cppOptions, csCompilation, "DW_OP_", "DwarfOperationKind"); + ProcessEnum(cppOptions, csCompilation, "DW_LANG_", "DwarfLanguageKind"); + ProcessEnum(cppOptions, csCompilation, "DW_CC_", "DwarfCallingConvention"); + ProcessEnum(cppOptions, csCompilation, "DW_UT_", "DwarfUnitKind"); + + GenerateDwarfAttributes(ns); + GenerateDwarfDIE(ns); + + csCompilation.DumpTo(GetCodeWriter(Path.Combine("LibObjectFile", "generated"))); + } + + private static Dictionary MapAttributeCompactNameToType = new Dictionary(); + + private static void GenerateDwarfAttributes(CSharpNamespace ns) + { + var alreadyDone = new HashSet(); + + var csHelper = new CSharpClass("DwarfHelper") + { + Modifiers = CSharpModifiers.Static | CSharpModifiers.Partial, + Visibility = CSharpVisibility.Public + }; + ns.Members.Add(csHelper); + + var csField = new CSharpField("AttributeToEncoding") + { + Modifiers = CSharpModifiers.Static | CSharpModifiers.ReadOnly, + Visibility = CSharpVisibility.Private, + FieldType = new CSharpArrayType(new CSharpFreeType("DwarfAttributeEncoding")) + }; + csHelper.Members.Add(csField); + + var fieldArrayBuilder = new StringBuilder(); + fieldArrayBuilder.AppendLine("new DwarfAttributeEncoding[] {"); + + int currentAttributeIndex = 0; + + foreach (var attrEncoding in MapAttributeToEncoding) + { + var attrEncodingParts = attrEncoding.Split(' ', StringSplitOptions.RemoveEmptyEntries); + var attributeName = attrEncodingParts[0]; + var attributeIndex = int.Parse(attrEncodingParts[1].Substring(2), System.Globalization.NumberStyles.HexNumber); + var rawName = attributeName.Substring("DW_AT_".Length); + //var csharpName = CSharpifyName(rawName); + + string attrType = "object"; + var kind = AttributeKind.Managed; + + if (attributeName == "DW_AT_accessibility") + { + attrType = "DwarfAccessibility"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_visibility") + { + attrType = "DwarfVisibility"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_virtuality") + { + attrType = "DwarfVirtuality"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_language") + { + attrType = "DwarfLanguageKind"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_identifier_case") + { + attrType = "DwarfIdentifierCaseKind"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_calling_convention") + { + attrType = "DwarfCallingConvention"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_inline") + { + attrType = "DwarfInlineKind"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_ordering") + { + attrType = "DwarfArrayOrderingKind"; + kind = AttributeKind.ValueType; + } + else if (attributeName == "DW_AT_discr_list") + { + attrType = "DwarfDiscriminantListKind"; + kind = AttributeKind.ValueType; + } + else if (attrEncodingParts.Length == 3) + { + switch (attrEncodingParts[2]) + { + case "string": + attrType = "string"; + break; + + case "flag": + attrType = "bool"; + kind = AttributeKind.ValueType; + break; + + case "reference": + attrType = "DwarfDIE"; + break; + + case "address": + attrType = "ulong"; + kind = AttributeKind.ValueType; + break; + + case "constant": + attrType = "DwarfConstant"; + kind = AttributeKind.ValueType; + break; + + case "lineptr": + attrType = "DwarfLineProgramTable"; + break; + + case "exprloc": + attrType = "DwarfExpression"; + break; + + case "loclist": + case "loclistptr": + attrType = "DwarfLocation"; + break; + + case "addrptr": + case "macptr": + case "rnglist": + case "rangelistptr": + case "rnglistsptr": + case "stroffsetsptr": + attrType = "ulong"; + kind = AttributeKind.ValueType; + break; + } + } + else if (attrEncodingParts.Length > 3) + { + var key = string.Join(" ", attrEncodingParts.Skip(2).ToArray()); + alreadyDone.Add(key); + + Console.WriteLine(attrEncoding); + + bool hasConstant = false; + for (int i = 2; i < attrEncodingParts.Length; i++) + { + switch (attrEncodingParts[i]) + { + case "loclist": + case "loclistptr": + attrType = "DwarfLocation"; + kind = AttributeKind.ValueType; + goto next; + case "constant": + hasConstant = true; + break; + } + } + + if (hasConstant) + { + attrType = "DwarfConstant"; + kind = AttributeKind.ValueType; + } + } + + next: + + MapAttributeCompactNameToType.Add(attributeName.Replace("_", string.Empty), new AttributeMapping(rawName, attrType, kind)); + + const int PaddingEncodingName = 50; + + for (; currentAttributeIndex < attributeIndex; currentAttributeIndex++) + { + fieldArrayBuilder.AppendLine($" {"DwarfAttributeEncoding.None",-PaddingEncodingName}, // 0x{currentAttributeIndex:x2} (undefined)"); + } + + for (int i = 2; i < attrEncodingParts.Length; i++) + { + string name; + switch (attrEncodingParts[i]) + { + case "string": + name = "String"; + break; + + case "flag": + name = "Flag"; + break; + + case "block": + name = "Block"; + break; + + case "reference": + name = "Reference"; + break; + + case "address": + name = "Address"; + break; + + case "constant": + name = "Constant"; + break; + + case "lineptr": + name = "LinePointer"; + break; + + case "exprloc": + name = "ExpressionLocation"; + break; + + case "loclist": + name = "LocationList"; + break; + + case "loclistptr": + name = "LocationListPointer"; + break; + + case "loclistsptr": + name = "LocationListsPointer"; + break; + + case "addrptr": + name = "AddressPointer"; + break; + + case "macptr": + name = "MacroPointer"; + break; + + case "rnglist": + name = "RangeList"; + break; + + case "rangelistptr": + name = "RangeListPointer"; + break; + + case "rnglistsptr": + name = "RangeListsPointer"; + break; + + case "stroffsetsptr": + name = "StringOffsetPointer"; + break; + default: + throw new InvalidOperationException($"Unknown encoding {attrEncodingParts[i]}"); + } + + bool isLast = i + 1 == attrEncodingParts.Length; + + fieldArrayBuilder.Append($" {"DwarfAttributeEncoding." + name + (isLast ? "" : " | "),-PaddingEncodingName}"); + + if (isLast) + { + fieldArrayBuilder.Append($", // 0x{currentAttributeIndex:x2} {attributeName} "); + } + fieldArrayBuilder.AppendLine(); + + } + + currentAttributeIndex++; + } + + fieldArrayBuilder.Append(" }"); + csField.InitValue = fieldArrayBuilder.ToString(); + + Console.WriteLine(); + foreach (var key in alreadyDone.ToArray().OrderBy(x => x)) + { + Console.WriteLine(key); + } + } + + struct AttributeMapping + { + public AttributeMapping(string rawName, string attributeType, AttributeKind kind) + { + RawName = rawName; + AttributeType = attributeType; + Kind = kind; + } + + public string RawName { get; set; } + + public string AttributeType { get; set; } + + public AttributeKind Kind { get; set; } + + public override string ToString() + { + return $"{nameof(RawName)}: {RawName}, {nameof(AttributeType)}: {AttributeType}, {nameof(Kind)}: {Kind}"; + } + } + + enum AttributeKind + { + Managed, + + ValueType, + + Link, + } + + private static void GenerateDwarfDIE(CSharpNamespace ns) + { + var file = File.ReadAllLines(@"C:\code\LibObjectFile\ext\dwarf-specs\attributesbytag.tex"); + + var regexDWTag = new Regex(@"^\\(DWTAG\w+)"); + var regexDWAT = new Regex(@"^&\\(DWAT\w+)"); + + int state = 0; + + string currentCompactTagName = null; + CSharpClass currentDIE = null; + + var dieClasses = new List(); + var dieTags = new List(); + + foreach (var line in file) + { + if (state == 0) + { + if (line.StartsWith(@"\begin{longtable}")) + { + continue; + } + else + { + state = 1; + } + } + var match = regexDWTag.Match(line); + if (match.Success) + { + var compactTagName = match.Groups[1].Value; + if (compactTagName == currentCompactTagName) + { + continue; + } + currentCompactTagName = compactTagName; + var fullTagName = MapTagCompactNameToFullName[compactTagName]; + dieTags.Add(fullTagName); + var csDIEName = fullTagName.Substring("DW_TAG_".Length); + csDIEName = CSharpifyName(csDIEName); + currentDIE = new CSharpClass($"DwarfDIE{csDIEName}"); + currentDIE.BaseTypes.Add(new CSharpFreeType("DwarfDIE")); + ns.Members.Add(currentDIE); + + var csConstructor = new CSharpMethod(); + csConstructor.IsConstructor = true; + csConstructor.Body = (writer, element) => writer.WriteLine($"this.Tag = (DwarfTag)DwarfNative.{fullTagName};"); + currentDIE.Members.Add(csConstructor); + + dieClasses.Add(currentDIE); + } + else + { + match = regexDWAT.Match(line); + if (match.Success) + { + var compactAttrName = match.Groups[1].Value; + var csProperty = CreatePropertyFromDwarfAttributeName(compactAttrName); + currentDIE.Members.Add(csProperty); + + // The DW_AT_description attribute can be used on any debugging information + // entry that may have a DW_AT_name attribute. For simplicity, this attribute is + // not explicitly shown. + if (compactAttrName == "DWATname") + { + csProperty = CreatePropertyFromDwarfAttributeName("DWATdescription"); + currentDIE.Members.Add(csProperty); + } + + + } + else if (currentDIE != null && line.Contains("{DECL}")) + { + currentDIE.BaseTypes[0] = new CSharpFreeType("DwarfDIEDeclaration"); + } + } + } + + // Generate the DIEHelper class + var dieHelperClass = new CSharpClass("DIEHelper") + { + Modifiers = CSharpModifiers.Partial | CSharpModifiers.Static, + Visibility = CSharpVisibility.Internal + }; + ns.Members.Add(dieHelperClass); + var dieHelperMethod = new CSharpMethod() + { + Name = "ConvertTagToDwarfDIE", + Modifiers = CSharpModifiers.Static, + Visibility = CSharpVisibility.Public + }; + dieHelperClass.Members.Add(dieHelperMethod); + + dieHelperMethod.Parameters.Add(new CSharpParameter("tag") { ParameterType = CSharpPrimitiveType.UShort() }); + dieHelperMethod.ReturnType = new CSharpFreeType("DwarfDIE"); + + dieHelperMethod.Body = (writer, element) => { + + writer.WriteLine("switch (tag)"); + writer.OpenBraceBlock(); + + for (var i = 0; i < dieClasses.Count; i++) + { + var dieCls = dieClasses[i]; + var dieTag = dieTags[i]; + writer.WriteLine($"case DwarfNative.{dieTag}:"); + writer.Indent(); + writer.WriteLine($"return new {dieCls.Name}();"); + writer.UnIndent(); + } + + writer.CloseBraceBlock(); + writer.WriteLine("return new DwarfDIE();"); + }; + } + + private static CSharpProperty CreatePropertyFromDwarfAttributeName(string compactAttrName) + { + if (compactAttrName == "DWATuseUTFeight") + { + compactAttrName = "DWATuseUTF8"; + } + + var map = MapAttributeCompactNameToType[compactAttrName]; + var rawAttrName = map.RawName; + var attrType = map.AttributeType; + + var propertyName = CSharpifyName(map.RawName); + + var csProperty = new CSharpProperty(propertyName) + { + Visibility = CSharpVisibility.Public, + ReturnType = new CSharpFreeType(map.Kind == AttributeKind.Managed ? attrType : $"{attrType}?"), + }; + + var attrName = CSharpifyName(rawAttrName); + + switch (map.Kind) + { + case AttributeKind.Managed: + csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeValue<{attrType}>(DwarfAttributeKind.{attrName});"); + csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeValue<{attrType}>(DwarfAttributeKind.{attrName}, value);"); + break; + case AttributeKind.ValueType: + if (map.AttributeType == "DwarfConstant") + { + csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeConstantOpt(DwarfAttributeKind.{attrName});"); + csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeConstantOpt(DwarfAttributeKind.{attrName}, value);"); + } + else if (map.AttributeType == "DwarfLocation") + { + csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeLocationOpt(DwarfAttributeKind.{attrName});"); + csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeLocationOpt(DwarfAttributeKind.{attrName}, value);"); + } + else + { + csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeValueOpt<{attrType}>(DwarfAttributeKind.{attrName});"); + csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeValueOpt<{attrType}>(DwarfAttributeKind.{attrName}, value);"); + } + break; + case AttributeKind.Link: + csProperty.GetBody = (writer, element) => + { + writer.WriteLine($"var attr = FindAttributeByKey(DwarfAttributeKind.{attrName});"); + writer.WriteLine($"return attr == null ? null : new {attrType}(attr.ValueAsU64, attr.ValueAsObject);"); + }; + csProperty.SetBody = (writer, element) => { writer.WriteLine($"SetAttributeLinkValue(DwarfAttributeKind.{attrName}, value);"); }; + break; + default: + throw new ArgumentOutOfRangeException(); + } + + return csProperty; + } + + private static string CSharpifyName(string rawName) + { + if (rawName.EndsWith("_pc")) + { + rawName = rawName.Replace("_pc", "_PC"); + } + + var newName = new StringBuilder(); + bool upperCase = true; + for (var i = 0; i < rawName.Length; i++) + { + var c = rawName[i]; + if (c == '_') + { + upperCase = true; + continue; + } + + if (upperCase) + { + newName.Append(char.ToUpperInvariant(c)); + upperCase = false; + } + else + { + newName.Append(c); + } + } + return newName.ToString(); + } + + + private static Dictionary MapTagCompactNameToFullName = new Dictionary() + { + {"DWTAGaccessdeclaration", "DW_TAG_access_declaration"}, + {"DWTAGarraytype", "DW_TAG_array_type"}, + {"DWTAGatomictype", "DW_TAG_atomic_type"}, + {"DWTAGbasetype", "DW_TAG_base_type"}, + {"DWTAGcallsite", "DW_TAG_call_site"}, + {"DWTAGcallsiteparameter", "DW_TAG_call_site_parameter"}, + {"DWTAGcatchblock", "DW_TAG_catch_block"}, + {"DWTAGclasstype", "DW_TAG_class_type"}, + {"DWTAGcoarraytype", "DW_TAG_coarray_type"}, + {"DWTAGcommonblock", "DW_TAG_common_block"}, + {"DWTAGcommoninclusion", "DW_TAG_common_inclusion"}, + {"DWTAGcompileunit", "DW_TAG_compile_unit"}, + {"DWTAGcondition", "DW_TAG_condition"}, + {"DWTAGconsttype", "DW_TAG_const_type"}, + {"DWTAGconstant", "DW_TAG_constant"}, + {"DWTAGdescriptortype", "DW_TAG_descriptor_type"}, + {"DWTAGdwarfprocedure", "DW_TAG_dwarf_procedure"}, + {"DWTAGdynamictype", "DW_TAG_dynamic_type"}, + {"DWTAGentrypoint", "DW_TAG_entry_point"}, + {"DWTAGenumerationtype", "DW_TAG_enumeration_type"}, + {"DWTAGenumerator", "DW_TAG_enumerator"}, + {"DWTAGfiletype", "DW_TAG_file_type"}, + {"DWTAGformalparameter", "DW_TAG_formal_parameter"}, + {"DWTAGfriend", "DW_TAG_friend"}, + {"DWTAGgenericsubrange", "DW_TAG_generic_subrange"}, + {"DWTAGhiuser", "DW_TAG_hi_user"}, + {"DWTAGimmutabletype", "DW_TAG_immutable_type"}, + {"DWTAGimporteddeclaration", "DW_TAG_imported_declaration"}, + {"DWTAGimportedmodule", "DW_TAG_imported_module"}, + {"DWTAGimportedunit", "DW_TAG_imported_unit"}, + {"DWTAGinheritance", "DW_TAG_inheritance"}, + {"DWTAGinlinedsubroutine", "DW_TAG_inlined_subroutine"}, + {"DWTAGinterfacetype", "DW_TAG_interface_type"}, + {"DWTAGlabel", "DW_TAG_label"}, + {"DWTAGlexicalblock", "DW_TAG_lexical_block"}, + {"DWTAGlouser", "DW_TAG_lo_user"}, + {"DWTAGmember", "DW_TAG_member"}, + {"DWTAGmodule", "DW_TAG_module"}, + {"DWTAGnamelist", "DW_TAG_namelist"}, + {"DWTAGnamelistitem", "DW_TAG_namelist_item"}, + {"DWTAGnamespace", "DW_TAG_namespace"}, + {"DWTAGpackedtype", "DW_TAG_packed_type"}, + {"DWTAGpartialunit", "DW_TAG_partial_unit"}, + {"DWTAGpointertype", "DW_TAG_pointer_type"}, + {"DWTAGptrtomembertype", "DW_TAG_ptr_to_member_type"}, + {"DWTAGreferencetype", "DW_TAG_reference_type"}, + {"DWTAGrestricttype", "DW_TAG_restrict_type"}, + {"DWTAGrvaluereferencetype", "DW_TAG_rvalue_reference_type"}, + {"DWTAGsettype", "DW_TAG_set_type"}, + {"DWTAGsharedtype", "DW_TAG_shared_type"}, + {"DWTAGskeletonunit", "DW_TAG_skeleton_unit"}, + {"DWTAGstringtype", "DW_TAG_string_type"}, + {"DWTAGstructuretype", "DW_TAG_structure_type"}, + {"DWTAGsubprogram", "DW_TAG_subprogram"}, + {"DWTAGsubrangetype", "DW_TAG_subrange_type"}, + {"DWTAGsubroutinetype", "DW_TAG_subroutine_type"}, + {"DWTAGtemplatealias", "DW_TAG_template_alias"}, + {"DWTAGtemplatetypeparameter", "DW_TAG_template_type_parameter"}, + {"DWTAGtemplatevalueparameter", "DW_TAG_template_value_parameter"}, + {"DWTAGthrowntype", "DW_TAG_thrown_type"}, + {"DWTAGtryblock", "DW_TAG_try_block"}, + {"DWTAGtypedef", "DW_TAG_typedef"}, + {"DWTAGtypeunit", "DW_TAG_type_unit"}, + {"DWTAGuniontype", "DW_TAG_union_type"}, + {"DWTAGunspecifiedparameters", "DW_TAG_unspecified_parameters"}, + {"DWTAGunspecifiedtype", "DW_TAG_unspecified_type"}, + {"DWTAGvariable", "DW_TAG_variable"}, + {"DWTAGvariant", "DW_TAG_variant"}, + {"DWTAGvariantpart", "DW_TAG_variant_part"}, + {"DWTAGvolatiletype", "DW_TAG_volatile_type"}, + {"DWTAGwithstmt", "DW_TAG_with_stmt"}, + }; + + // Extract from Dwarf 5 specs - Figure 20, Attribute encodings + private static readonly string[] MapAttributeToEncoding = new string[] + { + "DW_AT_sibling 0x01 reference", + "DW_AT_location 0x02 exprloc loclist", + "DW_AT_name 0x03 string", + "DW_AT_ordering 0x09 constant", + "DW_AT_byte_size 0x0b constant exprloc reference", + "DW_AT_bit_offset 0x0c constant exprloc reference", + "DW_AT_bit_size 0x0d constant exprloc reference", + "DW_AT_stmt_list 0x10 lineptr", + "DW_AT_low_pc 0x11 address", + "DW_AT_high_pc 0x12 address constant", + "DW_AT_language 0x13 constant", + "DW_AT_discr 0x15 reference", + "DW_AT_discr_value 0x16 constant", + "DW_AT_visibility 0x17 constant", + "DW_AT_import 0x18 reference", + "DW_AT_string_length 0x19 exprloc loclistptr", + "DW_AT_common_reference 0x1a reference", + "DW_AT_comp_dir 0x1b string", + "DW_AT_const_value 0x1c block constant string ", + "DW_AT_containing_type 0x1d reference", + "DW_AT_default_value 0x1e reference", + "DW_AT_inline 0x20 constant", + "DW_AT_is_optional 0x21 flag", + "DW_AT_lower_bound 0x22 constant exprloc reference", + "DW_AT_producer 0x25 string", + "DW_AT_prototyped 0x27 flag", + "DW_AT_return_addr 0x2a exprloc loclistptr", + "DW_AT_start_scope 0x2c constant rangelistptr", + "DW_AT_bit_stride 0x2e constant exprloc reference", + "DW_AT_upper_bound 0x2f constant exprloc reference", + "DW_AT_abstract_origin 0x31 reference", + "DW_AT_accessibility 0x32 constant", + "DW_AT_address_class 0x33 constant", + "DW_AT_artificial 0x34 flag", + "DW_AT_base_types 0x35 reference", + "DW_AT_calling_convention 0x36 constant", + "DW_AT_count 0x37 constant exprloc reference", + "DW_AT_data_member_location 0x38 constant exprloc loclistptr", + "DW_AT_decl_column 0x39 constant", + "DW_AT_decl_file 0x3a constant", + "DW_AT_decl_line 0x3b constant", + "DW_AT_declaration 0x3c flag", + "DW_AT_discr_list 0x3d block", + "DW_AT_encoding 0x3e constant", + "DW_AT_external 0x3f flag", + "DW_AT_frame_base 0x40 exprloc loclistptr", + "DW_AT_friend 0x41 reference", + "DW_AT_identifier_case 0x42 constant", + "DW_AT_macro_info 0x43 macptr", + "DW_AT_namelist_item 0x44 reference", + "DW_AT_priority 0x45 reference", + "DW_AT_segment 0x46 exprloc loclistptr", + "DW_AT_specification 0x47 reference", + "DW_AT_static_link 0x48 exprloc loclistptr", + "DW_AT_type 0x49 reference", + "DW_AT_use_location 0x4a exprloc loclistptr", + "DW_AT_variable_parameter 0x4b flag", + "DW_AT_virtuality 0x4c constant", + "DW_AT_vtable_elem_location 0x4d exprloc loclistptr ", + "DW_AT_allocated 0x4e constant exprloc reference", + "DW_AT_associated 0x4f constant exprloc reference", + "DW_AT_data_location 0x50 exprloc", + "DW_AT_byte_stride 0x51 constant exprloc reference", + "DW_AT_entry_pc 0x52 address", + "DW_AT_use_UTF8 0x53 flag", + "DW_AT_extension 0x54 reference", + "DW_AT_ranges 0x55 rangelistptr", + "DW_AT_trampoline 0x56 address flag reference string", + "DW_AT_call_column 0x57 constant", + "DW_AT_call_file 0x58 constant", + "DW_AT_call_line 0x59 constant", + "DW_AT_description 0x5a string", + "DW_AT_binary_scale 0x5b constant", + "DW_AT_decimal_scale 0x5c constant", + "DW_AT_small 0x5d reference", + "DW_AT_decimal_sign 0x5e constant", + "DW_AT_digit_count 0x5f constant", + "DW_AT_picture_string 0x60 string", + "DW_AT_mutable 0x61 flag ", + "DW_AT_threads_scaled 0x62 flag", + "DW_AT_explicit 0x63 flag", + "DW_AT_object_pointer 0x64 reference", + "DW_AT_endianity 0x65 constant", + "DW_AT_elemental 0x66 flag", + "DW_AT_pure 0x67 flag", + "DW_AT_recursive 0x68 flag", + "DW_AT_signature 0x69 reference", + "DW_AT_main_subprogram 0x6a flag", + "DW_AT_data_bit_offset 0x6b constant", + "DW_AT_const_expr 0x6c flag", + "DW_AT_enum_class 0x6d flag", + "DW_AT_linkage_name 0x6e string ", + "DW_AT_string_length_bit_size 0x6f constant", + "DW_AT_string_length_byte_size 0x70 constant", + "DW_AT_rank 0x71 constant exprloc", + "DW_AT_str_offsets_base 0x72 stroffsetsptr", + "DW_AT_addr_base 0x73 addrptr", + "DW_AT_rnglists_base 0x74 rnglistsptr", + "DW_AT_dwo_name 0x76 string", + "DW_AT_reference 0x77 flag", + "DW_AT_rvalue_reference 0x78 flag", + "DW_AT_macros 0x79 macptr", + "DW_AT_call_all_calls 0x7a flag", + "DW_AT_call_all_source_calls 0x7b flag", + "DW_AT_call_all_tail_calls 0x7c flag", + "DW_AT_call_return_pc 0x7d address", + "DW_AT_call_value 0x7e exprloc", + "DW_AT_call_origin 0x7f exprloc", + "DW_AT_call_parameter 0x80 reference", + "DW_AT_call_pc 0x81 address", + "DW_AT_call_tail_call 0x82 flag", + "DW_AT_call_target 0x83 exprloc", + "DW_AT_call_target_clobbered 0x84 exprloc", + "DW_AT_call_data_location 0x85 exprloc", + "DW_AT_call_data_value 0x86 exprloc", + "DW_AT_noreturn 0x87 flag", + "DW_AT_alignment 0x88 constant", + "DW_AT_export_symbols 0x89 flag", + "DW_AT_deleted 0x8a flag", + "DW_AT_defaulted 0x8b constant", + "DW_AT_loclists_base 0x8c loclistsptr", + }; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs new file mode 100644 index 00000000000000..992070cc99bf8c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs @@ -0,0 +1,327 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CppAst; +using CppAst.CodeGen.Common; +using CppAst.CodeGen.CSharp; +using Zio.FileSystems; + +namespace LibObjectFile.CodeGen +{ + partial class Program + { + private const string SrcFolderRelative = @"..\..\..\.."; + + static void Main(string[] args) + { + GenerateElf(); + GenerateDwarf(); + } + + private static CodeWriter GetCodeWriter(string subPath) + { + var fs = new PhysicalFileSystem(); + var destFolder = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, SrcFolderRelative, subPath)); + var subfs = new SubFileSystem(fs, fs.ConvertPathFromInternal(destFolder)); + var codeWriter = new CodeWriter(new CodeWriterOptions(subfs)); + return codeWriter; + } + + private static void AssertCompilation(CSharpCompilation csCompilation) + { + if (csCompilation.HasErrors) + { + foreach (var message in csCompilation.Diagnostics.Messages) + { + Console.Error.WriteLine(message); + } + Console.Error.WriteLine("Unexpected parsing errors"); + Environment.Exit(1); + } + } + + private static void GenerateElf() + { + var cppOptions = new CSharpConverterOptions() + { + DefaultClassLib = "ElfNative", + DefaultNamespace = "LibObjectFile.Elf", + DefaultOutputFilePath = "/LibObjectFile.Elf.generated.cs", + DefaultDllImportNameAndArguments = "NotUsed", + MappingRules = + { + map => map.MapMacroToConst("^EI.*", "uint8_t"), + map => map.MapMacroToConst("^ELFMAG\\d", "uint8_t"), + map => map.MapMacroToConst("^ELFCLASS.*", "uint8_t"), + map => map.MapMacroToConst("^ELFDATA.*", "uint8_t"), + map => map.MapMacroToConst("^ELFOSABI.*", "uint8_t"), + map => map.MapMacroToConst("^ET_.*", "uint16_t"), + map => map.MapMacroToConst("^EM_.*", "uint16_t"), + map => map.MapMacroToConst("^EV_.*", "uint8_t"), + map => map.MapMacroToConst("^SHN_.*", "uint32_t"), + map => map.MapMacroToConst("^SHT_.*", "uint32_t"), + map => map.MapMacroToConst("^SHF_.*", "uint32_t"), + map => map.MapMacroToConst("^EF_.*", "uint32_t"), + map => map.MapMacroToConst("^PT_.*", "uint32_t"), + map => map.MapMacroToConst("^PF_.*", "uint32_t"), + map => map.MapMacroToConst("^NT_.*", "uint32_t"), + map => map.MapMacroToConst("^DT_.*", "int32_t"), + map => map.MapMacroToConst("^DF_.*", "uint32_t"), + map => map.MapMacroToConst("^DTF_.*", "uint32_t"), + map => map.MapMacroToConst("^VER_DEF_.*", "uint16_t"), + map => map.MapMacroToConst("^VER_FLG_.*", "uint16_t"), + map => map.MapMacroToConst("^VER_NDX_.*", "uint16_t"), + map => map.MapMacroToConst("^VER_NEED_.*", "uint16_t"), + map => map.MapMacroToConst("^ELFCOMPRESS_.*", "int32_t"), + map => map.MapMacroToConst("^SYMINFO_.*", "uint16_t"), + map => map.MapMacroToConst("^STB_.*", "uint8_t"), + map => map.MapMacroToConst("^STT_.*", "uint8_t"), + map => map.MapMacroToConst("^STN_.*", "uint8_t"), + map => map.MapMacroToConst("^STV_.*", "uint8_t"), + map => map.MapMacroToConst("^R_.*", "uint32_t"), + map => map.MapMacroToConst("ELF_NOTE_OS_.*", "uint32_t"), + } + }; + + cppOptions.ConfigureForWindowsMsvc(CppTargetCpu.X86_64); + cppOptions.Defines.Add("_AMD64_"); + cppOptions.Defines.Add("_TARGET_AMD64_"); + cppOptions.Defines.Add("STARK_NO_ENUM_FLAG"); + cppOptions.GenerateEnumItemAsFields = false; + cppOptions.IncludeFolders.Add(Environment.CurrentDirectory); + + var csCompilation = CSharpConverter.Convert(@"#include ""elf.h""", cppOptions); + + AssertCompilation(csCompilation); + + // Add pragma + var csFile = csCompilation.Members.OfType().First(); + var ns = csFile.Members.OfType().First(); + csFile.Members.Insert(csFile.Members.IndexOf(ns), new CSharpLineElement("#pragma warning disable 1591") ); + + ProcessEnum(cppOptions, csCompilation, "EM_", "ElfArch"); + ProcessEnum(cppOptions, csCompilation, "ELFOSABI_", "ElfOSABI"); + ProcessEnum(cppOptions, csCompilation, "R_", "ElfRelocationType"); + ProcessEnum(cppOptions, csCompilation, "NT_", "ElfNoteType"); + + csCompilation.DumpTo(GetCodeWriter(Path.Combine("LibObjectFile", "generated"))); + } + + private static readonly Dictionary MapRelocMachineToArch = new Dictionary() + { + {"R_386_", "I386"}, + {"R_X86_64_", "X86_64"}, + {"R_ARM_", "ARM"}, + {"R_AARCH64_", "AARCH64"}, + }; + + private static readonly Dictionary MapRelocMachineToMachine = new Dictionary() + { + {"R_386_", "EM_386"}, + {"R_X86_64_", "EM_X86_64"}, + {"R_ARM_", "EM_ARM"}, + {"R_AARCH64_", "EM_AARCH64"}, + }; + + private static void ProcessEnum(CSharpConverterOptions cppOptions, CSharpCompilation csCompilation, string enumPrefix, string enumClassName) + { + var ns = csCompilation.Members.OfType().First().Members.OfType().First(); + + var rawElfClass = ns.Members.OfType().First(); + + var enumRawFields = rawElfClass.Members.OfType().Where(x => (x.Modifiers & CSharpModifiers.Const) != 0 && x.Name.StartsWith(enumPrefix)).ToList(); + + var enumClass = new CSharpStruct(enumClassName) + { + Modifiers = CSharpModifiers.Partial | CSharpModifiers.ReadOnly + }; + ns.Members.Add(enumClass); + + CSharpEnum stdEnum = null; + + var enumItemType = enumRawFields[0].FieldType; + + bool isReloc = enumPrefix == "R_"; + + if (!isReloc) + { + enumClass.Name = enumClass.Name + "Ex"; + stdEnum = new CSharpEnum(enumClassName) + { + Visibility = CSharpVisibility.Public + }; + ns.Members.Add(stdEnum); + stdEnum.BaseTypes.Add(enumItemType); + } + + var filteredFields = new List(); + + foreach (var enumRawField in enumRawFields) + { + var rawName = enumRawField.Name; + + string relocArch = null; + + if (isReloc) + { + foreach (var mapReloc in MapRelocMachineToArch) + { + if (rawName.StartsWith(mapReloc.Key)) + { + relocArch = mapReloc.Value; + break; + } + } + + if (relocArch == null) + { + continue; + } + } + + // skip lo/hi user + if (rawName.StartsWith("DW_") && (rawName.Contains("_lo_") || rawName.Contains("_hi_"))) + { + continue; + } + + // NUM fields + if (rawName.EndsWith("_NUM")) continue; + + filteredFields.Add(enumRawField); + + var csFieldName = isReloc ? rawName : rawName.Substring(enumPrefix.Length); // discard EM_ + if (csFieldName.StartsWith("386")) + { + csFieldName = $"I{csFieldName}"; + } + else + { + switch (csFieldName) + { + case "88K": + csFieldName = "M88K"; + break; + case "860": + csFieldName = "I860"; + break; + case "960": + csFieldName = "I960"; + break; + default: + // assume Motorola + if (csFieldName.StartsWith("68")) + { + csFieldName = $"M{csFieldName}"; + } + + break; + } + } + + if (char.IsDigit(csFieldName[0])) + { + throw new InvalidOperationException($"The enum name `{rawName}` starts with a number and needs to be modified"); + } + + if (rawName.StartsWith("DW_")) + { + csFieldName = CSharpifyName(csFieldName); + } + + csFieldName = CSharpHelper.EscapeName(csFieldName); + + var enumField = new CSharpField(csFieldName) + { + Modifiers = CSharpModifiers.Static | CSharpModifiers.ReadOnly, + FieldType = enumClass, + Visibility = CSharpVisibility.Public, + Comment = enumRawField.Comment, + InitValue = relocArch != null ? + $"new {enumClass.Name}(ElfArch.{relocArch}, {cppOptions.DefaultClassLib}.{rawName})" : + $"new {enumClass.Name}({cppOptions.DefaultClassLib}.{rawName})" + }; + + enumClass.Members.Add(enumField); + + if (!isReloc) + { + var stdEnumField = new CSharpEnumItem(csFieldName, $"{cppOptions.DefaultClassLib}.{rawName}"); + stdEnum.Members.Add(stdEnumField); + } + } + + var toStringInternal = new CSharpMethod() + { + Name = "ToStringInternal", + Visibility = CSharpVisibility.Private, + ReturnType = CSharpPrimitiveType.String() + }; + enumClass.Members.Add(toStringInternal); + + toStringInternal.Body = (writer, element) => + { + var values = new HashSet(); + if (isReloc) + { + writer.WriteLine("switch (((ulong)Value << 16) | (ulong)Arch.Value)"); + } + else + { + writer.WriteLine($"switch (({enumItemType})Value)"); + } + writer.OpenBraceBlock(); + foreach (var rawField in filteredFields) + { + var cppField = ((CppField)rawField.CppElement); + if (isReloc) + { + string relocMachine = null; + foreach (var mapReloc in MapRelocMachineToMachine) + { + if (rawField.Name.StartsWith(mapReloc.Key)) + { + relocMachine = mapReloc.Value; + break; + } + } + + if (relocMachine == null) + { + continue; + } + + if (!values.Add(relocMachine + "$" + cppField.InitValue.Value)) + { + continue; + } + + writer.WriteLine($"case ((ulong){cppOptions.DefaultClassLib}.{rawField.Name} << 16) | {cppOptions.DefaultClassLib}.{relocMachine} : return \"{rawField.Name}\";"); + } + else + { + if (!values.Add(cppField.InitValue.Value)) + { + continue; + } + + string descriptionText = rawField.Name; + //if (cppField.Comment != null) + //{ + // descriptionText += " - " + cppField.Comment.ToString().Replace("\"", "\\\""); + //} + descriptionText = descriptionText.Replace("\r\n", "").Replace("\n", ""); + writer.WriteLine($"case {cppOptions.DefaultClassLib}.{rawField.Name}: return \"{descriptionText}\";"); + } + } + + writer.WriteLine($"default: return null;"); + writer.CloseBraceBlock(); + }; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h new file mode 100644 index 00000000000000..3090c557a21174 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h @@ -0,0 +1,1432 @@ +/* + Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. + Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved. + Portions Copyright 2007-2017 David Anderson. All rights reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of version 2.1 of the GNU Lesser General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it would be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + Further, this software is distributed without any warranty that it is + free of the rightful claim of any third person regarding infringement + or the like. Any license provided herein, whether implied or + otherwise, applies only to this software file. Patent licenses, if + any, provided herein do not apply to combinations of this program with + other software, or any other product whatsoever. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, + USA. + +*/ + + +#ifndef __DWARF_H +#define __DWARF_H +#ifdef __cplusplus +extern "C" { +#endif + +/* + dwarf.h DWARF debugging information values + $Revision: 1.41 $ $Date: 2006/04/17 00:09:56 $ + + The comment "DWARF3" appears where there are + new entries from DWARF3 as of 2004, "DWARF3f" + where there are new entries as of the November 2005 + public review document and other comments apply + where extension entries appear. + + Extensions part of DWARF4 are marked DWARF4. + + A few extension names have omitted the 'vendor id' + (See chapter 7, "Vendor Extensibility"). Please + always use a 'vendor id' string in extension names. + + Vendors should use a vendor string in names and + whereever possible avoid duplicating values used by + other vendor extensions + + The DWARF1 comments indicate values unused in + DWARF2 and later but used or reserved in DWARF1. +*/ + + +#define DW_TAG_array_type 0x01 +#define DW_TAG_class_type 0x02 +#define DW_TAG_entry_point 0x03 +#define DW_TAG_enumeration_type 0x04 +#define DW_TAG_formal_parameter 0x05 +/* TAG_global_subroutine 0x06 DWARF1 only */ +/* TAG_global_variable 0x07 DWARF1 only */ +#define DW_TAG_imported_declaration 0x08 +/* reserved by DWARF1 0x09 DWARF1 only */ +#define DW_TAG_label 0x0a +#define DW_TAG_lexical_block 0x0b +/* TAG_local_variable 0x0c DWARF1 only. */ +#define DW_TAG_member 0x0d +/* reserved by DWARF1 0x0e DWARF1 only */ +#define DW_TAG_pointer_type 0x0f +#define DW_TAG_reference_type 0x10 +#define DW_TAG_compile_unit 0x11 +#define DW_TAG_string_type 0x12 +#define DW_TAG_structure_type 0x13 +/* TAG_subroutine 0x14 DWARF1 only */ +#define DW_TAG_subroutine_type 0x15 +#define DW_TAG_typedef 0x16 +#define DW_TAG_union_type 0x17 +#define DW_TAG_unspecified_parameters 0x18 +#define DW_TAG_variant 0x19 +#define DW_TAG_common_block 0x1a +#define DW_TAG_common_inclusion 0x1b +#define DW_TAG_inheritance 0x1c +#define DW_TAG_inlined_subroutine 0x1d +#define DW_TAG_module 0x1e +#define DW_TAG_ptr_to_member_type 0x1f +#define DW_TAG_set_type 0x20 +#define DW_TAG_subrange_type 0x21 +#define DW_TAG_with_stmt 0x22 +#define DW_TAG_access_declaration 0x23 +#define DW_TAG_base_type 0x24 +#define DW_TAG_catch_block 0x25 +#define DW_TAG_const_type 0x26 +#define DW_TAG_constant 0x27 +#define DW_TAG_enumerator 0x28 +#define DW_TAG_file_type 0x29 +#define DW_TAG_friend 0x2a +#define DW_TAG_namelist 0x2b + /* Early releases of this header had the following + misspelled with a trailing 's' */ +#define DW_TAG_namelist_item 0x2c /* DWARF3/2 spelling */ +#define DW_TAG_namelist_items 0x2c /* SGI misspelling/typo */ +#define DW_TAG_packed_type 0x2d +#define DW_TAG_subprogram 0x2e + /* The DWARF2 document had two spellings of the following + two TAGs, DWARF3 specifies the longer spelling. */ +#define DW_TAG_template_type_parameter 0x2f /* DWARF3/2 spelling*/ +#define DW_TAG_template_type_param 0x2f /* DWARF2 spelling*/ +#define DW_TAG_template_value_parameter 0x30 /* DWARF3/2 spelling*/ +#define DW_TAG_template_value_param 0x30 /* DWARF2 spelling*/ +#define DW_TAG_thrown_type 0x31 +#define DW_TAG_try_block 0x32 +#define DW_TAG_variant_part 0x33 +#define DW_TAG_variable 0x34 +#define DW_TAG_volatile_type 0x35 +#define DW_TAG_dwarf_procedure 0x36 /* DWARF3 */ +#define DW_TAG_restrict_type 0x37 /* DWARF3 */ +#define DW_TAG_interface_type 0x38 /* DWARF3 */ +#define DW_TAG_namespace 0x39 /* DWARF3 */ +#define DW_TAG_imported_module 0x3a /* DWARF3 */ +#define DW_TAG_unspecified_type 0x3b /* DWARF3 */ +#define DW_TAG_partial_unit 0x3c /* DWARF3 */ +#define DW_TAG_imported_unit 0x3d /* DWARF3 */ + /* Do not use DW_TAG_mutable_type */ +#define DW_TAG_mutable_type 0x3e /* Withdrawn from DWARF3 by DWARF3f. */ +#define DW_TAG_condition 0x3f /* DWARF3f */ +#define DW_TAG_shared_type 0x40 /* DWARF3f */ +#define DW_TAG_type_unit 0x41 /* DWARF4 */ +#define DW_TAG_rvalue_reference_type 0x42 /* DWARF4 */ +#define DW_TAG_template_alias 0x43 /* DWARF4 */ +#define DW_TAG_coarray_type 0x44 /* DWARF5 */ +#define DW_TAG_generic_subrange 0x45 /* DWARF5 */ +#define DW_TAG_dynamic_type 0x46 /* DWARF5 */ +#define DW_TAG_atomic_type 0x47 /* DWARF5 */ +#define DW_TAG_call_site 0x48 /* DWARF5 */ +#define DW_TAG_call_site_parameter 0x49 /* DWARF5 */ +#define DW_TAG_skeleton_unit 0x4a /* DWARF5 */ +#define DW_TAG_immutable_type 0x4b /* DWARF5 */ +#define DW_TAG_lo_user 0x4080 + +#define DW_TAG_MIPS_loop 0x4081 + +/* HP extensions: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz */ +#define DW_TAG_HP_array_descriptor 0x4090 /* HP */ + +/* GNU extensions. The first 3 missing the GNU_. */ +#define DW_TAG_format_label 0x4101 /* GNU. Fortran. */ +#define DW_TAG_function_template 0x4102 /* GNU. For C++ */ +#define DW_TAG_class_template 0x4103 /* GNU. For C++ */ +#define DW_TAG_GNU_BINCL 0x4104 /* GNU */ +#define DW_TAG_GNU_EINCL 0x4105 /* GNU */ + +/* GNU extension. http://gcc.gnu.org/wiki/TemplateParmsDwarf */ +#define DW_TAG_GNU_template_template_parameter 0x4106 /* GNU */ +#define DW_TAG_GNU_template_template_param 0x4106 /* GNU */ +#define DW_TAG_GNU_template_parameter_pack 0x4107 /* GNU */ +#define DW_TAG_GNU_formal_parameter_pack 0x4108 /* GNU */ + +#define DW_TAG_GNU_call_site 0x4109 /* GNU */ +#define DW_TAG_GNU_call_site_parameter 0x410a /* GNU */ + +/* ALTIUM extensions */ + /* DSP-C/Starcore __circ qualifier */ +#define DW_TAG_ALTIUM_circ_type 0x5101 /* ALTIUM */ + /* Starcore __mwa_circ qualifier */ +#define DW_TAG_ALTIUM_mwa_circ_type 0x5102 /* ALTIUM */ + /* Starcore __rev_carry qualifier */ +#define DW_TAG_ALTIUM_rev_carry_type 0x5103 /* ALTIUM */ + /* M16 __rom qualifier */ +#define DW_TAG_ALTIUM_rom 0x5111 /* ALTIUM */ + +/* The following 3 are extensions to support UPC */ +#define DW_TAG_upc_shared_type 0x8765 /* UPC */ +#define DW_TAG_upc_strict_type 0x8766 /* UPC */ +#define DW_TAG_upc_relaxed_type 0x8767 /* UPC */ + +/* PGI (STMicroelectronics) extensions. */ +#define DW_TAG_PGI_kanji_type 0xa000 /* PGI */ +#define DW_TAG_PGI_interface_block 0xa020 /* PGI */ +/* The following are SUN extensions */ +#define DW_TAG_SUN_function_template 0x4201 /* SUN */ +#define DW_TAG_SUN_class_template 0x4202 /* SUN */ +#define DW_TAG_SUN_struct_template 0x4203 /* SUN */ +#define DW_TAG_SUN_union_template 0x4204 /* SUN */ +#define DW_TAG_SUN_indirect_inheritance 0x4205 /* SUN */ +#define DW_TAG_SUN_codeflags 0x4206 /* SUN */ +#define DW_TAG_SUN_memop_info 0x4207 /* SUN */ +#define DW_TAG_SUN_omp_child_func 0x4208 /* SUN */ +#define DW_TAG_SUN_rtti_descriptor 0x4209 /* SUN */ +#define DW_TAG_SUN_dtor_info 0x420a /* SUN */ +#define DW_TAG_SUN_dtor 0x420b /* SUN */ +#define DW_TAG_SUN_f90_interface 0x420c /* SUN */ +#define DW_TAG_SUN_fortran_vax_structure 0x420d /* SUN */ +#define DW_TAG_SUN_hi 0x42ff /* SUN */ + +#define DW_TAG_hi_user 0xffff + +/* The following two are non-standard. Use DW_CHILDREN_yes + and DW_CHILDREN_no instead. These could + probably be deleted, but someone might be using them, + so they remain. */ +#define DW_children_no 0 +#define DW_children_yes 1 + +#define DW_FORM_addr 0x01 +/* FORM_REF 0x02 DWARF1 only */ +#define DW_FORM_block2 0x03 +#define DW_FORM_block4 0x04 +#define DW_FORM_data2 0x05 +#define DW_FORM_data4 0x06 +#define DW_FORM_data8 0x07 +#define DW_FORM_string 0x08 +#define DW_FORM_block 0x09 +#define DW_FORM_block1 0x0a +#define DW_FORM_data1 0x0b +#define DW_FORM_flag 0x0c +#define DW_FORM_sdata 0x0d +#define DW_FORM_strp 0x0e +#define DW_FORM_udata 0x0f +#define DW_FORM_ref_addr 0x10 +#define DW_FORM_ref1 0x11 +#define DW_FORM_ref2 0x12 +#define DW_FORM_ref4 0x13 +#define DW_FORM_ref8 0x14 +#define DW_FORM_ref_udata 0x15 +#define DW_FORM_indirect 0x16 +#define DW_FORM_sec_offset 0x17 /* DWARF4 */ +#define DW_FORM_exprloc 0x18 /* DWARF4 */ +#define DW_FORM_flag_present 0x19 /* DWARF4 */ +#define DW_FORM_strx 0x1a /* DWARF5 */ +#define DW_FORM_addrx 0x1b /* DWARF5 */ +#define DW_FORM_ref_sup4 0x1c /* DWARF5 */ +#define DW_FORM_strp_sup 0x1d /* DWARF5 */ +#define DW_FORM_data16 0x1e /* DWARF5 */ +#define DW_FORM_line_strp 0x1f /* DWARF5 */ +#define DW_FORM_ref_sig8 0x20 /* DWARF4 */ +#define DW_FORM_implicit_const 0x21 /* DWARF5 */ +#define DW_FORM_loclistx 0x22 /* DWARF5 */ +#define DW_FORM_rnglistx 0x23 /* DWARF5 */ +#define DW_FORM_ref_sup8 0x24 /* DWARF5 */ +#define DW_FORM_strx1 0x25 /* DWARF5 */ +#define DW_FORM_strx2 0x26 /* DWARF5 */ +#define DW_FORM_strx3 0x27 /* DWARF5 */ +#define DW_FORM_strx4 0x28 /* DWARF5 */ +#define DW_FORM_addrx1 0x29 /* DWARF5 */ +#define DW_FORM_addrx2 0x2a /* DWARF5 */ +#define DW_FORM_addrx3 0x2b /* DWARF5 */ +#define DW_FORM_addrx4 0x2c /* DWARF5 */ + +#define DW_FORM_GNU_addr_index 0x1f01 /* GNU extension in debug_info.dwo.*/ +#define DW_FORM_GNU_str_index 0x1f02 /* GNU extension, somewhat like DW_FORM_strp */ +#define DW_FORM_GNU_ref_alt 0x1f20 /* GNU extension. Offset in .debug_info. */ +#define DW_FORM_GNU_strp_alt 0x1f21 /* GNU extension. Offset in .debug_str of another object file. */ + +#define DW_AT_sibling 0x01 +#define DW_AT_location 0x02 +#define DW_AT_name 0x03 +/* reserved DWARF1 0x04, DWARF1 only */ +/* AT_fund_type 0x05, DWARF1 only */ +/* AT_mod_fund_type 0x06, DWARF1 only */ +/* AT_user_def_type 0x07, DWARF1 only */ +/* AT_mod_u_d_type 0x08, DWARF1 only */ +#define DW_AT_ordering 0x09 +#define DW_AT_subscr_data 0x0a +#define DW_AT_byte_size 0x0b +#define DW_AT_bit_offset 0x0c +#define DW_AT_bit_size 0x0d +/* reserved DWARF1 0x0d, DWARF1 only */ +#define DW_AT_element_list 0x0f +#define DW_AT_stmt_list 0x10 +#define DW_AT_low_pc 0x11 +#define DW_AT_high_pc 0x12 +#define DW_AT_language 0x13 +#define DW_AT_member 0x14 +#define DW_AT_discr 0x15 +#define DW_AT_discr_value 0x16 +#define DW_AT_visibility 0x17 +#define DW_AT_import 0x18 +#define DW_AT_string_length 0x19 +#define DW_AT_common_reference 0x1a +#define DW_AT_comp_dir 0x1b +#define DW_AT_const_value 0x1c +#define DW_AT_containing_type 0x1d +#define DW_AT_default_value 0x1e +/* reserved 0x1f */ +#define DW_AT_inline 0x20 +#define DW_AT_is_optional 0x21 +#define DW_AT_lower_bound 0x22 +/* reserved 0x23 */ +/* reserved 0x24 */ +#define DW_AT_producer 0x25 +/* reserved 0x26 */ +#define DW_AT_prototyped 0x27 +/* reserved 0x28 */ +/* reserved 0x29 */ +#define DW_AT_return_addr 0x2a +/* reserved 0x2b */ +#define DW_AT_start_scope 0x2c +/* reserved 0x2d */ +#define DW_AT_bit_stride 0x2e /* DWARF3 name */ +#define DW_AT_stride_size 0x2e /* DWARF2 name */ +#define DW_AT_upper_bound 0x2f +/* AT_virtual 0x30, DWARF1 only */ +#define DW_AT_abstract_origin 0x31 +#define DW_AT_accessibility 0x32 +#define DW_AT_address_class 0x33 +#define DW_AT_artificial 0x34 +#define DW_AT_base_types 0x35 +#define DW_AT_calling_convention 0x36 +#define DW_AT_count 0x37 +#define DW_AT_data_member_location 0x38 +#define DW_AT_decl_column 0x39 +#define DW_AT_decl_file 0x3a +#define DW_AT_decl_line 0x3b +#define DW_AT_declaration 0x3c +#define DW_AT_discr_list 0x3d /* DWARF2 */ +#define DW_AT_encoding 0x3e +#define DW_AT_external 0x3f +#define DW_AT_frame_base 0x40 +#define DW_AT_friend 0x41 +#define DW_AT_identifier_case 0x42 +#define DW_AT_macro_info 0x43 /* DWARF{234} not DWARF5 */ +#define DW_AT_namelist_item 0x44 +#define DW_AT_priority 0x45 +#define DW_AT_segment 0x46 +#define DW_AT_specification 0x47 +#define DW_AT_static_link 0x48 +#define DW_AT_type 0x49 +#define DW_AT_use_location 0x4a +#define DW_AT_variable_parameter 0x4b +#define DW_AT_virtuality 0x4c +#define DW_AT_vtable_elem_location 0x4d +#define DW_AT_allocated 0x4e /* DWARF3 */ +#define DW_AT_associated 0x4f /* DWARF3 */ +#define DW_AT_data_location 0x50 /* DWARF3 */ +#define DW_AT_byte_stride 0x51 /* DWARF3f */ +#define DW_AT_stride 0x51 /* DWARF3 (do not use) */ +#define DW_AT_entry_pc 0x52 /* DWARF3 */ +#define DW_AT_use_UTF8 0x53 /* DWARF3 */ +#define DW_AT_extension 0x54 /* DWARF3 */ +#define DW_AT_ranges 0x55 /* DWARF3 */ +#define DW_AT_trampoline 0x56 /* DWARF3 */ +#define DW_AT_call_column 0x57 /* DWARF3 */ +#define DW_AT_call_file 0x58 /* DWARF3 */ +#define DW_AT_call_line 0x59 /* DWARF3 */ +#define DW_AT_description 0x5a /* DWARF3 */ +#define DW_AT_binary_scale 0x5b /* DWARF3f */ +#define DW_AT_decimal_scale 0x5c /* DWARF3f */ +#define DW_AT_small 0x5d /* DWARF3f */ +#define DW_AT_decimal_sign 0x5e /* DWARF3f */ +#define DW_AT_digit_count 0x5f /* DWARF3f */ +#define DW_AT_picture_string 0x60 /* DWARF3f */ +#define DW_AT_mutable 0x61 /* DWARF3f */ +#define DW_AT_threads_scaled 0x62 /* DWARF3f */ +#define DW_AT_explicit 0x63 /* DWARF3f */ +#define DW_AT_object_pointer 0x64 /* DWARF3f */ +#define DW_AT_endianity 0x65 /* DWARF3f */ +#define DW_AT_elemental 0x66 /* DWARF3f */ +#define DW_AT_pure 0x67 /* DWARF3f */ +#define DW_AT_recursive 0x68 /* DWARF3f */ +#define DW_AT_signature 0x69 /* DWARF4 */ +#define DW_AT_main_subprogram 0x6a /* DWARF4 */ +#define DW_AT_data_bit_offset 0x6b /* DWARF4 */ +#define DW_AT_const_expr 0x6c /* DWARF4 */ +#define DW_AT_enum_class 0x6d /* DWARF4 */ +#define DW_AT_linkage_name 0x6e /* DWARF4 */ +#define DW_AT_string_length_bit_size 0x6f /* DWARF5 */ +#define DW_AT_string_length_byte_size 0x70 /* DWARF5 */ +#define DW_AT_rank 0x71 /* DWARF5 */ +#define DW_AT_str_offsets_base 0x72 /* DWARF5 */ +#define DW_AT_addr_base 0x73 /* DWARF5 */ + /* Use DW_AT_rnglists_base, DW_AT_ranges_base is obsolete as */ + /* it was only used in some DWARF5 drafts, not the final DWARF5. */ +#define DW_AT_rnglists_base 0x74 /* DWARF5 */ + /* DW_AT_dwo_id, an experiment in some DWARF4+. Not DWARF5! */ +#define DW_AT_dwo_id 0x75 /* DWARF4!*/ +#define DW_AT_dwo_name 0x76 /* DWARF5 */ +#define DW_AT_reference 0x77 /* DWARF5 */ +#define DW_AT_rvalue_reference 0x78 /* DWARF5 */ +#define DW_AT_macros 0x79 /* DWARF5 */ +#define DW_AT_call_all_calls 0x7a /* DWARF5 */ +#define DW_AT_call_all_source_calls 0x7b /* DWARF5 */ +#define DW_AT_call_all_tail_calls 0x7c /* DWARF5 */ +#define DW_AT_call_return_pc 0x7d /* DWARF5 */ +#define DW_AT_call_value 0x7e /* DWARF5 */ +#define DW_AT_call_origin 0x7f /* DWARF5 */ +#define DW_AT_call_parameter 0x80 /* DWARF5 */ +#define DW_AT_call_pc 0x81 /* DWARF5 */ +#define DW_AT_call_tail_call 0x82 /* DWARF5 */ +#define DW_AT_call_target 0x83 /* DWARF5 */ +#define DW_AT_call_target_clobbered 0x84 /* DWARF5 */ +#define DW_AT_call_data_location 0x85 /* DWARF5 */ +#define DW_AT_call_data_value 0x86 /* DWARF5 */ +#define DW_AT_noreturn 0x87 /* DWARF5 */ +#define DW_AT_alignment 0x88 /* DWARF5 */ +#define DW_AT_export_symbols 0x89 /* DWARF5 */ +#define DW_AT_deleted 0x8a /* DWARF5 */ +#define DW_AT_defaulted 0x8b /* DWARF5 */ +#define DW_AT_loclists_base 0x8c /* DWARF5 */ + +/* In extensions, we attempt to include the vendor extension + in the name even when the vendor leaves it out. */ + +/* HP extensions. */ +#define DW_AT_HP_block_index 0x2000 /* HP */ + +/* Follows extension so dwarfdump prints the most-likely-useful name. */ +#define DW_AT_lo_user 0x2000 + +#define DW_AT_MIPS_fde 0x2001 /* MIPS/SGI */ +#define DW_AT_MIPS_loop_begin 0x2002 /* MIPS/SGI */ +#define DW_AT_MIPS_tail_loop_begin 0x2003 /* MIPS/SGI */ +#define DW_AT_MIPS_epilog_begin 0x2004 /* MIPS/SGI */ +#define DW_AT_MIPS_loop_unroll_factor 0x2005 /* MIPS/SGI */ +#define DW_AT_MIPS_software_pipeline_depth 0x2006 /* MIPS/SGI */ +#define DW_AT_MIPS_linkage_name 0x2007 /* MIPS/SGI, GNU, and others.*/ +#define DW_AT_MIPS_stride 0x2008 /* MIPS/SGI */ +#define DW_AT_MIPS_abstract_name 0x2009 /* MIPS/SGI */ +#define DW_AT_MIPS_clone_origin 0x200a /* MIPS/SGI */ +#define DW_AT_MIPS_has_inlines 0x200b /* MIPS/SGI */ +#define DW_AT_MIPS_stride_byte 0x200c /* MIPS/SGI */ +#define DW_AT_MIPS_stride_elem 0x200d /* MIPS/SGI */ +#define DW_AT_MIPS_ptr_dopetype 0x200e /* MIPS/SGI */ +#define DW_AT_MIPS_allocatable_dopetype 0x200f /* MIPS/SGI */ +#define DW_AT_MIPS_assumed_shape_dopetype 0x2010 /* MIPS/SGI */ +#define DW_AT_MIPS_assumed_size 0x2011 /* MIPS/SGI */ + +/* HP extensions. */ +#define DW_AT_HP_unmodifiable 0x2001 /* conflict: MIPS */ +#define DW_AT_HP_actuals_stmt_list 0x2010 /* conflict: MIPS */ +#define DW_AT_HP_proc_per_section 0x2011 /* conflict: MIPS */ +#define DW_AT_HP_raw_data_ptr 0x2012 /* HP */ +#define DW_AT_HP_pass_by_reference 0x2013 /* HP */ +#define DW_AT_HP_opt_level 0x2014 /* HP */ +#define DW_AT_HP_prof_version_id 0x2015 /* HP */ +#define DW_AT_HP_opt_flags 0x2016 /* HP */ +#define DW_AT_HP_cold_region_low_pc 0x2017 /* HP */ +#define DW_AT_HP_cold_region_high_pc 0x2018 /* HP */ +#define DW_AT_HP_all_variables_modifiable 0x2019 /* HP */ +#define DW_AT_HP_linkage_name 0x201a /* HP */ +#define DW_AT_HP_prof_flags 0x201b /* HP */ + +#define DW_AT_CPQ_discontig_ranges 0x2001 /* COMPAQ/HP */ +#define DW_AT_CPQ_semantic_events 0x2002 /* COMPAQ/HP */ +#define DW_AT_CPQ_split_lifetimes_var 0x2003 /* COMPAQ/HP */ +#define DW_AT_CPQ_split_lifetimes_rtn 0x2004 /* COMPAQ/HP */ +#define DW_AT_CPQ_prologue_length 0x2005 /* COMPAQ/HP */ + +#define DW_AT_INTEL_other_endian 0x2026 /* Intel, 1 if byte swapped. */ + +/* GNU extensions. */ +#define DW_AT_sf_names 0x2101 /* GNU */ +#define DW_AT_src_info 0x2102 /* GNU */ +#define DW_AT_mac_info 0x2103 /* GNU */ +#define DW_AT_src_coords 0x2104 /* GNU */ +#define DW_AT_body_begin 0x2105 /* GNU */ +#define DW_AT_body_end 0x2106 /* GNU */ +#define DW_AT_GNU_vector 0x2107 /* GNU */ + +/* Thread safety, see http://gcc.gnu.org/wiki/ThreadSafetyAnnotation . */ +/* The values here are from gcc-4.6.2 include/dwarf2.h. The + values are not given on the web page at all, nor on web pages + it refers to. */ +#define DW_AT_GNU_guarded_by 0x2108 /* GNU */ +#define DW_AT_GNU_pt_guarded_by 0x2109 /* GNU */ +#define DW_AT_GNU_guarded 0x210a /* GNU */ +#define DW_AT_GNU_pt_guarded 0x210b /* GNU */ +#define DW_AT_GNU_locks_excluded 0x210c /* GNU */ +#define DW_AT_GNU_exclusive_locks_required 0x210d /* GNU */ +#define DW_AT_GNU_shared_locks_required 0x210e /* GNU */ + +/* See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo */ +#define DW_AT_GNU_odr_signature 0x210f /* GNU */ + +/* See See http://gcc.gnu.org/wiki/TemplateParmsDwarf */ +/* The value here is from gcc-4.6.2 include/dwarf2.h. The value is + not consistent with the web page as of December 2011. */ +#define DW_AT_GNU_template_name 0x2110 /* GNU */ +/* The GNU call site extension. + See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . */ +#define DW_AT_GNU_call_site_value 0x2111 /* GNU */ +#define DW_AT_GNU_call_site_data_value 0x2112 /* GNU */ +#define DW_AT_GNU_call_site_target 0x2113 /* GNU */ +#define DW_AT_GNU_call_site_target_clobbered 0x2114 /* GNU */ +#define DW_AT_GNU_tail_call 0x2115 /* GNU */ +#define DW_AT_GNU_all_tail_call_sites 0x2116 /* GNU */ +#define DW_AT_GNU_all_call_sites 0x2117 /* GNU */ +#define DW_AT_GNU_all_source_call_sites 0x2118 /* GNU */ +/* Section offset to .debug_macro section. */ +#define DW_AT_GNU_macros 0x2119 /* GNU */ +/* The GNU DebugFission project: http://gcc.gnu.org/wiki/DebugFission */ +#define DW_AT_GNU_dwo_name 0x2130 /* GNU */ +#define DW_AT_GNU_dwo_id 0x2131 /* GNU */ + +#define DW_AT_GNU_ranges_base 0x2132 /* GNU */ +#define DW_AT_GNU_addr_base 0x2133 /* GNU */ +#define DW_AT_GNU_pubnames 0x2134 /* GNU */ +#define DW_AT_GNU_pubtypes 0x2135 /* GNU */ + +/* To distinguish distinct basic blocks in a single source line. */ +#define DW_AT_GNU_discriminator 0x2136 /* GNU */ +/* Ada GNAT gcc attributes. constant integer forms. */ +#define DW_AT_GNU_numerator 0x2303 /* GNU */ +#define DW_AT_GNU_denominator 0x2304 /* GNU */ +#define DW_AT_GNU_bias 0x2305 /* GNU */ + + + +/* ALTIUM extension: ALTIUM Compliant location lists (flag) */ +#define DW_AT_ALTIUM_loclist 0x2300 /* ALTIUM */ + +/* Sun extensions */ +#define DW_AT_SUN_template 0x2201 /* SUN */ +#define DW_AT_VMS_rtnbeg_pd_address 0x2201 /* VMS */ +#define DW_AT_SUN_alignment 0x2202 /* SUN */ +#define DW_AT_SUN_vtable 0x2203 /* SUN */ +#define DW_AT_SUN_count_guarantee 0x2204 /* SUN */ +#define DW_AT_SUN_command_line 0x2205 /* SUN */ +#define DW_AT_SUN_vbase 0x2206 /* SUN */ +#define DW_AT_SUN_compile_options 0x2207 /* SUN */ +#define DW_AT_SUN_language 0x2208 /* SUN */ +#define DW_AT_SUN_browser_file 0x2209 /* SUN */ +#define DW_AT_SUN_vtable_abi 0x2210 /* SUN */ +#define DW_AT_SUN_func_offsets 0x2211 /* SUN */ +#define DW_AT_SUN_cf_kind 0x2212 /* SUN */ +#define DW_AT_SUN_vtable_index 0x2213 /* SUN */ +#define DW_AT_SUN_omp_tpriv_addr 0x2214 /* SUN */ +#define DW_AT_SUN_omp_child_func 0x2215 /* SUN */ +#define DW_AT_SUN_func_offset 0x2216 /* SUN */ +#define DW_AT_SUN_memop_type_ref 0x2217 /* SUN */ +#define DW_AT_SUN_profile_id 0x2218 /* SUN */ +#define DW_AT_SUN_memop_signature 0x2219 /* SUN */ +#define DW_AT_SUN_obj_dir 0x2220 /* SUN */ +#define DW_AT_SUN_obj_file 0x2221 /* SUN */ +#define DW_AT_SUN_original_name 0x2222 /* SUN */ +#define DW_AT_SUN_hwcprof_signature 0x2223 /* SUN */ +#define DW_AT_SUN_amd64_parmdump 0x2224 /* SUN */ +#define DW_AT_SUN_part_link_name 0x2225 /* SUN */ +#define DW_AT_SUN_link_name 0x2226 /* SUN */ +#define DW_AT_SUN_pass_with_const 0x2227 /* SUN */ +#define DW_AT_SUN_return_with_const 0x2228 /* SUN */ +#define DW_AT_SUN_import_by_name 0x2229 /* SUN */ +#define DW_AT_SUN_f90_pointer 0x222a /* SUN */ +#define DW_AT_SUN_pass_by_ref 0x222b /* SUN */ +#define DW_AT_SUN_f90_allocatable 0x222c /* SUN */ +#define DW_AT_SUN_f90_assumed_shape_array 0x222d /* SUN */ +#define DW_AT_SUN_c_vla 0x222e /* SUN */ +#define DW_AT_SUN_return_value_ptr 0x2230 /* SUN */ +#define DW_AT_SUN_dtor_start 0x2231 /* SUN */ +#define DW_AT_SUN_dtor_length 0x2232 /* SUN */ +#define DW_AT_SUN_dtor_state_initial 0x2233 /* SUN */ +#define DW_AT_SUN_dtor_state_final 0x2234 /* SUN */ +#define DW_AT_SUN_dtor_state_deltas 0x2235 /* SUN */ +#define DW_AT_SUN_import_by_lname 0x2236 /* SUN */ +#define DW_AT_SUN_f90_use_only 0x2237 /* SUN */ +#define DW_AT_SUN_namelist_spec 0x2238 /* SUN */ +#define DW_AT_SUN_is_omp_child_func 0x2239 /* SUN */ +#define DW_AT_SUN_fortran_main_alias 0x223a /* SUN */ +#define DW_AT_SUN_fortran_based 0x223b /* SUN */ + +/* See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ +#define DW_AT_use_GNAT_descriptive_type 0x2301 /* GNAT */ +#define DW_AT_GNAT_descriptive_type 0x2302 /* GNAT */ + +/* UPC extension */ +#define DW_AT_upc_threads_scaled 0x3210 /* UPC */ + +/* PGI (STMicroelectronics) extensions. */ +#define DW_AT_PGI_lbase 0x3a00 /* PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. */ +#define DW_AT_PGI_soffset 0x3a01 /* PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. */ +#define DW_AT_PGI_lstride 0x3a02 /* PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. */ + +/* There are two groups of Apple extensions here, it is + unclear what exactly is correct. */ +#define DW_AT_APPLE_optimized 0x3fe1 /* Apple */ +#define DW_AT_APPLE_flags 0x3fe2 /* Apple */ +#define DW_AT_APPLE_isa 0x3fe3 /* Apple */ +#define DW_AT_APPLE_block 0x3fe4 /* Apple */ +#define DW_AT_APPLE_major_runtime_vers 0x3fe5 /* Apple */ +#define DW_AT_APPLE_runtime_class 0x3fe6 /* Apple */ +#define DW_AT_APPLE_omit_frame_ptr 0x3fe7 /* Apple */ + +/* Apple Extensions for closures */ +#define DW_AT_APPLE_closure 0x3fe4 /* Apple */ + +#define DW_AT_hi_user 0x3fff + +/* OP values 0x01,0x02,0x04,0x05,0x07 are DWARF1 only */ +#define DW_OP_addr 0x03 +#define DW_OP_deref 0x06 +#define DW_OP_const1u 0x08 +#define DW_OP_const1s 0x09 +#define DW_OP_const2u 0x0a +#define DW_OP_const2s 0x0b +#define DW_OP_const4u 0x0c +#define DW_OP_const4s 0x0d +#define DW_OP_const8u 0x0e +#define DW_OP_const8s 0x0f +#define DW_OP_constu 0x10 +#define DW_OP_consts 0x11 +#define DW_OP_dup 0x12 +#define DW_OP_drop 0x13 +#define DW_OP_over 0x14 +#define DW_OP_pick 0x15 +#define DW_OP_swap 0x16 +#define DW_OP_rot 0x17 +#define DW_OP_xderef 0x18 +#define DW_OP_abs 0x19 +#define DW_OP_and 0x1a +#define DW_OP_div 0x1b +#define DW_OP_minus 0x1c +#define DW_OP_mod 0x1d +#define DW_OP_mul 0x1e +#define DW_OP_neg 0x1f +#define DW_OP_not 0x20 +#define DW_OP_or 0x21 +#define DW_OP_plus 0x22 +#define DW_OP_plus_uconst 0x23 +#define DW_OP_shl 0x24 +#define DW_OP_shr 0x25 +#define DW_OP_shra 0x26 +#define DW_OP_xor 0x27 +#define DW_OP_bra 0x28 +#define DW_OP_eq 0x29 +#define DW_OP_ge 0x2a +#define DW_OP_gt 0x2b +#define DW_OP_le 0x2c +#define DW_OP_lt 0x2d +#define DW_OP_ne 0x2e +#define DW_OP_skip 0x2f +#define DW_OP_lit0 0x30 +#define DW_OP_lit1 0x31 +#define DW_OP_lit2 0x32 +#define DW_OP_lit3 0x33 +#define DW_OP_lit4 0x34 +#define DW_OP_lit5 0x35 +#define DW_OP_lit6 0x36 +#define DW_OP_lit7 0x37 +#define DW_OP_lit8 0x38 +#define DW_OP_lit9 0x39 +#define DW_OP_lit10 0x3a +#define DW_OP_lit11 0x3b +#define DW_OP_lit12 0x3c +#define DW_OP_lit13 0x3d +#define DW_OP_lit14 0x3e +#define DW_OP_lit15 0x3f +#define DW_OP_lit16 0x40 +#define DW_OP_lit17 0x41 +#define DW_OP_lit18 0x42 +#define DW_OP_lit19 0x43 +#define DW_OP_lit20 0x44 +#define DW_OP_lit21 0x45 +#define DW_OP_lit22 0x46 +#define DW_OP_lit23 0x47 +#define DW_OP_lit24 0x48 +#define DW_OP_lit25 0x49 +#define DW_OP_lit26 0x4a +#define DW_OP_lit27 0x4b +#define DW_OP_lit28 0x4c +#define DW_OP_lit29 0x4d +#define DW_OP_lit30 0x4e +#define DW_OP_lit31 0x4f +#define DW_OP_reg0 0x50 +#define DW_OP_reg1 0x51 +#define DW_OP_reg2 0x52 +#define DW_OP_reg3 0x53 +#define DW_OP_reg4 0x54 +#define DW_OP_reg5 0x55 +#define DW_OP_reg6 0x56 +#define DW_OP_reg7 0x57 +#define DW_OP_reg8 0x58 +#define DW_OP_reg9 0x59 +#define DW_OP_reg10 0x5a +#define DW_OP_reg11 0x5b +#define DW_OP_reg12 0x5c +#define DW_OP_reg13 0x5d +#define DW_OP_reg14 0x5e +#define DW_OP_reg15 0x5f +#define DW_OP_reg16 0x60 +#define DW_OP_reg17 0x61 +#define DW_OP_reg18 0x62 +#define DW_OP_reg19 0x63 +#define DW_OP_reg20 0x64 +#define DW_OP_reg21 0x65 +#define DW_OP_reg22 0x66 +#define DW_OP_reg23 0x67 +#define DW_OP_reg24 0x68 +#define DW_OP_reg25 0x69 +#define DW_OP_reg26 0x6a +#define DW_OP_reg27 0x6b +#define DW_OP_reg28 0x6c +#define DW_OP_reg29 0x6d +#define DW_OP_reg30 0x6e +#define DW_OP_reg31 0x6f +#define DW_OP_breg0 0x70 +#define DW_OP_breg1 0x71 +#define DW_OP_breg2 0x72 +#define DW_OP_breg3 0x73 +#define DW_OP_breg4 0x74 +#define DW_OP_breg5 0x75 +#define DW_OP_breg6 0x76 +#define DW_OP_breg7 0x77 +#define DW_OP_breg8 0x78 +#define DW_OP_breg9 0x79 +#define DW_OP_breg10 0x7a +#define DW_OP_breg11 0x7b +#define DW_OP_breg12 0x7c +#define DW_OP_breg13 0x7d +#define DW_OP_breg14 0x7e +#define DW_OP_breg15 0x7f +#define DW_OP_breg16 0x80 +#define DW_OP_breg17 0x81 +#define DW_OP_breg18 0x82 +#define DW_OP_breg19 0x83 +#define DW_OP_breg20 0x84 +#define DW_OP_breg21 0x85 +#define DW_OP_breg22 0x86 +#define DW_OP_breg23 0x87 +#define DW_OP_breg24 0x88 +#define DW_OP_breg25 0x89 +#define DW_OP_breg26 0x8a +#define DW_OP_breg27 0x8b +#define DW_OP_breg28 0x8c +#define DW_OP_breg29 0x8d +#define DW_OP_breg30 0x8e +#define DW_OP_breg31 0x8f +#define DW_OP_regx 0x90 +#define DW_OP_fbreg 0x91 +#define DW_OP_bregx 0x92 +#define DW_OP_piece 0x93 +#define DW_OP_deref_size 0x94 +#define DW_OP_xderef_size 0x95 +#define DW_OP_nop 0x96 +#define DW_OP_push_object_address 0x97 /* DWARF3 */ +#define DW_OP_call2 0x98 /* DWARF3 */ +#define DW_OP_call4 0x99 /* DWARF3 */ +#define DW_OP_call_ref 0x9a /* DWARF3 */ +#define DW_OP_form_tls_address 0x9b /* DWARF3f */ +#define DW_OP_call_frame_cfa 0x9c /* DWARF3f */ +#define DW_OP_bit_piece 0x9d /* DWARF3f */ +#define DW_OP_implicit_value 0x9e /* DWARF4 */ +#define DW_OP_stack_value 0x9f /* DWARF4 */ +#define DW_OP_implicit_pointer 0xa0 /* DWARF5 */ +#define DW_OP_addrx 0xa1 /* DWARF5 */ +#define DW_OP_constx 0xa2 /* DWARF5 */ +#define DW_OP_entry_value 0xa3 /* DWARF5 */ +#define DW_OP_const_type 0xa4 /* DWARF5 */ +#define DW_OP_regval_type 0xa5 /* DWARF5 */ +#define DW_OP_deref_type 0xa6 /* DWARF5 */ +#define DW_OP_xderef_type 0xa7 /* DWARF5 */ +#define DW_OP_convert 0xa8 /* DWARF5 */ +#define DW_OP_reinterpret 0xa9 /* DWARF5 */ + + + /* GNU extensions. */ +#define DW_OP_GNU_push_tls_address 0xe0 /* GNU */ + +/* Follows extension so dwarfdump prints the most-likely-useful name. */ +#define DW_OP_lo_user 0xe0 + + +#define DW_OP_GNU_uninit 0xf0 /* GNU */ +#define DW_OP_GNU_encoded_addr 0xf1 /* GNU */ +#define DW_OP_GNU_implicit_pointer 0xf2 /* GNU */ +#define DW_OP_GNU_entry_value 0xf3 /* GNU */ +#define DW_OP_GNU_const_type 0xf4 /* GNU */ +#define DW_OP_GNU_regval_type 0xf5 /* GNU */ +#define DW_OP_GNU_deref_type 0xf6 /* GNU */ +#define DW_OP_GNU_convert 0xf7 /* GNU */ +#define DW_OP_GNU_reinterpret 0xf9 /* GNU */ +#define DW_OP_GNU_parameter_ref 0xfa /* GNU */ +#define DW_OP_GNU_addr_index 0xfb /* GNU DebugFission */ +#define DW_OP_GNU_const_index 0xfc /* GNU DebugFission */ + + /* HP extensions. */ +#define DW_OP_HP_unknown 0xe0 /* HP conflict: GNU */ +#define DW_OP_HP_is_value 0xe1 /* HP */ +#define DW_OP_HP_fltconst4 0xe2 /* HP */ +#define DW_OP_HP_fltconst8 0xe3 /* HP */ +#define DW_OP_HP_mod_range 0xe4 /* HP */ +#define DW_OP_HP_unmod_range 0xe5 /* HP */ +#define DW_OP_HP_tls 0xe6 /* HP */ + +#define DW_OP_INTEL_bit_piece 0xe8 /* Intel: made obsolete by DW_OP_bit_piece above. */ + + /* Apple extension. */ +#define DW_OP_APPLE_uninit 0xf0 /* Apple */ +#define DW_OP_PGI_omp_thread_num 0xf8 /* PGI (STMicroelectronics) */ + +#define DW_OP_hi_user 0xff + +#define DW_ATE_address 0x01 +#define DW_ATE_boolean 0x02 +#define DW_ATE_complex_float 0x03 +#define DW_ATE_float 0x04 +#define DW_ATE_signed 0x05 +#define DW_ATE_signed_char 0x06 +#define DW_ATE_unsigned 0x07 +#define DW_ATE_unsigned_char 0x08 +#define DW_ATE_imaginary_float 0x09 /* DWARF3 */ +#define DW_ATE_packed_decimal 0x0a /* DWARF3f */ +#define DW_ATE_numeric_string 0x0b /* DWARF3f */ +#define DW_ATE_edited 0x0c /* DWARF3f */ +#define DW_ATE_signed_fixed 0x0d /* DWARF3f */ +#define DW_ATE_unsigned_fixed 0x0e /* DWARF3f */ +#define DW_ATE_decimal_float 0x0f /* DWARF3f */ +#define DW_ATE_UTF 0x10 /* DWARF4 */ +#define DW_ATE_UCS 0x11 /* DWARF5 */ +#define DW_ATE_ASCII 0x12 /* DWARF5 */ + + +/* ALTIUM extensions. x80, x81 */ +#define DW_ATE_ALTIUM_fract 0x80 /* ALTIUM __fract type */ + +/* Follows extension so dwarfdump prints the most-likely-useful name. */ +#define DW_ATE_lo_user 0x80 + +/* Shown here to help dwarfdump build script. */ +#define DW_ATE_ALTIUM_accum 0x81 /* ALTIUM __accum type */ + +/* HP Floating point extensions. */ +#define DW_ATE_HP_float80 0x80 /* (80 bit). HP */ + + +#define DW_ATE_HP_complex_float80 0x81 /* Complex (80 bit). HP */ +#define DW_ATE_HP_float128 0x82 /* (128 bit). HP */ +#define DW_ATE_HP_complex_float128 0x83 /* Complex (128 bit). HP */ +#define DW_ATE_HP_floathpintel 0x84 /* (82 bit IA64). HP */ +#define DW_ATE_HP_imaginary_float80 0x85 /* HP */ +#define DW_ATE_HP_imaginary_float128 0x86 /* HP */ + +/* Sun extensions */ +#define DW_ATE_SUN_interval_float 0x91 +#define DW_ATE_SUN_imaginary_float 0x92 /* Obsolete: See DW_ATE_imaginary_float */ + +#define DW_ATE_hi_user 0xff + + +/* DWARF5 Defaulted Member Encodings. */ +#define DW_DEFAULTED_no 0x0 /* DWARF5 */ +#define DW_DEFAULTED_in_class 0x1 /* DWARF5 */ +#define DW_DEFAULTED_out_of_class 0x2 /* DWARF5 */ + + +#define DW_IDX_compile_unit 0x1 /* DWARF5 */ +#define DW_IDX_type_unit 0x2 /* DWARF5 */ +#define DW_IDX_die_offset 0x3 /* DWARF5 */ +#define DW_IDX_parent 0x4 /* DWARF5 */ +#define DW_IDX_type_hash 0x5 /* DWARF5 */ +#define DW_IDX_lo_user 0x2000 /* DWARF5 */ +#define DW_IDX_hi_user 0x0fff /* DWARF5 */ + +/* These with not-quite-the-same-names were used in DWARF4 + and never official and should not be used by anyone. */ +#define DW_LLEX_end_of_list_entry 0x0 /* DWARF4 experimental */ +#define DW_LLEX_base_address_selection_entry 0x01 /* DWARF4 experimental */ +#define DW_LLEX_start_end_entry 0x02 /* DWARF4 experimental */ +#define DW_LLEX_start_length_entry 0x03 /* DWARF4 experimental */ +#define DW_LLEX_offset_pair_entry 0x04 /* DWARF4 experimental */ + +/* DWARF5 Location List Entries in Split Objects */ +#define DW_LLE_end_of_list 0x0 /* DWARF5 */ +#define DW_LLE_base_addressx 0x01 /* DWARF5 */ +#define DW_LLE_startx_endx 0x02 /* DWARF5 */ +#define DW_LLE_startx_length 0x03 /* DWARF5 */ +#define DW_LLE_offset_pair 0x04 /* DWARF5 */ +#define DW_LLE_default_location 0x05 /* DWARF5 */ +#define DW_LLE_base_address 0x06 /* DWARF5 */ +#define DW_LLE_start_end 0x07 /* DWARF5 */ +#define DW_LLE_start_length 0x08 /* DWARF5 */ + +/* DWARF5 Range List Entries */ +#define DW_RLE_end_of_list 0x00 /* DWARF5 */ +#define DW_RLE_base_addressx 0x01 /* DWARF5 */ +#define DW_RLE_startx_endx 0x02 /* DWARF5 */ +#define DW_RLE_startx_length 0x03 /* DWARF5 */ +#define DW_RLE_offset_pair 0x04 /* DWARF5 */ +#define DW_RLE_base_address 0x05 /* DWARF5 */ +#define DW_RLE_start_end 0x06 /* DWARF5 */ +#define DW_RLE_start_length 0x07 /* DWARF5 */ + +/* DWARF5 Unit header unit type encodings */ +#define DW_UT_compile 0x01 /* DWARF5 */ +#define DW_UT_type 0x02 /* DWARF5 */ +#define DW_UT_partial 0x03 /* DWARF5 */ +#define DW_UT_skeleton 0x04 /* DWARF5 */ +#define DW_UT_split_compile 0x05 /* DWARF5 */ +#define DW_UT_split_type 0x06 /* DWARF5 */ +#define DW_UT_lo_user 0x80 /* DWARF5 */ +#define DW_UT_hi_user 0xff /* DWARF5 */ + + +/* DWARF5 DebugFission object section id values + for .dwp object section offsets hash table. + 0 is reserved, not used. + 2 is actually reserved, not used in DWARF5. + But 2 may be seen in some DWARF4 objects. +*/ +#define DW_SECT_INFO 1 /* .debug_info.dwo DWARF5 */ +#define DW_SECT_TYPES 2 /* .debug_types.dwo pre-DWARF5 */ +#define DW_SECT_ABBREV 3 /* .debug_abbrev.dwo DWARF5 */ +#define DW_SECT_LINE 4 /* .debug_line.dwo DWARF5 */ +#define DW_SECT_LOCLISTS 5 /* .debug_loclists.dwo DWARF5 */ +#define DW_SECT_STR_OFFSETS 6 /* .debug_str_offsets.dwo DWARF5 */ +#define DW_SECT_MACRO 7 /* .debug_macro.dwo DWARF5 */ +#define DW_SECT_RNGLISTS 8 /* .debug_rnglists.dwo DWARF5 */ + + +/* Decimal Sign codes. */ +#define DW_DS_unsigned 0x01 /* DWARF3f */ +#define DW_DS_leading_overpunch 0x02 /* DWARF3f */ +#define DW_DS_trailing_overpunch 0x03 /* DWARF3f */ +#define DW_DS_leading_separate 0x04 /* DWARF3f */ +#define DW_DS_trailing_separate 0x05 /* DWARF3f */ + +/* Endian code name. */ +#define DW_END_default 0x00 /* DWARF3f */ +#define DW_END_big 0x01 /* DWARF3f */ +#define DW_END_little 0x02 /* DWARF3f */ + +#define DW_END_lo_user 0x40 /* DWARF3f */ +#define DW_END_hi_user 0xff /* DWARF3f */ + +/* For use with DW_TAG_SUN_codeflags + If DW_TAG_SUN_codeflags is accepted as a dwarf standard, then + standard dwarf ATCF entries start at 0x01 */ +#define DW_ATCF_lo_user 0x40 /* SUN */ +#define DW_ATCF_SUN_mop_bitfield 0x41 /* SUN */ +#define DW_ATCF_SUN_mop_spill 0x42 /* SUN */ +#define DW_ATCF_SUN_mop_scopy 0x43 /* SUN */ +#define DW_ATCF_SUN_func_start 0x44 /* SUN */ +#define DW_ATCF_SUN_end_ctors 0x45 /* SUN */ +#define DW_ATCF_SUN_branch_target 0x46 /* SUN */ +#define DW_ATCF_SUN_mop_stack_probe 0x47 /* SUN */ +#define DW_ATCF_SUN_func_epilog 0x48 /* SUN */ +#define DW_ATCF_hi_user 0xff /* SUN */ + +/* Accessibility code name. */ +#define DW_ACCESS_public 0x01 +#define DW_ACCESS_protected 0x02 +#define DW_ACCESS_private 0x03 + +/* Visibility code name. */ +#define DW_VIS_local 0x01 +#define DW_VIS_exported 0x02 +#define DW_VIS_qualified 0x03 + +/* Virtuality code name. */ +#define DW_VIRTUALITY_none 0x00 +#define DW_VIRTUALITY_virtual 0x01 +#define DW_VIRTUALITY_pure_virtual 0x02 + +#define DW_LANG_C89 0x0001 +#define DW_LANG_C 0x0002 +#define DW_LANG_Ada83 0x0003 +#define DW_LANG_C_plus_plus 0x0004 +#define DW_LANG_Cobol74 0x0005 +#define DW_LANG_Cobol85 0x0006 +#define DW_LANG_Fortran77 0x0007 +#define DW_LANG_Fortran90 0x0008 +#define DW_LANG_Pascal83 0x0009 +#define DW_LANG_Modula2 0x000a +#define DW_LANG_Java 0x000b /* DWARF3 */ +#define DW_LANG_C99 0x000c /* DWARF3 */ +#define DW_LANG_Ada95 0x000d /* DWARF3 */ +#define DW_LANG_Fortran95 0x000e /* DWARF3 */ +#define DW_LANG_PLI 0x000f /* DWARF3 */ +#define DW_LANG_ObjC 0x0010 /* DWARF3f */ +#define DW_LANG_ObjC_plus_plus 0x0011 /* DWARF3f */ +#define DW_LANG_UPC 0x0012 /* DWARF3f */ +#define DW_LANG_D 0x0013 /* DWARF3f */ +#define DW_LANG_Python 0x0014 /* DWARF4 */ +/* The following 2 are not yet formally approved October 2010, but + it seems extremely likely they will be approved as the committee + chair agrees these should be ok and no one on the committee + has objected. */ +#define DW_LANG_OpenCL 0x0015 /* DWARF5 */ +#define DW_LANG_Go 0x0016 /* DWARF5 */ +#define DW_LANG_Modula3 0x0017 /* DWARF5 */ +#define DW_LANG_Haskel 0x0018 /* DWARF5 */ +#define DW_LANG_C_plus_plus_03 0x0019 /* DWARF5 */ +#define DW_LANG_C_plus_plus_11 0x001a /* DWARF5 */ +#define DW_LANG_OCaml 0x001b /* DWARF5 */ +#define DW_LANG_Rust 0x001c /* DWARF5 */ +#define DW_LANG_C11 0x001d /* DWARF5 */ +#define DW_LANG_Swift 0x001e /* DWARF5 */ +#define DW_LANG_Julia 0x001f /* DWARF5 */ +#define DW_LANG_Dylan 0x0020 /* DWARF5 */ +#define DW_LANG_C_plus_plus_14 0x0021 /* DWARF5 */ +#define DW_LANG_Fortran03 0x0022 /* DWARF5 */ +#define DW_LANG_Fortran08 0x0023 /* DWARF5 */ +#define DW_LANG_RenderScript 0x0024 /* DWARF5 */ +#define DW_LANG_BLISS 0x0025 /* DWARF5 */ +#define DW_LANG_lo_user 0x8000 +#define DW_LANG_Mips_Assembler 0x8001 /* MIPS */ +#define DW_LANG_Upc 0x8765 /* UPC, use + DW_LANG_UPC instead. */ +/* ALTIUM extension */ +#define DW_LANG_ALTIUM_Assembler 0x9101 /* ALTIUM */ + +/* Sun extensions */ +#define DW_LANG_SUN_Assembler 0x9001 /* SUN */ + +#define DW_LANG_hi_user 0xffff + +/* Identifier case name. */ +#define DW_ID_case_sensitive 0x00 +#define DW_ID_up_case 0x01 +#define DW_ID_down_case 0x02 +#define DW_ID_case_insensitive 0x03 + +/* Calling Convention Name. */ +#define DW_CC_normal 0x01 +#define DW_CC_program 0x02 +#define DW_CC_nocall 0x03 +#define DW_CC_pass_by_reference 0x04 /* DWARF5 */ +#define DW_CC_pass_by_value 0x05 /* DWARF5 */ +#define DW_CC_lo_user 0x40 + +#define DW_CC_GNU_renesas_sh 0x40 /* GNU */ +#define DW_CC_GNU_borland_fastcall_i386 0x41 /* GNU */ + + + +/* ALTIUM extensions. */ +/* Function is an interrupt handler, return address on system stack. */ +#define DW_CC_ALTIUM_interrupt 0x65 /* ALTIUM*/ + +/* Near function model, return address on system stack. */ +#define DW_CC_ALTIUM_near_system_stack 0x66 /*ALTIUM */ + +/* Near function model, return address on user stack. */ +#define DW_CC_ALTIUM_near_user_stack 0x67 /* ALTIUM */ + +/* Huge function model, return address on user stack. */ +#define DW_CC_ALTIUM_huge_user_stack 0x68 /* ALTIUM */ + + +#define DW_CC_hi_user 0xff + +/* Inline Code Name. */ +#define DW_INL_not_inlined 0x00 +#define DW_INL_inlined 0x01 +#define DW_INL_declared_not_inlined 0x02 +#define DW_INL_declared_inlined 0x03 + +/* Ordering Name. */ +#define DW_ORD_row_major 0x00 +#define DW_ORD_col_major 0x01 + +/* Discriminant Descriptor Name. */ +#define DW_DSC_label 0x00 +#define DW_DSC_range 0x01 + +/* Line number header entry format encodings. DWARF5 */ +#define DW_LNCT_path 0x1 /* DWARF5 */ +#define DW_LNCT_directory_index 0x2 /* DWARF5 */ +#define DW_LNCT_timestamp 0x3 /* DWARF5 */ +#define DW_LNCT_size 0x4 /* DWARF5 */ +#define DW_LNCT_MD5 0x5 /* DWARF5 */ +/* Experimental two-level line tables. Non standard */ +#define DW_LNCT_GNU_subprogram_name 0x6 +#define DW_LNCT_GNU_decl_file 0x7 +#define DW_LNCT_GNU_decl_line 0x8 +#define DW_LNCT_lo_user 0x2000 /* DWARF5 */ +#define DW_LNCT_hi_user 0x3fff /* DWARF5 */ + +/* Line number standard opcode name. */ +#define DW_LNS_copy 0x01 +#define DW_LNS_advance_pc 0x02 +#define DW_LNS_advance_line 0x03 +#define DW_LNS_set_file 0x04 +#define DW_LNS_set_column 0x05 +#define DW_LNS_negate_stmt 0x06 +#define DW_LNS_set_basic_block 0x07 +#define DW_LNS_const_add_pc 0x08 +#define DW_LNS_fixed_advance_pc 0x09 +#define DW_LNS_set_prologue_end 0x0a /* DWARF3 */ +#define DW_LNS_set_epilogue_begin 0x0b /* DWARF3 */ +#define DW_LNS_set_isa 0x0c /* DWARF3 */ + +/* Experimental two-level line tables. NOT STD DWARF5 */ +/* Not saying GNU or anything. There are no + DW_LNS_lo_user or DW_LNS_hi_user values though. + DW_LNS_set_address_from_logical and + DW_LNS_set_subprogram being both 0xd + to avoid using up more space in the special opcode table. + EXPERIMENTAL DW_LNS follow. +*/ +#define DW_LNS_set_address_from_logical 0x0d /* Actuals table only */ +#define DW_LNS_set_subprogram 0x0d /* Logicals table only */ +#define DW_LNS_inlined_call 0x0e /* Logicals table only */ +#define DW_LNS_pop_context 0x0f /* Logicals table only */ + +/* Line number extended opcode name. */ +#define DW_LNE_end_sequence 0x01 +#define DW_LNE_set_address 0x02 +#define DW_LNE_define_file 0x03 /* DWARF4 and earlier only */ +#define DW_LNE_set_discriminator 0x04 /* DWARF4 */ + +/* HP extensions. */ +#define DW_LNE_HP_negate_is_UV_update 0x11 /* 17 HP */ +#define DW_LNE_HP_push_context 0x12 /* 18 HP */ +#define DW_LNE_HP_pop_context 0x13 /* 19 HP */ +#define DW_LNE_HP_set_file_line_column 0x14 /* 20 HP */ +#define DW_LNE_HP_set_routine_name 0x15 /* 21 HP */ +#define DW_LNE_HP_set_sequence 0x16 /* 22 HP */ +#define DW_LNE_HP_negate_post_semantics 0x17 /* 23 HP */ +#define DW_LNE_HP_negate_function_exit 0x18 /* 24 HP */ +#define DW_LNE_HP_negate_front_end_logical 0x19 /* 25 HP */ +#define DW_LNE_HP_define_proc 0x20 /* 32 HP */ + +#define DW_LNE_HP_source_file_correlation 0x80 /* HP */ +#define DW_LNE_lo_user 0x80 /* DWARF3 */ +#define DW_LNE_hi_user 0xff /* DWARF3 */ + +/* These are known values for DW_LNS_set_isa. */ +/* These identifiers are not defined by any DWARFn standard. */ +#define DW_ISA_UNKNOWN 0 +/* The following two are ARM specific. */ +#define DW_ISA_ARM_thumb 1 /* ARM ISA */ +#define DW_ISA_ARM_arm 2 /* ARM ISA */ + + +/* Macro information, DWARF5 */ +#define DW_MACRO_define 0x01 /* DWARF5 */ +#define DW_MACRO_undef 0x02 /* DWARF5 */ +#define DW_MACRO_start_file 0x03 /* DWARF5 */ +#define DW_MACRO_end_file 0x04 /* DWARF5 */ +#define DW_MACRO_define_strp 0x05 /* DWARF5 */ +#define DW_MACRO_undef_strp 0x06 /* DWARF5 */ +#define DW_MACRO_import 0x07 /* DWARF5 */ +#define DW_MACRO_define_sup 0x08 /* DWARF5 */ +#define DW_MACRO_undef_sup 0x09 /* DWARF5 */ +#define DW_MACRO_import_sup 0x0a /* DWARF5 */ +#define DW_MACRO_define_strx 0x0b /* DWARF5 */ +#define DW_MACRO_undef_strx 0x0c /* DWARF5 */ +#define DW_MACRO_lo_user 0xe0 +#define DW_MACRO_hi_user 0xff + +/* Macro information, DWARF2-DWARF4. */ +#define DW_MACINFO_define 0x01 +#define DW_MACINFO_undef 0x02 +#define DW_MACINFO_start_file 0x03 +#define DW_MACINFO_end_file 0x04 +#define DW_MACINFO_vendor_ext 0xff + +/* CFA operator compaction (a space saving measure, see + the DWARF standard) means DW_CFA_extended and DW_CFA_nop + have the same value here. */ +#define DW_CFA_advance_loc 0x40 +#define DW_CFA_offset 0x80 +#define DW_CFA_restore 0xc0 +#define DW_CFA_extended 0 + +#define DW_CFA_nop 0x00 +#define DW_CFA_set_loc 0x01 +#define DW_CFA_advance_loc1 0x02 +#define DW_CFA_advance_loc2 0x03 +#define DW_CFA_advance_loc4 0x04 +#define DW_CFA_offset_extended 0x05 +#define DW_CFA_restore_extended 0x06 +#define DW_CFA_undefined 0x07 +#define DW_CFA_same_value 0x08 +#define DW_CFA_register 0x09 +#define DW_CFA_remember_state 0x0a +#define DW_CFA_restore_state 0x0b +#define DW_CFA_def_cfa 0x0c +#define DW_CFA_def_cfa_register 0x0d +#define DW_CFA_def_cfa_offset 0x0e +#define DW_CFA_def_cfa_expression 0x0f /* DWARF3 */ +#define DW_CFA_expression 0x10 /* DWARF3 */ +#define DW_CFA_offset_extended_sf 0x11 /* DWARF3 */ +#define DW_CFA_def_cfa_sf 0x12 /* DWARF3 */ +#define DW_CFA_def_cfa_offset_sf 0x13 /* DWARF3 */ +#define DW_CFA_val_offset 0x14 /* DWARF3f */ +#define DW_CFA_val_offset_sf 0x15 /* DWARF3f */ +#define DW_CFA_val_expression 0x16 /* DWARF3f */ +#define DW_CFA_lo_user 0x1c +#define DW_CFA_low_user 0x1c /* Incorrect spelling, do not use. */ + +/* SGI/MIPS extension. */ +#define DW_CFA_MIPS_advance_loc8 0x1d /* MIPS */ + +/* GNU extensions. */ +#define DW_CFA_GNU_window_save 0x2d /* GNU */ +#define DW_CFA_GNU_args_size 0x2e /* GNU */ +#define DW_CFA_GNU_negative_offset_extended 0x2f /* GNU */ + +/* Metaware if HC is augmentation, apparently meaning High C + and the op has a single uleb operand. + See http://sourceforge.net/p/elftoolchain/tickets/397/ */ +#define DW_CFA_METAWARE_info 0x34 + +#define DW_CFA_high_user 0x3f + +/* GNU exception header encoding. See the Generic + Elf Specification of the Linux Standard Base (LSB). + http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/dwarfext.html + The upper 4 bits indicate how the value is to be applied. + The lower 4 bits indicate the format of the data. + These identifiers are not defined by any DWARFn standard. +*/ +#define DW_EH_PE_absptr 0x00 /* GNU */ +#define DW_EH_PE_uleb128 0x01 /* GNU */ +#define DW_EH_PE_udata2 0x02 /* GNU */ +#define DW_EH_PE_udata4 0x03 /* GNU */ +#define DW_EH_PE_udata8 0x04 /* GNU */ +#define DW_EH_PE_sleb128 0x09 /* GNU */ +#define DW_EH_PE_sdata2 0x0A /* GNU */ +#define DW_EH_PE_sdata4 0x0B /* GNU */ +#define DW_EH_PE_sdata8 0x0C /* GNU */ + +#define DW_EH_PE_pcrel 0x10 /* GNU */ +#define DW_EH_PE_textrel 0x20 /* GNU */ +#define DW_EH_PE_datarel 0x30 /* GNU */ +#define DW_EH_PE_funcrel 0x40 /* GNU */ +#define DW_EH_PE_aligned 0x50 /* GNU */ + +#define DW_EH_PE_omit 0xff /* GNU. Means no value present. */ + + +/* Mapping from machine registers and pseudo-regs into the + .debug_frame table. DW_FRAME entries are machine specific. + These describe MIPS/SGI R3000, R4K, R4400 and all later + MIPS/SGI IRIX machines. They describe a mapping from + hardware register number to the number used in the table + to identify that register. + + The CFA (Canonical Frame Address) described in DWARF is + called the Virtual Frame Pointer on MIPS/SGI machines. + + The DW_FRAME* names here are MIPS/SGI specific. + Libdwarf interfaces defined in 2008 make the + frame definitions here (and the fixed table sizes + they imply) obsolete. They are left here for compatibility. +*/ +/* Default column used for CFA in the libdwarf reader client. + Assumes reg 0 never appears as + a register in DWARF information. Usable for MIPS, + but never a good idea, really. */ +/* These identifiers are not defined by any DWARFn standard. */ +#define DW_FRAME_CFA_COL 0 + +#define DW_FRAME_REG1 1 /* integer reg 1 */ +#define DW_FRAME_REG2 2 /* integer reg 2 */ +#define DW_FRAME_REG3 3 /* integer reg 3 */ +#define DW_FRAME_REG4 4 /* integer reg 4 */ +#define DW_FRAME_REG5 5 /* integer reg 5 */ +#define DW_FRAME_REG6 6 /* integer reg 6 */ +#define DW_FRAME_REG7 7 /* integer reg 7 */ +#define DW_FRAME_REG8 8 /* integer reg 8 */ +#define DW_FRAME_REG9 9 /* integer reg 9 */ +#define DW_FRAME_REG10 10 /* integer reg 10 */ +#define DW_FRAME_REG11 11 /* integer reg 11 */ +#define DW_FRAME_REG12 12 /* integer reg 12 */ +#define DW_FRAME_REG13 13 /* integer reg 13 */ +#define DW_FRAME_REG14 14 /* integer reg 14 */ +#define DW_FRAME_REG15 15 /* integer reg 15 */ +#define DW_FRAME_REG16 16 /* integer reg 16 */ +#define DW_FRAME_REG17 17 /* integer reg 17 */ +#define DW_FRAME_REG18 18 /* integer reg 18 */ +#define DW_FRAME_REG19 19 /* integer reg 19 */ +#define DW_FRAME_REG20 20 /* integer reg 20 */ +#define DW_FRAME_REG21 21 /* integer reg 21 */ +#define DW_FRAME_REG22 22 /* integer reg 22 */ +#define DW_FRAME_REG23 23 /* integer reg 23 */ +#define DW_FRAME_REG24 24 /* integer reg 24 */ +#define DW_FRAME_REG25 25 /* integer reg 25 */ +#define DW_FRAME_REG26 26 /* integer reg 26 */ +#define DW_FRAME_REG27 27 /* integer reg 27 */ +#define DW_FRAME_REG28 28 /* integer reg 28 */ +#define DW_FRAME_REG29 29 /* integer reg 29 */ +#define DW_FRAME_REG30 30 /* integer reg 30 */ +#define DW_FRAME_REG31 31 /* integer reg 31, aka ra */ + + /* MIPS1, 2 have only some of these 64-bit registers. + ** MIPS1 save/restore takes 2 instructions per 64-bit reg, and + ** in that case, the register is considered stored after the second + ** swc1. + */ +#define DW_FRAME_FREG0 32 /* 64-bit floating point reg 0 */ +#define DW_FRAME_FREG1 33 /* 64-bit floating point reg 1 */ +#define DW_FRAME_FREG2 34 /* 64-bit floating point reg 2 */ +#define DW_FRAME_FREG3 35 /* 64-bit floating point reg 3 */ +#define DW_FRAME_FREG4 36 /* 64-bit floating point reg 4 */ +#define DW_FRAME_FREG5 37 /* 64-bit floating point reg 5 */ +#define DW_FRAME_FREG6 38 /* 64-bit floating point reg 6 */ +#define DW_FRAME_FREG7 39 /* 64-bit floating point reg 7 */ +#define DW_FRAME_FREG8 40 /* 64-bit floating point reg 8 */ +#define DW_FRAME_FREG9 41 /* 64-bit floating point reg 9 */ +#define DW_FRAME_FREG10 42 /* 64-bit floating point reg 10 */ +#define DW_FRAME_FREG11 43 /* 64-bit floating point reg 11 */ +#define DW_FRAME_FREG12 44 /* 64-bit floating point reg 12 */ +#define DW_FRAME_FREG13 45 /* 64-bit floating point reg 13 */ +#define DW_FRAME_FREG14 46 /* 64-bit floating point reg 14 */ +#define DW_FRAME_FREG15 47 /* 64-bit floating point reg 15 */ +#define DW_FRAME_FREG16 48 /* 64-bit floating point reg 16 */ +#define DW_FRAME_FREG17 49 /* 64-bit floating point reg 17 */ +#define DW_FRAME_FREG18 50 /* 64-bit floating point reg 18 */ +#define DW_FRAME_FREG19 51 /* 64-bit floating point reg 19 */ +#define DW_FRAME_FREG20 52 /* 64-bit floating point reg 20 */ +#define DW_FRAME_FREG21 53 /* 64-bit floating point reg 21 */ +#define DW_FRAME_FREG22 54 /* 64-bit floating point reg 22 */ +#define DW_FRAME_FREG23 55 /* 64-bit floating point reg 23 */ +#define DW_FRAME_FREG24 56 /* 64-bit floating point reg 24 */ +#define DW_FRAME_FREG25 57 /* 64-bit floating point reg 25 */ +#define DW_FRAME_FREG26 58 /* 64-bit floating point reg 26 */ +#define DW_FRAME_FREG27 59 /* 64-bit floating point reg 27 */ +#define DW_FRAME_FREG28 60 /* 64-bit floating point reg 28 */ +#define DW_FRAME_FREG29 61 /* 64-bit floating point reg 29 */ +#define DW_FRAME_FREG30 62 /* 64-bit floating point reg 30 */ +#define DW_FRAME_FREG31 63 /* 64-bit floating point reg 31 */ + +#define DW_FRAME_FREG32 64 /* 64-bit floating point reg 32 */ +#define DW_FRAME_FREG33 65 /* 64-bit floating point reg 33 */ +#define DW_FRAME_FREG34 66 /* 64-bit floating point reg 34 */ +#define DW_FRAME_FREG35 67 /* 64-bit floating point reg 35 */ +#define DW_FRAME_FREG36 68 /* 64-bit floating point reg 36 */ +#define DW_FRAME_FREG37 69 /* 64-bit floating point reg 37 */ +#define DW_FRAME_FREG38 70 /* 64-bit floating point reg 38 */ +#define DW_FRAME_FREG39 71 /* 64-bit floating point reg 39 */ +#define DW_FRAME_FREG40 72 /* 64-bit floating point reg 40 */ +#define DW_FRAME_FREG41 73 /* 64-bit floating point reg 41 */ +#define DW_FRAME_FREG42 74 /* 64-bit floating point reg 42 */ +#define DW_FRAME_FREG43 75 /* 64-bit floating point reg 43 */ +#define DW_FRAME_FREG44 76 /* 64-bit floating point reg 44 */ +#define DW_FRAME_FREG45 77 /* 64-bit floating point reg 45 */ +#define DW_FRAME_FREG46 78 /* 64-bit floating point reg 46 */ +#define DW_FRAME_FREG47 79 /* 64-bit floating point reg 47 */ +#define DW_FRAME_FREG48 80 /* 64-bit floating point reg 48 */ +#define DW_FRAME_FREG49 81 /* 64-bit floating point reg 49 */ +#define DW_FRAME_FREG50 82 /* 64-bit floating point reg 50 */ +#define DW_FRAME_FREG51 83 /* 64-bit floating point reg 51 */ +#define DW_FRAME_FREG52 84 /* 64-bit floating point reg 52 */ +#define DW_FRAME_FREG53 85 /* 64-bit floating point reg 53 */ +#define DW_FRAME_FREG54 86 /* 64-bit floating point reg 54 */ +#define DW_FRAME_FREG55 87 /* 64-bit floating point reg 55 */ +#define DW_FRAME_FREG56 88 /* 64-bit floating point reg 56 */ +#define DW_FRAME_FREG57 89 /* 64-bit floating point reg 57 */ +#define DW_FRAME_FREG58 90 /* 64-bit floating point reg 58 */ +#define DW_FRAME_FREG59 91 /* 64-bit floating point reg 59 */ +#define DW_FRAME_FREG60 92 /* 64-bit floating point reg 60 */ +#define DW_FRAME_FREG61 93 /* 64-bit floating point reg 61 */ +#define DW_FRAME_FREG62 94 /* 64-bit floating point reg 62 */ +#define DW_FRAME_FREG63 95 /* 64-bit floating point reg 63 */ +#define DW_FRAME_FREG64 96 /* 64-bit floating point reg 64 */ +#define DW_FRAME_FREG65 97 /* 64-bit floating point reg 65 */ +#define DW_FRAME_FREG66 98 /* 64-bit floating point reg 66 */ +#define DW_FRAME_FREG67 99 /* 64-bit floating point reg 67 */ +#define DW_FRAME_FREG68 100 /* 64-bit floating point reg 68 */ +#define DW_FRAME_FREG69 101 /* 64-bit floating point reg 69 */ +#define DW_FRAME_FREG70 102 /* 64-bit floating point reg 70 */ +#define DW_FRAME_FREG71 103 /* 64-bit floating point reg 71 */ +#define DW_FRAME_FREG72 104 /* 64-bit floating point reg 72 */ +#define DW_FRAME_FREG73 105 /* 64-bit floating point reg 73 */ +#define DW_FRAME_FREG74 106 /* 64-bit floating point reg 74 */ +#define DW_FRAME_FREG75 107 /* 64-bit floating point reg 75 */ +#define DW_FRAME_FREG76 108 /* 64-bit floating point reg 76 */ + +/* ***IMPORTANT NOTE, TARGET DEPENDENCY **** + The following 4 #defines are dependent on + the target cpu(s) that you apply libdwarf to. + Ensure that DW_FRAME_UNDEFINED_VAL and DW_FRAME_SAME_VAL + do not conflict with the range [0-DW_FRAME_STATIC_LINK]. + The value 63 works for MIPS cpus at least up to the R16000. + + For a cpu with more than 63 real registers + DW_FRAME_HIGHEST_NORMAL_REGISTER + must be increased for things to work properly! + Also ensure that DW_FRAME_UNDEFINED_VAL DW_FRAME_SAME_VAL + are not in the range [0-DW_FRAME_STATIC_LINK] + + Having DW_FRAME_HIGHEST_NORMAL_REGISTER be higher than + is strictly needed is safe. + +*/ + +#ifndef DW_FRAME_HIGHEST_NORMAL_REGISTER +#define DW_FRAME_HIGHEST_NORMAL_REGISTER 188 +#endif +/* This is the number of columns in the Frame Table. + This constant should + be kept in sync with DW_REG_TABLE_SIZE defined in libdwarf.h + It must also be large enough to be beyond the highest + compiler-defined-register (meaning DW_FRAME_RA_COL DW_FRAME_STATIC_LINK + in the MIPS/IRIX case */ +#ifndef DW_FRAME_LAST_REG_NUM +#define DW_FRAME_LAST_REG_NUM (DW_FRAME_HIGHEST_NORMAL_REGISTER + 3) +#endif + + +/* Column recording ra (return address from a function call). + This is common to many architectures, but as a 'simple register' + is not necessarily adequate for all architectures. + For MIPS/IRIX this register number is actually recorded on disk + in the .debug_frame section. + */ +#define DW_FRAME_RA_COL (DW_FRAME_HIGHEST_NORMAL_REGISTER + 1) + +/* Column recording static link applicable to up-level + addressing, as in IRIX mp code, pascal, etc. + This is common to many architectures but + is not necessarily adequate for all architectures. + For MIPS/IRIX this register number is actually recorded on disk + in the .debug_frame section. +*/ +#define DW_FRAME_STATIC_LINK (DW_FRAME_HIGHEST_NORMAL_REGISTER + 2) + + + +/* + DW_FRAME_UNDEFINED_VAL and DW_FRAME_SAME_VAL are + never on disk, just generated by libdwarf. See libdwarf.h + for their values. +*/ + + + +#define DW_CHILDREN_no 0x00 +#define DW_CHILDREN_yes 0x01 + +#define DW_ADDR_none 0 + +#ifdef __cplusplus +} +#endif +#endif /* __DWARF_H */ diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h new file mode 100644 index 00000000000000..2fbb310083636f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h @@ -0,0 +1,3367 @@ +/* This file defines standard ELF types, structures, and macros. + Copyright (C) 1995-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ELF_H +#define _ELF_H 1 + +/* Standard ELF types. */ + +#include + +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +/* Type for version symbol information. */ +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ +} Elf64_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD. */ +#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */ +#define ELFOSABI_LINUX ELFOSABI_GNU /* Object uses GNU ELF extensions. */ +#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ +#define ELFOSABI_AIX 7 /* IBM AIX. */ +#define ELFOSABI_IRIX 8 /* SGI Irix. */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ +#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ + +#define EM_PARISC 15 /* HPPA */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ + +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ + +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II */ +#define EM_AARCH64 183 /* ARM AARCH64 */ +#define EM_TILEPRO 188 /* Tilera TILEPro */ +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ +#define EM_TILEGX 191 /* Tilera TILE-Gx */ +#define EM_NUM 192 + +/* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ + +#define EM_ALPHA 0x9026 + +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct +{ + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +typedef struct +{ + Elf64_Word sh_name; /* Section name (string tbl index) */ + Elf64_Word sh_type; /* Section type */ + Elf64_Xword sh_flags; /* Section flags */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Section size in bytes */ + Elf64_Word sh_link; /* Link to another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices *k/ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_BEFORE 0xff00 /* Order section before all others (Solaris). */ +#define SHN_AFTER 0xff01 /* Order section after all others (Solaris). */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ + +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific. */ +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */ +#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Legal values for sh_flags (section flags). */ + +#define SHF_WRITE (1 << 0) /* Writable */ +#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MERGE (1 << 4) /* Might be merged */ +#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ +#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ +#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling required */ +#define SHF_GROUP (1 << 9) /* Section is member of a group. */ +#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ +#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ +#define SHF_ORDERED (1 << 30) /* Special ordering requirement (Solaris). */ +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless referenced or allocated (Solaris).*/ + +/* Section compression header. Used when SHF_COMPRESSED is set. */ + +typedef struct +{ + Elf32_Word ch_type; /* Compression format. */ + Elf32_Word ch_size; /* Uncompressed data size. */ + Elf32_Word ch_addralign; /* Uncompressed data alignment. */ +} Elf32_Chdr; + +typedef struct +{ + Elf64_Word ch_type; /* Compression format. */ + Elf64_Word ch_reserved; + Elf64_Xword ch_size; /* Uncompressed data size. */ + Elf64_Xword ch_addralign; /* Uncompressed data alignment. */ +} Elf64_Chdr; + +/* Legal values for ch_type (compression algorithm). */ +#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE algorithm. */ +#define ELFCOMPRESS_LOOS 0x60000000 /* Start of OS-specific. */ +#define ELFCOMPRESS_HIOS 0x6fffffff /* End of OS-specific. */ +#define ELFCOMPRESS_LOPROC 0x70000000 /* Start of processor-specific. */ +#define ELFCOMPRESS_HIPROC 0x7fffffff /* End of processor-specific. */ + +/* Section group handling. */ +#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ + +/* Symbol table entry. */ + +typedef struct +{ + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +typedef struct +{ + Elf64_Word st_name; /* Symbol name (string tbl index) */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf64_Section st_shndx; /* Section index */ + Elf64_Addr st_value; /* Symbol value */ + Elf64_Xword st_size; /* Symbol size */ +} Elf64_Sym; + +/* The syminfo section if available contains additional information about + every dynamic symbol. */ + +typedef struct +{ + Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf32_Half si_flags; /* Per symbol flags */ +} Elf32_Syminfo; + +typedef struct +{ + Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf64_Half si_flags; /* Per symbol flags */ +} Elf64_Syminfo; + +/* Possible values for si_boundto. */ +#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ + +/* Possible bitmasks for si_flags. */ +#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ +#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy loaded */ +/* Syminfo version values. */ +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_GNU_UNIQUE 10 /* Unique symbol. */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_TLS 6 /* Symbol is thread-local data object*/ +#define STT_NUM 7 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* I have seen two different definitions of the Elf64_Rel and + Elf64_Rela structures, so we'll leave them out until Novell (or + whoever) gets their act together. */ +/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ +} Elf64_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ +} Elf64_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + +/* Program segment header. */ + +typedef struct +{ + Elf32_Word p_type; /* Segment type */ + Elf32_Off p_offset; /* Segment file offset */ + Elf32_Addr p_vaddr; /* Segment virtual address */ + Elf32_Addr p_paddr; /* Segment physical address */ + Elf32_Word p_filesz; /* Segment size in file */ + Elf32_Word p_memsz; /* Segment size in memory */ + Elf32_Word p_flags; /* Segment flags */ + Elf32_Word p_align; /* Segment alignment */ +} Elf32_Phdr; + +typedef struct +{ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment */ +} Elf64_Phdr; + +/* Special value for e_phnum. This indicates that the real number of + program headers is too large to fit into e_phnum. Instead the real + value is in the field sh_info of section 0. */ + +#define PN_XNUM 0xffff + +/* Legal values for p_type (segment type). */ + +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* Thread-local storage segment */ +#define PT_NUM 8 /* Number of defined types */ +#define PT_LOOS 0x60000000 /* Start of OS-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ +#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* End of OS-specific */ +#define PT_LOPROC 0x70000000 /* Start of processor-specific */ +#define PT_HIPROC 0x7fffffff /* End of processor-specific */ + +/* Legal values for p_flags (segment flags). */ + +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ +#define PF_MASKOS 0x0ff00000 /* OS-specific */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Legal values for note segment descriptor types for core files. */ + +#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ +#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ +#define NT_PRXREG 4 /* Contains copy of prxregset struct */ +#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ +#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* Contains copy of auxv array */ +#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ +#define NT_ASRS 8 /* Contains copy of asrset struct */ +#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ +#define NT_PSINFO 13 /* Contains copy of psinfo struct */ +#define NT_PRCRED 14 /* Contains copy of prcred struct */ +#define NT_UTSNAME 15 /* Contains copy of utsname struct */ +#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ +#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ +#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */ +#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t, size might increase */ +#define NT_FILE 0x46494c45 /* Contains information about mapped files */ +#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */ +#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ +#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ +#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ +#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ +#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ +#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ +#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */ +#define NT_S390_TIMER 0x301 /* s390 timer register */ +#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ +#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ +#define NT_S390_CTRS 0x304 /* s390 control registers */ +#define NT_S390_PREFIX 0x305 /* s390 prefix register */ +#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ +#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ +#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ +#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ +#define NT_ARM_TLS 0x401 /* ARM TLS register */ +#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ +#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ + +/* Legal values for the note segment descriptor types for object files. */ + +#define NT_VERSION 1 /* Contains a version string. */ + + +/* Dynamic section entry. */ + +typedef struct +{ + Elf32_Sword d_tag; /* Dynamic entry type */ + union + { + Elf32_Word d_val; /* Integer value */ + Elf32_Addr d_ptr; /* Address value */ + } d_un; +} Elf32_Dyn; + +typedef struct +{ + Elf64_Sxword d_tag; /* Dynamic entry type */ + union + { + Elf64_Xword d_val; /* Integer value */ + Elf64_Addr d_ptr; /* Address value */ + } d_un; +} Elf64_Dyn; + +/* Legal values for d_tag (dynamic entry type). */ + +#define DT_NULL 0 /* Marks end of dynamic section */ +#define DT_NEEDED 1 /* Name of needed library */ +#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ +#define DT_PLTGOT 3 /* Processor defined value */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocs */ +#define DT_RELASZ 8 /* Total size of Rela relocs */ +#define DT_RELAENT 9 /* Size of one Rela reloc */ +#define DT_STRSZ 10 /* Size of string table */ +#define DT_SYMENT 11 /* Size of one symbol table entry */ +#define DT_INIT 12 /* Address of init function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Name of shared object */ +#define DT_RPATH 15 /* Library search path (deprecated) */ +#define DT_SYMBOLIC 16 /* Start symbol search here */ +#define DT_REL 17 /* Address of Rel relocs */ +#define DT_RELSZ 18 /* Total size of Rel relocs */ +#define DT_RELENT 19 /* Size of one Rel reloc */ +#define DT_PLTREL 20 /* Type of reloc in PLT */ +#define DT_DEBUG 21 /* For debugging; unspecified */ +#define DT_TEXTREL 22 /* Reloc might modify .text */ +#define DT_JMPREL 23 /* Address of PLT relocs */ +#define DT_BIND_NOW 24 /* Process relocations of object */ +#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ +#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ +#define DT_RUNPATH 29 /* Library search path */ +#define DT_FLAGS 30 /* Flags for the object being loaded */ +#define DT_ENCODING 32 /* Start of encoded range */ +#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ +#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ +#define DT_NUM 34 /* Number used */ +#define DT_LOOS 0x6000000d /* Start of OS-specific */ +#define DT_HIOS 0x6ffff000 /* End of OS-specific */ +#define DT_LOPROC 0x70000000 /* Start of processor-specific */ +#define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM 0x36 /* Most used by any processor */ + +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's + approach. */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ +#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting the following DT_* entry. */ +#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ +#define DT_VALNUM 12 + +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + + If any adjustment is made to the ELF object after it has been + built these entries will need to be adjusted. */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */ +#define DT_TLSDESC_PLT 0x6ffffef6 +#define DT_TLSDESC_GOT 0x6ffffef7 +#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ +#define DT_CONFIG 0x6ffffefa /* Configuration information. */ +#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ +#define DT_AUDIT 0x6ffffefc /* Object auditing. */ +#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ +#define DT_MOVETAB 0x6ffffefe /* Move table. */ +#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 11 + +/* The versioning entry types. The next are defined as part of the GNU extension. */ +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + +/* These were chosen by Sun. */ +#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ +#define DT_VERDEF 0x6ffffffc /* Address of version definition table */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ +#define DT_VERNEED 0x6ffffffe /* Address of table with needed versions */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ +#define DT_VERSIONTAGNUM 16 + +/* Sun added these machine-independent extensions in the "processor-specific" range. Be compatible. */ +#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ +#define DT_FILTER 0x7fffffff /* Shared object to get values from */ +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + +/* Values of `d_un.d_val' in the DT_FLAGS entry. */ +#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ +#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ +#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ +#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ + +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry in the dynamic section. */ +#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ +#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ +#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ +#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ +#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ +#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ +#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ +#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ +#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ +#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ +#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ +#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ +#define DF_1_NODIRECT 0x00020000 /* Object has no-direct binding. */ +#define DF_1_IGNMULDEF 0x00040000 +#define DF_1_NOKSYMS 0x00080000 +#define DF_1_NOHDR 0x00100000 +#define DF_1_EDITED 0x00200000 /* Object is modified after built. */ +#define DF_1_NORELOC 0x00400000 +#define DF_1_SYMINTPOSE 0x00800000 /* Object has individual interposers. */ +#define DF_1_GLOBAUDIT 0x01000000 /* Global auditing required. */ +#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */ + +/* Flags for the feature selection in DT_FEATURE_1. */ +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ +#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ +#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not generally available. */ + +/* Version definition sections. */ + +typedef struct +{ + Elf32_Half vd_version; /* Version revision */ + Elf32_Half vd_flags; /* Version information */ + Elf32_Half vd_ndx; /* Version Index */ + Elf32_Half vd_cnt; /* Number of associated aux entries */ + Elf32_Word vd_hash; /* Version name hash value */ + Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf32_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf32_Verdef; + +typedef struct +{ + Elf64_Half vd_version; /* Version revision */ + Elf64_Half vd_flags; /* Version information */ + Elf64_Half vd_ndx; /* Version Index */ + Elf64_Half vd_cnt; /* Number of associated aux entries */ + Elf64_Word vd_hash; /* Version name hash value */ + Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf64_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf64_Verdef; + + +/* Legal values for vd_version (version revision). */ +#define VER_DEF_NONE 0 /* No version */ +#define VER_DEF_CURRENT 1 /* Current version */ +#define VER_DEF_NUM 2 /* Given version number */ + +/* Legal values for vd_flags (version information flags). */ +#define VER_FLG_BASE 0x1 /* Version definition of file itself */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + +/* Versym symbol index values. */ +#define VER_NDX_LOCAL 0 /* Symbol is local. */ +#define VER_NDX_GLOBAL 1 /* Symbol is global. */ +#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ +#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ + +/* Auxialiary version information. */ + +typedef struct +{ + Elf32_Word vda_name; /* Version or dependency names */ + Elf32_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf32_Verdaux; + +typedef struct +{ + Elf64_Word vda_name; /* Version or dependency names */ + Elf64_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf64_Verdaux; + + +/* Version dependency section. */ + +typedef struct +{ + Elf32_Half vn_version; /* Version of structure */ + Elf32_Half vn_cnt; /* Number of associated aux entries */ + Elf32_Word vn_file; /* Offset of filename for this + dependency */ + Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf32_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf32_Verneed; + +typedef struct +{ + Elf64_Half vn_version; /* Version of structure */ + Elf64_Half vn_cnt; /* Number of associated aux entries */ + Elf64_Word vn_file; /* Offset of filename for this + dependency */ + Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf64_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf64_Verneed; + + +/* Legal values for vn_version (version revision). */ +#define VER_NEED_NONE 0 /* No version */ +#define VER_NEED_CURRENT 1 /* Current version */ +#define VER_NEED_NUM 2 /* Given version number */ + +/* Auxiliary needed version information. */ + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name */ + Elf32_Half vna_flags; /* Dependency specific information */ + Elf32_Half vna_other; /* Unused */ + Elf32_Word vna_name; /* Dependency name string offset */ + Elf32_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf32_Vernaux; + +typedef struct +{ + Elf64_Word vna_hash; /* Hash value of dependency name */ + Elf64_Half vna_flags; /* Dependency specific information */ + Elf64_Half vna_other; /* Unused */ + Elf64_Word vna_name; /* Dependency name string offset */ + Elf64_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf64_Vernaux; + +/* Auxiliary vector. */ + +/* This vector is normally only used by the program interpreter. The + usual definition in an ABI supplement uses the name auxv_t. The + vector is not usually defined in a standard file, but it + can't hurt. We rename it to avoid conflicts. The sizes of these + types are an arrangement between the exec server and the program + interpreter, so we don't fully specify them here. */ + +typedef struct +{ + uint32_t a_type; /* Entry type */ + union + { + uint32_t a_val; /* Integer value */ + /* We use to have pointer elements added here. We cannot do that, + though, since it does not work when using 32-bit definitions + on 64-bit platforms and vice versa. */ + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + uint64_t a_type; /* Entry type */ + union + { + uint64_t a_val; /* Integer value */ + /* We use to have pointer elements added here. We cannot do that, + though, since it does not work when using 32-bit definitions + on 64-bit platforms and vice versa. */ + } a_un; +} Elf64_auxv_t; + +/* Note section contents. Each entry in the note section begins with + a header of a fixed form. */ + +typedef struct +{ + Elf32_Word n_namesz; /* Length of the note's name. */ + Elf32_Word n_descsz; /* Length of the note's descriptor. */ + Elf32_Word n_type; /* Type of the note. */ +} Elf32_Nhdr; + +typedef struct +{ + Elf64_Word n_namesz; /* Length of the note's name. */ + Elf64_Word n_descsz; /* Length of the note's descriptor. */ + Elf64_Word n_type; /* Type of the note. */ +} Elf64_Nhdr; + +/* Known names of notes. */ + +/* Solaris entries in the note section have this name. */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* Note entries for GNU systems have this name. */ +#define ELF_NOTE_GNU "GNU" + + +/* Defined types of notes for Solaris. */ + +/* Value of descriptor (one word) is desired pagesize for the binary. */ +#define ELF_NOTE_PAGESIZE_HINT 1 + + +/* Defined note types for GNU systems. */ + +/* ABI information. The descriptor consists of words: + word 0: OS descriptor + word 1: major version of the ABI + word 2: minor version of the ABI + word 3: subminor version of the ABI +*/ +#define NT_GNU_ABI_TAG 1 +#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */ + +/* Known OSes. These values can appear in word 0 of an + NT_GNU_ABI_TAG note section entry. */ +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + +/* Synthetic hwcap information. The descriptor begins with two words: + word 0: number of entries + word 1: bitmask of enabled entries + Then follow variable-length entries, one byte followed by a + '\0'-terminated hwcap name string. The byte gives the bit + number to test if enabled, (1U << bit) & bitmask. */ +#define NT_GNU_HWCAP 2 + +/* Build ID bits as generated by ld --build-id. + The descriptor consists of any nonzero number of bytes. */ +#define NT_GNU_BUILD_ID 3 + +/* Version note generated by GNU gold containing a version string. */ +#define NT_GNU_GOLD_VERSION 4 + + +/* Move records. */ +typedef struct +{ + Elf32_Xword m_value; /* Symbol value. */ + Elf32_Word m_info; /* Size and index. */ + Elf32_Word m_poffset; /* Symbol offset. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Stride info. */ +} Elf32_Move; + +typedef struct +{ + Elf64_Xword m_value; /* Symbol value. */ + Elf64_Xword m_info; /* Size and index. */ + Elf64_Xword m_poffset; /* Symbol offset. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Stride info. */ +} Elf64_Move; + +/* Macro to construct move records. */ +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + + +/* Motorola 68k specific definitions. */ + +/* Values for Elf32_Ehdr.e_flags. */ +#define EF_CPU32 0x00810000 + +/* m68k relocs. */ + +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ +#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */ +#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */ +#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */ +#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */ +#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */ +#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */ +#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */ +#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */ +#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */ +#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */ +#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */ +#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */ +#define R_68K_TLS_LE32 37 /* 32 bit offset relative to static TLS block */ +#define R_68K_TLS_LE16 38 /* 16 bit offset relative to static TLS block */ +#define R_68K_TLS_LE8 39 /* 8 bit offset relative to static TLS block */ +#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */ +#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */ +#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */ +/* Keep this the last entry. */ +#define R_68K_NUM 43 + +/* Intel 80386 specific definitions. */ + +/* i386 relocs. */ + +#define R_386_NONE 0 /* No reloc */ +#define R_386_32 1 /* Direct 32 bit */ +#define R_386_PC32 2 /* PC relative 32 bit */ +#define R_386_GOT32 3 /* 32 bit GOT entry */ +#define R_386_PLT32 4 /* 32 bit PLT address */ +#define R_386_COPY 5 /* Copy symbol at runtime */ +#define R_386_GLOB_DAT 6 /* Create GOT entry */ +#define R_386_JMP_SLOT 7 /* Create PLT entry */ +#define R_386_RELATIVE 8 /* Adjust by program base */ +#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ +#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ +#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS block offset */ +#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block offset */ +#define R_386_TLS_LE 17 /* Offset relative to static TLS block */ +#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of general dynamic thread local data */ +#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of local dynamic thread local data in LE code */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic + thread local data */ +#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ +#define R_386_TLS_GD_CALL 26 /* Relocation for call to + __tls_get_addr() */ +#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ +#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic + thread local data in LE code */ +#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ +#define R_386_TLS_LDM_CALL 30 /* Relocation for call to + __tls_get_addr() in LDM code */ +#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ +#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ +#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS + block offset */ +#define R_386_TLS_LE_32 34 /* Negated offset relative to static + TLS block */ +#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ +#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ +#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ +#define R_386_SIZE32 38 /* 32-bit symbol size */ +#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */ +#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS + descriptor for + relaxation. */ +#define R_386_TLS_DESC 41 /* TLS descriptor containing + pointer to code and to + argument, returning the TLS + offset for the symbol. */ +#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */ +/* Keep this the last entry. */ +#define R_386_NUM 43 + +/* SUN SPARC specific definitions. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ + +/* Values for Elf64_Ehdr.e_flags. */ + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 /* little endian data */ +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ + +/* SPARC relocs. */ + +#define R_SPARC_NONE 0 /* No reloc */ +#define R_SPARC_8 1 /* Direct 8 bit */ +#define R_SPARC_16 2 /* Direct 16 bit */ +#define R_SPARC_32 3 /* Direct 32 bit */ +#define R_SPARC_DISP8 4 /* PC relative 8 bit */ +#define R_SPARC_DISP16 5 /* PC relative 16 bit */ +#define R_SPARC_DISP32 6 /* PC relative 32 bit */ +#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ +#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ +#define R_SPARC_HI22 9 /* High 22 bit */ +#define R_SPARC_22 10 /* Direct 22 bit */ +#define R_SPARC_13 11 /* Direct 13 bit */ +#define R_SPARC_LO10 12 /* Truncated 10 bit */ +#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ +#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ +#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ +#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ +#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ +#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ +#define R_SPARC_COPY 19 /* Copy symbol at runtime */ +#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ +#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ +#define R_SPARC_RELATIVE 22 /* Adjust by program base */ +#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ + +/* Additional Sparc64 relocs. */ + +#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ +#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ +#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ +#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ +#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ +#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ +#define R_SPARC_10 30 /* Direct 10 bit */ +#define R_SPARC_11 31 /* Direct 11 bit */ +#define R_SPARC_64 32 /* Direct 64 bit */ +#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ +#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ +#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ +#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ +#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ +#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ +#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ +#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ +#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ +#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */ +#define R_SPARC_7 43 /* Direct 7 bit */ +#define R_SPARC_5 44 /* Direct 5 bit */ +#define R_SPARC_6 45 /* Direct 6 bit */ +#define R_SPARC_DISP64 46 /* PC relative 64 bit */ +#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ +#define R_SPARC_HIX22 48 /* High 22 bit complemented */ +#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ +#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ +#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ +#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ +#define R_SPARC_REGISTER 53 /* Global register usage */ +#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ +#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 +#define R_SPARC_SIZE32 86 +#define R_SPARC_SIZE64 87 +#define R_SPARC_WDISP10 88 +#define R_SPARC_JMP_IREL 248 +#define R_SPARC_IRELATIVE 249 +#define R_SPARC_GNU_VTINHERIT 250 +#define R_SPARC_GNU_VTENTRY 251 +#define R_SPARC_REV32 252 +/* Keep this the last entry. */ +#define R_SPARC_NUM 253 + +/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */ +#define EF_MIPS_PIC 2 /* Contains PIC code. */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */ +#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */ +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */ +#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */ +#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */ + +/* The following are unofficial names and should not be used. */ + +#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1 +#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2 +#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3 +#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4 +#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5 +#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32 +#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64 + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_PLT 0x8 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* Entries found in sections of type SHT_MIPS_GPTAB. */ + +typedef union +{ + struct + { + Elf32_Word gt_current_g_value; /* -G value used for compilation. */ + Elf32_Word gt_unused; /* Not used. */ + } gt_header; /* First entry in section. */ + struct + { + Elf32_Word gt_g_value; /* If this value were used for -G. */ + Elf32_Word gt_bytes; /* This many bytes would be used. */ + } gt_entry; /* Subsequent entries in section. */ +} Elf32_gptab; + +/* Entry found in sections of type SHT_MIPS_REGINFO. */ + +typedef struct +{ + Elf32_Word ri_gprmask; /* General registers used. */ + uint32_t ri_cprmask[4]; /* Coprocessor registers used. */ + Elf32_Sword ri_gp_value; /* $gp register value. */ +} Elf32_RegInfo; + +/* Entries found in sections of type SHT_MIPS_OPTIONS. */ + +typedef struct +{ + unsigned char kind; /* Determines interpretation of the + variable part of descriptor. */ + unsigned char size; /* Size of descriptor, including header. */ + Elf32_Section section; /* Section header index of section affected, + 0 for global options. */ + Elf32_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* Values for `kind' field in Elf_Options. */ + +#define ODK_NULL 0 /* Undefined. */ +#define ODK_REGINFO 1 /* Register usage information. */ +#define ODK_EXCEPTIONS 2 /* Exception processing options. */ +#define ODK_PAD 3 /* Section padding options. */ +#define ODK_HWPATCH 4 /* Hardware workarounds performed */ +#define ODK_FILL 5 /* record the fill value used by the linker. */ +#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ +#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ +#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ + +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ + +#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ +#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ +#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ +#define OEX_SMM 0x20000 /* Force sequential memory mode? */ +#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ + +#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ +#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ +#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ +#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + +/* Entry found in `.options' section. */ + +typedef struct +{ + Elf32_Word hwp_flags1; /* Extra flags. */ + Elf32_Word hwp_flags2; /* Extra flags. */ +} Elf_Options_Hw; + +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ +#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ +#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ +#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ +#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ +#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ +#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ +#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ +#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ +#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ +#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ +#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ +#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ +#define R_MIPS_GLOB_DAT 51 +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 +/* Keep this the last entry. */ +#define R_MIPS_NUM 128 + +/* Legal values for p_type field of Elf32_Phdr. */ + +#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */ +#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ +#define PT_MIPS_OPTIONS 0x70000002 +#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */ + +/* Special program header types. */ + +#define PF_MIPS_LOCAL 0x10000000 + +/* Legal values for d_tag field of Elf32_Dyn. */ + +#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ +#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ +#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ +#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ +#define DT_MIPS_FLAGS 0x70000005 /* Flags */ +#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ +#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ +#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ +#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ +#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ +#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ +#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ +#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in + DT_MIPS_DELTA_CLASS. */ +#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in + DT_MIPS_DELTA_INSTANCE. */ +#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in + DT_MIPS_DELTA_RELOC. */ +#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta + relocations refer to. */ +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in + DT_MIPS_DELTA_SYM. */ +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the + class declaration. */ +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in + DT_MIPS_DELTA_CLASSSYM. */ +#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ +#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve + function stored in GOT. */ +#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added + by rld on dlopen() calls. */ +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ +#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ +#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ +/* The address of .got.plt in an executable using the new non-PIC ABI. */ +#define DT_MIPS_PLTGOT 0x70000032 +/* The base of the PLT in an executable using the new non-PIC ABI if that + PLT is writable. For a non-writable PLT, this is omitted or has a zero + value. */ +#define DT_MIPS_RWPLT 0x70000034 +/* An alternative description of the classic MIPS RLD_MAP that is usable + in a PIE as it stores a relative offset from the address of the tag + rather than an absolute address. */ +#define DT_MIPS_RLD_MAP_REL 0x70000035 +#define DT_MIPS_NUM 0x36 + +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ + +#define RHF_NONE 0 /* No flags */ +#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ +#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + +/* Entries found in sections of type SHT_MIPS_LIBLIST. */ + +typedef struct +{ + Elf32_Word l_name; /* Name (string table index) */ + Elf32_Word l_time_stamp; /* Timestamp */ + Elf32_Word l_checksum; /* Checksum */ + Elf32_Word l_version; /* Interface version */ + Elf32_Word l_flags; /* Flags */ +} Elf32_Lib; + +typedef struct +{ + Elf64_Word l_name; /* Name (string table index) */ + Elf64_Word l_time_stamp; /* Timestamp */ + Elf64_Word l_checksum; /* Checksum */ + Elf64_Word l_version; /* Interface version */ + Elf64_Word l_flags; /* Flags */ +} Elf64_Lib; + + +/* Legal values for l_flags. */ + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ +#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + +/* Entries found in sections of type SHT_MIPS_CONFLICT. */ + +typedef Elf32_Addr Elf32_Conflict; + +typedef struct +{ + /* Version of flags structure. */ + Elf32_Half version; + /* The level of the ISA: 1-5, 32, 64. */ + unsigned char isa_level; + /* The revision of ISA: 0 for MIPS V and below, 1-n otherwise. */ + unsigned char isa_rev; + /* The size of general purpose registers. */ + unsigned char gpr_size; + /* The size of co-processor 1 registers. */ + unsigned char cpr1_size; + /* The size of co-processor 2 registers. */ + unsigned char cpr2_size; + /* The floating-point ABI. */ + unsigned char fp_abi; + /* Processor-specific extension. */ + Elf32_Word isa_ext; + /* Mask of ASEs used. */ + Elf32_Word ases; + /* Mask of general flags. */ + Elf32_Word flags1; + Elf32_Word flags2; +} Elf_MIPS_ABIFlags_v0; + +/* Values for the register size bytes of an abi flags structure. */ + +#define MIPS_AFL_REG_NONE 0x00 /* No registers. */ +#define MIPS_AFL_REG_32 0x01 /* 32-bit registers. */ +#define MIPS_AFL_REG_64 0x02 /* 64-bit registers. */ +#define MIPS_AFL_REG_128 0x03 /* 128-bit registers. */ + +/* Masks for the ases word of an ABI flags structure. */ + +#define MIPS_AFL_ASE_DSP 0x00000001 /* DSP ASE. */ +#define MIPS_AFL_ASE_DSPR2 0x00000002 /* DSP R2 ASE. */ +#define MIPS_AFL_ASE_EVA 0x00000004 /* Enhanced VA Scheme. */ +#define MIPS_AFL_ASE_MCU 0x00000008 /* MCU (MicroController) ASE. */ +#define MIPS_AFL_ASE_MDMX 0x00000010 /* MDMX ASE. */ +#define MIPS_AFL_ASE_MIPS3D 0x00000020 /* MIPS-3D ASE. */ +#define MIPS_AFL_ASE_MT 0x00000040 /* MT ASE. */ +#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 /* SmartMIPS ASE. */ +#define MIPS_AFL_ASE_VIRT 0x00000100 /* VZ ASE. */ +#define MIPS_AFL_ASE_MSA 0x00000200 /* MSA ASE. */ +#define MIPS_AFL_ASE_MIPS16 0x00000400 /* MIPS16 ASE. */ +#define MIPS_AFL_ASE_MICROMIPS 0x00000800 /* MICROMIPS ASE. */ +#define MIPS_AFL_ASE_XPA 0x00001000 /* XPA ASE. */ +#define MIPS_AFL_ASE_MASK 0x00001fff /* All ASEs. */ + +/* Values for the isa_ext word of an ABI flags structure. */ + +#define MIPS_AFL_EXT_XLR 1 /* RMI Xlr instruction. */ +#define MIPS_AFL_EXT_OCTEON2 2 /* Cavium Networks Octeon2. */ +#define MIPS_AFL_EXT_OCTEONP 3 /* Cavium Networks OcteonP. */ +#define MIPS_AFL_EXT_LOONGSON_3A 4 /* Loongson 3A. */ +#define MIPS_AFL_EXT_OCTEON 5 /* Cavium Networks Octeon. */ +#define MIPS_AFL_EXT_5900 6 /* MIPS R5900 instruction. */ +#define MIPS_AFL_EXT_4650 7 /* MIPS R4650 instruction. */ +#define MIPS_AFL_EXT_4010 8 /* LSI R4010 instruction. */ +#define MIPS_AFL_EXT_4100 9 /* NEC VR4100 instruction. */ +#define MIPS_AFL_EXT_3900 10 /* Toshiba R3900 instruction. */ +#define MIPS_AFL_EXT_10000 11 /* MIPS R10000 instruction. */ +#define MIPS_AFL_EXT_SB1 12 /* Broadcom SB-1 instruction. */ +#define MIPS_AFL_EXT_4111 13 /* NEC VR4111/VR4181 instruction. */ +#define MIPS_AFL_EXT_4120 14 /* NEC VR4120 instruction. */ +#define MIPS_AFL_EXT_5400 15 /* NEC VR5400 instruction. */ +#define MIPS_AFL_EXT_5500 16 /* NEC VR5500 instruction. */ +#define MIPS_AFL_EXT_LOONGSON_2E 17 /* ST Microelectronics Loongson 2E. */ +#define MIPS_AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */ + +/* Masks for the flags1 word of an ABI flags structure. */ +#define MIPS_AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */ + +/* HPPA specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ +#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ +#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ +#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ +#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch + prediction. */ +#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ +#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ + +/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ + +#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ +#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ +#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ + +/* Additional section indeces. */ + +#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared + symbols in ANSI C. */ +#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ +#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ +#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ +#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ +#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + +/* HPPA relocs. */ + +#define R_PARISC_NONE 0 /* No reloc. */ +#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ +#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ +#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ +#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ +#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ +#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ +#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ +#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ +#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ +#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ +#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ +#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ +#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ +#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ +#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ +#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ +#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ +#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ +#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ +#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ +#define R_PARISC_FPTR64 64 /* 64 bits function address. */ +#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ +#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */ +#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */ +#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ +#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ +#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ +#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ +#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ +#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ +#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ +#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ +#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ +#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ +#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ +#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ +#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ +#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ +#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ +#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ +#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 /* Copy relocation. */ +#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ +#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ +#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ +#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ +#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ +#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ +#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ +#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ +#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_GNU_VTENTRY 232 +#define R_PARISC_GNU_VTINHERIT 233 +#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */ +#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */ +#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */ +#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */ +#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */ +#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */ +#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */ +#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */ +#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */ +#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */ +#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */ +#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */ +#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L +#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R +#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L +#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R +#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 +#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 +#define R_PARISC_HIRESERVE 255 + +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + +/* Alpha specific definitions. */ + +/* Legal values for e_flags field of Elf64_Ehdr. */ + +#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ +#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ + +/* Legal values for sh_type field of Elf64_Shdr. */ + +/* These two are primerily concerned with ECOFF debugging info. */ +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + +/* Legal values for sh_flags field of Elf64_Shdr. */ + +#define SHF_ALPHA_GPREL 0x10000000 + +/* Legal values for st_other field of Elf64_Sym. */ +#define STO_ALPHA_NOPV 0x80 /* No PV required. */ +#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ + +/* Alpha relocs. */ + +#define R_ALPHA_NONE 0 /* No reloc */ +#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ +#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ +#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ +#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ +#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ +#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ +#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ +#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ +#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ +#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ +#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ +#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ +#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ +#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ +#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ +#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ +#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ +#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 +/* Keep this the last entry. */ +#define R_ALPHA_NUM 46 + +/* Magic values of the LITUSE relocation addend. */ +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + +/* Legal values for d_tag of Elf64_Dyn. */ +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) +#define DT_ALPHA_NUM 1 + +/* PowerPC specific declarations */ + +/* Values for Elf32/64_Ehdr.e_flags. */ +#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ + +/* Cygnus local bits below */ +#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib + flag */ + +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* PowerPC relocations defined for the TLS access ABI. */ +#define R_PPC_TLS 67 /* none (sym+add)@tls */ +#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ +#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ +#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ +#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ +#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ +#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ +#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ +#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ +#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ +#define R_PPC_TLSGD 95 /* none (sym+add)@tlsgd */ +#define R_PPC_TLSLD 96 /* none (sym+add)@tlsld */ + +/* The remaining relocs are from the Embedded ELF ABI, and are not + in the SVR4 ELF ABI. */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ + +/* Diab tool relocations. */ +#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ +#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ +#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ +#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ +#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ +#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ + +/* GNU extension to support local ifunc. */ +#define R_PPC_IRELATIVE 248 + +/* GNU relocs used in PIC code sequences. */ +#define R_PPC_REL16 249 /* half16 (sym+add-.) */ +#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */ +#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */ +#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */ + +/* This is a phony reloc to handle any old fashioned TOC16 references + that may still be in object files. */ +#define R_PPC_TOC16 255 + +/* PowerPC specific values for the Dyn d_tag field. */ +#define DT_PPC_GOT (DT_LOPROC + 0) +#define DT_PPC_OPT (DT_LOPROC + 1) +#define DT_PPC_NUM 2 + +/* PowerPC specific values for the DT_PPC_OPT Dyn entry. */ +#define PPC_OPT_TLS 1 + +/* PowerPC64 relocations defined by the ABIs */ +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ +#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ +#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ +#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ +#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ +#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ +#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ +#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ +#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ +#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ +#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ +#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ +#define R_PPC64_PLT64 45 /* doubleword64 L + A */ +#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ +#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ +#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ +#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ +#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ +#define R_PPC64_TOC 51 /* doubleword64 .TOC */ +#define R_PPC64_PLTGOT16 52 /* half16* M + A */ +#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ +#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ +#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ + +#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ +#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ +#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ +#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ +#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ +#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ +#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ +#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ +#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ +#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ +#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ + +/* PowerPC64 relocations defined for the TLS access ABI. */ +#define R_PPC64_TLS 67 /* none (sym+add)@tls */ +#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ +#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ +#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ +#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ +#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ +#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ +#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ +#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ +#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ +#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ +#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ +#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ +#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ +#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ +#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ +#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ +#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ +#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */ +#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */ +#define R_PPC64_TOCSAVE 109 /* none */ + +/* Added when HA and HI relocs were changed to report overflows. */ +#define R_PPC64_ADDR16_HIGH 110 +#define R_PPC64_ADDR16_HIGHA 111 +#define R_PPC64_TPREL16_HIGH 112 +#define R_PPC64_TPREL16_HIGHA 113 +#define R_PPC64_DTPREL16_HIGH 114 +#define R_PPC64_DTPREL16_HIGHA 115 + +/* GNU extension to support local ifunc. */ +#define R_PPC64_JMP_IREL 247 +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 /* half16 (sym+add-.) */ +#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */ +#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */ +#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */ + +/* e_flags bits specifying ABI. + 1 for original function descriptor using ABI, + 2 for revised ABI without function descriptors, + 0 for unspecified or not using any features affected by the differences. */ +#define EF_PPC64_ABI 3 + +/* PowerPC64 specific values for the Dyn d_tag field. */ +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_OPT (DT_LOPROC + 3) +#define DT_PPC64_NUM 4 + +/* PowerPC64 specific values for the DT_PPC64_OPT Dyn entry. */ +#define PPC64_OPT_TLS 1 +#define PPC64_OPT_MULTI_TOC 2 + +/* PowerPC64 specific values for the Elf64_Sym st_other field. */ +#define STO_PPC64_LOCAL_BIT 5 +#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT) +#define PPC64_LOCAL_ENTRY_OFFSET(other) \ + (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2) + + +/* ARM specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 +#define EF_ARM_SOFT_FLOAT 0x200 +#define EF_ARM_VFP_FLOAT 0x400 +#define EF_ARM_MAVERICK_FLOAT 0x800 + +#define EF_ARM_ABI_FLOAT_SOFT 0x200 /* NB conflicts with EF_ARM_SOFT_FLOAT */ +#define EF_ARM_ABI_FLOAT_HARD 0x400 /* NB conflicts with EF_ARM_VFP_FLOAT */ + + +/* Other constants defined in the ARM ELF spec. version B-01. */ +/* NB. These conflict with values defined above. */ +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + +/* Constants defined in AAELF. */ +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_LE8 0x00400000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + +/* Additional symbol types for Thumb. */ +#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ +#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ + +/* ARM-specific values for sh_flags */ +#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ +#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step. */ + +/* ARM-specific program header flags */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location + addressed by the static base. */ +#define PF_ARM_PI 0x20000000 /* Position-independent segment. */ +#define PF_ARM_ABS 0x40000000 /* Absolute segment. */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */ +#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */ +#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */ + + +/* AArch64 relocs. */ + +#define R_AARCH64_NONE 0 /* No relocation. */ + +/* ILP32 AArch64 relocs. */ +#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */ +#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */ +#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */ +#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */ +#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */ +#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */ +#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */ +#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */ +#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */ +#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */ + +/* LP64 AArch64 relocs. */ +#define R_AARCH64_ABS64 257 /* Direct 64 bit. */ +#define R_AARCH64_ABS32 258 /* Direct 32 bit. */ +#define R_AARCH64_ABS16 259 /* Direct 16-bit. */ +#define R_AARCH64_PREL64 260 /* PC-relative 64-bit. */ +#define R_AARCH64_PREL32 261 /* PC-relative 32-bit. */ +#define R_AARCH64_PREL16 262 /* PC-relative 16-bit. */ +#define R_AARCH64_MOVW_UABS_G0 263 /* Dir. MOVZ imm. from bits 15:0. */ +#define R_AARCH64_MOVW_UABS_G0_NC 264 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_UABS_G1 265 /* Dir. MOVZ imm. from bits 31:16. */ +#define R_AARCH64_MOVW_UABS_G1_NC 266 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_UABS_G2 267 /* Dir. MOVZ imm. from bits 47:32. */ +#define R_AARCH64_MOVW_UABS_G2_NC 268 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_UABS_G3 269 /* Dir. MOV{K,Z} imm. from 63:48. */ +#define R_AARCH64_MOVW_SABS_G0 270 /* Dir. MOV{N,Z} imm. from 15:0. */ +#define R_AARCH64_MOVW_SABS_G1 271 /* Dir. MOV{N,Z} imm. from 31:16. */ +#define R_AARCH64_MOVW_SABS_G2 272 /* Dir. MOV{N,Z} imm. from 47:32. */ +#define R_AARCH64_LD_PREL_LO19 273 /* PC-rel. LD imm. from bits 20:2. */ +#define R_AARCH64_ADR_PREL_LO21 274 /* PC-rel. ADR imm. from bits 20:0. */ +#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page-rel. ADRP imm. from 32:12. */ +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Likewise; no overflow check. */ +#define R_AARCH64_ADD_ABS_LO12_NC 277 /* Dir. ADD imm. from bits 11:0. */ +#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* Likewise for LD/ST; no check. */ +#define R_AARCH64_TSTBR14 279 /* PC-rel. TBZ/TBNZ imm. from 15:2. */ +#define R_AARCH64_CONDBR19 280 /* PC-rel. cond. br. imm. from 20:2. */ +#define R_AARCH64_JUMP26 282 /* PC-rel. B imm. from bits 27:2. */ +#define R_AARCH64_CALL26 283 /* Likewise for CALL. */ +#define R_AARCH64_LDST16_ABS_LO12_NC 284 /* Dir. ADD imm. from bits 11:1. */ +#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* Likewise for bits 11:2. */ +#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* Likewise for bits 11:3. */ +#define R_AARCH64_MOVW_PREL_G0 287 /* PC-rel. MOV{N,Z} imm. from 15:0. */ +#define R_AARCH64_MOVW_PREL_G0_NC 288 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_PREL_G1 289 /* PC-rel. MOV{N,Z} imm. from 31:16. */ +#define R_AARCH64_MOVW_PREL_G1_NC 290 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_PREL_G2 291 /* PC-rel. MOV{N,Z} imm. from 47:32. */ +#define R_AARCH64_MOVW_PREL_G2_NC 292 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_PREL_G3 293 /* PC-rel. MOV{N,Z} imm. from 63:48. */ +#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* Dir. ADD imm. from bits 11:4. */ +#define R_AARCH64_MOVW_GOTOFF_G0 300 /* GOT-rel. off. MOV{N,Z} imm. 15:0. */ +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_GOTOFF_G1 302 /* GOT-rel. o. MOV{N,Z} imm. 31:16. */ +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_GOTOFF_G2 304 /* GOT-rel. o. MOV{N,Z} imm. 47:32. */ +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* Likewise for MOVK; no check. */ +#define R_AARCH64_MOVW_GOTOFF_G3 306 /* GOT-rel. o. MOV{N,Z} imm. 63:48. */ +#define R_AARCH64_GOTREL64 307 /* GOT-relative 64-bit. */ +#define R_AARCH64_GOTREL32 308 /* GOT-relative 32-bit. */ +#define R_AARCH64_GOT_LD_PREL19 309 /* PC-rel. GOT off. load imm. 20:2. */ +#define R_AARCH64_LD64_GOTOFF_LO15 310 /* GOT-rel. off. LD/ST imm. 14:3. */ +#define R_AARCH64_ADR_GOT_PAGE 311 /* P-page-rel. GOT off. ADRP 32:12. */ +#define R_AARCH64_LD64_GOT_LO12_NC 312 /* Dir. GOT off. LD/ST imm. 11:3. */ +#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* GOT-page-rel. GOT off. LD/ST 14:3 */ +#define R_AARCH64_TLSGD_ADR_PREL21 512 /* PC-relative ADR imm. 20:0. */ +#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* page-rel. ADRP imm. 32:12. */ +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* direct ADD imm. from 11:0. */ +#define R_AARCH64_TLSGD_MOVW_G1 515 /* GOT-rel. MOV{N,Z} 31:16. */ +#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* GOT-rel. MOVK imm. 15:0. */ +#define R_AARCH64_TLSLD_ADR_PREL21 517 /* Like 512; local dynamic model. */ +#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Like 513; local dynamic model. */ +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* Like 514; local dynamic model. */ +#define R_AARCH64_TLSLD_MOVW_G1 520 /* Like 515; local dynamic model. */ +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* Like 516; local dynamic model. */ +#define R_AARCH64_TLSLD_LD_PREL19 522 /* TLS PC-rel. load imm. 20:2. */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* TLS DTP-rel. MOV{N,Z} 47:32. */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* TLS DTP-rel. MOV{N,Z} 31:16. */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* Likewise; MOVK; no check. */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* TLS DTP-rel. MOV{N,Z} 15:0. */ +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 /* Likewise; MOVK; no check. */ +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTP-rel. ADD imm. from 23:12. */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTP-rel. ADD imm. from 11:0. */ +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* Likewise; no ovfl. check. */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTP-rel. LD/ST imm. 11:0. */ +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* Likewise; no check. */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTP-rel. LD/ST imm. 11:1. */ +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* Likewise; no check. */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTP-rel. LD/ST imm. 11:2. */ +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* Likewise; no check. */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTP-rel. LD/ST imm. 11:3. */ +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* Likewise; no check. */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* GOT-rel. MOV{N,Z} 31:16. */ +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* GOT-rel. MOVK 15:0. */ +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page-rel. ADRP 32:12. */ +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* Direct LD off. 11:3. */ +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* PC-rel. load imm. 20:2. */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TLS TP-rel. MOV{N,Z} 47:32. */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TLS TP-rel. MOV{N,Z} 31:16. */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* Likewise; MOVK; no check. */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 /* TLS TP-rel. MOV{N,Z} 15:0. */ +#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 /* Likewise; MOVK; no check. */ +#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 /* TP-rel. ADD imm. 23:12. */ +#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 /* TP-rel. ADD imm. 11:0. */ +#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 /* Likewise; no ovfl. check. */ +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 /* TP-rel. LD/ST off. 11:0. */ +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 /* Likewise; no ovfl. check. */ +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 /* TP-rel. LD/ST off. 11:1. */ +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 /* Likewise; no check. */ +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 /* TP-rel. LD/ST off. 11:2. */ +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 /* Likewise; no check. */ +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TP-rel. LD/ST off. 11:3. */ +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* Likewise; no check. */ +#define R_AARCH64_TLSDESC_LD_PREL19 560 /* PC-rel. load immediate 20:2. */ +#define R_AARCH64_TLSDESC_ADR_PREL21 561 /* PC-rel. ADR immediate 20:0. */ +#define R_AARCH64_TLSDESC_ADR_PAGE21 562 /* Page-rel. ADRP imm. 32:12. */ +#define R_AARCH64_TLSDESC_LD64_LO12 563 /* Direct LD off. from 11:3. */ +#define R_AARCH64_TLSDESC_ADD_LO12 564 /* Direct ADD imm. from 11:0. */ +#define R_AARCH64_TLSDESC_OFF_G1 565 /* GOT-rel. MOV{N,Z} imm. 31:16. */ +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* GOT-rel. MOVK imm. 15:0; no ck. */ +#define R_AARCH64_TLSDESC_LDR 567 /* Relax LDR. */ +#define R_AARCH64_TLSDESC_ADD 568 /* Relax ADD. */ +#define R_AARCH64_TLSDESC_CALL 569 /* Relax BLR. */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TP-rel. LD/ST off. 11:4. */ +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* Likewise; no check. */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTP-rel. LD/ST imm. 11:4. */ +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* Likewise; no check. */ +#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ +#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */ +#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */ +#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */ +#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */ +#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */ +#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */ +#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */ +#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */ + +/* ARM relocs. */ + +#define R_ARM_NONE 0 /* No reloc */ +#define R_ARM_PC24 1 /* Deprecated PC relative 26 bit branch. */ +#define R_ARM_ABS32 2 /* Direct 32 bit */ +#define R_ARM_REL32 3 /* PC relative 32 bit */ +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 /* Direct 16 bit */ +#define R_ARM_ABS12 6 /* Direct 12 bit */ +#define R_ARM_THM_ABS5 7 /* Direct & 0x7C (LDR, STR). */ +#define R_ARM_ABS8 8 /* Direct 8 bit */ +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 /* PC relative 24 bit (Thumb32 BL). */ +#define R_ARM_THM_PC8 11 /* PC relative & 0x3FC (Thumb16 LDR, ADD, ADR). */ +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 /* Obsolete static relocation. */ +#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */ +#define R_ARM_THM_SWI8 14 /* Reserved. */ +#define R_ARM_XPC25 15 /* Reserved. */ +#define R_ARM_THM_XPC22 16 /* Reserved. */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ +#define R_ARM_COPY 20 /* Copy symbol at runtime */ +#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ +#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ +#define R_ARM_RELATIVE 23 /* Adjust by program base */ +#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ +#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ +#define R_ARM_GOT32 26 /* 32 bit GOT entry */ +#define R_ARM_PLT32 27 /* Deprecated, 32 bit PLT address. */ +#define R_ARM_CALL 28 /* PC relative 24 bit (BL, BLX). */ +#define R_ARM_JUMP24 29 /* PC relative 24 bit (B, BL). */ +#define R_ARM_THM_JUMP24 30 /* PC relative 24 bit (Thumb32 B.W). */ +#define R_ARM_BASE_ABS 31 /* Adjust by program base. */ +#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete. */ +#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete. */ +#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete. */ +#define R_ARM_LDR_SBREL_11_0 35 /* Deprecated, prog. base relative. */ +#define R_ARM_ALU_SBREL_19_12 36 /* Deprecated, prog. base relative. */ +#define R_ARM_ALU_SBREL_27_20 37 /* Deprecated, prog. base relative. */ +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 /* Program base relative. */ +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 /* 32 bit PC relative. */ +#define R_ARM_MOVW_ABS_NC 43 /* Direct 16-bit (MOVW). */ +#define R_ARM_MOVT_ABS 44 /* Direct high 16-bit (MOVT). */ +#define R_ARM_MOVW_PREL_NC 45 /* PC relative 16-bit (MOVW). */ +#define R_ARM_MOVT_PREL 46 /* PC relative (MOVT). */ +#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW). */ +#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit (Thumb32 MOVT). */ +#define R_ARM_THM_MOVW_PREL_NC 49 /* PC relative 16 bit (Thumb32 MOVW). */ +#define R_ARM_THM_MOVT_PREL 50 /* PC relative high 16 bit (Thumb32 MOVT). */ +#define R_ARM_THM_JUMP19 51 /* PC relative 20 bit (Thumb32 B.W). */ +#define R_ARM_THM_JUMP6 52 /* PC relative X & 0x7E (Thumb16 CBZ, CBNZ). */ +#define R_ARM_THM_ALU_PREL_11_0 53 /* PC relative 12 bit (Thumb32 ADR.W). */ +#define R_ARM_THM_PC12 54 /* PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). */ +#define R_ARM_ABS32_NOI 55 /* Direct 32-bit. */ +#define R_ARM_REL32_NOI 56 /* PC relative 32-bit. */ +#define R_ARM_ALU_PC_G0_NC 57 /* PC relative (ADD, SUB). */ +#define R_ARM_ALU_PC_G0 58 /* PC relative (ADD, SUB). */ +#define R_ARM_ALU_PC_G1_NC 59 /* PC relative (ADD, SUB). */ +#define R_ARM_ALU_PC_G1 60 /* PC relative (ADD, SUB). */ +#define R_ARM_ALU_PC_G2 61 /* PC relative (ADD, SUB). */ +#define R_ARM_LDR_PC_G1 62 /* PC relative (LDR,STR,LDRB,STRB). */ +#define R_ARM_LDR_PC_G2 63 /* PC relative (LDR,STR,LDRB,STRB). */ +#define R_ARM_LDRS_PC_G0 64 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ +#define R_ARM_LDRS_PC_G1 65 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ +#define R_ARM_LDRS_PC_G2 66 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ +#define R_ARM_LDC_PC_G0 67 /* PC relative (LDC, STC). */ +#define R_ARM_LDC_PC_G1 68 /* PC relative (LDC, STC). */ +#define R_ARM_LDC_PC_G2 69 /* PC relative (LDC, STC). */ +#define R_ARM_ALU_SB_G0_NC 70 /* Program base relative (ADD,SUB). */ +#define R_ARM_ALU_SB_G0 71 /* Program base relative (ADD,SUB). */ +#define R_ARM_ALU_SB_G1_NC 72 /* Program base relative (ADD,SUB). */ +#define R_ARM_ALU_SB_G1 73 /* Program base relative (ADD,SUB). */ +#define R_ARM_ALU_SB_G2 74 /* Program base relative (ADD,SUB). */ +#define R_ARM_LDR_SB_G0 75 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDR_SB_G1 76 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDR_SB_G2 77 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDRS_SB_G0 78 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDRS_SB_G1 79 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDRS_SB_G2 80 /* Program base relative (LDR, STR, LDRB, STRB). */ +#define R_ARM_LDC_SB_G0 81 /* Program base relative (LDC,STC). */ +#define R_ARM_LDC_SB_G1 82 /* Program base relative (LDC,STC). */ +#define R_ARM_LDC_SB_G2 83 /* Program base relative (LDC,STC). */ +#define R_ARM_MOVW_BREL_NC 84 /* Program base relative 16 bit (MOVW). */ +#define R_ARM_MOVT_BREL 85 /* Program base relative high 16 bit (MOVT). */ +#define R_ARM_MOVW_BREL 86 /* Program base relative 16 bit (MOVW). */ +#define R_ARM_THM_MOVW_BREL_NC 87 /* Program base relative 16 bit (Thumb32 MOVW). */ +#define R_ARM_THM_MOVT_BREL 88 /* Program base relative high 16 bit (Thumb32 MOVT). */ +#define R_ARM_THM_MOVW_BREL 89 /* Program base relative 16 bit (Thumb32 MOVW). */ +#define R_ARM_TLS_GOTDESC 90 +#define R_ARM_TLS_CALL 91 +#define R_ARM_TLS_DESCSEQ 92 /* TLS relaxation. */ +#define R_ARM_THM_TLS_CALL 93 +#define R_ARM_PLT32_ABS 94 +#define R_ARM_GOT_ABS 95 /* GOT entry. */ +#define R_ARM_GOT_PREL 96 /* PC relative GOT entry. */ +#define R_ARM_GOT_BREL12 97 /* GOT entry relative to GOT origin (LDR). */ +#define R_ARM_GOTOFF12 98 /* 12 bit, GOT entry relative to GOT origin (LDR, STR). */ +#define R_ARM_GOTRELAX 99 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 /* PC relative & 0xFFE (Thumb16 B). */ +#define R_ARM_THM_PC9 103 /* PC relative & 0x1FE (Thumb16 B/B). */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic thread local data */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic thread local data */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS block */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of static TLS block offset */ +#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static TLS block */ +#define R_ARM_TLS_LDO12 109 /* 12 bit relative to TLS block (LDR, STR). */ +#define R_ARM_TLS_LE12 110 /* 12 bit relative to static TLS block (LDR, STR). */ +#define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative to GOT origin (LDR). */ +#define R_ARM_ME_TOO 128 /* Obsolete. */ +#define R_ARM_THM_TLS_DESCSEQ 129 +#define R_ARM_THM_TLS_DESCSEQ16 129 +#define R_ARM_THM_TLS_DESCSEQ32 130 +#define R_ARM_THM_GOT_BREL12 131 /* GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). */ +#define R_ARM_IRELATIVE 160 +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 +/* Keep this the last entry. */ +#define R_ARM_NUM 256 + +/* IA-64 specific declarations. */ + +/* Processor specific flags for the Ehdr e_flags field. */ +#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ +#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ +#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ +#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + +/* Processor specific flags for the Phdr p_flags field. */ +#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ + +/* Processor specific flags for the Shdr sh_flags field. */ +#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ +#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Dyn d_tag field. */ +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ +#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ +#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ +#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ +#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ +#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ +#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ +#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_COPY 0x84 /* copy relocation */ +#define R_IA64_SUB 0x85 /* Addend and symbol difference */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ +#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ +#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ +#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ +#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ +#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ +#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ +#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ +#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ +#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ +#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ +#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ +#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ +#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ +#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ + +/* SH specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_SH_MACH_MASK 0x1f +#define EF_SH_UNKNOWN 0x0 +#define EF_SH1 0x1 +#define EF_SH2 0x2 +#define EF_SH3 0x3 +#define EF_SH_DSP 0x4 +#define EF_SH3_DSP 0x5 +#define EF_SH4AL_DSP 0x6 +#define EF_SH3E 0x8 +#define EF_SH4 0x9 +#define EF_SH2E 0xb +#define EF_SH4A 0xc +#define EF_SH2A 0xd +#define EF_SH4_NOFPU 0x10 +#define EF_SH4A_NOFPU 0x11 +#define EF_SH4_NOMMU_NOFPU 0x12 +#define EF_SH2A_NOFPU 0x13 +#define EF_SH3_NOMMU 0x14 +#define EF_SH2A_SH4_NOFPU 0x15 +#define EF_SH2A_SH3_NOFPU 0x16 +#define EF_SH2A_SH4 0x17 +#define EF_SH2A_SH3E 0x18 + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +/* Keep this the last entry. */ +#define R_SH_NUM 256 + +/* S/390 specific definitions. */ + +/* Valid values for the e_flags field. */ + +#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */ + +/* Additional s390 relocs */ + +#define R_390_NONE 0 /* No reloc. */ +#define R_390_8 1 /* Direct 8 bit. */ +#define R_390_12 2 /* Direct 12 bit. */ +#define R_390_16 3 /* Direct 16 bit. */ +#define R_390_32 4 /* Direct 32 bit. */ +#define R_390_PC32 5 /* PC relative 32 bit. */ +#define R_390_GOT12 6 /* 12 bit GOT offset. */ +#define R_390_GOT32 7 /* 32 bit GOT offset. */ +#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ +#define R_390_COPY 9 /* Copy symbol at runtime. */ +#define R_390_GLOB_DAT 10 /* Create GOT entry. */ +#define R_390_JMP_SLOT 11 /* Create PLT entry. */ +#define R_390_RELATIVE 12 /* Adjust by program base. */ +#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ +#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ +#define R_390_GOT16 15 /* 16 bit GOT offset. */ +#define R_390_PC16 16 /* PC relative 16 bit. */ +#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ +#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ +#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ +#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ +#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ +#define R_390_64 22 /* Direct 64 bit. */ +#define R_390_PC64 23 /* PC relative 64 bit. */ +#define R_390_GOT64 24 /* 64 bit GOT offset. */ +#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ +#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ +#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ +#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ +#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ +#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ +#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ +#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ +#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ +#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ +#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ +#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ +#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ +#define R_390_TLS_GDCALL 38 /* Tag for function call in general dynamic TLS code. */ +#define R_390_TLS_LDCALL 39 /* Tag for function call in local dynamic TLS code. */ +#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic thread local data. */ +#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic thread local data. */ +#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS block offset. */ +#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS block offset. */ +#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS block offset. */ +#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic thread local data in LE code. */ +#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic thread local data in LE code. */ +#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for negated static TLS block offset. */ +#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for negated static TLS block offset. */ +#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for negated static TLS block offset. */ +#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to static TLS block. */ +#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to static TLS block. */ +#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS block. */ +#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS block. */ +#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ +#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ +#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS block. */ +#define R_390_20 57 /* Direct 20 bit. */ +#define R_390_GOT20 58 /* 20 bit GOT offset. */ +#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ +#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS block offset. */ +#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */ +/* Keep this the last entry. */ +#define R_390_NUM 62 + + +/* CRIS relocations. */ +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + + +/* AMD x86-64 relocations. */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */ +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ +#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset to two GOT entries for GD symbol */ +#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset to two GOT entries for LD symbol */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset to GOT entry for IE symbol */ +#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ +#define R_X86_64_PC64 24 /* PC relative 64 bit */ +#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */ +#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative offset to GOT */ +#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */ +#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset to GOT entry */ +#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */ +#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */ +#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset to PLT entry */ +#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */ +#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */ +#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */ +#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS descriptor. */ +#define R_X86_64_TLSDESC 36 /* TLS descriptor. */ +#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */ +#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */ + +#define R_X86_64_NUM 39 + + +/* AM33 relocations. */ +#define R_MN10300_NONE 0 /* No reloc. */ +#define R_MN10300_32 1 /* Direct 32 bit. */ +#define R_MN10300_16 2 /* Direct 16 bit. */ +#define R_MN10300_8 3 /* Direct 8 bit. */ +#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ +#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ +#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ +#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ +#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ +#define R_MN10300_24 9 /* Direct 24 bit. */ +#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ +#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ +#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ +#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ +#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ +#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ +#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ +#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ +#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ +#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ +#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ +#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ +#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ +#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ +#define R_MN10300_TLS_GD 24 /* 32-bit offset for global dynamic. */ +#define R_MN10300_TLS_LD 25 /* 32-bit offset for local dynamic. */ +#define R_MN10300_TLS_LDO 26 /* Module-relative offset. */ +#define R_MN10300_TLS_GOTIE 27 /* GOT offset for static TLS block offset. */ +#define R_MN10300_TLS_IE 28 /* GOT address for static TLS block offset. */ +#define R_MN10300_TLS_LE 29 /* Offset relative to static TLS block. */ +#define R_MN10300_TLS_DTPMOD 30 /* ID of module containing symbol. */ +#define R_MN10300_TLS_DTPOFF 31 /* Offset in module TLS block. */ +#define R_MN10300_TLS_TPOFF 32 /* Offset in static TLS block. */ +#define R_MN10300_SYM_DIFF 33 /* Adjustment for next reloc as needed by linker relaxation. */ +#define R_MN10300_ALIGN 34 /* Alignment requirement for linker relaxation. */ +#define R_MN10300_NUM 35 + + +/* M32R relocs. */ +#define R_M32R_NONE 0 /* No reloc. */ +#define R_M32R_16 1 /* Direct 16 bit. */ +#define R_M32R_32 2 /* Direct 32 bit. */ +#define R_M32R_24 3 /* Direct 24 bit. */ +#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ +#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ +#define R_M32R_LO16 9 /* Low 16 bit. */ +#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 +/* M32R relocs use SHT_RELA. */ +#define R_M32R_16_RELA 33 /* Direct 16 bit. */ +#define R_M32R_32_RELA 34 /* Direct 32 bit. */ +#define R_M32R_24_RELA 35 /* Direct 24 bit. */ +#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ +#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ +#define R_M32R_LO16_RELA 41 /* Low 16 bit */ +#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 +#define R_M32R_REL32 45 /* PC relative 32 bit. */ + +#define R_M32R_GOT24 48 /* 24 bit GOT entry */ +#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ +#define R_M32R_COPY 50 /* Copy symbol at runtime */ +#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ +#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ +#define R_M32R_RELATIVE 53 /* Adjust by program base */ +#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ +#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ +#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned low */ +#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed low */ +#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ +#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to GOT with unsigned low */ +#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to GOT with signed low */ +#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to GOT */ +#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT with unsigned low */ +#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT with signed low */ +#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ +#define R_M32R_NUM 256 /* Keep this the last entry. */ + +/* MicroBlaze relocations */ +#define R_MICROBLAZE_NONE 0 /* No reloc. */ +#define R_MICROBLAZE_32 1 /* Direct 32 bit. */ +#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */ +#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */ +#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */ +#define R_MICROBLAZE_64 5 /* Direct 64 bit. */ +#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */ +#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */ +#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */ +#define R_MICROBLAZE_64_NONE 9 /* No reloc. */ +#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */ +#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */ +#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */ +#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */ +#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */ +#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */ +#define R_MICROBLAZE_REL 16 /* Adjust by program base. */ +#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */ +#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */ +#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */ +#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */ +#define R_MICROBLAZE_COPY 21 /* Runtime copy. */ +#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */ +#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */ +#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */ +#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */ +#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */ +#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */ +#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */ +#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */ + +/* Legal values for d_tag (dynamic entry type). */ +#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */ + +/* Nios II relocations. */ +#define R_NIOS2_NONE 0 /* No reloc. */ +#define R_NIOS2_S16 1 /* Direct signed 16 bit. */ +#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */ +#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */ +#define R_NIOS2_CALL26 4 /* Direct call. */ +#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */ +#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */ +#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */ +#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */ +#define R_NIOS2_HI16 9 /* High 16 bit. */ +#define R_NIOS2_LO16 10 /* Low 16 bit. */ +#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */ +#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */ +#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */ +#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */ +#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */ +#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */ +#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */ +#define R_NIOS2_UJMP 18 /* Unconditional branch. */ +#define R_NIOS2_CJMP 19 /* Conditional branch. */ +#define R_NIOS2_CALLR 20 /* Indirect call through register. */ +#define R_NIOS2_ALIGN 21 /* Alignment requirement for linker relaxation. */ +#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */ +#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */ +#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */ +#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */ +#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */ +#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */ +#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */ +#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */ +#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */ +#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */ +#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */ +#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */ +#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */ +#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */ +#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */ +#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */ +#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */ +#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */ +#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */ +#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */ +#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */ +#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */ +#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */ +#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */ + +/* TILEPro relocations. */ +#define R_TILEPRO_NONE 0 /* No reloc */ +#define R_TILEPRO_32 1 /* Direct 32 bit */ +#define R_TILEPRO_16 2 /* Direct 16 bit */ +#define R_TILEPRO_8 3 /* Direct 8 bit */ +#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */ +#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */ +#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */ +#define R_TILEPRO_LO16 7 /* Low 16 bit */ +#define R_TILEPRO_HI16 8 /* High 16 bit */ +#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */ +#define R_TILEPRO_COPY 10 /* Copy relocation */ +#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */ +#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */ +#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */ +#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */ +#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */ +#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */ +#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */ +#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */ +#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */ +#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */ +#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */ +#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */ +#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */ +#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */ +#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */ +#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */ +#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */ +#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */ +#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */ +#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */ +#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */ +#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */ +#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */ +#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */ +#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */ +#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */ +#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */ +#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */ +#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */ +#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */ +#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */ +#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */ +#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */ +#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */ +#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */ +#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */ +#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */ +#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */ +#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */ +/* Relocs 56-59 are currently not defined. */ +#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */ +#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */ +#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */ +#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */ +#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */ +#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */ +#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */ +#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */ +#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */ +#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */ +#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */ +#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */ +#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */ +#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */ + +#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ +#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ + +#define R_TILEPRO_NUM 130 + + +/* TILE-Gx relocations. */ +#define R_TILEGX_NONE 0 /* No reloc */ +#define R_TILEGX_64 1 /* Direct 64 bit */ +#define R_TILEGX_32 2 /* Direct 32 bit */ +#define R_TILEGX_16 3 /* Direct 16 bit */ +#define R_TILEGX_8 4 /* Direct 8 bit */ +#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */ +#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */ +#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */ +#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */ +#define R_TILEGX_HW0 9 /* hword 0 16-bit */ +#define R_TILEGX_HW1 10 /* hword 1 16-bit */ +#define R_TILEGX_HW2 11 /* hword 2 16-bit */ +#define R_TILEGX_HW3 12 /* hword 3 16-bit */ +#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */ +#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */ +#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */ +#define R_TILEGX_COPY 16 /* Copy relocation */ +#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */ +#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */ +#define R_TILEGX_RELATIVE 19 /* Adjust by program base */ +#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */ +#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */ +#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */ +#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */ +#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */ +#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */ +#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */ +#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */ +#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */ +#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */ +#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */ +#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */ +#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */ +#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */ +#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */ +#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */ +#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */ +#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */ +#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */ +#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */ +#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */ +#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */ +#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */ +#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */ +#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */ +#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */ +#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */ +#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */ +#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */ +#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */ +#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */ +#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */ +#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */ +#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */ +#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */ +#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */ +#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */ +#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */ +#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */ +#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */ +#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */ +#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */ +#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */ +#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */ +#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */ +#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */ +#define R_TILEGX_IMM16_X0_HW0_PLT_PCREL 66 /* X0 pipe PC-rel PLT hword 0 */ +#define R_TILEGX_IMM16_X1_HW0_PLT_PCREL 67 /* X1 pipe PC-rel PLT hword 0 */ +#define R_TILEGX_IMM16_X0_HW1_PLT_PCREL 68 /* X0 pipe PC-rel PLT hword 1 */ +#define R_TILEGX_IMM16_X1_HW1_PLT_PCREL 69 /* X1 pipe PC-rel PLT hword 1 */ +#define R_TILEGX_IMM16_X0_HW2_PLT_PCREL 70 /* X0 pipe PC-rel PLT hword 2 */ +#define R_TILEGX_IMM16_X1_HW2_PLT_PCREL 71 /* X1 pipe PC-rel PLT hword 2 */ +#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */ +#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */ +#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */ +#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */ +#define R_TILEGX_IMM16_X0_HW3_PLT_PCREL 76 /* X0 pipe PC-rel PLT hword 3 */ +#define R_TILEGX_IMM16_X1_HW3_PLT_PCREL 77 /* X1 pipe PC-rel PLT hword 3 */ +#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */ +#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */ +#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */ +#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */ +#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */ +#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */ +#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */ +#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */ +#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */ +#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */ +#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */ +#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */ +/* Relocs 90-91 are currently not defined. */ +#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */ +#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */ +#define R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL 94 /* X0 pipe PC-rel PLT last hword 0 */ +#define R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL 95 /* X1 pipe PC-rel PLT last hword 0 */ +#define R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL 96 /* X0 pipe PC-rel PLT last hword 1 */ +#define R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL 97 /* X1 pipe PC-rel PLT last hword 1 */ +#define R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL 98 /* X0 pipe PC-rel PLT last hword 2 */ +#define R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL 99 /* X1 pipe PC-rel PLT last hword 2 */ +#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */ +#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */ +#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */ +#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */ +/* Relocs 104-105 are currently not defined. */ +#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */ +#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */ +#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */ +#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */ +#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */ +#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */ +#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */ +#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */ +#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */ +#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */ +#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */ +#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */ +#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */ +#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */ +#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */ +#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */ + +#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ +#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ + +#define R_TILEGX_NUM 130 + +#endif /* elf.h */ diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs new file mode 100644 index 00000000000000..1a318e98cefe47 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs @@ -0,0 +1,42 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using NUnit.Framework; + +namespace LibObjectFile.Tests.Ar +{ + public abstract class ArTestBase + { + protected static void ExpectNoDiagnostics(DiagnosticBag diagnostics) + { + if (diagnostics.Messages.Count != 0) + { + Console.WriteLine(diagnostics); + Assert.AreEqual(0, diagnostics.Messages.Count, $"Invalid number of diagnostics found, expecting no diagnostics"); + } + } + + protected static void ExpectDiagnostics(DiagnosticBag diagnostics, params DiagnosticId[] ids) + { + if (diagnostics.Messages.Count != ids.Length) + { + Console.WriteLine(diagnostics); + Assert.AreEqual(ids.Length, diagnostics.Messages.Count, $"Invalid number of diagnostics found, expecting {ids.Length} entries [{string.Join(", ", ids)}]"); + } + + for (var i = 0; i < diagnostics.Messages.Count; i++) + { + var diagnosticsMessage = diagnostics.Messages[i]; + var expectedId = ids[i]; + + if (expectedId != diagnosticsMessage.Id) + { + Console.WriteLine(diagnostics); + Assert.AreEqual(expectedId, diagnosticsMessage.Id, $"Invalid Id {diagnosticsMessage.Id} found for diagnostics [{i}] while expecting {expectedId} from entries [{string.Join(", ", ids)}]"); + } + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs new file mode 100644 index 00000000000000..9cbc9bee83f0e0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs @@ -0,0 +1,431 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; +using System.Linq; +using System.Text; +using LibObjectFile.Ar; +using NUnit.Framework; + +namespace LibObjectFile.Tests.Ar +{ + public class ArTests : ArTestBase + { + [Test] + public void CheckInvalidHeader() + { + // Incorrect magic length + { + var stream = new MemoryStream(new byte[] { 1, 2, 3, 4 }); + Assert.False(ArArchiveFile.IsAr(stream, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidMagicLength); + } + + // Correct length, magic invalid + { + var stream = new MemoryStream(new byte[] + { + (byte)'!', + (byte)'<', + (byte)'a', + (byte)'r', + (byte)'c', + (byte)'h', + (byte)'>', + (byte)'?', + }); + Assert.False(ArArchiveFile.IsAr(stream, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_MagicNotFound); + } + + // Valid + { + var stream = new MemoryStream(new byte[] + { + (byte)'!', + (byte)'<', + (byte)'a', + (byte)'r', + (byte)'c', + (byte)'h', + (byte)'>', + (byte)'\n', + }); + Assert.True(ArArchiveFile.IsAr(stream, out var diagnostics)); + ExpectNoDiagnostics(diagnostics); + } + } + + [Test] + public void CheckInvalidFileEntry() + { + // Incorrect entry length + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + stream.Write(new byte[] {(byte)'a', (byte)'b'}); + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidFileEntryLength); + } + + // Input invalid non-numeric characters into decimal/octal fields in file entry + { + var offsets = new int[] + { + ArFile.FieldTimestampOffset, + ArFile.FieldOwnerIdOffset, + ArFile.FieldGroupIdOffset, + ArFile.FieldFileModeOffset, + ArFile.FieldFileSizeOffset, + ArFile.FieldEndCharactersOffset + }; + foreach (var offset in offsets) + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[offset] = (byte)'a'; + stream.Write(entry); + + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry); + } + } + + // Input name with `/` + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[0] = (byte)'a'; + entry[1] = (byte)'b'; + entry[2] = (byte)'/'; + entry[3] = (byte)'c'; + + entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; + entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; + + stream.Write(entry); + + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterInFileEntryName); + } + + // Input length of content + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[0] = (byte)'a'; + entry[ArFile.FieldFileSizeOffset] = (byte)'2'; + entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; + entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; + + stream.Write(entry); + + var continuePosition = stream.Position; + + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); + + stream.Position = continuePosition; + + stream.WriteByte(0); + stream.WriteByte(1); + + stream.Position = 0; + + // Check that we can actually read the content + + var result = ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out var arFile, out diagnostics); + ExpectNoDiagnostics(diagnostics); + Assert.True(result, $"Error while reading file: {diagnostics}"); + Assert.AreEqual(1, arFile.Files.Count, "Invalid number of file entries found"); + Assert.AreEqual("a", arFile.Files[0].Name, "Invalid name of file entry[0] found"); + Assert.AreEqual(2, arFile.Files[0].Size, "Invalid size of file entry[0] found"); + Assert.IsInstanceOf(arFile.Files[0], "Invalid instance of of file entry[0] "); + + var fileStream = ((ArBinaryFile) arFile.Files[0]).Stream; + var read = new byte[] + { + (byte)fileStream.ReadByte(), + (byte)fileStream.ReadByte() + }; + Assert.AreEqual(new byte[] { 0, 1}, read, "Invalid content of of file entry[0] "); + + Assert.Null(arFile.SymbolTable, "Invalid non-null symbol table found"); + + } + + // Input length of content + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[0] = (byte)'a'; + entry[ArFile.FieldFileSizeOffset] = (byte)'1'; + entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; + entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; + + stream.Write(entry); + stream.WriteByte(0); + + var continuePosition = stream.Position; + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); + + stream.Position = continuePosition; + stream.WriteByte(0); + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_ExpectingNewLineCharacter); + + stream.Position = continuePosition; + stream.WriteByte((byte)'\n'); + stream.Position = 0; + + Assert.True(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out diagnostics)); + ExpectNoDiagnostics(diagnostics); + } + } + + [Test] + public void CheckInvalidBSDFileEntry() + { + // Input invalid BSD Length + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[0] = (byte)'#'; + entry[1] = (byte)'1'; + entry[2] = (byte)'/'; + entry[3] = (byte)'a'; + + stream.Write(entry); + + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry); + } + + // Input invalid BSD Length + { + var stream = new MemoryStream(); + stream.Write(ArArchiveFile.Magic); + var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); + entry.Fill((byte)' '); + entry[0] = (byte)'#'; + entry[1] = (byte)'1'; + entry[2] = (byte)'/'; + entry[3] = (byte)'2'; // it will try to read 2 bytes for the name but won't find it + + entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; + entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; + + stream.Write(entry); + + var continuePosition = stream.Position; + + stream.Position = 0; + + Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out _, out var diagnostics)); + ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); + + // Check validity of BSD name + + stream.Position = continuePosition; + stream.WriteByte((byte)'a'); + stream.WriteByte((byte)'b'); + + stream.Position = 0; + + var result = ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out var arFile, out diagnostics); + Assert.True(result, $"Error while reading file: {diagnostics}"); + Assert.AreEqual(1, arFile.Files.Count, "Invalid number of file entries found"); + Assert.AreEqual("ab", arFile.Files[0].Name, "Invalid name of file entry[0] found"); + Assert.Null(arFile.SymbolTable, "Invalid non-null symbol table found"); + } + } + + [Test] + public void CheckLibraryWithELF() + { + var cppName = "helloworld"; + var cppObj = $"{cppName}.o"; + var cppLib = $"lib{cppName}.a"; + File.Delete(cppObj); + File.Delete(cppLib); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -c -o {cppObj}"); + LinuxUtil.RunLinuxExe("ar", $"rcs {cppLib} {cppObj}"); + + using (var stream = new FileStream(cppLib, FileMode.Open, FileAccess.Read)) + { + Assert.True(ArArchiveFile.IsAr(stream)); + + var arFile = ArArchiveFile.Read(stream, new ArArchiveFileReaderOptions(ArArchiveKind.GNU) {ProcessObjectFiles = false}); + + var elfFile = arFile.Files.FirstOrDefault(x => x.Name == cppObj); + + Assert.NotNull(elfFile, $"Unable to find {cppObj} file in {cppLib}"); + + Assert.NotNull(arFile.SymbolTable, $"Unable to find symbol table in {cppLib}"); + + Assert.AreEqual(1, arFile.SymbolTable.Symbols.Count, "Invalid number of symbols in Symbol table"); + Assert.AreEqual("main", arFile.SymbolTable.Symbols[0].Name, "Invalid symbol found"); + Assert.AreEqual(elfFile, arFile.SymbolTable.Symbols[0].File, "Invalid symbol to file found"); + + var outStream = new MemoryStream(); + arFile.Write(outStream); + var newArray = outStream.ToArray(); + outStream.Position = 0; + + var cppLibCopy = $"lib{cppName}_copy.a"; + using (var copyStream = new FileStream(cppLibCopy, FileMode.Create, FileAccess.Write)) + { + outStream.CopyTo(copyStream); + } + + var originalStream = new MemoryStream(); + stream.Position = 0; + stream.CopyTo(originalStream); + var originalArray = originalStream.ToArray(); + + Assert.AreEqual(originalArray, newArray, $"Non binary matching between file {cppLib} and {cppLibCopy}"); + } + } + + [Test] + public void CheckCreateArLibrary() + { + var libName = "libcustom.a"; + + var file = new ArArchiveFile(); + using (var stream = new FileStream(libName, FileMode.Create, FileAccess.Write)) + { + var symbolTable = new ArSymbolTable(); + file.AddFile(symbolTable); + + file.AddFile(new ArBinaryFile() { Name = "file2.txt", OwnerId = 0666, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file")) }); + + file.AddFile(new ArBinaryFile() { Name = "file3.txt", OwnerId = 0777, GroupId = 0744, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file3")) }); + + file.AddFile(new ArBinaryFile() { Name = "file4.txt", OwnerId = 0777, GroupId = 0744, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file4")) }); + + file.AddFile(new ArBinaryFile() { Name = "file5.txt", OwnerId = 0706, GroupId = 0705, FileMode = 0x123456, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file5")) }); + + file.AddFile(new ArBinaryFile() { Name = "long_file_name_large_file6.txt", Timestamp = DateTimeOffset.UtcNow.AddSeconds(-2), Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file6 yoyo")) }); + + symbolTable.Symbols.Add(new ArSymbol() { File = file.Files[1], Name = "my_symbol" }); + + file.Write(stream); + stream.Flush(); + } + + // Check that AR is able to read back what we just serialized + { + var fileNameBuilder = new StringBuilder(); + foreach (var fileEntry in file.Files) + { + if (fileEntry.IsSystem) continue; + fileNameBuilder.Append($"{fileEntry.Name}\n"); + } + + var fileNameList = fileNameBuilder.ToString().Trim(); + var fileNameListFromAr = LinuxUtil.RunLinuxExe("ar", $"t {libName}").Trim(); + Assert.AreEqual(fileNameListFromAr, fileNameList); + } + + // Display the content of each file via AR + { + var contentBuilder = new StringBuilder(); + foreach (var fileEntry in file.Files) + { + if (!(fileEntry is ArBinaryFile arBinary)) continue; + + arBinary.Stream.Position = 0; + contentBuilder.Append(Encoding.UTF8.GetString(((MemoryStream) arBinary.Stream).ToArray())); + } + + var content = contentBuilder.ToString().Trim(); + var contentFromAr = LinuxUtil.RunLinuxExe("ar", $"p {libName}").Trim(); + Assert.AreEqual(contentFromAr, content); + } + + ArArchiveFile file2; + using (var stream = new FileStream(libName, FileMode.Open, FileAccess.Read)) + { + file2 = ArArchiveFile.Read(stream, ArArchiveKind.GNU); + } + + Assert.NotNull(file2.SymbolTable); + CompareArFiles(file, file2); + + var libNameBsd = "libcustom_bsd.a"; + file.Kind = ArArchiveKind.BSD; + using (var stream = new FileStream(libNameBsd, FileMode.Create, FileAccess.Write)) + { + file.Write(stream); + stream.Flush(); + } + + ArArchiveFile archiveFileBsd; + using (var stream = new FileStream(libNameBsd, FileMode.Open, FileAccess.Read)) + { + archiveFileBsd = ArArchiveFile.Read(stream, ArArchiveKind.BSD); + } + + CompareArFiles(file, archiveFileBsd); + } + + private static void CompareArFiles(ArArchiveFile archiveFile, ArArchiveFile file2) + { + Assert.AreEqual(archiveFile.Files.Count, file2.Files.Count, "File entries count don't match"); + for (var i = 0; i < archiveFile.Files.Count; i++) + { + var fileEntry = archiveFile.Files[i]; + var file2Entry = file2.Files[i]; + Assert.AreEqual(fileEntry.GetType(), file2Entry.GetType(), $"File entry [{i}] for {archiveFile} type don't match "); + Assert.AreEqual(fileEntry.Name, file2Entry.Name, $"File entry Name [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.Timestamp, file2Entry.Timestamp, $"File entry Timestamp [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.OwnerId, file2Entry.OwnerId, $"File entry Timestamp [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.GroupId, file2Entry.GroupId, $"File entry Timestamp [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.FileMode, file2Entry.FileMode, $"File entry Timestamp [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.Size, file2Entry.Size, $"File entry Size [{i}] for {archiveFile}"); + Assert.AreEqual(fileEntry.ToString(), file2Entry.ToString(), $"File entry ToString() [{i}] for {archiveFile}"); + + if (fileEntry is ArSymbolTable fileSymbolTable) + { + var file2SymbolTable = (ArSymbolTable) (file2Entry); + for (var j = 0; j < fileSymbolTable.Symbols.Count; j++) + { + var fileSymbol = fileSymbolTable.Symbols[j]; + var file2Symbol = file2SymbolTable.Symbols[j]; + + Assert.AreEqual(fileSymbol.ToString(), file2Symbol.ToString(), $"Invalid symbol [{j}]"); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs new file mode 100644 index 00000000000000..6a159ab29a917c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs @@ -0,0 +1,546 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; +using LibObjectFile.Dwarf; +using LibObjectFile.Elf; +using NUnit.Framework; + +namespace LibObjectFile.Tests.Dwarf +{ + public class DwarfTests + { + [TestCase(0UL)] + [TestCase(1UL)] + [TestCase(50UL)] + [TestCase(0x7fUL)] + [TestCase(0x80UL)] + [TestCase(0x81UL)] + [TestCase(0x12345UL)] + [TestCase(2147483647UL)] // int.MaxValue + [TestCase(4294967295UL)] // uint.MaxValue + [TestCase(ulong.MaxValue)] + public void TestLEB128(ulong value) + { + var stream = new MemoryStream(); + + stream.WriteULEB128(value); + + Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfULEB128(value)); + + stream.Position = 0; + var readbackValue = stream.ReadULEB128(); + + Assert.AreEqual(value, readbackValue); + } + + [TestCase(0L)] + [TestCase(1L)] + [TestCase(50L)] + [TestCase(0x7fL)] + [TestCase(0x80L)] + [TestCase(0x81L)] + [TestCase(0x12345L)] + [TestCase(2147483647L)] // int.MaxValue + [TestCase(4294967295L)] // uint.MaxValue + [TestCase(long.MinValue)] + [TestCase(long.MaxValue)] + public void TestSignedLEB128(long value) + { + var stream = new MemoryStream(); + + { + // check positive + stream.WriteILEB128(value); + Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfILEB128(value)); + + stream.Position = 0; + var readbackValue = stream.ReadSignedLEB128(); + Assert.AreEqual(value, readbackValue); + } + + { + stream.Position = 0; + // Check negative + value = -value; + stream.WriteILEB128(value); + Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfILEB128(value)); + + stream.Position = 0; + var readbackValue = stream.ReadSignedLEB128(); + Assert.AreEqual(value, readbackValue); + } + } + + + [Test] + public void TestDebugLineHelloWorld() + { + var cppName = "helloworld"; + var cppExe = $"{cppName}_debug"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -o {cppExe}"); + + ElfObjectFile elf; + using (var inStream = File.OpenRead(cppExe)) + { + Console.WriteLine($"ReadBack from {cppExe}"); + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + var elfContext = new DwarfElfContext(elf); + var inputContext = new DwarfReaderContext(elfContext); + inputContext.DebugLinePrinter = Console.Out; + var dwarf = DwarfFile.Read(inputContext); + + inputContext.DebugLineStream.Position = 0; + + var copyInputDebugLineStream = new MemoryStream(); + inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); + inputContext.DebugLineStream.Position = 0; + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = inputContext.IsLittleEndian, + EnableRelocation = false, + AddressSize = inputContext.AddressSize, + DebugLineStream = new MemoryStream() + }; + dwarf.Write(outputContext); + + Console.WriteLine(); + Console.WriteLine("====================================================="); + Console.WriteLine("Readback"); + Console.WriteLine("====================================================="); + Console.WriteLine(); + + var reloadContext = new DwarfReaderContext() + { + IsLittleEndian = outputContext.IsLittleEndian, + AddressSize = outputContext.AddressSize, + DebugLineStream = outputContext.DebugLineStream + }; + + reloadContext.DebugLineStream.Position = 0; + reloadContext.DebugLineStream = outputContext.DebugLineStream; + reloadContext.DebugLinePrinter = Console.Out; + + var dwarf2 = DwarfFile.Read(reloadContext); + + var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); + var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); + Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); + } + + [Test] + public void TestDebugLineLibMultipleObjs() + { + var cppName = "lib"; + var libShared = $"{cppName}_debug.so"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}_a.cpp {cppName}_b.cpp -g -shared -o {libShared}"); + + ElfObjectFile elf; + using (var inStream = File.OpenRead(libShared)) + { + Console.WriteLine($"ReadBack from {libShared}"); + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + var elfContext = new DwarfElfContext(elf); + var inputContext = new DwarfReaderContext(elfContext); + inputContext.DebugLinePrinter = Console.Out; + var dwarf = DwarfFile.Read(inputContext); + + inputContext.DebugLineStream.Position = 0; + + var copyInputDebugLineStream = new MemoryStream(); + inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); + inputContext.DebugLineStream.Position = 0; + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = inputContext.IsLittleEndian, + EnableRelocation = false, + AddressSize = inputContext.AddressSize, + DebugLineStream = new MemoryStream() + }; + dwarf.Write(outputContext); + + Console.WriteLine(); + Console.WriteLine("====================================================="); + Console.WriteLine("Readback"); + Console.WriteLine("====================================================="); + Console.WriteLine(); + + var reloadContext = new DwarfReaderContext() + { + IsLittleEndian = outputContext.IsLittleEndian, + AddressSize = outputContext.AddressSize, + DebugLineStream = outputContext.DebugLineStream + }; + + reloadContext.DebugLineStream.Position = 0; + reloadContext.DebugLineStream = outputContext.DebugLineStream; + reloadContext.DebugLinePrinter = Console.Out; + + var dwarf2 = DwarfFile.Read(reloadContext); + + var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); + var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); + Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); + } + + [Test] + public void TestDebugLineSmall() + { + var cppName = "small"; + var cppObj = $"{cppName}_debug.o"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + ElfObjectFile elf; + using (var inStream = File.OpenRead(cppObj)) + { + Console.WriteLine($"ReadBack from {cppObj}"); + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + var elfContext = new DwarfElfContext(elf); + var inputContext = new DwarfReaderContext(elfContext); + inputContext.DebugLinePrinter = Console.Out; + var dwarf = DwarfFile.Read(inputContext); + + inputContext.DebugLineStream.Position = 0; + var copyInputDebugLineStream = new MemoryStream(); + inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); + inputContext.DebugLineStream.Position = 0; + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = inputContext.IsLittleEndian, + AddressSize = inputContext.AddressSize, + DebugLineStream = new MemoryStream() + }; + dwarf.Write(outputContext); + + Console.WriteLine(); + Console.WriteLine("====================================================="); + Console.WriteLine("Readback"); + Console.WriteLine("====================================================="); + Console.WriteLine(); + + var reloadContext = new DwarfReaderContext() + { + IsLittleEndian = outputContext.IsLittleEndian, + AddressSize = outputContext.AddressSize, + DebugLineStream = outputContext.DebugLineStream + }; + + reloadContext.DebugLineStream.Position = 0; + reloadContext.DebugLineStream = outputContext.DebugLineStream; + reloadContext.DebugLinePrinter = Console.Out; + + var dwarf2 = DwarfFile.Read(reloadContext); + + var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); + var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); + Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); + } + + + + [Test] + public void TestDebugLineMultipleFunctions() + { + var cppName = "multiple_functions"; + var cppObj = $"{cppName}_debug.o"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + + ElfObjectFile elf; + using (var inStream = File.OpenRead(cppObj)) + { + Console.WriteLine($"ReadBack from {cppObj}"); + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + var elfContext = new DwarfElfContext(elf); + var inputContext = new DwarfReaderContext(elfContext); + inputContext.DebugLinePrinter = Console.Out; + var dwarf = DwarfFile.Read(inputContext); + + inputContext.DebugLineStream.Position = 0; + var copyInputDebugLineStream = new MemoryStream(); + inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); + inputContext.DebugLineStream.Position = 0; + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = inputContext.IsLittleEndian, + AddressSize = inputContext.AddressSize, + DebugLineStream = new MemoryStream() + }; + dwarf.Write(outputContext); + + Console.WriteLine(); + Console.WriteLine("====================================================="); + Console.WriteLine("Readback"); + Console.WriteLine("====================================================="); + Console.WriteLine(); + + var reloadContext = new DwarfReaderContext() + { + IsLittleEndian = outputContext.IsLittleEndian, + AddressSize = outputContext.AddressSize, + DebugLineStream = outputContext.DebugLineStream + }; + + reloadContext.DebugLineStream.Position = 0; + reloadContext.DebugLineStream = outputContext.DebugLineStream; + reloadContext.DebugLinePrinter = Console.Out; + + var dwarf2 = DwarfFile.Read(reloadContext); + + var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); + var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); + Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); + } + + + [Test] + public void TestDebugInfoSmall() + { + var cppName = "small"; + var cppObj = $"{cppName}_debug.o"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + + ElfObjectFile elf; + using (var inStream = File.OpenRead(cppObj)) + { + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + var elfContext = new DwarfElfContext(elf); + var inputContext = new DwarfReaderContext(elfContext); + var dwarf = DwarfFile.Read(inputContext); + + dwarf.AbbreviationTable.Print(Console.Out); + dwarf.InfoSection.Print(Console.Out); + dwarf.AddressRangeTable.Print(Console.Out); + + PrintStreamLength(inputContext); + + Console.WriteLine(); + Console.WriteLine("===================================================================="); + Console.WriteLine("Write Back"); + Console.WriteLine("===================================================================="); + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = inputContext.IsLittleEndian, + AddressSize = inputContext.AddressSize, + DebugAbbrevStream = new MemoryStream(), + DebugLineStream = new MemoryStream(), + DebugInfoStream = new MemoryStream(), + DebugStringStream = new MemoryStream(), + DebugAddressRangeStream = new MemoryStream() + }; + dwarf.Write(outputContext); + + dwarf.AbbreviationTable.Print(Console.Out); + dwarf.InfoSection.Print(Console.Out); + dwarf.InfoSection.PrintRelocations(Console.Out); + dwarf.AddressRangeTable.Print(Console.Out); + dwarf.AddressRangeTable.PrintRelocations(Console.Out); + + dwarf.WriteToElf(elfContext); + + var cppObj2 = $"{cppName}_debug2.o"; + using (var outStream = new FileStream(cppObj2, FileMode.Create)) + { + elf.Write(outStream); + } + + PrintStreamLength(outputContext); + } + + + [Test] + public void CreateDwarf() + { + // Create ELF object + var elf = new ElfObjectFile(ElfArch.X86_64); + + var codeSection = new ElfBinarySection(new MemoryStream(new byte[0x64])).ConfigureAs(ElfSectionSpecialType.Text); + elf.AddSection(codeSection); + var stringSection = new ElfStringTable(); + elf.AddSection(stringSection); + elf.AddSection(new ElfSymbolTable() { Link = stringSection }); + elf.AddSection(new ElfSectionHeaderStringTable()); + + var elfDiagnostics = new DiagnosticBag(); + elf.UpdateLayout(elfDiagnostics); + Assert.False(elfDiagnostics.HasErrors); + + // Create DWARF Object + var dwarfFile = new DwarfFile(); + + // Create .debug_line information + var fileName = new DwarfFileName() + { + Name = "check1.cpp", + Directory = Environment.CurrentDirectory, + }; + var fileName2 = new DwarfFileName() + { + Name = "check2.cpp", + Directory = Environment.CurrentDirectory, + }; + + // First line table + for (int i = 0; i < 2; i++) + { + var lineTable = new DwarfLineProgramTable(); + dwarfFile.LineSection.AddLineProgramTable(lineTable); + + lineTable.AddressSize = DwarfAddressSize.Bit64; + lineTable.FileNames.Add(fileName); + lineTable.FileNames.Add(fileName2); + lineTable.AddLineSequence(new DwarfLineSequence() + { + + new DwarfLine() + { + File = fileName, + Address = 0, + Column = 1, + Line = 1, + }, + new DwarfLine() + { + File = fileName, + Address = 1, + Column = 1, + Line = 2, + } + } + ); + // NOTE: doesn't seem to be generated by regular GCC + // (it seems that only one line sequence is usually used) + lineTable.AddLineSequence(new DwarfLineSequence() + { + + new DwarfLine() + { + File = fileName2, + Address = 0, + Column = 1, + Line = 1, + }, + } + ); + } + + // Create .debug_info + var rootDIE = new DwarfDIECompileUnit() + { + Name = fileName.Name, + LowPC = 0, // 0 relative to base virtual address + HighPC = (int)codeSection.Size, // default is offset/length after LowPC + CompDir = fileName.Directory, + StmtList = dwarfFile.LineSection.LineTables[0], + }; + var subProgram = new DwarfDIESubprogram() + { + Name = "MyFunction", + }; + rootDIE.AddChild(subProgram); + + var locationList = new DwarfLocationList(); + var regExpression = new DwarfExpression(); + regExpression.AddOperation(new DwarfOperation { Kind = DwarfOperationKindEx.Reg0 }); + var regExpression2 = new DwarfExpression(); + regExpression2.AddOperation(new DwarfOperation { Kind = DwarfOperationKindEx.Reg2 }); + locationList.AddLocationListEntry(new DwarfLocationListEntry + { + Start = 0, + End = 0x10, + Expression = regExpression, + }); + locationList.AddLocationListEntry(new DwarfLocationListEntry + { + Start = 0x10, + End = 0x20, + Expression = regExpression2, + }); + var variable = new DwarfDIEVariable() + { + Name = "a", + Location = locationList, + }; + dwarfFile.LocationSection.AddLocationList(locationList); + subProgram.AddChild(variable); + + var cu = new DwarfCompilationUnit() + { + AddressSize = DwarfAddressSize.Bit64, + Root = rootDIE + }; + dwarfFile.InfoSection.AddUnit(cu); + + // AddressRange table + dwarfFile.AddressRangeTable.AddressSize = DwarfAddressSize.Bit64; + dwarfFile.AddressRangeTable.Unit = cu; + dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, codeSection.Size)); + + // Transfer DWARF To ELF + var dwarfElfContext = new DwarfElfContext(elf); + dwarfFile.WriteToElf(dwarfElfContext); + + var outputFileName = "create_dwarf.o"; + using (var output = new FileStream(outputFileName, FileMode.Create)) + { + elf.Write(output); + } + + elf.Print(Console.Out); + Console.WriteLine(); + dwarfFile.AbbreviationTable.Print(Console.Out); + Console.WriteLine(); + dwarfFile.AddressRangeTable.Print(Console.Out); + Console.WriteLine(); + dwarfFile.InfoSection.Print(Console.Out); + + Console.WriteLine("ReadBack --debug-dump=rawline"); + var readelf = LinuxUtil.ReadElf(outputFileName, "--debug-dump=rawline").TrimEnd(); + Console.WriteLine(readelf); + } + + private static void PrintStreamLength(DwarfReaderWriterContext context) + { + if (context.DebugInfoStream != null) + { + Console.WriteLine($".debug_info {context.DebugInfoStream.Length}"); + } + if (context.DebugAbbrevStream != null) + { + Console.WriteLine($".debug_abbrev {context.DebugAbbrevStream.Length}"); + } + if (context.DebugAddressRangeStream != null) + { + Console.WriteLine($".debug_aranges {context.DebugAddressRangeStream.Length}"); + } + if (context.DebugStringStream != null) + { + Console.WriteLine($".debug_str {context.DebugStringStream.Length}"); + } + if (context.DebugLineStream != null) + { + Console.WriteLine($".debug_line {context.DebugLineStream.Length}"); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs new file mode 100644 index 00000000000000..658975d0b559ec --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs @@ -0,0 +1,425 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; +using System.Text; +using LibObjectFile.Elf; +using NUnit.Framework; + +namespace LibObjectFile.Tests.Elf +{ + public class ElfSimpleTests : ElfTestBase + { + [Test] + public void TryReadThrows() + { + static void CheckInvalidLib(bool isReadOnly) + { + using var stream = File.OpenRead("TestFiles/cmnlib.b00"); + Assert.False(ElfObjectFile.TryRead(stream, out var elf, out var diagnostics, new ElfReaderOptions() { ReadOnly = isReadOnly })); + Assert.NotNull(elf); + Assert.AreEqual(4, diagnostics.Messages.Count, "Invalid number of error messages found"); + Assert.AreEqual(DiagnosticId.ELF_ERR_IncompleteProgramHeader32Size, diagnostics.Messages[0].Id); + for (int i = 1; i < diagnostics.Messages.Count; i++) + { + Assert.AreEqual(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, diagnostics.Messages[i].Id); + } + } + + CheckInvalidLib(false); + CheckInvalidLib(true); + } + + [Test] + public void TryReadFailed() + { + using var stream = File.OpenRead(typeof(ElfSimpleTests).Assembly.Location); + + Assert.False(ElfObjectFile.TryRead(stream, out var elfObjectFile, out var diagnostics)); + Assert.True(diagnostics.HasErrors); + Assert.AreEqual(1, diagnostics.Messages.Count); + Assert.AreEqual(DiagnosticId.ELF_ERR_InvalidHeaderMagic, diagnostics.Messages[0].Id); + } + + + [Test] + public void SimpleEmptyWithDefaultSections() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + AssertReadElf(elf, "empty_default.elf"); + } + + [Test] + public void SimpleEmpty() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + for (int i = elf.Sections.Count - 1; i >= 0; i--) + { + elf.RemoveSectionAt(i); + } + AssertReadElf(elf, "empty.elf"); + } + + [Test] + public void SimpleCodeSection() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + var codeStream = new MemoryStream(); + codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); + codeStream.Position = 0; + + var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); + elf.AddSection(codeSection); + elf.AddSection(new ElfSectionHeaderStringTable()); + + AssertReadElf(elf, "test.elf"); + } + + [Test] + public void TestBss() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + var stream = new MemoryStream(); + stream.Write(new byte[] { 1, 2, 3, 4 }); + stream.Position = 0; + var codeSection = new ElfBinarySection(stream).ConfigureAs(ElfSectionSpecialType.Text); + elf.AddSection(codeSection); + + elf.AddSection(new ElfAlignedShadowSection(1024)); + + var bssSection = new ElfBinarySection().ConfigureAs(ElfSectionSpecialType.Bss); + elf.AddSection(bssSection); + + elf.AddSection(new ElfSectionHeaderStringTable()); + + var diagnostics = new DiagnosticBag(); + elf.UpdateLayout(diagnostics); + Assert.False(diagnostics.HasErrors); + + Assert.AreEqual(1024, bssSection.Offset); + + AssertReadElf(elf, "test_bss.elf"); + } + + [Test] + public void SimpleCodeSectionAndSymbolSection() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + var codeStream = new MemoryStream(); + codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); + codeStream.Position = 0; + + var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); + elf.AddSection(codeSection); + + var stringSection = new ElfStringTable(); + elf.AddSection(stringSection); + + var symbolSection = new ElfSymbolTable() + { + Link = stringSection, + + Entries = + { + new ElfSymbol() + { + Name = "local_symbol", + Bind = ElfSymbolBind.Local, + Section = codeSection, + Size = 16, + Type = ElfSymbolType.Function, + Visibility = ElfSymbolVisibility.Protected, + Value = 0x7896 + }, + new ElfSymbol() + { + Name = "GlobalSymbol", + Bind = ElfSymbolBind.Global, + Section = codeSection, + Size = 4, + Type = ElfSymbolType.Function, + Value = 0x12345 + } + } + }; + elf.AddSection(symbolSection); + elf.AddSection(new ElfSectionHeaderStringTable()); + + AssertReadElf(elf, "test2.elf"); + } + + [Test] + public void SimpleProgramHeaderAndCodeSectionAndSymbolSection() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + var codeStream = new MemoryStream(); + codeStream.Write(new byte[4096]); + + var codeSection = elf.AddSection( + new ElfBinarySection(codeStream) + { + VirtualAddress = 0x1000, + Alignment = 4096 + }.ConfigureAs(ElfSectionSpecialType.Text) + ); + + var dataStream = new MemoryStream(); + dataStream.Write(new byte[1024]); + + var dataSection = elf.AddSection( + new ElfBinarySection(dataStream) + { + VirtualAddress = 0x2000, + Alignment = 4096 + }.ConfigureAs(ElfSectionSpecialType.ReadOnlyData) + ); + + var stringSection = elf.AddSection(new ElfStringTable()); + + var symbolSection = elf.AddSection( + new ElfSymbolTable() + { + Link = stringSection, + + Entries = + { + new ElfSymbol() + { + Name = "local_symbol", + Bind = ElfSymbolBind.Local, + Section = codeSection, + Size = 16, + Type = ElfSymbolType.Function, + Visibility = ElfSymbolVisibility.Protected, + Value = 0x7896 + }, + new ElfSymbol() + { + Name = "GlobalSymbol", + Bind = ElfSymbolBind.Global, + Section = codeSection, + Size = 4, + Type = ElfSymbolType.Function, + Value = 0x12345 + } + } + } + ); + elf.AddSection(new ElfSectionHeaderStringTable()); + + elf.AddSegment(new ElfSegment() + { + Type = ElfSegmentTypeCore.Load, + Range = codeSection, + VirtualAddress = 0x1000, + PhysicalAddress = 0x1000, + Flags = ElfSegmentFlagsCore.Readable|ElfSegmentFlagsCore.Executable, + Size = 4096, + SizeInMemory = 4096, + Alignment = 4096, + }); + + elf.AddSegment(new ElfSegment() + { + Type = ElfSegmentTypeCore.Load, + Range = dataSection, + VirtualAddress = 0x2000, + PhysicalAddress = 0x2000, + Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Writable, + Size = 1024, + SizeInMemory = 1024, + Alignment = 4096, + }); + + AssertReadElf(elf, "test3.elf"); + } + + + [Test] + public void SimpleProgramHeaderAndCodeSectionAndSymbolSectionAndRelocation() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + var codeStream = new MemoryStream(); + codeStream.Write(new byte[4096]); + + var codeSection = elf.AddSection( + new ElfBinarySection(codeStream) + { + VirtualAddress = 0x1000, + Alignment = 4096 + }.ConfigureAs(ElfSectionSpecialType.Text) + ); + + + var dataStream = new MemoryStream(); + dataStream.Write(new byte[1024]); + + var dataSection = elf.AddSection( + new ElfBinarySection(dataStream) + { + VirtualAddress = 0x2000, + Alignment = 4096 + }.ConfigureAs(ElfSectionSpecialType.ReadOnlyData) + ); + + var stringSection = elf.AddSection(new ElfStringTable()); + + var symbolSection = elf.AddSection( + new ElfSymbolTable() + { + Link = stringSection, + + Entries = + { + new ElfSymbol() + { + Name = "local_symbol", + Bind = ElfSymbolBind.Local, + Section = codeSection, + Size = 16, + Type = ElfSymbolType.Function, + Visibility = ElfSymbolVisibility.Protected, + Value = 0x7896 + }, + new ElfSymbol() + { + Name = "GlobalSymbol", + Bind = ElfSymbolBind.Global, + Section = codeSection, + Size = 4, + Type = ElfSymbolType.Function, + Value = 0x12345 + } + } + } + ); + + elf.AddSegment( + new ElfSegment() + { + Type = ElfSegmentTypeCore.Load, + Range = codeSection, + VirtualAddress = 0x1000, + PhysicalAddress = 0x1000, + Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Executable, + Size = 4096, + SizeInMemory = 4096, + Alignment = 4096, + } + ); + + elf.AddSegment( + new ElfSegment() + { + Type = ElfSegmentTypeCore.Load, + Range = dataSection, + VirtualAddress = 0x2000, + PhysicalAddress = 0x2000, + Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Writable, + Size = 1024, + SizeInMemory = 1024, + Alignment = 4096, + } + ); + + var relocTable = elf.AddSection( + new ElfRelocationTable + { + Name = ".rela.text", + Link = symbolSection, + Info = codeSection, + Entries = + { + new ElfRelocation() + { + SymbolIndex = 1, + Type = ElfRelocationType.R_X86_64_32, + Offset = 0 + }, + new ElfRelocation() + { + SymbolIndex = 2, + Type = ElfRelocationType.R_X86_64_8, + Offset = 0 + } + } + } + ); + + elf.AddSection(new ElfSectionHeaderStringTable()); + + AssertReadElf(elf, "test4.elf"); + } + + + [Test] + public void TestHelloWorld() + { + var cppName = "helloworld"; + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -o {cppName}"); + + ElfObjectFile elf; + using (var inStream = File.OpenRead(cppName)) + { + Console.WriteLine($"ReadBack from {cppName}"); + elf = ElfObjectFile.Read(inStream); + elf.Print(Console.Out); + } + + using (var outStream = File.OpenWrite($"{cppName}_copy")) + { + elf.Write(outStream); + outStream.Flush(); + } + + var expected = LinuxUtil.ReadElf(cppName); + var result = LinuxUtil.ReadElf($"{cppName}_copy"); + if (expected != result) + { + Console.WriteLine("=== Result:"); + Console.WriteLine(result); + + Console.WriteLine("=== Expected:"); + Console.WriteLine(expected); + + Assert.AreEqual(expected, result); + } + } + + [Test] + public void TestAlignedSection() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + + // By default 0x1000 + var alignedSection = new ElfAlignedShadowSection(); + elf.AddSection(alignedSection); + + var codeStream = new MemoryStream(); + codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); + codeStream.Position = 0; + + var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); + elf.AddSection(codeSection); + + elf.AddSection(new ElfSectionHeaderStringTable()); + + var diagnostics = elf.Verify(); + Assert.False(diagnostics.HasErrors); + + elf.UpdateLayout(diagnostics); + Assert.False(diagnostics.HasErrors); + + elf.Print(Console.Out); + + Assert.AreEqual(alignedSection.UpperAlignment, codeSection.Offset, "Invalid alignment"); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs new file mode 100644 index 00000000000000..7377d9a3bfc8e1 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs @@ -0,0 +1,98 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; +using LibObjectFile.Elf; +using NUnit.Framework; + +namespace LibObjectFile.Tests.Elf +{ + public abstract class ElfTestBase + { + protected static void AssertReadElf(ElfObjectFile elf, string fileName) + { + AssertReadElfInternal(elf, fileName); + AssertReadBack(elf, fileName, readAsReadOnly: false); + AssertReadBack(elf, fileName, readAsReadOnly: true); + AssertLsbMsb(elf, fileName); + } + + private static void AssertReadElfInternal(ElfObjectFile elf, string fileName, bool writeFile = true, string context = null) + { + if (writeFile) + { + using (var stream = new FileStream(Path.Combine(Environment.CurrentDirectory, fileName), FileMode.Create)) + { + elf.Write(stream); + stream.Flush(); + Assert.AreEqual(stream.Length, (long)elf.Layout.TotalSize); + } + } + + var stringWriter = new StringWriter(); + elf.Print(stringWriter); + + var result = stringWriter.ToString().Replace("\r\n", "\n").TrimEnd(); + Console.WriteLine(result); + var readelf = LinuxUtil.ReadElf(fileName).TrimEnd(); + if (readelf != result) + { + Console.WriteLine("=== Expected:"); + Console.WriteLine(readelf); + Console.WriteLine("=== Result:"); + Console.WriteLine(result); + if (context != null) + { + Assert.AreEqual(readelf, result, context); + } + else + { + Assert.AreEqual(readelf, result); + } + } + } + + private static void AssertReadBack(ElfObjectFile elf, string fileName, bool readAsReadOnly) + { + ElfObjectFile newObjectFile; + + var filePath = Path.Combine(Environment.CurrentDirectory, fileName); + using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + newObjectFile = ElfObjectFile.Read(stream, new ElfReaderOptions() {ReadOnly = readAsReadOnly}); + + Console.WriteLine(); + Console.WriteLine("============================================================================="); + Console.WriteLine($"readback {(readAsReadOnly ? "as readonly" : "as readwrite")}"); + Console.WriteLine("============================================================================="); + Console.WriteLine(); + + AssertReadElfInternal(newObjectFile, fileName, false, $"Unexpected error while reading back {fileName}"); + + var originalBuffer = File.ReadAllBytes(filePath); + var memoryStream = new MemoryStream(); + newObjectFile.Write(memoryStream); + var newBuffer = memoryStream.ToArray(); + + Assert.AreEqual(originalBuffer, newBuffer, "Invalid binary diff between write -> (original) -> read -> write -> (new)"); + } + } + + private static void AssertLsbMsb(ElfObjectFile elf, string fileName) + { + Console.WriteLine(); + Console.WriteLine("*****************************************************************************"); + Console.WriteLine("LSB to MSB"); + Console.WriteLine("*****************************************************************************"); + Console.WriteLine(); + + elf.Encoding = ElfEncoding.Msb; + var newFileName = Path.GetFileNameWithoutExtension(fileName) + "_msb.elf"; + AssertReadElfInternal(elf, newFileName); + AssertReadBack(elf, newFileName, readAsReadOnly: false); + AssertReadBack(elf, newFileName, readAsReadOnly: true); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj new file mode 100644 index 00000000000000..094beb5118c2a1 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj @@ -0,0 +1,50 @@ + + + + net6.0 + 8.0 + true + false + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + + + + + + + + + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs new file mode 100644 index 00000000000000..77cfe3bd70fe45 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs @@ -0,0 +1,101 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; + +namespace LibObjectFile.Tests +{ + public static class LinuxUtil + { + public static string ReadElf(string file, string arguments = "-W -a") + { + return RunLinuxExe("readelf", $"{file} {arguments}"); + } + + public static string RunLinuxExe(string exe, string arguments, string distribution = "Ubuntu-18.04") + { + if (exe == null) throw new ArgumentNullException(nameof(exe)); + if (arguments == null) throw new ArgumentNullException(nameof(arguments)); + if (distribution == null) throw new ArgumentNullException(nameof(distribution)); + + // redirect to a file the output as there is a bug reading back stdout with WSL + var wslOut = $"wsl_stdout_{Guid.NewGuid()}.txt"; + + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + if (isWindows) + { + arguments = $"-d {distribution} {exe} {arguments} > {wslOut}"; + exe = "wsl.exe"; + } + + StringBuilder errorBuilder = null; + StringBuilder outputBuilder = new StringBuilder(); + + using (var process = new Process() + { + StartInfo = new ProcessStartInfo(exe, arguments) + { + UseShellExecute = false, + RedirectStandardOutput = !isWindows, + CreateNoWindow = true, + RedirectStandardError = true, + }, + }) + { + + process.ErrorDataReceived += (sender, args) => + { + if (errorBuilder == null) + { + errorBuilder = new StringBuilder(); + } + + errorBuilder.Append(args.Data).Append('\n'); + }; + + if (!isWindows) + { + process.OutputDataReceived += (sender, args) => { outputBuilder.Append(args.Data).Append('\n'); }; + } + + process.Start(); + process.BeginErrorReadLine(); + + if (!isWindows) + { + process.BeginOutputReadLine(); + } + + process.WaitForExit(); + + if (process.ExitCode != 0) + { + throw new InvalidOperationException($"Error while running command `{exe} {arguments}`: {errorBuilder}"); + } + + if (isWindows) + { + var generated = Path.Combine(Environment.CurrentDirectory, wslOut); + var result = File.ReadAllText(generated); + try + { + File.Delete(generated); + } + catch + { + // ignore + } + + return result; + } + } + + return outputBuilder.ToString(); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 new file mode 100644 index 0000000000000000000000000000000000000000..39ee3f3b288e087e123e0061ad4ffb4a0bf98519 GIT binary patch literal 180 zcmb<-^>JflWMqH=CI$@#7|#SM$i%?FYQmtvzyg%R2DTss*+EROegPn31CRy8Cfq +int main(int argc, char** argv) +{ + printf("HelloWorld!\n"); +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp new file mode 100644 index 00000000000000..feeda9f1c11445 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp @@ -0,0 +1,4 @@ +int process_add(int a, int b) +{ + return a + b; +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp new file mode 100644 index 00000000000000..a48e8274cb0768 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp @@ -0,0 +1,4 @@ +float process_add2(float a, float b) +{ + return a + b; +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp new file mode 100644 index 00000000000000..dea924723f9d12 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp @@ -0,0 +1,14 @@ +int process_add(int a, int b) +{ + return a + b; +} + +float process_add2(float a, float b) +{ + return a + b; +} + +float process_both(int a, float b) +{ + return (float)process_add(a, (int)b) + process_add2((float)a, b); +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp new file mode 100644 index 00000000000000..b614c4e53730ac --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp @@ -0,0 +1,22 @@ +struct MyStruct +{ + unsigned char* str; + + int count; +}; + +typedef char (*TransformCharDelegate)(char); + +int ProcessStructs(MyStruct* input, MyStruct* output, TransformCharDelegate transform) +{ + int acc = 0; + for(int i = 0; i < input->count; i++) + { + auto value1 = input->str[i]; + auto value2 = output->str[i]; + auto value3 = transform(value1) + transform(value2); + + acc += value1 + value2 + value3; + } + return acc; +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln new file mode 100644 index 00000000000000..494ef1b06cfe77 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln @@ -0,0 +1,59 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile", "LibObjectFile\LibObjectFile.csproj", "{4395EB77-43C4-4292-8449-D7B03D479313}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile.Tests", "LibObjectFile.Tests\LibObjectFile.Tests.csproj", "{DE76269F-077C-4F8D-8DEF-A2EB5764996D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile.CodeGen", "LibObjectFile.CodeGen\LibObjectFile.CodeGen.csproj", "{A42D56D8-B0D1-4809-9210-B1285F1C4409}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D117A3-A530-46EE-A873-4FE18DCA6841}" + ProjectSection(SolutionItems) = preProject + ..\.gitignore = ..\.gitignore + ..\changelog.md = ..\changelog.md + ..\.github\workflows\CI.yml = ..\.github\workflows\CI.yml + Directory.Build.props = Directory.Build.props + dotnet-releaser.toml = dotnet-releaser.toml + ..\license.txt = ..\license.txt + ..\readme.md = ..\readme.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{BD580DD4-4E27-4FE6-8E3B-E773BE9555E0}" + ProjectSection(SolutionItems) = preProject + ..\doc\readme.md = ..\doc\readme.md + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "objdasm", "objdasm\objdasm.csproj", "{056AA737-6B5F-47A6-8426-E7918D930C5C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4395EB77-43C4-4292-8449-D7B03D479313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4395EB77-43C4-4292-8449-D7B03D479313}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4395EB77-43C4-4292-8449-D7B03D479313}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4395EB77-43C4-4292-8449-D7B03D479313}.Release|Any CPU.Build.0 = Release|Any CPU + {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Release|Any CPU.Build.0 = Release|Any CPU + {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Release|Any CPU.Build.0 = Release|Any CPU + {056AA737-6B5F-47A6-8426-E7918D930C5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {056AA737-6B5F-47A6-8426-E7918D930C5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {056AA737-6B5F-47A6-8426-E7918D930C5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {056AA737-6B5F-47A6-8426-E7918D930C5C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1137A8C0-B13F-4D49-ACC2-425BBA1B193C} + EndGlobalSection +EndGlobal diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings new file mode 100644 index 00000000000000..446dc7e29ccc57 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings @@ -0,0 +1,16 @@ + + Copyright (c) Alexandre Mutel. All rights reserved. +This file is licensed under the BSD-Clause 2 license. +See the license.txt file in the project root for more information. + BSD + DIE + GNU + LEB + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd new file mode 100644 index 00000000000000..a3f7e9725a7dc9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd @@ -0,0 +1,65 @@ + + + + + + AABAEACAAABAAQKAAAAQAAAwgAAAAACAAAAAAAMAEIA= + Ar\ArArchiveFile.cs + + + + + + + + + + + + EgAAIAAMAAAAEFIFAkACAAQgEEAAEIQAAAGRAIEEgAA= + Ar\ArFile.cs + + + + + + AAgIAAAAAABAAQAFAAAAAAQgEAAAAAAAAAAAIAEAAAA= + Ar\ArSymbolTable.cs + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAgAAAIAAAAAAAAIAEAAAA= + Ar\ArBinaryFile.cs + + + + + + AAAAAAAAAAAAQAAAAAAAAAAgAAAAAAAAAAAAIAEAAAA= + Ar\ArElfFile.cs + + + + + + + + + IIAMBgAQAAAEAYGAAAAEHAAggCAoQAkIEUgAiAUBACA= + Elf\ElfObjectFile.cs + + + + + + AAAAAAAAAAAQAAAEAAAQAAQAAAAEAAAAAAAAAAAAAAA= + Ar\ArSymbol.cs + + + + \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs new file mode 100644 index 00000000000000..a95b5b2bfaf17c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs @@ -0,0 +1,381 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace LibObjectFile.Ar +{ + /// + /// An 'ar' archive file. + /// + public sealed class ArArchiveFile : ObjectFileNode + { + private readonly List _files; + + /// + /// Gets the bytes !<arch>\n involved in the magic file header of an archive + /// + public static ReadOnlySpan Magic => new ReadOnlySpan(new byte[] + { + (byte)'!', + (byte)'<', + (byte)'a', + (byte)'r', + (byte)'c', + (byte)'h', + (byte)'>', + (byte)'\n', + }); + + /// + /// Initializes a new instance. + /// + public ArArchiveFile() + { + _files = new List(); + Kind = ArArchiveKind.GNU; + } + + /// + /// Gets or sets the type of this archive file. + /// + public ArArchiveKind Kind { get; set; } + + /// + /// Gets the associated to this instance. Must be first entry in + /// + public ArSymbolTable SymbolTable { get; private set; } + + /// + /// Internal extended file names used for GNU entries. + /// + internal ArLongNamesTable LongNamesTable { get; set; } + + /// + /// Gets the file entries. Use or to manipulate the entries. + /// + public IReadOnlyList Files => _files; + + /// + /// Adds a file to . + /// + /// A file + public void AddFile(ArFile file) + { + if (file == null) throw new ArgumentNullException(nameof(file)); + if (file.Parent != null) + { + if (file.Parent == this) throw new InvalidOperationException("Cannot add the file as it is already added"); + if (file.Parent != this) throw new InvalidOperationException($"Cannot add the file as it is already added to another {nameof(ArArchiveFile)} instance"); + } + + if (file is ArSymbolTable symbolTable) + { + InsertFileAt(0, file); + return; + } + + file.Parent = this; + file.Index = (uint)_files.Count; + _files.Add(file); + } + + /// + /// Inserts a file into at the specified index. + /// + /// Index into to insert the specified file + /// The file to insert + public void InsertFileAt(int index, ArFile file) + { + if (index < 0 || index > _files.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_files.Count}"); + if (file == null) throw new ArgumentNullException(nameof(file)); + if (file.Parent != null) + { + if (file.Parent == this) throw new InvalidOperationException("Cannot add the file as it is already added"); + if (file.Parent != this) throw new InvalidOperationException($"Cannot add the file as it is already added to another {nameof(ArArchiveFile)} instance"); + } + + if (file is ArSymbolTable symbolTable) + { + if (SymbolTable == null) + { + if (index != 0) + { + throw new ArgumentException($"Cannot only add a symbol table at index 0", nameof(file)); + } + SymbolTable = symbolTable; + } + else + { + throw new ArgumentException($"Cannot add this symbol table as an existing symbol table is already present in the file entries of {this}", nameof(file)); + } + } + else + { + if (SymbolTable != null && index == 0) + { + throw new ArgumentException($"Cannot add the entry {file} at index 0 because a symbol table is already set and must be the first entry in the list of files", nameof(file)); + } + } + + file.Index = (uint)index; + _files.Insert(index, file); + file.Parent = this; + + // Update the index of following files + for (int i = index + 1; i < _files.Count; i++) + { + var nextFile = _files[i]; + nextFile.Index++; + } + } + + /// + /// Removes a file from + /// + /// The file to remove + public void RemoveFile(ArFile file) + { + if (file == null) throw new ArgumentNullException(nameof(file)); + if (file.Parent != this) + { + throw new InvalidOperationException($"Cannot remove this file as it is not part of this {nameof(ArArchiveFile)} instance"); + } + + // If we are removing the SymbolTable + if (file == SymbolTable) + { + SymbolTable = null; + } + + var i = (int)file.Index; + _files.RemoveAt(i); + file.Index = 0; + + // Update indices for other sections + for (int j = i + 1; j < _files.Count; j++) + { + var nextEntry = _files[j]; + nextEntry.Index--; + } + + file.Parent = null; + } + + /// + /// Removes a file from at the specified index. + /// + /// Index into to remove the specified file + public ArFile RemoveFileAt(int index) + { + if (index < 0 || index > _files.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_files.Count}"); + var file = _files[index]; + RemoveFile(file); + return file; + } + + public override void Verify(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + for (var i = 0; i < Files.Count; i++) + { + var item = Files[i]; + if (item.Name == null) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullFileEntryName, $"Invalid null FileName for file entry [{i}] in {this}"); + } + else if (Kind == ArArchiveKind.Common) + { + var count = Encoding.UTF8.GetByteCount(item.Name); + if (count > ArFile.FieldNameLength) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileEntryNameTooLong, $"Invalid length ({count} bytes) for file entry [{i}] {item.Name} in {this}. Must be <= {ArFile.FieldNameLength} for {Kind} ar file"); + } + } + + item.Verify(diagnostics); + } + } + + /// + /// Detects from the specified stream if there is an 'ar' archive file header. + /// + /// The stream to detect the presence of an 'ar' archive file header. + /// true if an 'ar' archive file header was detected. false otherwise. + public static bool IsAr(Stream stream) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + var startPosition = stream.Position; + var result = ArArchiveFileReader.IsAr(stream, null); + stream.Position = startPosition; + return result; + } + + /// + /// Detects from the specified stream if there is an 'ar' archive file header. + /// + /// The stream to detect the presence of an 'ar' archive file header. + /// The diagnostics + /// true if an 'ar' archive file header was detected. false otherwise. + public static bool IsAr(Stream stream, out DiagnosticBag diagnostics) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + var startPosition = stream.Position; + diagnostics = new DiagnosticBag(); + var result = ArArchiveFileReader.IsAr(stream, diagnostics); + stream.Position = startPosition; + return result; + } + + /// + /// Reads an 'ar' archive file from the specified stream. + /// + /// The stream to read 'ar' a archive file from. + /// The type of 'ar' archive to read. + /// An instance of if the read was successful. + /// In case of an invalid file. + public static ArArchiveFile Read(Stream stream, ArArchiveKind archiveKind) + { + return Read(stream, new ArArchiveFileReaderOptions(archiveKind)); + } + + /// + /// Reads an 'ar' archive file from the specified stream. + /// + /// The stream to read 'ar' a archive file from. + /// The options used for reading this 'ar' file. + /// An instance of if the read was successful. + /// In case of an invalid file. + public static ArArchiveFile Read(Stream stream, ArArchiveFileReaderOptions options) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + if (options == null) throw new ArgumentNullException(nameof(options)); + + if (!TryRead(stream, options, out var arFile, out var diagnostics)) + { + throw new ObjectFileException("Invalid ar file", diagnostics); + } + + return arFile; + } + + /// + /// Tries to reads an 'ar' archive file from the specified stream. + /// + /// The stream to read 'ar' a archive file from. + /// The type of 'ar' archive to read. + /// The output 'ar' archive file if the read was successful. + /// The output associated diagnostics after reading the archive. + /// true An instance of if the read was successful. + public static bool TryRead(Stream stream, ArArchiveKind archiveKind, out ArArchiveFile arArchiveFile, out DiagnosticBag diagnostics) + { + return TryRead(stream, new ArArchiveFileReaderOptions(archiveKind), out arArchiveFile, out diagnostics); + } + + /// + /// Tries to reads an 'ar' archive file from the specified stream. + /// + /// The stream to read 'ar' a archive file from. + /// The options used for reading this 'ar' file. + /// The output 'ar' archive file if the read was successful. + /// The output associated diagnostics after reading the archive. + /// true An instance of if the read was successful. + public static bool TryRead(Stream stream, ArArchiveFileReaderOptions options, out ArArchiveFile arArchiveFile, out DiagnosticBag diagnostics) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + if (options == null) throw new ArgumentNullException(nameof(options)); + + arArchiveFile = new ArArchiveFile { Kind = options.ArchiveKind }; + var reader = new ArArchiveFileReader(arArchiveFile, stream, options); + diagnostics = reader.Diagnostics; + reader.Read(); + + return !reader.Diagnostics.HasErrors; + } + + /// + /// Writes this 'ar' archive file to the specified stream. + /// + /// The stream to write to. + public void Write(Stream stream) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + var writer = new ArArchiveFileWriter(this, stream); + writer.Write(); + } + + public void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + Size = 0; + + if (Kind == ArArchiveKind.GNU) + { + if (LongNamesTable == null) + { + LongNamesTable = new ArLongNamesTable + { + Parent = this + }; + } + + if (SymbolTable != null && SymbolTable.Index == 0) + { + LongNamesTable.Index = 1; + } + else + { + LongNamesTable.Index = 1; + } + } + else + { + // Don't use headers + LongNamesTable = null; + } + + ulong size = (ulong)Magic.Length; + + // Clear the internal names + foreach (var entry in Files) + { + entry.InternalName = null; + } + + for (var i = 0; i < Files.Count; i++) + { + var entry = Files[i]; + + entry.UpdateLayout(diagnostics); + if (diagnostics.HasErrors) return; + + // If we have a GNU headers and they are required, add them to the offset and size + if (LongNamesTable != null && LongNamesTable.Index == i) + { + LongNamesTable.UpdateLayout(diagnostics); + if (diagnostics.HasErrors) return; + + var headerSize = LongNamesTable.Size; + if (headerSize > 0) + { + LongNamesTable.Offset = size; + size += ArFile.FileEntrySizeInBytes + LongNamesTable.Size; + if ((size & 1) != 0) size++; + } + } + + entry.Offset = size; + size += ArFile.FileEntrySizeInBytes + entry.Size; + if ((size & 1) != 0) size++; + } + + Size = size; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs new file mode 100644 index 00000000000000..557d7946e4b00f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs @@ -0,0 +1,352 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Diagnostics; +using System.IO; +using System.Text; +using LibObjectFile.Elf; + +namespace LibObjectFile.Ar +{ + /// + /// Class for reading and building an from a . + /// + public class ArArchiveFileReader : ObjectFileReaderWriter + { + private ArLongNamesTable _futureHeaders; + + internal ArArchiveFileReader(ArArchiveFile arArchiveFile, Stream stream, ArArchiveFileReaderOptions options) : base(stream) + { + ArArchiveFile = arArchiveFile; + Options = options; + IsReadOnly = options.IsReadOnly; + } + + public ArArchiveFileReaderOptions Options { get; } + + public override bool IsReadOnly { get; } + + internal ArArchiveFile ArArchiveFile { get; } + + internal static bool IsAr(Stream stream, DiagnosticBag diagnostics) + { + Span magic = stackalloc byte[ArArchiveFile.Magic.Length]; + int magicLength = stream.Read(magic); + if (magicLength != magic.Length) + { + if (diagnostics != null) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidMagicLength, $"Invalid length {magicLength} while trying to read ! from stream while expecting at least {magic.Length} bytes"); + } + return false; + } + + if (!magic.SequenceEqual(ArArchiveFile.Magic)) + { + if (diagnostics != null) + { + diagnostics.Error(DiagnosticId.AR_ERR_MagicNotFound, $"Magic !\\n not found"); + } + return false; + } + + return true; + } + + internal void Read() + { + if (!IsAr(Stream, Diagnostics)) + { + return; + } + + Span entryBuffer = stackalloc byte[ArFile.FileEntrySizeInBytes]; + + _futureHeaders = null; + + while (TryReadFileEntry(entryBuffer, out var fileEntry)) + { + if (fileEntry is ArLongNamesTable arGnuFutureHeaders) + { + if (_futureHeaders != null) + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidDuplicatedFutureHeadersTable, $"Invalid duplicated future headers table found at offset {fileEntry.Offset} while another table was already found at offset {_futureHeaders.Offset}. This file is invalid."); + break; + } + + _futureHeaders = arGnuFutureHeaders; + } + else + { + ArArchiveFile.AddFile(fileEntry); + } + } + + if (Diagnostics.HasErrors) return; + + // Perform a pass after all entries have been read + foreach (var arFileEntry in ArArchiveFile.Files) + { + arFileEntry.AfterReadInternal(this.Diagnostics); + } + } + + private bool TryReadFileEntry(Span buffer, out ArFile entry) + { + entry = null; + + Debug.Assert((Stream.Position & 1) == 0); + + long entryOffset = Stream.Position; + int length = Stream.Read(buffer); + if (length == 0) + { + return false; + } + + if (length < buffer.Length) + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileEntryLength, $"Invalid length {length} while trying to read a file entry from stream at offset {entryOffset}. Expecting {buffer.Length} bytes"); + return false; + } + // 0 16 File identifier ASCII + // discard right padding characters + int idLength = 16; + while (idLength > 0) + { + if (buffer[idLength - 1] != ' ') + { + break; + } + idLength--; + } + + string name = null; + ulong? bsdNameLength = null; + + if (idLength > 3 && ArArchiveFile.Kind == ArArchiveKind.BSD) + { + if (buffer[0] == '#' && buffer[1] == '1' && buffer[2] == '/') + { + // If we have a future header table, we are using it and expecting only numbers + if (!TryDecodeDecimal(entryOffset, buffer, 3, ArFile.FieldNameLength - 3, $"BSD Name length following #1/ at offset {entryOffset}", out ulong bsdNameLengthDecoded)) + { + // Don't try to process more entries, the archive might be corrupted + return false; + } + + bsdNameLength = bsdNameLengthDecoded; + } + } + + // If the last char is `/` + // Keep file names with / or // + // But remove trailing `/`for regular file names + if (!bsdNameLength.HasValue && ArArchiveFile.Kind != ArArchiveKind.Common && idLength > 0 && buffer[idLength - 1] == '/') + { + if (!(idLength == 1 || idLength == 2 && buffer[idLength - 2] == '/')) + { + idLength--; + } + } + + if (_futureHeaders != null && buffer[0] == (byte)'/') + { + // If we have a future header table, we are using it and expecting only numbers + if (!TryDecodeDecimal(entryOffset, buffer, 1, ArFile.FieldNameLength - 1, $"Name with offset to Future Headers Table at file offset {entryOffset}", out ulong offsetInFutureHeaders)) + { + // Don't try to process more entries, the archive might be corrupted + return false; + } + + // If the number is ok, check that we have actually a string for this offset + if (!_futureHeaders.FileNames.TryGetValue((int)offsetInFutureHeaders, out name)) + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidReferenceToFutureHeadersTable, $"Invalid reference {offsetInFutureHeaders} found at file offset {entryOffset}. This file is invalid."); + } + } + + if (!bsdNameLength.HasValue && name == null) + { + name = idLength == 0 ? string.Empty : Encoding.UTF8.GetString(buffer.Slice(0, idLength)); + } + + // 16 12 File modification timestamp Decimal + if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldTimestampOffset, ArFile.FieldTimestampLength, "File modification timestamp Decimal", out ulong timestamp)) + { + return false; + } + + // 28 6 Owner ID Decimal + if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldOwnerIdOffset, ArFile.FieldOwnerIdLength, "Owner ID", out ulong ownerId)) + { + return false; + } + + // 34 6 Group ID Decimal + if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldGroupIdOffset, ArFile.FieldGroupIdLength, "Group ID", out ulong groupId)) + { + return false; + } + + // 40 8 File mode Octal + if (!TryDecodeOctal(entryOffset, buffer, ArFile.FieldFileModeOffset, ArFile.FieldFileModeLength, "File mode", out uint fileMode)) + { + return false; + } + + // 48 10 File size in bytes Decimal + if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldFileSizeOffset, ArFile.FieldFileSizeLength, "File size in bytes", out ulong fileSize)) + { + return false; + } + + // 58 2 Ending characters 0x60 0x0A + if (buffer[ArFile.FieldEndCharactersOffset] != 0x60 || buffer[ArFile.FieldEndCharactersOffset + 1] != '\n') + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII characters found 0x{buffer[ArFile.FieldEndCharactersOffset]:x} 0x{buffer[ArFile.FieldEndCharactersOffset+1]:x} instead of `\\n at the end of file entry at offset {entryOffset + ArFile.FieldEndCharactersOffset}"); + return false; + } + + entry = CreateFileEntryFromName(name); + entry.Timestamp = DateTimeOffset.FromUnixTimeSeconds((long)timestamp); + entry.OwnerId = (uint)ownerId; + entry.GroupId = (uint)groupId; + entry.FileMode = fileMode; + entry.Offset = (ulong)entryOffset; + entry.Size = fileSize; + + // Read the BSD name if necessary + if (bsdNameLength.HasValue) + { + var nameLength = (int) bsdNameLength.Value; + var bufferForName = ArrayPool.Shared.Rent(nameLength); + var streamPosition = Stream.Position; + var dataReadCount = Stream.Read(bufferForName, 0, nameLength); + if (dataReadCount != nameLength) + { + Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file while trying to read the filename from the data section of the file entry at offset of {streamPosition}. Expecting {nameLength} bytes while only {dataReadCount} bytes were read from the stream."); + return false; + } + name = Encoding.UTF8.GetString(bufferForName, 0, nameLength); + } + + if (!entry.IsSystem) + { + if (name.Contains('/')) + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterInFileEntryName, $"The character `/` was found in the entry `{name}` while it is invalid."); + return false; + } + entry.Name = name; + } + + entry.ReadInternal(this); + + // The end of an entry is always aligned + if ((Stream.Position & 1) != 0) + { + long padOffset = Stream.Position; + int pad = Stream.ReadByte(); + if (pad < 0) + { + Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file while trying to Invalid character 0x{pad:x} found at offset {padOffset} while expecting \\n 0xa"); + return false; + } + if (pad != '\n') + { + Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Invalid character 0x{pad:x} found at offset {padOffset} while expecting \\n 0xa"); + return false; + } + } + + return true; + } + + private bool TryDecodeDecimal(long entryOffset, Span buffer, int offset, int length, string fieldName, out ulong value) + { + value = 0; + // == 0, expect number or space + // == 1, expect space + int state = 0; + for (int i = 0; i < length; i++) + { + var c = buffer[offset + i]; + if (state == 0 && c >= '0' && c <= '9') + { + value = value * 10 + (ulong) (c - '0'); + } + else if (state >= 0 && c == ' ') + { + state = 1; + } + else + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII character 0x{c:x} found instead of {state switch { 0 => "' '/space or decimal 0-9", _ => "' '/space" }} in file entry at file offset {entryOffset + i} while decoding field entry `{fieldName}`"); + return false; + } + } + return true; + } + + private bool TryDecodeOctal(long entryOffset, Span buffer, int offset, int length, string fieldName, out uint value) + { + value = 0; + // == 0, expect number or space + // == 1, expect space + int state = 0; + for (int i = 0; i < length; i++) + { + var c = buffer[offset + i]; + if (state == 0 && c >= '0' && c <= '7') + { + value = value * 8 + (uint)(c - '0'); + } + else if (state >= 0 && c == ' ') + { + state = 1; + } + else + { + Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII character 0x{c:x} found instead of {state switch { 0 => "' '/space or octal 0-7", _ => "' '/space" }} in file entry at file offset {entryOffset + i} while decoding field entry `{fieldName}`"); + return false; + } + } + return true; + } + + private ArFile CreateFileEntryFromName(string name) + { + if (ArArchiveFile.Kind == ArArchiveKind.GNU) + { + switch (name) + { + case ArSymbolTable.DefaultGNUSymbolTableName: + return new ArSymbolTable(); + case ArLongNamesTable.DefaultName: + return new ArLongNamesTable(); + } + } + else if (ArArchiveFile.Kind == ArArchiveKind.BSD) + { + if (name == ArSymbolTable.DefaultBSDSymbolTableName) + { + return new ArSymbolTable(); + } + } + + if (Options.ProcessObjectFiles) + { + if (ElfObjectFile.IsElf(Stream)) + { + return new ArElfFile(); + } + } + + return new ArBinaryFile(); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs new file mode 100644 index 00000000000000..5c476839a48c36 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs @@ -0,0 +1,41 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Ar +{ + /// + /// Reader options used by and other methods. + /// + public class ArArchiveFileReaderOptions + { + /// + /// Initializes a new instance. + /// + /// Type of the 'ar' file to load (GNU, BSD...) + public ArArchiveFileReaderOptions(ArArchiveKind archiveKind) + { + ArchiveKind = archiveKind; + ProcessObjectFiles = true; + } + + /// + /// Gets or sets a boolean indicating if the file entries must keep a readonly view + /// on the original stream for the content of the file entries, or it should copy + /// them to modifiable . + /// + public bool IsReadOnly { get; set; } + + /// + /// Gets or sets the type of file to load + /// + public ArArchiveKind ArchiveKind { get; set; } + + /// + /// Gets or sets a boolean indicating if object files are being processed to return + /// typed entries () instead of generic binary file entry (). + /// Default is true + /// + public bool ProcessObjectFiles { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs new file mode 100644 index 00000000000000..f0181cc47499e9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs @@ -0,0 +1,203 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Diagnostics; +using System.IO; +using System.Text; + +namespace LibObjectFile.Ar +{ + /// + /// Class for writing an to a . + /// + public class ArArchiveFileWriter: ObjectFileReaderWriter + { + private long _startStreamOffset; + + internal ArArchiveFileWriter(ArArchiveFile archiveFile, Stream stream) : base(stream) + { + ArArchiveFile = archiveFile; + IsReadOnly = false; + } + + private ArArchiveFile ArArchiveFile { get; } + + public override bool IsReadOnly { get; } + + internal void Write() + { + var localDiagnostics = new DiagnosticBag(); + ArArchiveFile.UpdateLayout(localDiagnostics); + if (localDiagnostics.HasErrors) + { + throw new ObjectFileException("Invalid ar file", localDiagnostics); + } + // Copy for warnings + localDiagnostics.CopyTo(Diagnostics); + + _startStreamOffset = Stream.Position; + + Stream.Write(ArArchiveFile.Magic); + Span entryBuffer = stackalloc byte[ArFile.FileEntrySizeInBytes]; + + var headers = ArArchiveFile.LongNamesTable; + + // Serialize all file entries + for (var i = 0; i < ArArchiveFile.Files.Count; i++) + { + var file = ArArchiveFile.Files[i]; + + // Serialize the headers at the correct position only if they are required + if (headers != null && headers.Index == i && headers.Size > 0) + { + WriteFileEntry(entryBuffer, headers); + if (Diagnostics.HasErrors) break; + } + + WriteFileEntry(entryBuffer, file); + if (Diagnostics.HasErrors) break; + } + + if (Diagnostics.HasErrors) + { + throw new ObjectFileException("Unexpected error while writing ar file", Diagnostics); + } + } + + private void WriteFileEntry(Span buffer, ArFile file) + { + Debug.Assert((ulong)(Stream.Position - _startStreamOffset) == file.Offset); + buffer.Fill((byte)' '); + + var name = file.InternalName; + + bool postFixSlash = false; + + if (name == null) + { + name = file.Name; + if (ArArchiveFile.Kind != ArArchiveKind.Common && !name.EndsWith("/")) + { + postFixSlash = true; + } + } + + uint? bsdNameLength = null; + + if (ArArchiveFile.Kind == ArArchiveKind.BSD) + { + var nameLength = Encoding.UTF8.GetByteCount(name); + if (nameLength > ArFile.FieldNameLength) + { + name = $"#1/{nameLength}"; + bsdNameLength = (uint)nameLength; + postFixSlash = false; + } + } + + // Encode Length + int length = Encoding.UTF8.GetBytes(name, buffer.Slice(0, ArFile.FieldNameLength)); + if (postFixSlash) + { + buffer[length] = (byte) '/'; + } + + if (!(file is ArLongNamesTable)) + { + // 16 12 File modification timestamp Decimal + EncodeDecimal(buffer, ArFile.FieldTimestampOffset, ArFile.FieldTimestampLength, (ulong)file.Timestamp.ToUnixTimeSeconds()); + // 28 6 Owner ID Decimal + EncodeDecimal(buffer, ArFile.FieldOwnerIdOffset, ArFile.FieldOwnerIdLength, file.OwnerId); + // 34 6 Group ID Decimal + EncodeDecimal(buffer, ArFile.FieldGroupIdOffset, ArFile.FieldGroupIdLength, file.GroupId); + // 40 8 File mode Octal + EncodeOctal(buffer, ArFile.FieldFileModeOffset, ArFile.FieldFileModeLength, file.FileMode); + } + // 48 10 File size in bytes Decimal + EncodeDecimal(buffer, ArFile.FieldFileSizeOffset, ArFile.FieldFileSizeLength, file.Size); + + buffer[ArFile.FieldEndCharactersOffset] = 0x60; + buffer[ArFile.FieldEndCharactersOffset + 1] = (byte) '\n'; + + // Write the entry + Stream.Write(buffer); + + // Handle BSD file name by serializing the name before the data if it is required + if (bsdNameLength.HasValue) + { + uint nameLength = bsdNameLength.Value; + var bufferName = ArrayPool.Shared.Rent((int) nameLength); + Encoding.UTF8.GetBytes(file.Name, 0, file.Name.Length, bufferName, 0); + try + { + Stream.Write(bufferName, 0, (int)nameLength); + } + finally + { + ArrayPool.Shared.Return(bufferName); + } + } + + // Write the content following the entry + file.WriteInternal(this); + + // Align to even byte + if ((Stream.Position & 1) != 0) + { + Stream.WriteByte((byte)'\n'); + } + } + + private void EncodeDecimal(in Span buffer, int offset, int size, ulong value) + { + int count = value == 0 ? 1 : 0; + var check = value; + while (check > 0) + { + check /= 10; + count++; + } + + if (count > size) + { + Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Cannot encode decimal `{value}` as the size is exceeding the available size {size}"); + return; + } + + check = value; + for (int i = 0; i < count; i++) + { + var dec = check % 10; + buffer[offset + count - i - 1] = (byte)((byte) '0' + dec); + check = check / 10; + } + } + + private void EncodeOctal(in Span buffer, int offset, int size, ulong value) + { + int count = value == 0 ? 1 : 0; + var check = value; + while (check > 0) + { + check /= 8; + count++; + } + + if (count > size) + { + Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Cannot encode octal `{value}` as the size is exceeding the available size {size}"); + } + + check = value; + for (int i = 0; i < count; i++) + { + var dec = check % 8; + buffer[offset + count - i - 1] = (byte)((byte)'0' + dec); + check = check / 8; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs new file mode 100644 index 00000000000000..6887e3fea5f672 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs @@ -0,0 +1,32 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Ar +{ + /// + /// The type of archive. + /// + public enum ArArchiveKind + { + /// + /// The common variant, used for example by 'deb' package files. + /// Supports only file names up to 16 characters. + /// + Common, + + /// + /// The GNU variant, used by the `ar` utility on GNU and other systems (including Windows) + /// Based on file format, but using a different strategy + /// for storing long file names, incompatible with format. + /// + GNU, + + /// + /// The BSD variant, used by the `ar` utility on BSD systems (including MacOS) + /// Based on file format and backward compatible with it, + /// but allows to store longer file names and file names containing space. + /// + BSD, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs new file mode 100644 index 00000000000000..c85c7d9b08796f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs @@ -0,0 +1,39 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Ar +{ + /// + /// An binary stream . + /// + public sealed class ArBinaryFile : ArFile + { + /// + /// Gets or sets the stream associated to this entry. + /// + public Stream Stream { get; set; } + + protected override void Read(ArArchiveFileReader reader) + { + Stream = reader.ReadAsStream(Size); + } + + protected override void Write(ArArchiveFileWriter writer) + { + if (Stream != null) + { + writer.Write(Stream); + } + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + Size = Stream != null ? (ulong) Stream.Length : 0; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs new file mode 100644 index 00000000000000..4a496ebaf6664e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs @@ -0,0 +1,62 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using LibObjectFile.Elf; +using LibObjectFile.Utils; + +namespace LibObjectFile.Ar +{ + /// + /// An ELF file entry. + /// + public sealed class ArElfFile : ArFile + { + public ArElfFile() + { + } + + public ArElfFile(ElfObjectFile elfObjectFile) + { + ElfObjectFile = elfObjectFile; + } + + /// + /// Gets or sets the ELF object file. + /// + public ElfObjectFile ElfObjectFile { get; set; } + + protected override void Read(ArArchiveFileReader reader) + { + var startPosition = reader.Stream.Position; + var endPosition = startPosition + (long) Size; + ElfObjectFile = ElfObjectFile.Read(new SliceStream(reader.Stream, reader.Stream.Position, (long)Size)); + reader.Stream.Position = endPosition; + } + + protected override void Write(ArArchiveFileWriter writer) + { + if (ElfObjectFile != null) + { + ElfObjectFile.TryWrite(writer.Stream, out var diagnostics); + diagnostics.CopyTo(writer.Diagnostics); + } + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + Size = 0; + + if (ElfObjectFile != null) + { + ElfObjectFile.UpdateLayout(diagnostics); + if (!diagnostics.HasErrors) + { + Size = ElfObjectFile.Layout.TotalSize; + } + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs new file mode 100644 index 00000000000000..3977b5c589d594 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs @@ -0,0 +1,148 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Ar +{ + /// + /// Base class for a file entry in + /// + public abstract partial class ArFile : ArObject + { + private string _name; + private DateTimeOffset _timestamp; + + protected ArFile() + { + Timestamp = DateTimeOffset.UtcNow; + } + + /// + /// Gets or sets the name of the file in the archive entry. + /// + public virtual string Name + { + get => _name; + set + { + if (IsSystem) + { + throw CannotModifyProperty(nameof(Name)); + } + + if (value != null && value.Contains('/')) + { + throw new ArgumentException("The character `/` is not allowed in a file name entry"); + } + + _name = value; + } + } + + /// + /// Gets or sets the real (internal) name used for storing this entry (used by ) + /// + internal string InternalName { get; set; } + + /// + /// Gets or sets the timestamp of this file (clamped to seconds since 1970/01/01) + /// + public DateTimeOffset Timestamp + { + get => _timestamp; + + // We clamp the timestamp to the precision supported by the system + set => _timestamp = DateTimeOffset.FromUnixTimeSeconds(value.ToUnixTimeSeconds()); + } + + /// + /// Gets or sets the owner id. + /// + public uint OwnerId { get; set; } + + /// + /// Gets or sets the group id. + /// + public uint GroupId { get; set; } + + /// + /// Gets or sets the file mode. + /// + public uint FileMode { get; set; } + + /// + /// Gets a boolean indicating if this entry is a system entry (symbol table, header references) + /// and so does not respect naming (that should exclude for example `/`) + /// + public virtual bool IsSystem => false; + + internal void AfterReadInternal(DiagnosticBag diagnostics) + { + AfterRead(diagnostics); + } + + internal void ReadInternal(ArArchiveFileReader reader) + { + var expectedSize = (long)Size; + var beforePosition = reader.Stream.Position; + Read(reader); + var afterPosition = reader.Stream.Position; + var size = afterPosition - beforePosition; + // Verifies that the Size property is actually valid with what is being read + if (size != expectedSize) + { + reader.Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected EOF / size (expected: {expectedSize} != read: {size}) while trying to read file entry {Name}"); + } + } + + internal void WriteInternal(ArArchiveFileWriter writer) + { + var expectedSize = (long)Size; + var beforePosition = writer.Stream.Position; + Write(writer); + var afterPosition = writer.Stream.Position; + var size = afterPosition - beforePosition; + + // Verifies that the Size property is actually valid with what is being written + if (size != expectedSize) + { + // In that case, we don't log a diagnostics but throw an error, as it is an implementation problem. + throw new InvalidOperationException($"Invalid implementation of {GetType()}.{nameof(Write)} method. The Size written to the disk doesn't match (expected: {expectedSize} != written: {size}) while trying to write file entry {Name}"); + } + } + + /// + /// Reads this entry from a stream. + /// + /// The reader associated with the stream to read from. + protected abstract void Read(ArArchiveFileReader reader); + + /// + /// Performs after-read operation after all the other entries have been loaded. + /// + /// A diagnostic bag + protected virtual void AfterRead(DiagnosticBag diagnostics) { } + + /// + /// Writes this entry to a stream. + /// + /// The writer associated with the stream to write to. + protected abstract void Write(ArArchiveFileWriter writer); + + protected InvalidOperationException CannotModifyProperty(string propertyName) + { + return new InvalidOperationException($"Cannot modify the property {propertyName} for this {GetType()} file entry instance"); + } + + public override string ToString() + { + return $"{this.GetType().Name} [{Index}] `{Name}`"; + } + + public override void Verify(DiagnosticBag diagnostics) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs new file mode 100644 index 00000000000000..4338152e671bdb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs @@ -0,0 +1,84 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Ar +{ + public abstract partial class ArFile + { + /// + /// Size in bytes of an AR file entry + /// + public const int FileEntrySizeInBytes = 60; + + /// + /// Offset of the filename in the entry + /// + public const int FieldNameOffset = 0; + + /// + /// Length in bytes of the filename in the entry + /// + public const int FieldNameLength = 16; + + /// + /// Offset of the timestamp in the entry + /// + public const int FieldTimestampOffset = 16; + + /// + /// Length in bytes of the timestamp in the entry + /// + public const int FieldTimestampLength = 12; + + /// + /// Offset of the owner ID in the entry + /// + public const int FieldOwnerIdOffset = 28; + + /// + /// Length in bytes of the timestamp in the entry + /// + public const int FieldOwnerIdLength = 6; + + /// + /// Offset of the group ID in the entry + /// + public const int FieldGroupIdOffset = 34; + + /// + /// Length in bytes of the timestamp in the entry + /// + public const int FieldGroupIdLength = 6; + + /// + /// Offset of the file mode in the entry + /// + public const int FieldFileModeOffset = 40; + + /// + /// Length in bytes of the timestamp in the entry + /// + public const int FieldFileModeLength = 8; + + /// + /// Offset of the file size in the entry + /// + public const int FieldFileSizeOffset = 48; + + /// + /// Length in bytes of the timestamp in the entry + /// + public const int FieldFileSizeLength = 10; + + /// + /// Offset of the end characters in the entry + /// + public const int FieldEndCharactersOffset = 58; + + /// + /// Length in bytes of the end characters in the entry + /// + public const int FieldEndCharactersLength = 2; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs new file mode 100644 index 00000000000000..c6ef19773bbd6c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs @@ -0,0 +1,148 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Text; + +namespace LibObjectFile.Ar +{ + /// + /// Internal class used for loading long file names for GNU `ar` and Windows `lib` archives. + /// + internal class ArLongNamesTable : ArFile + { + public const string DefaultName = "//"; + + public ArLongNamesTable() + { + } + + public override string Name + { + get => DefaultName; + set => base.Name = value; + } + + public Dictionary FileNames { get; private set; } + + public override bool IsSystem => true; + + protected override void Read(ArArchiveFileReader reader) + { + FileNames = new Dictionary(); + + var buffer = ArrayPool.Shared.Rent((int)Size); + int readCount = reader.Stream.Read(buffer, 0, (int)Size); + int startFileIndex = 0; + for (int i = 0; i < readCount; i++) + { + if (buffer[i] == '\n') + { + var fileNameLength = i - startFileIndex; + if (fileNameLength > 0) + { + // Discard trailing `/` + if (buffer[startFileIndex + fileNameLength - 1] == '/') + { + fileNameLength--; + } + + // TODO: Is it UTF8 or ASCII? + FileNames.Add(startFileIndex, Encoding.UTF8.GetString(buffer, startFileIndex, fileNameLength)); + } + startFileIndex = i + 1; + } + } + ArrayPool.Shared.Return(buffer); + } + + protected override void Write(ArArchiveFileWriter writer) + { + var buffer = ArrayPool.Shared.Rent((int)Size); + uint offset = 0; + for (var i = (int)Index; i < Parent.Files.Count; i++) + { + var file = Parent.Files[i]; + + if (file is ArLongNamesTable) break; + + var fileName = file.Name; + if (fileName == null || fileName.StartsWith("/")) + { + continue; + } + + // byte count + `/` + var fileNameLength = Encoding.UTF8.GetByteCount(fileName) + 1; + if (fileNameLength <= FieldNameLength) + { + file.InternalName = null; + continue; + } + + // Add `\n` + fileNameLength++; + + if (fileNameLength > buffer.Length) + { + ArrayPool.Shared.Return(buffer); + buffer = ArrayPool.Shared.Rent(fileNameLength); + } + + file.InternalName = $"/{offset}"; + + Encoding.UTF8.GetBytes(fileName, 0, fileName.Length, buffer, 0); + buffer[fileNameLength - 2] = (byte)'/'; + buffer[fileNameLength - 1] = (byte)'\n'; + + writer.Write(buffer, 0, fileNameLength); + offset += (uint)fileNameLength; + } + + if ((offset & 1) != 0) + { + writer.Stream.WriteByte((byte)'\n'); + } + ArrayPool.Shared.Return(buffer); + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + Size = 0; + + if (Parent == null) return; + + ulong size = 0; + for (var i = (int)Index; i < Parent.Files.Count; i++) + { + var file = Parent.Files[i]; + if (file is ArLongNamesTable) break; + + if (file.Name == null || file.Name.StartsWith("/")) + { + continue; + } + + var byteCount = Encoding.UTF8.GetByteCount(file.Name); + // byte count + `/` + if (byteCount + 1 > FieldNameLength) + { + // byte count + `/` + `\n` + size += (ulong)byteCount + 2; + } + } + + if ((size & 1) != 0) + { + size++; + } + + // Once it is calculated freeze it + Size = size; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs new file mode 100644 index 00000000000000..33d92f0d80013f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs @@ -0,0 +1,35 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; +using LibObjectFile.Elf; + +namespace LibObjectFile.Ar +{ + public abstract class ArObject : ObjectFileNode + { + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is ArArchiveFile)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(ArArchiveFile)}"); + } + } + + + /// + /// Gets the containing . Might be null if this section or segment + /// does not belong to an existing . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + public new ArArchiveFile Parent + { + get => (ArArchiveFile)base.Parent; + internal set => base.Parent = value; + } + + public abstract void UpdateLayout(DiagnosticBag diagnostics); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs new file mode 100644 index 00000000000000..a5750d9ae722eb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs @@ -0,0 +1,48 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Ar +{ + /// + /// A symbol stored in a + /// + public struct ArSymbol + { + /// + /// Initializes a new instance. + /// + /// The name of the symbol. + /// The associated file entry this symbol is coming from . + public ArSymbol(string name, ArFile file) : this() + { + Name = name; + File = file; + } + + /// + /// Gets or sets the name of this symbol. + /// + public string Name { get; set; } + + /// + /// Internal offset for the name (used for reading) + /// + internal uint NameOffset { get; set; } + + /// + /// Gets or sets the associated file entry this symbol is coming from . + /// + public ArFile File { get; set; } + + /// + /// Internal offset of the file (used for reading) + /// + internal ulong FileOffset { get; set; } + + public override string ToString() + { + return $"Symbol: {Name} => {nameof(File)}: {File}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs new file mode 100644 index 00000000000000..716da0a1bc8614 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs @@ -0,0 +1,242 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; + +namespace LibObjectFile.Ar +{ + /// + /// The symbol table. When used it must be the first entry in . + /// + public sealed class ArSymbolTable : ArFile + { + public const string DefaultBSDSymbolTableName = "__.SYMDEF"; + public const string DefaultGNUSymbolTableName = "/"; + + public ArSymbolTable() + { + Symbols = new List(); + } + + public override string Name + { + get + { + if (Parent == null) return ""; + + return Parent.Kind == ArArchiveKind.BSD ? DefaultBSDSymbolTableName : DefaultGNUSymbolTableName; + } + set => base.Name = value; + } + + public override bool IsSystem => true; + + /// + /// Gets the symbols associated to this table. + /// + public List Symbols { get; } + + protected override void Read(ArArchiveFileReader reader) + { + long startOffset = reader.Stream.Position; + + bool isBSD = reader.ArArchiveFile.Kind == ArArchiveKind.BSD; + + // A 32-bit big endian integer, giving the number of entries in the table. + uint entryCount = reader.Stream.ReadU32(false); + + // A set of 32-bit big endian integers. One for each symbol, recording the position within the archive of the header for the file containing this symbol. + for (uint i = 0; i < entryCount; i++) + { + uint stringOffset = 0; + + if (isBSD) + { + stringOffset = reader.Stream.ReadU32(false); + } + + uint offsetOfFile = reader.Stream.ReadU32(false); + + var symbol = new ArSymbol + { + NameOffset = stringOffset, + FileOffset = offsetOfFile, + }; + Symbols.Add(symbol); + } + + // A set of Zero-terminated strings. Each is a symbol name, and occurs in the same order as the list of positions in part 2. + var startStringTableOffset = isBSD ? reader.Stream.Position : 0; + + for (uint i = 0; i < entryCount; i++) + { + bool hasError = false; + var symbol = Symbols[(int)i]; + + var absoluteStringOffset = startStringTableOffset + symbol.NameOffset; + + if (isBSD && absoluteStringOffset >= startOffset + (long)Size) + { + hasError = true; + } + else + { + // Only BSD requires to position correctly + if (isBSD) + { + reader.Stream.Position = absoluteStringOffset; + } + + var text = reader.ReadStringUTF8NullTerminated(); + symbol.Name = text; + Symbols[(int)i] = symbol; + } + + if (hasError) + { + reader.Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected EOF while trying to read the string name [{i}] at file offset {absoluteStringOffset} in {this}"); + return; + } + } + + var sizeRead = (ulong) (reader.Stream.Position - startOffset); + if ((sizeRead & 1) != 0) + { + if (reader.Stream.ReadByte() >= 0) + { + sizeRead++; + } + } + Debug.Assert(Size == sizeRead); + } + + protected override void AfterRead(DiagnosticBag diagnostics) + { + var offsets = new Dictionary(); + foreach (var fileEntry in Parent.Files) + { + offsets[fileEntry.Offset] = fileEntry; + } + + for (var i = 0; i < Symbols.Count; i++) + { + var symbol = Symbols[i]; + if (offsets.TryGetValue(symbol.FileOffset, out var fileEntry)) + { + symbol.File = fileEntry; + Symbols[i] = symbol; + } + else + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileOffsetInSystemVSymbolLookupTable, $"Unable to find file at offset {symbol.FileOffset} for symbol entry [{i}] in {this}"); + } + } + } + + protected override void Write(ArArchiveFileWriter writer) + { + long startOffset = writer.Stream.Position; + writer.Stream.WriteU32(false, (uint)Symbols.Count); + + uint stringOffset = 0; + bool isBSD = Parent.Kind == ArArchiveKind.BSD; + foreach (var symbol in Symbols) + { + if (isBSD) + { + writer.Stream.WriteU32(false, stringOffset); + } + + writer.Stream.WriteU32(false, (uint)symbol.File.Offset); + + if (isBSD) + { + stringOffset += (uint) Encoding.UTF8.GetByteCount(symbol.Name) + 1; + } + } + + foreach (var symbol in Symbols) + { + writer.WriteStringUTF8NullTerminated(symbol.Name); + } + + var sizeWritten = writer.Stream.Position - startOffset; + if ((sizeWritten & 1) != 0) + { + writer.Stream.WriteByte(0); + sizeWritten++; + } + + // Double check that the size is actually matching what we have been serializing + Debug.Assert(sizeWritten == (long)Size); + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + for (var i = 0; i < Symbols.Count; i++) + { + var symbol = Symbols[i]; + if (string.IsNullOrEmpty(symbol.Name)) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullOrEmptySymbolName, $"Invalid null or empty symbol name [{i}] in {this}"); + } + + if (symbol.File == null) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullFileForSymbol, $"Invalid null file for symbol `{symbol.Name}` [{i}] in {this}"); + } + else if (symbol.File.Parent == null) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullParentFileForSymbol, $"Invalid null Parent for file `{symbol.File}` for symbol `{symbol.Name}` [{i}] in {this}"); + } + else if (symbol.File.Parent != Parent) + { + diagnostics.Error(DiagnosticId.AR_ERR_InvalidParentFileForSymbol, $"Invalid parent for file `{symbol.File}` for symbol `{symbol.Name}` [{i}] in {this}. The parent {nameof(ArArchiveFile)} is not the same instance as this symbol table"); + } + } + } + + public override string ToString() + { + return $"{base.ToString()}, {nameof(Symbols)} Count: {Symbols.Count}"; + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + if (Parent == null) return; + + // number of entries (both for BSD and GNU) + ulong sizeOfTable = sizeof(uint); + + foreach (var symbol in Symbols) + { + if (symbol.Name != null) + { + sizeOfTable += (ulong)Encoding.UTF8.GetByteCount(symbol.Name) + 1; + + // uint file_offset + sizeOfTable += sizeof(uint); + + if (Parent.Kind == ArArchiveKind.BSD) + { + // uint string_offset + sizeOfTable += sizeof(uint); + } + } + } + + if ((sizeOfTable & 1) != 0) + { + sizeOfTable++; + } + + Size = sizeOfTable; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs new file mode 100644 index 00000000000000..75e6ed0b575928 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs @@ -0,0 +1,106 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; + +namespace LibObjectFile +{ + /// + /// A container for used for error reporting while reading/writing object files. + /// + [DebuggerDisplay("Count = {Messages.Count}, HasErrors = {" + nameof(HasErrors) + "}")] + public class DiagnosticBag + { + private readonly List _messages; + + public DiagnosticBag() + { + _messages = new List(); + } + + /// + /// List of messages. + /// + public IReadOnlyList Messages => _messages; + + /// + /// If this instance contains error messages. + /// + public bool HasErrors { get; private set; } + + /// + /// Clear all messages. + /// + public void Clear() + { + _messages.Clear(); + HasErrors = false; + } + + /// + /// Copy all the in this bag to another bag. + /// + /// The diagnostics receiving the copy of the + public void CopyTo(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + foreach (var diagnosticMessage in Messages) + { + diagnostics.Log(diagnosticMessage); + } + } + + /// + /// Logs the specified . + /// + /// The diagnostic message + public void Log(DiagnosticMessage message) + { + if (message.Message == null) throw new InvalidOperationException($"{nameof(DiagnosticMessage)}.{nameof(DiagnosticMessage.Message)} cannot be null"); + _messages.Add(message); + if (message.Kind == DiagnosticKind.Error) + { + HasErrors = true; + } + } + + /// + /// Log an error . + /// + /// The identifier of the diagnostic. + /// The text of the message + /// An optional context + public void Error(DiagnosticId id, string message, object context = null) + { + if (message == null) throw new ArgumentNullException(nameof(message)); + Log(new DiagnosticMessage(DiagnosticKind.Error, id, message, context)); + } + + /// + /// Log an error . + /// + /// The identifier of the diagnostic. + /// The text of the message + /// An optional context + public void Warning(DiagnosticId id, string message, object context = null) + { + if (message == null) throw new ArgumentNullException(nameof(message)); + Log(new DiagnosticMessage(DiagnosticKind.Warning, id, message, context)); + } + + public override string ToString() + { + var builder = new StringBuilder(); + foreach (var diagnosticMessage in Messages) + { + builder.AppendLine(diagnosticMessage.ToString()); + } + + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs new file mode 100644 index 00000000000000..6f2c645577881b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs @@ -0,0 +1,115 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + /// + /// Defines the various diagnostic message ids. + /// + public enum DiagnosticId + { + CMN_ERR_UnexpectedEndOfFile = 1, + + // Elf + ELF_ERR_LinkOrInfoSectionNull = 102, + ELF_ERR_LinkOrInfoInvalidSectionType = 103, + ELF_ERR_LinkOrInfoInvalidSectionInstance = 104, + ELF_ERR_InvalidHeaderFileClassNone = 105, + ELF_ERR_InvalidHeaderIdentLength = 106, + ELF_ERR_InvalidHeaderMagic = 107, + //ELF_ERR_InvalidHeaderFileClass = 8, + //ELF_ERR_InvalidHeaderEncoding = 9, + ELF_ERR_MissingProgramHeaderTableSection = 110, + ELF_ERR_InvalidSectionHeaderCount = 111, + ELF_ERR_IncompleteHeader32Size = 112, + ELF_ERR_IncompleteHeader64Size = 113, + ELF_ERR_InvalidZeroProgramHeaderTableEntrySize = 114, + ELF_ERR_InvalidProgramHeaderStreamOffset = 115, + ELF_ERR_IncompleteProgramHeader32Size = 116, + ELF_ERR_IncompleteProgramHeader64Size = 117, + ELF_ERR_InvalidZeroSectionHeaderTableEntrySize = 118, + ELF_ERR_InvalidSectionHeaderStreamOffset = 119, + ELF_ERR_IncompleteSectionHeader32Size = 120, + ELF_ERR_IncompleteSectionHeader64Size = 121, + ELF_ERR_InvalidResolvedLink = 122, + ELF_ERR_InvalidFirstSectionExpectingUndefined = 123, + ELF_ERR_InvalidStringIndexMissingStringHeaderTable = 124, + ELF_ERR_InvalidStringIndex = 125, + ELF_ERR_InvalidOverlappingSections = 126, + ELF_ERR_InvalidSegmentRange = 127, + ELF_ERR_InvalidSectionSizeKind = 128, + ELF_ERR_InvalidSectionLinkParent = 129, + ELF_ERR_InvalidSectionInfoParent = 130, + ELF_ERR_InvalidSegmentRangeBeginSectionParent = 131, + ELF_ERR_InvalidSegmentRangeEndSectionParent = 132, + ELF_ERR_InvalidSegmentRangeBeginOffset = 133, + ELF_ERR_InvalidSegmentRangeEndOffset = 134, + ELF_ERR_InvalidSegmentRangeIndices = 135, + ELF_ERR_IncompleteRelocationAddendsEntry32Size = 136, + ELF_ERR_IncompleteRelocationEntry32Size = 137, + ELF_ERR_IncompleteRelocationAddendsEntry64Size = 138, + ELF_ERR_IncompleteRelocationEntry64Size = 139, + ELF_WRN_InvalidRelocationTablePrefixName = 140, + ELF_WRN_InvalidRelocationTablePrefixTargetName = 141, + ELF_ERR_InvalidRelocationInfoParent = 142, + ELF_ERR_InvalidRelocationEntryAddend = 143, + ELF_ERR_InvalidRelocationEntryArch = 144, + ELF_ERR_InvalidRelocationSymbolIndex = 145, + ELF_ERR_IncompleteSymbolEntry32Size = 146, + ELF_ERR_IncompleteSymbolEntry64Size = 147, + ELF_ERR_InvalidFirstSymbolEntryNonNull = 148, + ELF_ERR_InvalidSymbolEntryNameIndex = 149, + ELF_ERR_InvalidSymbolEntrySectionParent = 150, + ELF_ERR_InvalidSymbolEntryLocalPosition = 151, + ELF_ERR_IncompleteNoteEntrySize = 152, + ELF_ERR_IncompleNoteGnuAbiTag = 153, + ELF_ERR_InvalidSegmentVirtualAddressOrOffset = 154, + ELF_ERR_InvalidSegmentAlignmentForLoad = 155, + ELF_ERR_InvalidStreamForSectionNoBits = 156, + ELF_ERR_InvalidNullSection = 157, + ELF_ERR_InvalidAlignmentOutOfRange = 158, + + AR_ERR_InvalidMagicLength = 1000, + AR_ERR_MagicNotFound = 1001, + AR_ERR_ExpectingNewLineCharacter = 1002, + //AR_ERR_UnexpectedEndOfFile = 1003, + AR_ERR_InvalidFileEntryLength = 1004, + AR_ERR_InvalidNonPrintableASCIIFoundInFileEntry = 1005, + AR_ERR_InvalidCharacterFoundInFileEntry = 1006, + AR_ERR_InvalidNullFileEntryName = 1007, + AR_ERR_InvalidFileOffsetInSystemVSymbolLookupTable = 1008, + AR_ERR_InvalidDuplicatedFutureHeadersTable = 1009, + AR_ERR_InvalidReferenceToFutureHeadersTable = 1010, + AR_ERR_InvalidFileEntryNameTooLong = 1011, + AR_ERR_InvalidCharacterInFileEntryName = 1012, + AR_ERR_InvalidNullOrEmptySymbolName = 1013, + AR_ERR_InvalidNullFileForSymbol = 1014, + AR_ERR_InvalidNullParentFileForSymbol = 1015, + AR_ERR_InvalidParentFileForSymbol = 1016, + AR_ERR_InvalidFileEntrySize = 1017, + + + DWARF_ERR_AttributeLEB128OutOfRange = 2000, + DWARF_ERR_VersionNotSupported = 2001, + DWARF_ERR_InvalidData = 2002, + DWARF_WRN_UnsupportedLineExtendedCode = 2003, + DWARF_ERR_InvalidReference = 2004, + DWARF_ERR_MissingStringTable = 2005, + DWARF_ERR_InvalidNumberOfStandardOpCodeLengths = 2006, + DWARF_ERR_InvalidStandardOpCodeLength = 2007, + DWARF_WRN_CannotEncodeAddressIncrement = 2008, + DWARF_ERR_InvalidNullFileNameEntry = 2009, + DWARF_ERR_InvalidFileName = 2010, + DWARF_ERR_InvalidMaximumOperationsPerInstruction = 2011, + DWARF_ERR_InvalidNegativeAddressDelta = 2012, + DWARF_ERR_InvalidOperationIndex = 2013, + DWARF_ERR_InvalidAddressSize = 2014, + DWARF_ERR_UnsupportedUnitType = 2015, + DWARF_ERR_InvalidNullUnitForAddressRangeTable = 2016, + DWARF_ERR_InvalidParentUnitForAddressRangeTable = 2017, + DWARF_ERR_InvalidParentForDIE = 2018, + DWARF_WRN_InvalidExtendedOpCodeLength = 2019, + + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs new file mode 100644 index 00000000000000..2ec742585f4a7e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs @@ -0,0 +1,22 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + /// + /// Defines the kind of a + /// + public enum DiagnosticKind + { + /// + /// A warning message. + /// + Warning, + + /// + /// An error message. + /// + Error, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs new file mode 100644 index 00000000000000..52633fde11564a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs @@ -0,0 +1,53 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + /// + /// A diagnostic message. + /// + public readonly struct DiagnosticMessage + { + public DiagnosticMessage(DiagnosticKind kind, DiagnosticId id, string message) + { + Kind = kind; + Id = id; + Context = null; + Message = message; + } + + public DiagnosticMessage(DiagnosticKind kind, DiagnosticId id, string message, object context) + { + Kind = kind; + Id = id; + Context = context; + Message = message; + } + + /// + /// Gets the kind of this message. + /// + public DiagnosticKind Kind { get; } + + /// + /// Gets the id of this message. + /// + public DiagnosticId Id { get; } + + /// + /// Gets the context of this message. + /// + public object Context { get; } + + /// + /// Gets the associated text of this message. + /// + public string Message { get; } + + public override string ToString() + { + return $"{Kind} LB{(uint)Id:0000}: {Message}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs new file mode 100644 index 00000000000000..593b0150581c77 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs @@ -0,0 +1,241 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] + public sealed class DwarfAbbreviation : DwarfObject + { + private readonly List _items; + private readonly Dictionary _mapItems; // Only used if code are non contiguous + private readonly Dictionary _mapKeyToItem; + private ulong _nextCode; + + public DwarfAbbreviation() + { + _items = new List(); + _mapItems = new Dictionary(); + _mapKeyToItem = new Dictionary(); + _nextCode = 1; + } + + public void Reset() + { + // Reset parent dependency + foreach (var dwarfAbbreviationItem in _items) + { + dwarfAbbreviationItem.Parent = null; + } + + if (_mapItems.Count > 0) + { + foreach (var keyPair in _mapItems) + { + keyPair.Value.Parent = null; + } + } + + _items.Clear(); + _mapItems.Clear(); + _mapKeyToItem.Clear(); + _nextCode = 1; + } + + public IEnumerable Items => _mapItems.Count > 0 ? GetMapItems() : _items; + + private IEnumerable GetMapItems() + { + foreach (var item in _mapItems.Values) + { + yield return item; + } + } + + public DwarfAbbreviationItem GetOrCreate(DwarfAbbreviationItemKey itemKey) + { + if (!_mapKeyToItem.TryGetValue(itemKey, out var item)) + { + item = new DwarfAbbreviationItem(_nextCode, itemKey.Tag, itemKey.HasChildren, itemKey.Descriptors) + { + Parent = this + }; + + if (_mapItems.Count > 0) + { + + _mapItems[_nextCode] = item; + } + else + { + _items.Add(item); + } + + _mapKeyToItem[itemKey] = item; + + _nextCode++; + } + + return item; + } + + public bool TryFindByCode(ulong code, out DwarfAbbreviationItem item) + { + item = null; + if (code == 0) + { + return false; + } + + code--; + + if (_mapItems.Count > 0) + { + return _mapItems.TryGetValue(code, out item); + } + + if (code < int.MaxValue && (int)code < _items.Count) + { + item = _items[(int) code]; + return true; + } + + item = null; + return false; + } + + private string DebuggerDisplay => $"Count = {(_mapItems.Count > 0 ? _mapItems.Count : _items.Count)}"; + + private bool TryReadNext(DwarfReader reader) + { + var startOffset = (ulong)reader.Offset; + var code = reader.ReadULEB128(); + if (code == 0) + { + return false; + } + + var item = new DwarfAbbreviationItem + { + Offset = startOffset, + Code = code + }; + + var index = code - 1; + bool canAddToList = _mapItems.Count == 0 && index < int.MaxValue && _items.Count == (int)index; + + item.ReadInternal(reader); + + if (canAddToList) + { + _items.Add(item); + _nextCode++; + } + else + { + if (_mapItems.Count == 0) + { + for (var i = 0; i < _items.Count; i++) + { + var previousItem = _items[i]; + _mapItems.Add((ulong)i + 1, previousItem); + } + _items.Clear(); + } + + // TODO: check collisions + if (_mapItems.ContainsKey(code)) + { + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"Invalid code {code} found while another code already exists in this abbreviation."); + return false; + } + _mapItems.Add(code, item); + + _nextCode = Math.Max(code, _nextCode) + 1; + } + + var key = new DwarfAbbreviationItemKey(item.Tag, item.HasChildren, item.Descriptors); + _mapKeyToItem.Add(key, item); + + return true; + } + + protected override void Read(DwarfReader reader) + { + Offset = reader.Offset; + while (TryReadNext(reader)) + { + } + + Size = (ulong)reader.Offset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + Debug.Assert(startOffset == Offset); + if (_mapItems.Count > 0) + { + foreach (var itemPair in _mapItems) + { + var item = itemPair.Value; + item.WriteInternal(writer); + } + + } + else + { + if (_items.Count > 0) + { + foreach (var item in _items) + { + item.WriteInternal(writer); + } + } + } + + // End of abbreviation item + writer.WriteULEB128(0); + + Debug.Assert(writer.Offset - startOffset == Size); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var endOffset = Offset; + + if (_mapItems.Count > 0) + { + foreach (var itemPair in _mapItems) + { + var item = itemPair.Value; + item.Offset = endOffset; + item.UpdateLayoutInternal(layoutContext); + endOffset += item.Size; + } + + } + else + { + if (_items.Count > 0) + { + foreach (var item in _items) + { + item.Offset = endOffset; + item.UpdateLayoutInternal(layoutContext); + endOffset += item.Size; + } + } + } + + endOffset += DwarfHelper.SizeOfULEB128(0); + + Size = endOffset - Offset; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs new file mode 100644 index 00000000000000..32d1df7e121946 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs @@ -0,0 +1,125 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfAbbreviationItem : DwarfObject + { + internal DwarfAbbreviationItem() + { + } + + internal DwarfAbbreviationItem(ulong code, DwarfTagEx tag, bool hasChildren, DwarfAttributeDescriptors descriptors) + { + Code = code; + Tag = tag; + HasChildren = hasChildren; + Descriptors = descriptors; + } + + public ulong Code { get; internal set; } + + public DwarfTagEx Tag { get; private set; } + + public bool HasChildren { get; private set; } + + public DwarfAttributeDescriptors Descriptors { get; private set; } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var endOffset = Offset; + + // Code + endOffset += DwarfHelper.SizeOfULEB128(Code); + + // Tag + endOffset += DwarfHelper.SizeOfULEB128((uint)Tag.Value); + + // HasChildren + endOffset += 1; + + var descriptors = Descriptors; + for (int i = 0; i < descriptors.Length; i++) + { + var descriptor = descriptors[i]; + endOffset += DwarfHelper.SizeOfULEB128((uint)descriptor.Kind.Value); + endOffset += DwarfHelper.SizeOfULEB128((uint)descriptor.Form.Value); + } + + // Null Kind and Form + endOffset += DwarfHelper.SizeOfULEB128(0) * 2; + + Size = endOffset - Offset; + } + + protected override void Read(DwarfReader reader) + { + var itemTag = new DwarfTagEx(reader.ReadULEB128AsU32()); + Tag = itemTag; + var hasChildrenRaw = reader.ReadU8(); + bool hasChildren = false; + if (hasChildrenRaw == DwarfNative.DW_CHILDREN_yes) + { + hasChildren = true; + } + else if (hasChildrenRaw != DwarfNative.DW_CHILDREN_no) + { + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"Invalid children {hasChildrenRaw}. Must be either {DwarfNative.DW_CHILDREN_yes} or {DwarfNative.DW_CHILDREN_no}"); + return; + } + + HasChildren = hasChildren; + + List descriptors = null; + + while (true) + { + var attributeName = new DwarfAttributeKindEx(reader.ReadULEB128AsU32()); + var attributeForm = new DwarfAttributeFormEx(reader.ReadULEB128AsU32()); + + if (attributeForm.Value == 0 && attributeForm.Value == 0) + { + break; + } + + if (descriptors == null) descriptors = new List(1); + descriptors.Add(new DwarfAttributeDescriptor(attributeName, attributeForm)); + } + + Descriptors = descriptors != null ? new DwarfAttributeDescriptors(descriptors.ToArray()) : new DwarfAttributeDescriptors(); + + Size = reader.Offset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + Debug.Assert(startOffset == Offset); + + // Code + writer.WriteULEB128(Code); + + // Tag + writer.WriteULEB128((uint)Tag.Value); + + // HasChildren + writer.WriteU8(HasChildren ? DwarfNative.DW_CHILDREN_yes : DwarfNative.DW_CHILDREN_no); + + var descriptors = Descriptors; + for (int i = 0; i < descriptors.Length; i++) + { + var descriptor = descriptors[i]; + writer.WriteULEB128((uint)descriptor.Kind.Value); + writer.WriteULEB128((uint)descriptor.Form.Value); + } + writer.WriteULEB128(0); + writer.WriteULEB128(0); + + Debug.Assert(writer.Offset - startOffset == Size); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs new file mode 100644 index 00000000000000..a94024abbc4814 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs @@ -0,0 +1,61 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public readonly struct DwarfAbbreviationItemKey : IEquatable + { + public DwarfAbbreviationItemKey(DwarfTagEx tag, bool hasChildren, DwarfAttributeDescriptors descriptors) + { + Tag = tag; + HasChildren = hasChildren; + Descriptors = descriptors; + } + + + public readonly DwarfTagEx Tag; + + public readonly bool HasChildren; + + public readonly DwarfAttributeDescriptors Descriptors; + + public bool Equals(DwarfAbbreviationItemKey other) + { + return Tag == other.Tag && HasChildren == other.HasChildren && Descriptors.Equals(other.Descriptors); + } + + public override bool Equals(object obj) + { + return obj is DwarfAbbreviationItemKey other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Tag.GetHashCode(); + hashCode = (hashCode * 397) ^ HasChildren.GetHashCode(); + hashCode = (hashCode * 397) ^ Descriptors.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(DwarfAbbreviationItemKey left, DwarfAbbreviationItemKey right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfAbbreviationItemKey left, DwarfAbbreviationItemKey right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return $"{nameof(Tag)}: {Tag}, {nameof(HasChildren)}: {HasChildren}, {nameof(Descriptors)}: {Descriptors}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs new file mode 100644 index 00000000000000..dc607b201fcfcd --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs @@ -0,0 +1,86 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public class DwarfAbbreviationTable : DwarfSection + { + private readonly List _abbreviations; + + public DwarfAbbreviationTable() + { + _abbreviations = new List(); + } + + public IReadOnlyList Abbreviations => _abbreviations; + + internal void AddAbbreviation(DwarfAbbreviation abbreviation) + { + _abbreviations.Add(this, abbreviation); + } + + internal void RemoveAbbreviation(DwarfAbbreviation abbreviation) + { + _abbreviations.Remove(this, abbreviation); + } + + internal DwarfAbbreviation RemoveAbbreviationAt(int index) + { + return _abbreviations.RemoveAt(this, index); + } + + internal void Reset() + { + foreach(var abbreviation in _abbreviations) + { + abbreviation.Reset(); + } + _abbreviations.Clear(); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + ulong endOffset = Offset; + foreach (var abbreviation in _abbreviations) + { + abbreviation.Offset = endOffset; + abbreviation.UpdateLayoutInternal(layoutContext); + endOffset += abbreviation.Size; + } + + Size = endOffset - Offset; + } + + protected override void Read(DwarfReader reader) + { + var endOffset = reader.Offset; + while (reader.Offset < reader.Length) + { + var abbreviation = new DwarfAbbreviation + { + Offset = endOffset + }; + abbreviation.ReadInternal(reader); + endOffset += abbreviation.Size; + AddAbbreviation(abbreviation); + } + + Size = endOffset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + foreach (var abbreviation in _abbreviations) + { + abbreviation.WriteInternal(writer); + } + + Debug.Assert(writer.Offset - startOffset == Size); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs new file mode 100644 index 00000000000000..67f3271f9e0d6f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs @@ -0,0 +1,15 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfAccessibility : byte + { + Public = DwarfNative.DW_ACCESS_public, + + Private = DwarfNative.DW_ACCESS_private, + + Protected = DwarfNative.DW_ACCESS_protected, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs new file mode 100644 index 00000000000000..6a9e9d12bc9ba5 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs @@ -0,0 +1,27 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public struct DwarfAddressRange + { + public DwarfAddressRange(ulong segment, ulong address, ulong length) + { + Segment = segment; + Address = address; + Length = length; + } + + public ulong Segment { get; set; } + + public ulong Address { get; set; } + + public ulong Length { get; set; } + + public override string ToString() + { + return $"{nameof(Segment)}: 0x{Segment:x16}, {nameof(Address)}: 0x{Address:x16}, {nameof(Length)}: 0x{Length:x16}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs new file mode 100644 index 00000000000000..8bc3a3d22771cf --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs @@ -0,0 +1,277 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using LibObjectFile.Utils; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("Count = {Ranges.Count,nq}")] + public class DwarfAddressRangeTable : DwarfRelocatableSection + { + public DwarfAddressRangeTable() + { + Ranges = new List(); + Version = 2; + } + + public ushort Version { get; set; } + + public bool Is64BitEncoding { get; set; } + + public DwarfAddressSize AddressSize { get; set; } + + public DwarfAddressSize SegmentSelectorSize { get; set; } + + public ulong DebugInfoOffset { get; private set; } + + public DwarfUnit Unit { get; set; } + + public List Ranges { get; } + + public ulong HeaderLength => Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding); + + protected override void Read(DwarfReader reader) + { + Offset = reader.Offset; + var unitLength = reader.ReadUnitLength(); + Is64BitEncoding = reader.Is64BitEncoding; + Version = reader.ReadU16(); + + if (Version != 2) + { + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version {Version} for .debug_aranges not supported"); + return; + } + + DebugInfoOffset = reader.ReadUIntFromEncoding(); + + AddressSize = reader.ReadAddressSize(); + + var segment_selector_size = (DwarfAddressSize)reader.ReadU8(); + SegmentSelectorSize = segment_selector_size; + + var align = (ulong)segment_selector_size + (ulong)AddressSize * 2; + + // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple + reader.Offset = AlignHelper.AlignToUpper(reader.Offset, align); + + while (true) + { + ulong segment = 0; + switch (segment_selector_size) + { + case DwarfAddressSize.Bit8: + segment = reader.ReadU8(); + break; + + case DwarfAddressSize.Bit16: + segment = reader.ReadU16(); + break; + + case DwarfAddressSize.Bit32: + segment = reader.ReadU32(); + break; + + case DwarfAddressSize.Bit64: + segment = reader.ReadU64(); + break; + + case DwarfAddressSize.None: + break; + } + + ulong address = 0; + ulong length = 0; + switch (AddressSize) + { + case DwarfAddressSize.Bit8: + address = reader.ReadU8(); + length = reader.ReadU8(); + break; + case DwarfAddressSize.Bit16: + address = reader.ReadU16(); + length = reader.ReadU16(); + break; + case DwarfAddressSize.Bit32: + address = reader.ReadU32(); + length = reader.ReadU32(); + break; + case DwarfAddressSize.Bit64: + address = reader.ReadU64(); + length = reader.ReadU64(); + break; + } + + if (segment == 0 && address == 0 && length == 0) + { + break; + } + + Ranges.Add(new DwarfAddressRange(segment, address, length)); + } + + Size = reader.Offset - Offset; + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + if (Version != 2) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Non supported version {Version} for .debug_aranges"); + } + + if (Unit == null) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNullUnitForAddressRangeTable, $"Invalid {nameof(Unit)} for .debug_aranges that cannot be null"); + } + else + { + var parentFile = Unit.GetParentFile(); + if (this.Parent != parentFile) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentUnitForAddressRangeTable, $"Invalid parent {nameof(DwarfFile)} of {nameof(Unit)} for .debug_aranges that doesn't match the parent of instance"); + } + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + ulong sizeOf = 0; + // unit_length + sizeOf += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); + + // version + sizeOf += 2; + + // debug_info_offset + sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); + + // Address size + sizeOf += 1; + + // segment selector size + sizeOf += 1; + + var align = (ulong)SegmentSelectorSize + (ulong)AddressSize * 2; + + // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple + sizeOf = AlignHelper.AlignToUpper(sizeOf, align); + + // SizeOf ranges + 1 (for last 0 entry) + sizeOf += ((ulong)Ranges.Count + 1UL) * align; + + Size = sizeOf; + + if (Unit != null) + { + DebugInfoOffset = Unit.Offset; + } + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + + // unit_length + writer.WriteUnitLength(Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding)); + + // version + writer.WriteU16(Version); + + // debug_info_offset + var debugInfoOffset = DebugInfoOffset; + if (writer.EnableRelocation) + { + writer.RecordRelocation(DwarfRelocationTarget.DebugInfo, writer.SizeOfUIntEncoding(), debugInfoOffset); + debugInfoOffset = 0; + } + writer.WriteUIntFromEncoding(debugInfoOffset); + + // address_size + writer.AddressSize = AddressSize; + writer.WriteU8((byte)AddressSize); + + writer.WriteU8((byte)SegmentSelectorSize); + + var align = (ulong)SegmentSelectorSize + (ulong)AddressSize * 2; + + // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple + var nextOffset = AlignHelper.AlignToUpper(writer.Offset, align); + for (ulong offset = writer.Offset; offset < nextOffset; offset++) + { + writer.WriteU8(0); + } + Debug.Assert(writer.Offset == nextOffset); + + foreach (var range in Ranges) + { + if (SegmentSelectorSize != 0) + { + switch (SegmentSelectorSize) + { + case DwarfAddressSize.Bit8: + writer.WriteU8((byte)range.Segment); + break; + case DwarfAddressSize.Bit16: + writer.WriteU16((ushort)range.Segment); + break; + case DwarfAddressSize.Bit32: + writer.WriteU32((uint)range.Segment); + break; + case DwarfAddressSize.Bit64: + writer.WriteU64((ulong)range.Segment); + break; + } + } + + writer.WriteAddress(DwarfRelocationTarget.Code, range.Address); + writer.WriteUInt(range.Length); + } + + if (SegmentSelectorSize != 0) + { + switch (SegmentSelectorSize) + { + case DwarfAddressSize.Bit8: + writer.WriteU8(0); + break; + case DwarfAddressSize.Bit16: + writer.WriteU16(0); + break; + case DwarfAddressSize.Bit32: + writer.WriteU32(0); + break; + case DwarfAddressSize.Bit64: + writer.WriteU64(0); + break; + } + } + + switch (AddressSize) + { + case DwarfAddressSize.Bit8: + writer.WriteU16(0); + break; + case DwarfAddressSize.Bit16: + writer.WriteU32(0); + break; + case DwarfAddressSize.Bit32: + writer.WriteU64(0); + break; + case DwarfAddressSize.Bit64: + writer.WriteU64(0); + writer.WriteU64(0); + break; + } + + Debug.Assert(writer.Offset - startOffset == Size); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs new file mode 100644 index 00000000000000..c2f072e8c30064 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs @@ -0,0 +1,19 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfAddressSize : byte + { + None = 0, + + Bit8 = 1, + + Bit16 = 2, + + Bit32 = 4, + + Bit64 = 8, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs new file mode 100644 index 00000000000000..8464d0c6d521c0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs @@ -0,0 +1,13 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfArrayOrderingKind : byte + { + RowMajor = DwarfNative.DW_ORD_row_major, + + ColumnMajor = DwarfNative.DW_ORD_col_major, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs new file mode 100644 index 00000000000000..7ccaaccb185001 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs @@ -0,0 +1,991 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfAttribute : DwarfObject, IComparable + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private ulong _valueAsU64; + + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private object _valueAsObject; + + public DwarfAttributeKindEx Kind { get; set; } + + public bool ValueAsBoolean + { + get => _valueAsU64 != 0; + set => _valueAsU64 = value ? 1U : 0; + } + + public int ValueAsI32 + { + get => (int)_valueAsU64; + set => _valueAsU64 = (ulong)(long)value; + } + + public uint ValueAsU32 + { + get => (uint)_valueAsU64; + set => _valueAsU64 = value; + } + + public long ValueAsI64 + { + get => (long)_valueAsU64; + set => _valueAsU64 = (ulong)value; + } + + public ulong ValueAsU64 + { + get => _valueAsU64; + set => _valueAsU64 = value; + } + + /// + /// Gets or sets the encoding used for this attribute. Default is null meaning that the encoding + /// is detected automatically. Some attributes may require to explicitly set this encoding to disambiguate + /// between different encoding form (e.g boolean => instead of ) + /// + public DwarfAttributeEncoding? Encoding { get; set; } + + public DwarfAttributeFormEx Form { get; internal set; } + + public object ValueAsObject + { + get => _valueAsObject; + set + { + if (_valueAsObject is DwarfExpression oldExpression) + { + oldExpression.Parent = null; + } + _valueAsObject = value; + + if (value is DwarfExpression newExpression) + { + if (newExpression.Parent != null) throw new InvalidOperationException($"Cannot set the {newExpression.GetType()} as it already belongs to another {newExpression.Parent.GetType()} instance"); + newExpression.Parent = this; + } + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + // Check DwarfDIE reference + if (ValueAsObject is DwarfDIE attrDIE) + { + var thisSection = this.GetParentSection(); + var attrSection = attrDIE.GetParentSection(); + + if (thisSection != attrSection) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForDIE, $"Invalid parent for the DIE {attrDIE} referenced by the attribute {this}. It must be within the same parent {attrSection.GetType()}."); + } + } + else if (ValueAsObject is DwarfExpression expr) + { + expr.Verify(diagnostics); + } + } + + public int CompareTo(DwarfAttribute other) + { + return ((uint)Kind).CompareTo((uint)other.Kind); + } + + public override string ToString() + { + if (ValueAsObject != null) + { + return ValueAsU64 != 0 ? $"{nameof(Kind)}: {Kind}, Value: {ValueAsObject} Offset: {ValueAsU64}" : $"{nameof(Kind)}: {Kind}, Value: {ValueAsObject}"; + } + else + { + return $"{nameof(Kind)}: {Kind}, Value: {ValueAsU64}"; + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var addressSize = layoutContext.CurrentUnit.AddressSize; + var is64BitEncoding = layoutContext.CurrentUnit.Is64BitEncoding; + + var endOffset = Offset; + switch (Form.Value) + { + case DwarfAttributeForm.Addr: + endOffset += DwarfHelper.SizeOfUInt(addressSize); // WriteUInt(ValueAsU64); + break; + case DwarfAttributeForm.Data1: + endOffset += 1; // WriteU8((byte)ValueAsU64); + break; + case DwarfAttributeForm.Data2: + endOffset += 2; // WriteU16((ushort)ValueAsU64); + break; + case DwarfAttributeForm.Data4: + endOffset += 4; // WriteU32((uint)ValueAsU64); + break; + case DwarfAttributeForm.Data8: + endOffset += 8; // WriteU64(ValueAsU64); + break; + case DwarfAttributeForm.String: + endOffset += DwarfHelper.SizeOfStringUTF8NullTerminated((string)ValueAsObject); + break; + case DwarfAttributeForm.Block: + { + var stream = (Stream)ValueAsObject; + endOffset += DwarfHelper.SizeOfULEB128((ulong)stream.Length); + endOffset += (ulong)stream.Length; + break; + } + case DwarfAttributeForm.Block1: + { + var stream = (Stream)ValueAsObject; + endOffset += 1; + endOffset += (ulong)stream.Length; + break; + } + case DwarfAttributeForm.Block2: + { + var stream = (Stream)ValueAsObject; + endOffset += 2; + endOffset += (ulong)stream.Length; + break; + } + case DwarfAttributeForm.Block4: + { + var stream = (Stream)ValueAsObject; + endOffset += 4; + endOffset += (ulong)stream.Length; + break; + } + case DwarfAttributeForm.Flag: + endOffset += 1; // WriteU8((byte)(ValueAsU64 != 0 ? 1 : 0)); + break; + case DwarfAttributeForm.Sdata: + endOffset += DwarfHelper.SizeOfILEB128(ValueAsI64); // WriteILEB128(ValueAsI64); + break; + case DwarfAttributeForm.Strp: + endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); // WriteUIntFromEncoding(offset); + break; + case DwarfAttributeForm.Udata: + endOffset += DwarfHelper.SizeOfULEB128(ValueAsU64); // ReadULEB128(); + break; + case DwarfAttributeForm.RefAddr: + endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); // WriteUIntFromEncoding(dieRef.Offset); + break; + case DwarfAttributeForm.Ref1: + endOffset += 1; // WriteU8((byte)(dieRef.Offset - _currentUnit.Offset)); + break; + case DwarfAttributeForm.Ref2: + endOffset += 2; // WriteU16((ushort)(dieRef.Offset - _currentUnit.Offset)); + break; + case DwarfAttributeForm.Ref4: + endOffset += 4; // WriteU32((uint)(dieRef.Offset - _currentUnit.Offset)); + break; + case DwarfAttributeForm.Ref8: + endOffset += 8; // WriteU64((dieRef.Offset - _currentUnit.Offset)); + break; + case DwarfAttributeForm.RefUdata: + { + var dieRef = (DwarfDIE)ValueAsObject; + endOffset += DwarfHelper.SizeOfULEB128(dieRef.Offset - layoutContext.CurrentUnit.Offset); // WriteULEB128((dieRef.Offset - _currentUnit.Offset)); + break; + } + + //case DwarfAttributeForm.indirect: + //{ + // attributeForm = ReadLEB128As(); + // goto indirect; + //} + + // addptr + // lineptr + // loclist + // loclistptr + // macptr + // rnglist + // rngrlistptr + // stroffsetsptr + case DwarfAttributeForm.SecOffset: + endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); + break; + + case DwarfAttributeForm.Exprloc: + var expr = (DwarfExpression)ValueAsObject; + expr.Offset = endOffset; + expr.UpdateLayoutInternal(layoutContext); + endOffset += expr.Size; + break; + + case DwarfAttributeForm.FlagPresent: + break; + + case DwarfAttributeForm.RefSig8: + endOffset += 8; // WriteU64(ValueAsU64); + break; + + case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); + case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); + case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); + case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); + case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); + case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); + case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); + case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); + case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); + case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); + case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); + case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); + case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); + case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); + case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); + case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); + case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); + case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); + case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); + case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); + case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); + case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); + default: + throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {Form}"); + } + + Size = endOffset - Offset; + } + + protected override void Read(DwarfReader reader) + { + var descriptor = reader.CurrentAttributeDescriptor; + + Kind = descriptor.Kind; + Form = descriptor.Form; + + ReadAttributeFormRawValue(reader); + + Size = reader.Offset - Offset; + + ResolveAttributeValue(reader); + } + + private void ResolveAttributeValue(DwarfReader reader) + { + switch (Kind.Value) + { + case DwarfAttributeKind.DeclFile: + { + var currentLineProgramTable = reader.CurrentLineProgramTable; + if (currentLineProgramTable == null) + { + // Log and error + } + else + { + var file = currentLineProgramTable.FileNames[ValueAsI32 - 1]; + ValueAsU64 = 0; + ValueAsObject = file; + } + break; + } + + case DwarfAttributeKind.StmtList: + { + if (ValueAsU64 == 0) return; + + if (reader.File.LineSection != null) + { + if (reader.OffsetToLineProgramTable.TryGetValue(ValueAsU64, out var lineProgramTable)) + { + ValueAsU64 = 0; + ValueAsObject = lineProgramTable; + reader.PushLineProgramTable(lineProgramTable); + } + else + { + // Log and error + } + } + else + { + + // Log an error + } + + break; + + } + + case DwarfAttributeKind.Location: + { + if (Form == DwarfAttributeFormEx.SecOffset) + { + if (reader.OffsetToLocationList.TryGetValue(ValueAsU64, out var locationList)) + { + ValueAsU64 = 0; + ValueAsObject = locationList; + } + else + { + // Log and error + } + } + break; + } + } + } + + + private void ReadAttributeFormRawValue(DwarfReader reader) + { + var attributeForm = Form; + + indirect: + switch (attributeForm.Value) + { + case DwarfAttributeForm.Addr: + { + ValueAsU64 = reader.ReadUInt(); + break; + } + + case DwarfAttributeForm.Data1: + { + ValueAsU64 = reader.ReadU8(); + break; + } + case DwarfAttributeForm.Data2: + { + ValueAsU64 = reader.ReadU16(); + break; + } + case DwarfAttributeForm.Data4: + { + ValueAsU64 = reader.ReadU32(); + break; + } + case DwarfAttributeForm.Data8: + { + ValueAsU64 = reader.ReadU64(); + break; + } + + case DwarfAttributeForm.String: + { + ValueAsObject = reader.ReadStringUTF8NullTerminated(); + break; + } + + case DwarfAttributeForm.Block: + { + var length = reader.ReadULEB128(); + ValueAsObject = reader.ReadAsStream(length); + break; + } + case DwarfAttributeForm.Block1: + { + var length = reader.ReadU8(); + ValueAsObject = reader.ReadAsStream(length); + break; + } + case DwarfAttributeForm.Block2: + { + var length = reader.ReadU16(); + ValueAsObject = reader.ReadAsStream(length); + break; + } + case DwarfAttributeForm.Block4: + { + var length = reader.ReadU32(); + ValueAsObject = reader.ReadAsStream(length); + break; + } + + case DwarfAttributeForm.Flag: + { + ValueAsBoolean = reader.ReadU8() != 0; + break; + } + case DwarfAttributeForm.Sdata: + { + ValueAsI64 = reader.ReadILEB128(); + break; + } + case DwarfAttributeForm.Strp: + { + var offset = reader.ReadUIntFromEncoding(); + ValueAsObject = reader.File.StringTable.GetStringFromOffset(offset); + break; + } + case DwarfAttributeForm.Udata: + { + ValueAsU64 = reader.ReadULEB128(); + break; + } + case DwarfAttributeForm.RefAddr: + { + ValueAsU64 = reader.ReadUIntFromEncoding(); + reader.ResolveAttributeReferenceWithinSection(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.Ref1: + { + ValueAsU64 = reader.ReadU8(); + reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.Ref2: + { + ValueAsU64 = reader.ReadU16(); + reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.Ref4: + { + ValueAsU64 = reader.ReadU32(); + reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.Ref8: + { + ValueAsU64 = reader.ReadU64(); + reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.RefUdata: + { + ValueAsU64 = reader.ReadULEB128(); + reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); + break; + } + case DwarfAttributeForm.Indirect: + { + attributeForm = new DwarfAttributeFormEx(reader.ReadULEB128AsU32()); + goto indirect; + } + + // addptr + // lineptr + // loclist + // loclistptr + // macptr + // rnglist + // rngrlistptr + // stroffsetsptr + case DwarfAttributeForm.SecOffset: + { + ValueAsU64 = reader.ReadUIntFromEncoding(); + //Console.WriteLine($"attribute {Key} offset: {ValueAsU64}"); + break; + } + + case DwarfAttributeForm.Exprloc: + { + var expression = new DwarfExpression(); + expression.ReadInternal(reader); + ValueAsObject = expression; + break; + } + + case DwarfAttributeForm.FlagPresent: + { + ValueAsBoolean = true; + break; + } + + case DwarfAttributeForm.RefSig8: + { + var offset = reader.ReadU64(); + ValueAsU64 = offset; + break; + } + + case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); + case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); + case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); + case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); + case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); + case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); + case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); + case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); + case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); + case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); + case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); + case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); + case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); + case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); + case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); + case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); + case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); + case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); + case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); + case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); + case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); + case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); + default: + throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {attributeForm.Value}"); + } + } + + internal void UpdateAttributeForm(DwarfLayoutContext context) + { + Form = ComputeAttributeForm(context); + } + + private DwarfAttributeForm ComputeAttributeForm(DwarfLayoutContext context) + { + var key = Kind; + var encoding = DwarfHelper.GetAttributeEncoding(key); + + if (encoding == DwarfAttributeEncoding.None) + { + switch (Kind.Value) + { + case DwarfAttributeKind.GNUAllCallSites: + case DwarfAttributeKind.GNUAllTailCallSites: + encoding = DwarfAttributeEncoding.Flag; + break; + case DwarfAttributeKind.GNUCallSiteTarget: + case DwarfAttributeKind.GNUCallSiteValue: + encoding = DwarfAttributeEncoding.ExpressionLocation | DwarfAttributeEncoding.LocationList; + break; + + default: + // TODO: Add pluggable support for requesting attribute encoding here + throw new InvalidOperationException($"Unsupported attribute {this} with unknown encoding"); + } + } + + // If the attribute has a requested encoding + if (Encoding.HasValue) + { + var requestedEncoding = Encoding.Value; + if ((encoding & requestedEncoding) == 0) + { + throw new InvalidOperationException($"Requested encoding {requestedEncoding} for {this} doesn't match supported encoding {encoding} for this attribute"); + } + + // Replace encoding with requested encoding + encoding = requestedEncoding; + } + + // Do we still have a complex encoding? + if ((((uint)encoding) & ((uint)encoding - 1)) != 0U) + { + // if we have, try to detect which one we should select + if (ValueAsObject is DwarfDIE) + { + if ((encoding & DwarfAttributeEncoding.Reference) == 0) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The DIE value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Reference."); + } + + encoding = DwarfAttributeEncoding.Reference; + } + else if (this.ValueAsObject is Stream) + { + if ((encoding & DwarfAttributeEncoding.Block) == 0) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The Stream value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Block."); + } + + encoding = DwarfAttributeEncoding.Block; + } + else if (this.ValueAsObject is string) + { + if ((encoding & DwarfAttributeEncoding.String) == 0) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The string value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting String."); + } + + encoding = DwarfAttributeEncoding.String; + } + else if (this.ValueAsObject is DwarfExpression) + { + if ((encoding & DwarfAttributeEncoding.ExpressionLocation) == 0) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The expression value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting ExpressionLocation."); + } + + encoding = DwarfAttributeEncoding.ExpressionLocation; + } + else if (this.ValueAsObject is DwarfLocationList) + { + if ((encoding & DwarfAttributeEncoding.LocationList) == 0) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The expression value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting LocationList."); + } + + encoding = DwarfAttributeEncoding.LocationList; + } + else if ((encoding & DwarfAttributeEncoding.Address) != 0) + { + if (this.ValueAsObject != null) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The {this.ValueAsObject.GetType()} value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Address."); + } + + // If not specified explicitly, We consider HighPC as a constant (delta from LowPC) + if (this.Kind == DwarfAttributeKindEx.HighPC) + { + encoding = DwarfAttributeEncoding.Constant; + } + else + { + encoding = DwarfAttributeEncoding.Address; + } + } + else if ((encoding & DwarfAttributeEncoding.Constant) != 0) + { + if (this.ValueAsObject != null) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The {this.ValueAsObject.GetType()} value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Constant."); + } + + encoding = DwarfAttributeEncoding.Constant; + } + } + + switch (encoding) + { + case DwarfAttributeEncoding.Address: + return DwarfAttributeForm.Addr; + + case DwarfAttributeEncoding.Block: + VerifyAttributeValueNotNull(context); + + if (!(this.ValueAsObject is Stream)) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a System.IO.Stream"); + } + + return DwarfAttributeForm.Block; + + case DwarfAttributeEncoding.Constant: + + if (this.ValueAsU64 <= byte.MaxValue) + { + return DwarfAttributeForm.Data1; + } + + if (this.ValueAsU64 <= ushort.MaxValue) + { + return DwarfAttributeForm.Data2; + } + + if (this.ValueAsU64 <= uint.MaxValue) + { + return DwarfAttributeForm.Data4; + } + + return DwarfAttributeForm.Data8; + + case DwarfAttributeEncoding.ExpressionLocation: + VerifyAttributeValueNotNull(context); + + if (!(this.ValueAsObject is DwarfExpression)) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfExpression)}"); + } + + return DwarfAttributeForm.Exprloc; + + case DwarfAttributeEncoding.Flag: + return this.ValueAsBoolean ? DwarfAttributeForm.FlagPresent : DwarfAttributeForm.Flag; + + case DwarfAttributeEncoding.LinePointer: + bool canHaveNull = this.Kind.Value == DwarfAttributeKind.StmtList; + if (!canHaveNull) + { + VerifyAttributeValueNotNull(context); + + if (!(this.ValueAsObject is DwarfLine)) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfLine)}"); + } + } + + return DwarfAttributeForm.SecOffset; + + + case DwarfAttributeEncoding.Reference: + VerifyAttributeValueNotNull(context); + + if (this.ValueAsObject is DwarfDIE die) + { + var dieParentUnit = die.GetParentUnit(); + // If we are not from the same unit + if (dieParentUnit != context.CurrentUnit) + { + return DwarfAttributeForm.RefAddr; + } + } + else + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfDIE)}"); + } + + return context.Config.DefaultAttributeFormForReference; + + case DwarfAttributeEncoding.String: + VerifyAttributeValueNotNull(context); + + if (this.ValueAsObject is string str) + { + // Create string offset + if (context.File.StringTable.Contains(str)) + { + return DwarfAttributeForm.Strp; + } + } + else + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a string."); + } + + return DwarfAttributeForm.String; + + case DwarfAttributeEncoding.RangeList: + case DwarfAttributeEncoding.LocationList: + case DwarfAttributeEncoding.Indirect: + case DwarfAttributeEncoding.AddressPointer: + case DwarfAttributeEncoding.LocationListsPointer: + case DwarfAttributeEncoding.RangeListsPointer: + case DwarfAttributeEncoding.StringOffsetPointer: + case DwarfAttributeEncoding.LocationListPointer: + case DwarfAttributeEncoding.MacroPointer: + case DwarfAttributeEncoding.RangeListPointer: + return DwarfAttributeForm.SecOffset; + } + + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The encoding {encoding} of attribute {this} from DIE {this.Parent} is not supported."); + return DwarfAttributeForm.Data8; + } + + private void VerifyAttributeValueNotNull(DwarfLayoutContext context) + { + if (ValueAsObject == null) + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object value of attribute {this} from DIE {this.Parent} cannot be null"); + } + } + + protected override void Write(DwarfWriter writer) + { + var startAttributeOffset = Offset; + Debug.Assert(Offset == startAttributeOffset); + + switch (Form.Value) + { + case DwarfAttributeForm.Addr: + { + writer.WriteAddress(DwarfRelocationTarget.Code, ValueAsU64); + break; + } + case DwarfAttributeForm.Data1: + { + writer.WriteU8((byte) ValueAsU64); + break; + } + case DwarfAttributeForm.Data2: + { + writer.WriteU16((ushort) ValueAsU64); + break; + } + case DwarfAttributeForm.Data4: + { + writer.WriteU32((uint) ValueAsU64); + break; + } + case DwarfAttributeForm.Data8: + { + writer.WriteU64(ValueAsU64); + break; + } + case DwarfAttributeForm.String: + { + writer.WriteStringUTF8NullTerminated((string) ValueAsObject); + break; + } + case DwarfAttributeForm.Block: + { + var stream = (Stream) ValueAsObject; + writer.WriteULEB128((ulong) stream.Length); + writer.Write(stream); + break; + } + case DwarfAttributeForm.Block1: + { + var stream = (Stream) ValueAsObject; + writer.WriteU8((byte) stream.Length); + writer.Write(stream); + break; + } + case DwarfAttributeForm.Block2: + { + var stream = (Stream) ValueAsObject; + writer.WriteU16((ushort) stream.Length); + writer.Write(stream); + break; + } + case DwarfAttributeForm.Block4: + { + var stream = (Stream) ValueAsObject; + writer.WriteU32((uint) stream.Length); + writer.Write(stream); + break; + } + case DwarfAttributeForm.Flag: + { + writer.WriteU8((byte) (ValueAsU64 != 0 ? 1 : 0)); + break; + } + case DwarfAttributeForm.Sdata: + { + writer.WriteILEB128(ValueAsI64); + break; + } + case DwarfAttributeForm.Strp: + { + var offset = writer.File.StringTable.GetOrCreateString((string) ValueAsObject); + if (writer.EnableRelocation) + { + writer.RecordRelocation(DwarfRelocationTarget.DebugString, writer.SizeOfUIntEncoding(), offset); + offset = 0; + } + writer.WriteUIntFromEncoding(offset); + break; + } + case DwarfAttributeForm.Udata: + { + writer.WriteULEB128(ValueAsU64); + break; + } + case DwarfAttributeForm.RefAddr: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteUIntFromEncoding(dieRef.Offset); + break; + } + case DwarfAttributeForm.Ref1: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteU8((byte) (dieRef.Offset - writer.CurrentUnit.Offset)); + break; + } + case DwarfAttributeForm.Ref2: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteU16((ushort) (dieRef.Offset - writer.CurrentUnit.Offset)); + break; + } + case DwarfAttributeForm.Ref4: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteU32((uint) (dieRef.Offset - writer.CurrentUnit.Offset)); + break; + } + case DwarfAttributeForm.Ref8: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteU64((dieRef.Offset - writer.CurrentUnit.Offset)); + break; + } + case DwarfAttributeForm.RefUdata: + { + var dieRef = (DwarfDIE) ValueAsObject; + writer.WriteULEB128((dieRef.Offset - writer.CurrentUnit.Offset)); + break; + } + + //case DwarfAttributeForm.indirect: + //{ + // attributeForm = reader.ReadLEB128As(); + // goto indirect; + //} + + // addptr + // lineptr + // loclist + // loclistptr + // macptr + // rnglist + // rngrlistptr + // stroffsetsptr + case DwarfAttributeForm.SecOffset: + { + if (ValueAsObject != null) + { + writer.WriteUIntFromEncoding(((DwarfObject) ValueAsObject).Offset); + } + else + { + writer.WriteUIntFromEncoding(ValueAsU64); + } + break; + } + + case DwarfAttributeForm.Exprloc: + ((DwarfExpression) ValueAsObject).WriteInternal(writer); + break; + + case DwarfAttributeForm.FlagPresent: + Debug.Assert(ValueAsBoolean); + break; + + case DwarfAttributeForm.RefSig8: + writer.WriteU64(ValueAsU64); + break; + + case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); + case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); + case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); + case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); + case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); + case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); + case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); + case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); + case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); + case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); + case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); + case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); + case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); + case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); + case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); + case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); + case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); + case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); + case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); + case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); + case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); + case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); + default: + throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {Form}"); + } + + Debug.Assert(writer.Offset - startAttributeOffset == Size); + } + + private static readonly DwarfReader.DwarfDIEReferenceResolver DwarfAttributeDIEReferenceResolverInstance = DwarfAttributeDIEReferenceResolver; + + private static DwarfReader.DwarfDIEReference AttributeToDIERef(DwarfAttribute attr) + { + return new DwarfReader.DwarfDIEReference(attr.ValueAsU64, attr, DwarfAttributeDIEReferenceResolverInstance); + } + + private static void DwarfAttributeDIEReferenceResolver(ref DwarfReader.DwarfDIEReference dieRef) + { + var attr = (DwarfAttribute)dieRef.DwarfObject; + attr.ValueAsU64 = 0; + attr.ValueAsObject = dieRef.Resolved; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs new file mode 100644 index 00000000000000..8add13ebb6f564 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs @@ -0,0 +1,55 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("{Kind} {Form}")] + public readonly struct DwarfAttributeDescriptor : IEquatable + { + public static readonly DwarfAttributeDescriptor Empty = new DwarfAttributeDescriptor(); + + public DwarfAttributeDescriptor(DwarfAttributeKindEx kind, DwarfAttributeFormEx form) + { + Kind = kind; + Form = form; + } + + public readonly DwarfAttributeKindEx Kind; + + public readonly DwarfAttributeFormEx Form; + + public bool IsNull => Kind.Value == 0 && Form.Value == 0; + + public bool Equals(DwarfAttributeDescriptor other) + { + return Kind.Equals(other.Kind) && Form.Equals(other.Form); + } + + public override bool Equals(object obj) + { + return obj is DwarfAttributeDescriptor other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + return (Kind.GetHashCode() * 397) ^ Form.GetHashCode(); + } + } + + public static bool operator ==(DwarfAttributeDescriptor left, DwarfAttributeDescriptor right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfAttributeDescriptor left, DwarfAttributeDescriptor right) + { + return !left.Equals(right); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs new file mode 100644 index 00000000000000..50ffe430b2d428 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs @@ -0,0 +1,82 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] + public readonly struct DwarfAttributeDescriptors : IEquatable + { + private readonly DwarfAttributeDescriptor[] _descriptors; + + public DwarfAttributeDescriptors(DwarfAttributeDescriptor[] descriptors) + { + _descriptors = descriptors ?? throw new ArgumentNullException(nameof(descriptors)); + } + + public int Length => _descriptors?.Length ?? 0; + + public DwarfAttributeDescriptor this[int index] + { + get + { + if (_descriptors == null) throw new ArgumentException("This descriptors instance is not initialized"); + return _descriptors[index]; + } + } + + public bool Equals(DwarfAttributeDescriptors other) + { + if (ReferenceEquals(_descriptors, other._descriptors)) return true; + if (_descriptors == null || other._descriptors == null) return false; + if (_descriptors.Length != other._descriptors.Length) return false; + + for (int i = 0; i < _descriptors.Length; i++) + { + if (_descriptors[i] != other._descriptors[i]) + { + return false; + } + } + return true; + } + + + public override bool Equals(object obj) + { + return obj is DwarfAttributeDescriptors other && Equals(other); + } + + public override int GetHashCode() + { + int hashCode = _descriptors == null ? 0 : _descriptors.Length; + if (hashCode == 0) return hashCode; + foreach (var descriptor in _descriptors) + { + hashCode = (hashCode * 397) ^ descriptor.GetHashCode(); + } + return hashCode; + } + + private string DebuggerDisplay => ToString(); + + public static bool operator ==(DwarfAttributeDescriptors left, DwarfAttributeDescriptors right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfAttributeDescriptors left, DwarfAttributeDescriptors right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return $"Count = {_descriptors.Length}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs new file mode 100644 index 00000000000000..f722ab38d57b5a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs @@ -0,0 +1,50 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + [Flags] + public enum DwarfAttributeEncoding + { + None, + + Address = 1, + + Block = 1 << 1, + + Constant = 1 << 2, + + ExpressionLocation = 1 << 3, + + Flag = 1 << 4, + + LinePointer = 1 << 5, + + LocationListPointer = 1 << 6, + + MacroPointer = 1 << 7, + + RangeListPointer = 1 << 8, + + Reference = 1 << 9, + + String = 1 << 10, + + RangeList = 1 << 11, + + Indirect = 1 << 12, + + LocationList = 1 << 13, + + AddressPointer = 1 << 14, + + LocationListsPointer = 1 << 15, + + RangeListsPointer = 1 << 16, + + StringOffsetPointer = 1 << 17, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs new file mode 100644 index 00000000000000..fa00158fca37de --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs @@ -0,0 +1,64 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + /// + /// Defines the kind of an . + /// This is the value seen in + /// + [DebuggerDisplay("{ToString(),nq}")] + public readonly partial struct DwarfAttributeFormEx : IEquatable + { + public DwarfAttributeFormEx(uint value) + { + Value = (DwarfAttributeForm)value; + } + public DwarfAttributeFormEx(DwarfAttributeForm value) + { + Value = value; + } + + public readonly DwarfAttributeForm Value; + + public bool Equals(DwarfAttributeFormEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfAttributeFormEx other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(DwarfAttributeFormEx left, DwarfAttributeFormEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfAttributeFormEx left, DwarfAttributeFormEx right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfAttributeFormEx)} (0x{Value:X4})"; + } + + public static explicit operator uint(DwarfAttributeFormEx form) => (uint)form.Value; + + public static implicit operator DwarfAttributeFormEx(DwarfAttributeForm kind) => new DwarfAttributeFormEx(kind); + + public static implicit operator DwarfAttributeForm(DwarfAttributeFormEx kind) => kind.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs new file mode 100644 index 00000000000000..eb12ac9f8109fe --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs @@ -0,0 +1,66 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + /// + /// Defines the kind of an . + /// This is the value seen in + /// + [DebuggerDisplay("{ToString(),nq}")] + public readonly partial struct DwarfAttributeKindEx : IEquatable + { + public DwarfAttributeKindEx(uint value) + { + Value = (DwarfAttributeKind)value; + } + + public DwarfAttributeKindEx(DwarfAttributeKind value) + { + Value = value; + } + + public readonly DwarfAttributeKind Value; + + + public bool Equals(DwarfAttributeKindEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfAttributeKindEx other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(DwarfAttributeKindEx left, DwarfAttributeKindEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfAttributeKindEx left, DwarfAttributeKindEx right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfAttributeKindEx)} (0x{Value:X4})"; + } + + public static explicit operator uint(DwarfAttributeKindEx kind) => (uint)kind.Value; + + public static implicit operator DwarfAttributeKindEx(DwarfAttributeKind kind) => new DwarfAttributeKindEx(kind); + + public static implicit operator DwarfAttributeKind(DwarfAttributeKindEx kind) => kind.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs new file mode 100644 index 00000000000000..b68406fcc583cc --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs @@ -0,0 +1,21 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public class DwarfAttributeValue + { + public DwarfAttributeValue(object value) + { + Value = value; + } + + public object Value { get; set; } + + public override string ToString() + { + return $"{nameof(Value)}: {Value}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs new file mode 100644 index 00000000000000..ce84db351ca3ac --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs @@ -0,0 +1,59 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public readonly partial struct DwarfCallingConventionEx : IEquatable + { + public DwarfCallingConventionEx(byte value) + { + Value = (DwarfCallingConvention)value; + } + + public DwarfCallingConventionEx(DwarfCallingConvention value) + { + Value = value; + } + + public readonly DwarfCallingConvention Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfCallingConvention)} (0x{Value:x2})"; + } + + public bool Equals(DwarfCallingConventionEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfCallingConventionEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(DwarfCallingConventionEx left, DwarfCallingConventionEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfCallingConventionEx left, DwarfCallingConventionEx right) + { + return !left.Equals(right); + } + + public static explicit operator uint(DwarfCallingConventionEx callConv) => (uint)callConv.Value; + + public static implicit operator DwarfCallingConventionEx(DwarfCallingConvention callConv) => new DwarfCallingConventionEx(callConv); + + public static implicit operator DwarfCallingConvention(DwarfCallingConventionEx callConv) => callConv.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs new file mode 100644 index 00000000000000..86603c49c493cd --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs @@ -0,0 +1,81 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public class DwarfCompilationUnit : DwarfUnit + { + public DwarfCompilationUnit() + { + Kind = DwarfUnitKind.Compile; + // Default to version 4 + Version = 4; + } + + protected override void ReadHeader(DwarfReader reader) + { + if (Version < 5) + { + // 3. debug_abbrev_offset (section offset) + DebugAbbreviationOffset = reader.ReadUIntFromEncoding(); + + // 4. address_size (ubyte) + AddressSize = reader.ReadAddressSize(); + reader.AddressSize = AddressSize; + } + else + { + // NOTE: order of address_size/debug_abbrev_offset are different from Dwarf 4 + + // 4. address_size (ubyte) + AddressSize = reader.ReadAddressSize(); + reader.AddressSize = AddressSize; + + // 5. debug_abbrev_offset (section offset) + DebugAbbreviationOffset = reader.ReadUIntFromEncoding(); + } + } + + protected override void WriteHeader(DwarfWriter writer) + { + if (Version < 5) + { + // 3. debug_abbrev_offset (section offset) + var abbrevOffset = Abbreviation.Offset; + if (writer.EnableRelocation) + { + writer.RecordRelocation(DwarfRelocationTarget.DebugAbbrev, writer.SizeOfUIntEncoding(), abbrevOffset); + abbrevOffset = 0; + } + writer.WriteUIntFromEncoding(abbrevOffset); + + // 4. address_size (ubyte) + writer.WriteAddressSize(AddressSize); + } + else + { + // NOTE: order of address_size/debug_abbrev_offset are different from Dwarf 4 + + // 4. address_size (ubyte) + writer.WriteAddressSize(AddressSize); + + // 5. debug_abbrev_offset (section offset) + var abbrevOffset = Abbreviation.Offset; + if (writer.EnableRelocation) + { + writer.RecordRelocation(DwarfRelocationTarget.DebugAbbrev, writer.SizeOfUIntEncoding(), abbrevOffset); + abbrevOffset = 0; + } + writer.WriteUIntFromEncoding(abbrevOffset); + } + } + + protected override ulong GetLayoutHeaderSize() + { + // 3. debug_abbrev_offset (section offset) + // 4. address_size (ubyte) + return DwarfHelper.SizeOfUInt(Is64BitEncoding) + 1; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs new file mode 100644 index 00000000000000..8c83fa06656967 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs @@ -0,0 +1,71 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public struct DwarfConstant + { + public DwarfConstant(int value) + { + AsValue = new DwarfInteger() {I64 = value}; + AsObject = null; + } + + public DwarfConstant(DwarfExpression expression) + { + AsValue = default; + AsObject = expression; + } + + public DwarfConstant(DwarfDIE dieRef) + { + AsValue = default; + AsObject = dieRef; + } + + public DwarfConstant(Stream stream) + { + AsValue = default; + AsObject = stream; + } + + public DwarfInteger AsValue; + + public object AsObject; + + public DwarfExpression AsExpression => AsObject as DwarfExpression; + + public DwarfDIE AsReference => AsObject as DwarfDIE; + + public Stream AsStream => AsObject as Stream; + + public string AsString => AsObject as string; + + public override string ToString() + { + if (AsExpression != null) return $"Constant Expression: {AsExpression}"; + if (AsReference != null) return $"Constant Reference: {AsReference}"; + if (AsStream != null) return $"Constant Block: Length = {AsStream.Length}"; + if (AsString != null) return $"Constant String: {AsString}"; + return $"Constant Value: {AsValue}"; + } + + public static implicit operator DwarfConstant(int value) + { + return new DwarfConstant(value); + } + + public static implicit operator DwarfConstant(DwarfExpression value) + { + return new DwarfConstant(value); + } + + public static implicit operator DwarfConstant(DwarfDIE value) + { + return new DwarfConstant(value); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs new file mode 100644 index 00000000000000..83940ffffff356 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs @@ -0,0 +1,16 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfContainer : DwarfObject + { + public override void Verify(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs new file mode 100644 index 00000000000000..2c739980d5df02 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs @@ -0,0 +1,516 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This attribute is licensed under the BSD-Clause 2 license. +// See the license.txt attribute in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public class DwarfDIE : DwarfContainer + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly List _attributes; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private readonly List _children; + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private DwarfTagEx _tag; + + /// + /// The current line program table when reading. + /// + internal DwarfLineProgramTable CurrentLineProgramTable; + + public DwarfDIE() + { + _attributes = new List(); + _children = new List(); + } + + protected DwarfDIE(DwarfTagEx tag) + { + _tag = tag; + } + + public virtual DwarfTagEx Tag + { + get => _tag; + set => _tag = value; + } + + public IReadOnlyList Attributes => _attributes; + + public IReadOnlyList Children => _children; + + public DwarfAbbreviationItem Abbrev { get; internal set; } + + /// + /// Adds a child to . + /// + /// A child + public void AddChild(DwarfDIE child) + { + _children.Add(this, child); + } + + /// + /// Inserts a child into at the specified index. + /// + /// Index into to insert the specified child + /// The child to insert + public void InsertChildAt(int index, DwarfDIE child) + { + _children.InsertAt(this, index, child); + } + + /// + /// Removes a child from + /// + /// The child to remove + public void RemoveChild(DwarfDIE child) + { + _children.Remove(this, child); + } + + /// + /// Removes a child from at the specified index. + /// + /// Index into to remove the specified child + public DwarfDIE RemoveChildAt(int index) + { + return _children.RemoveAt(this, index); + } + + /// + /// Adds an attribute to . + /// + /// A attribute + public void AddAttribute(DwarfAttribute attribute) + { + _attributes.AddSorted(this, attribute, true); + } + + /// + /// Removes an attribute from + /// + /// The attribute to remove + public void RemoveAttribute(DwarfAttribute attribute) + { + _attributes.Remove(this, attribute); + } + + /// + /// Removes an attribute from at the specified index. + /// + /// Index into to remove the specified attribute + public DwarfAttribute RemoveAttributeAt(int index) + { + return _attributes.RemoveAt(this, index); + } + + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var attr in _attributes) + { + attr.Verify(diagnostics); + } + + foreach (var child in _children) + { + child.Verify(diagnostics); + } + } + + public override string ToString() + { + return $"{nameof(Tag)}: {Tag}, {nameof(Attributes)}: {Attributes.Count}, {nameof(Children)}: {Children.Count}"; + } + + protected TValue GetAttributeValue(DwarfAttributeKind kind) + { + foreach (var attr in _attributes) + { + if (attr.Kind == kind) + { + return (TValue)attr.ValueAsObject; + } + } + + return default; + } + + protected unsafe TValue? GetAttributeValueOpt(DwarfAttributeKind kind) where TValue : unmanaged + { + Debug.Assert(sizeof(TValue) <= sizeof(ulong)); + + foreach (var attr in _attributes) + { + if (attr.Kind == kind) + { + ulong localU64 = attr.ValueAsU64; + return *(TValue*) &localU64; + } + } + + return default; + } + + protected DwarfConstant? GetAttributeConstantOpt(DwarfAttributeKind kind) + { + foreach (var attr in _attributes) + { + if (attr.Kind == kind) + { + return new DwarfConstant + { + AsValue = + { + U64 = attr.ValueAsU64 + }, + AsObject = attr.ValueAsObject + }; + } + } + + return null; + } + + protected void SetAttributeConstantOpt(DwarfAttributeKind kind, DwarfConstant? cst) + { + for (int i = 0; i < _attributes.Count; i++) + { + var attr = _attributes[i]; + if (attr.Kind == kind) + { + if (!cst.HasValue) + { + RemoveAttributeAt(i); + } + else + { + var value = cst.Value; + attr.ValueAsU64 = value.AsValue.U64; + attr.ValueAsObject = value.AsExpression; + } + return; + } + } + + if (cst.HasValue) + { + var value = cst.Value; + AddAttribute(new DwarfAttribute() + { + Kind = kind, + ValueAsU64 = value.AsValue.U64, + ValueAsObject = value.AsExpression + }); + } + } + + protected DwarfLocation? GetAttributeLocationOpt(DwarfAttributeKind kind) + { + foreach (var attr in _attributes) + { + if (attr.Kind == kind) + { + return new DwarfLocation + { + AsValue = + { + U64 = attr.ValueAsU64 + }, + AsObject = attr.ValueAsObject + }; + } + } + + return null; + } + + protected void SetAttributeLocationOpt(DwarfAttributeKind kind, DwarfLocation? cst) + { + for (int i = 0; i < _attributes.Count; i++) + { + var attr = _attributes[i]; + if (attr.Kind == kind) + { + if (!cst.HasValue) + { + RemoveAttributeAt(i); + } + else + { + var value = cst.Value; + attr.ValueAsU64 = value.AsValue.U64; + attr.ValueAsObject = value.AsObject; + } + return; + } + } + + if (cst.HasValue) + { + var value = cst.Value; + AddAttribute(new DwarfAttribute() + { + Kind = kind, + ValueAsU64 = value.AsValue.U64, + ValueAsObject = value.AsObject + }); + } + } + + public DwarfAttribute FindAttributeByKey(DwarfAttributeKind kind) + { + foreach (var attr in _attributes) + { + if (attr.Kind == kind) + { + return attr; + } + } + + return null; + } + + protected unsafe void SetAttributeValue(DwarfAttributeKind kind, TValue value) + { + for (int i = 0; i < _attributes.Count; i++) + { + var attr = _attributes[i]; + if (attr.Kind == kind) + { + if (value == null) + { + RemoveAttributeAt(i); + } + else + { + attr.ValueAsObject = value; + } + return; + } + } + + if (value == null) return; + AddAttribute(new DwarfAttribute() { Kind = kind, ValueAsObject = value}); + } + + protected void SetAttributeLinkValue(DwarfAttributeKind kind, TLink link) where TLink : IObjectFileNodeLink + { + for (int i = 0; i < _attributes.Count; i++) + { + var attr = _attributes[i]; + if (attr.Kind == kind) + { + if (link == null) + { + RemoveAttributeAt(i); + } + else + { + attr.ValueAsU64 = link.GetRelativeOffset(); + attr.ValueAsObject = link.GetObjectFileNode(); + } + return; + } + } + + AddAttribute(new DwarfAttribute() + { + Kind = kind, + ValueAsU64 = link.GetRelativeOffset(), + ValueAsObject = link.GetObjectFileNode() + }); + } + + protected unsafe void SetAttributeValueOpt(DwarfAttributeKind kind, TValue? value) where TValue : unmanaged + { + Debug.Assert(sizeof(TValue) <= sizeof(ulong)); + + for (int i = 0; i < _attributes.Count; i++) + { + var attr = _attributes[i]; + if (attr.Kind == kind) + { + if (!value.HasValue) + { + RemoveAttributeAt(i); + } + else + { + ulong valueU64 = 0; + *((TValue*) &valueU64) = value.Value; + attr.ValueAsU64 = valueU64; + attr.ValueAsObject = null; + } + return; + } + } + + if (value.HasValue) + { + var attr = new DwarfAttribute() {Kind = kind}; + ulong valueU64 = 0; + *((TValue*)&valueU64) = value.Value; + attr.ValueAsU64 = valueU64; + AddAttribute(attr); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var abbrev = Abbrev; + + var endOffset = Offset; + endOffset += DwarfHelper.SizeOfULEB128(abbrev.Code); // WriteULEB128(abbreviationItem.Code); + + foreach (var attr in _attributes) + { + attr.Offset = endOffset; + attr.UpdateLayoutInternal(layoutContext); + endOffset += attr.Size; + } + + if (abbrev.HasChildren) + { + foreach (var child in _children) + { + child.Offset = endOffset; + child.UpdateLayout(layoutContext); + endOffset += child.Size; + } + + // Encode abbreviation 0 code + endOffset += DwarfHelper.SizeOfULEB128(0); + } + + Size = endOffset - Offset; + } + + protected override void Read(DwarfReader reader) + { + // Store map offset to DIE to resolve references + reader.PushDIE(this); + + // Console.WriteLine($" <{level}><{die.Offset:x}> Abbrev Number: {abbreviationCode} ({die.Tag})"); + + var descriptors = Abbrev.Descriptors; + if (descriptors.Length > 0) + { + for (int i = 0; i < descriptors.Length; i++) + { + reader.CurrentAttributeDescriptor = descriptors[i]; + + var attribute = new DwarfAttribute() + { + Offset = reader.Offset, + }; + + attribute.ReadInternal(reader); + + AddAttribute(attribute); + } + } + + if (Abbrev.HasChildren) + { + while (true) + { + reader.DIELevel++; + var child = ReadInstance(reader); + reader.DIELevel--; + if (child == null) break; + + AddChild(child); + } + } + + reader.PopDIE(); + + Size = reader.Offset - Offset; + } + + internal static DwarfDIE ReadInstance(DwarfReader reader) + { + var startDIEOffset = reader.Offset; + var abbreviationCode = reader.ReadULEB128(); + DwarfDIE die = null; + + if (abbreviationCode != 0) + { + + if (!reader.CurrentUnit.Abbreviation.TryFindByCode(abbreviationCode, out var abbreviationItem)) + { + throw new InvalidOperationException($"Invalid abbreviation code {abbreviationCode}"); + } + + die = DIEHelper.ConvertTagToDwarfDIE((ushort) abbreviationItem.Tag); + die.Offset = startDIEOffset; + die.Abbrev = abbreviationItem; + die.Tag = abbreviationItem.Tag; + die.ReadInternal(reader); + } + + return die; + } + + internal void UpdateAbbreviationItem(DwarfLayoutContext context) + { + // Initialize the offset of DIE to ulong.MaxValue to make sure that when we have a reference + // to it, we can detect if it is a forward or backward reference. + // If it is a backward reference, we will be able to encode the offset + // otherwise we will have to pad the encoding with NOP (for DwarfOperation in expressions) + Offset = ulong.MaxValue; + + // TODO: pool if not used by GetOrCreate below + var descriptorArray = new DwarfAttributeDescriptor[Attributes.Count]; + + for (var i = 0; i < Attributes.Count; i++) + { + var attr = Attributes[i]; + attr.UpdateAttributeForm(context); + descriptorArray[i] = new DwarfAttributeDescriptor(attr.Kind, attr.Form); + } + + var key = new DwarfAbbreviationItemKey(Tag, Children.Count > 0, new DwarfAttributeDescriptors(descriptorArray)); + var item = context.CurrentUnit.Abbreviation.GetOrCreate(key); + + Abbrev = item; + + foreach (var children in Children) + { + children.UpdateAbbreviationItem(context); + } + } + + protected override void Write(DwarfWriter writer) + { + var startDIEOffset = Offset; + Debug.Assert(Offset == startDIEOffset); + var abbrev = Abbrev; + writer.WriteULEB128(abbrev.Code); + + foreach (var attr in _attributes) + { + attr.WriteInternal(writer); + } + + if (abbrev.HasChildren) + { + foreach (var child in _children) + { + child.Write(writer); + } + writer.WriteULEB128(0); + } + + Debug.Assert(Size == writer.Offset - startDIEOffset); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs new file mode 100644 index 00000000000000..179a1c00badd0e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs @@ -0,0 +1,28 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfDIEDeclaration : DwarfDIE + { + // DW_AT_decl_column, DW_AT_decl_file, and DW_AT_decl_line + public ulong? DeclColumn + { + get => GetAttributeValueOpt(DwarfAttributeKind.DeclColumn); + set => SetAttributeValueOpt(DwarfAttributeKind.DeclColumn, value); + } + + public DwarfFileName DeclFile + { + get => GetAttributeValue(DwarfAttributeKind.DeclFile); + set => SetAttributeValue(DwarfAttributeKind.DeclFile, value); + } + + public ulong? DeclLine + { + get => GetAttributeValueOpt(DwarfAttributeKind.DeclLine); + set => SetAttributeValueOpt(DwarfAttributeKind.DeclLine, value); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs new file mode 100644 index 00000000000000..b059ae44e3aee0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs @@ -0,0 +1,13 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfDiscriminantListKind : byte + { + Label = DwarfNative.DW_DSC_label, + + Range = DwarfNative.DW_DSC_range, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs new file mode 100644 index 00000000000000..a8bf8953c6f574 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs @@ -0,0 +1,341 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using LibObjectFile.Elf; + +namespace LibObjectFile.Dwarf +{ + public class DwarfElfContext + { + private readonly int _codeSectionSymbolIndex; + private int _infoSectionSymbolIndex; + private int _abbreviationTableSymbolIndex; + private int _lineTableSymbolIndex; + private int _stringTableSymbolIndex; + private int _locationSectionSymbolIndex; + private readonly ElfSymbolTable _symbolTable; + + public DwarfElfContext(ElfObjectFile elf) + { + Elf = elf ?? throw new ArgumentNullException(nameof(elf)); + + var relocContext = new ElfRelocationContext(); + + var codeSection = elf.Sections.OfType().FirstOrDefault(s => s.Name == ".text"); + + _symbolTable = elf.Sections.OfType().FirstOrDefault(); + var mapSectionToSymbolIndex = new Dictionary(); + if (_symbolTable != null) + { + for (var i = 0; i < _symbolTable.Entries.Count; i++) + { + var entry = _symbolTable.Entries[i]; + + if (entry.Type == ElfSymbolType.Section && entry.Section.Section != null) + { + mapSectionToSymbolIndex[entry.Section.Section] = i; + } + } + + if (codeSection != null) + { + if (!mapSectionToSymbolIndex.TryGetValue(codeSection, out _codeSectionSymbolIndex)) + { + _codeSectionSymbolIndex = _symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() + { + Type = ElfSymbolType.Section, + Section = codeSection, + }); + } + } + } + + foreach (var section in elf.Sections) + { + switch (section.Name.Value) + { + case ".debug_info": + InfoSection = ((ElfBinarySection)section); + mapSectionToSymbolIndex.TryGetValue(InfoSection, out _infoSectionSymbolIndex); + break; + case ".debug_abbrev": + AbbreviationTable = ((ElfBinarySection)section); + mapSectionToSymbolIndex.TryGetValue(AbbreviationTable, out _abbreviationTableSymbolIndex); + break; + case ".debug_aranges": + AddressRangeTable = ((ElfBinarySection)section); + break; + case ".debug_str": + StringTable = ((ElfBinarySection)section); + mapSectionToSymbolIndex.TryGetValue(StringTable, out _stringTableSymbolIndex); + break; + case ".debug_line": + LineTable = ((ElfBinarySection)section); + mapSectionToSymbolIndex.TryGetValue(LineTable, out _lineTableSymbolIndex); + break; + case ".debug_loc": + LocationSection = ((ElfBinarySection)section); + mapSectionToSymbolIndex.TryGetValue(LocationSection, out _locationSectionSymbolIndex); + break; + + case ".rela.debug_aranges": + case ".rel.debug_aranges": + RelocAddressRangeTable = (ElfRelocationTable)section; + RelocAddressRangeTable.Relocate(relocContext); + break; + + case ".rela.debug_line": + case ".rel.debug_line": + RelocLineTable = (ElfRelocationTable)section; + RelocLineTable.Relocate(relocContext); + break; + + case ".rela.debug_info": + case ".rel.debug_info": + RelocInfoSection = (ElfRelocationTable)section; + RelocInfoSection.Relocate(relocContext); + break; + + case ".rela.debug_loc": + case ".rel.debug_loc": + RelocLocationSection = (ElfRelocationTable)section; + RelocLocationSection.Relocate(relocContext); + break; + } + } + } + + public ElfObjectFile Elf { get; } + + public bool IsLittleEndian => Elf.Encoding == ElfEncoding.Lsb; + + public DwarfAddressSize AddressSize => Elf.FileClass == ElfFileClass.Is64 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; + + public ElfBinarySection InfoSection { get; private set; } + + public ElfRelocationTable RelocInfoSection { get; set; } + + public ElfBinarySection AbbreviationTable { get; set; } + + public ElfBinarySection AddressRangeTable { get; private set; } + + public ElfRelocationTable RelocAddressRangeTable { get; set; } + + public ElfBinarySection StringTable { get; set; } + + public ElfBinarySection LineTable { get; set; } + + public ElfRelocationTable RelocLineTable { get; set; } + + public ElfBinarySection LocationSection { get; private set; } + + public ElfRelocationTable RelocLocationSection { get; set; } + + public int CodeSectionSymbolIndex => _codeSectionSymbolIndex; + + public int InfoSectionSymbolIndex => _infoSectionSymbolIndex; + + public int StringTableSymbolIndex => _stringTableSymbolIndex; + + public int AbbreviationTableSymbolIndex => _abbreviationTableSymbolIndex; + + public int LineTableSymbolIndex => _lineTableSymbolIndex; + + public int LocationSectionSymbolIndex => _locationSectionSymbolIndex; + + public ElfBinarySection GetOrCreateInfoSection() + { + return InfoSection ??= GetOrCreateDebugSection(".debug_info", true, out _infoSectionSymbolIndex); + } + + public ElfRelocationTable GetOrCreateRelocInfoSection() + { + return RelocInfoSection ??= GetOrCreateRelocationTable(InfoSection); + } + + public ElfBinarySection GetOrCreateAbbreviationTable() + { + return AbbreviationTable ??= GetOrCreateDebugSection(".debug_abbrev", true, out _abbreviationTableSymbolIndex); + } + + public ElfBinarySection GetOrCreateAddressRangeTable() + { + return AddressRangeTable ??= GetOrCreateDebugSection(".debug_aranges", false, out _); + } + + public ElfRelocationTable GetOrCreateRelocAddressRangeTable() + { + return RelocAddressRangeTable ??= GetOrCreateRelocationTable(AddressRangeTable); + } + + public ElfBinarySection GetOrCreateLineSection() + { + return LineTable ??= GetOrCreateDebugSection(".debug_line", true, out _lineTableSymbolIndex); + } + + public ElfRelocationTable GetOrCreateRelocLineSection() + { + return RelocLineTable ??= GetOrCreateRelocationTable(LineTable); + } + + public ElfBinarySection GetOrCreateStringTable() + { + return StringTable ??= GetOrCreateDebugSection(".debug_str", true, out _stringTableSymbolIndex); + } + + public ElfBinarySection GetOrCreateLocationSection() + { + return LocationSection ??= GetOrCreateDebugSection(".debug_loc", true, out _locationSectionSymbolIndex); + } + + public ElfRelocationTable GetOrCreateRelocLocationSection() + { + return RelocLocationSection ??= GetOrCreateRelocationTable(LocationSection); + } + + public void RemoveStringTable() + { + if (StringTable != null) + { + Elf.RemoveSection(StringTable); + StringTable = null; + } + } + + public void RemoveAbbreviationTable() + { + if (AbbreviationTable != null) + { + Elf.RemoveSection(AbbreviationTable); + AbbreviationTable = null; + } + } + + public void RemoveLineTable() + { + if (LineTable != null) + { + Elf.RemoveSection(LineTable); + LineTable = null; + } + + RemoveRelocLineTable(); + } + + public void RemoveRelocLineTable() + { + if (RelocLineTable != null) + { + Elf.RemoveSection(RelocLineTable); + RelocLineTable = null; + } + } + + public void RemoveAddressRangeTable() + { + if (AddressRangeTable != null) + { + Elf.RemoveSection(AddressRangeTable); + AddressRangeTable = null; + } + + RemoveRelocAddressRangeTable(); + } + + public void RemoveRelocAddressRangeTable() + { + if (RelocAddressRangeTable != null) + { + Elf.RemoveSection(RelocAddressRangeTable); + RelocAddressRangeTable = null; + } + } + + public void RemoveInfoSection() + { + if (InfoSection != null) + { + Elf.RemoveSection(InfoSection); + InfoSection = null; + } + + RemoveRelocInfoSection(); + } + + public void RemoveRelocInfoSection() + { + if (RelocInfoSection != null) + { + Elf.RemoveSection(RelocInfoSection); + RelocInfoSection = null; + } + } + + public void RemoveLocationSection() + { + if (LocationSection != null) + { + Elf.RemoveSection(LocationSection); + LocationSection = null; + } + + RemoveRelocLocationSection(); + } + + public void RemoveRelocLocationSection() + { + if (RelocLocationSection != null) + { + Elf.RemoveSection(RelocLocationSection); + RelocLocationSection = null; + } + } + + private ElfBinarySection GetOrCreateDebugSection(string name, bool createSymbol, out int symbolIndex) + { + var newSection = new ElfBinarySection() + { + Name = name, + Alignment = 1, + Type = ElfSectionType.ProgBits, + Stream = new MemoryStream(), + }; + + Elf.AddSection(newSection); + symbolIndex = 0; + + if (createSymbol && _symbolTable != null) + { + symbolIndex = _symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() + { + Type = ElfSymbolType.Section, + Section = newSection, + }); + } + + return newSection; + } + + private ElfRelocationTable GetOrCreateRelocationTable(ElfBinarySection section) + { + var newSection = new ElfRelocationTable() + { + Name = $".rela{section.Name}", + Alignment = (ulong)AddressSize, + Flags = ElfSectionFlags.InfoLink, + Type = ElfSectionType.RelocationAddends, + Info = section, + Link = _symbolTable, + }; + Elf.AddSection(newSection); + return newSection; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs new file mode 100644 index 00000000000000..9dbe2aad16cd6b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs @@ -0,0 +1,132 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("Count = {Operations.Count,nq}")] + public class DwarfExpression : DwarfObject + { + private readonly List _operations; + + public DwarfExpression() + { + _operations = new List(); + } + + public IReadOnlyList Operations => _operations; + + internal List InternalOperations => _operations; + + public ulong OperationLengthInBytes { get; internal set; } + + public void AddOperation(DwarfOperation operation) + { + if (operation == null) throw new ArgumentNullException(nameof(operation)); + _operations.Add(this, operation); + } + + public void RemoveOperation(DwarfOperation operation) + { + if (operation == null) throw new ArgumentNullException(nameof(operation)); + _operations.Remove(this, operation); + } + + public DwarfOperation RemoveOperationAt(int index) + { + return _operations.RemoveAt(this, index); + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var op in _operations) + { + op.Verify(diagnostics); + } + } + + internal void ReadInternal(DwarfReader reader, bool inLocationSection = false) + { + Offset = reader.Offset; + var size = inLocationSection ? reader.ReadU16() : reader.ReadULEB128(); + OperationLengthInBytes = size; + var endPosition = reader.Offset + size; + + while (reader.Offset < endPosition) + { + var op = new DwarfOperation() {Offset = reader.Offset}; + op.ReadInternal(reader); + AddOperation(op); + } + + Size = reader.Offset - Offset; + } + + internal void WriteInternal(DwarfWriter writer, bool inLocationSection = false) + { + Debug.Assert(Offset == writer.Offset); + Debug.Assert(!inLocationSection || OperationLengthInBytes <= ushort.MaxValue); + + var startExpressionOffset = writer.Offset; + if (inLocationSection) + { + writer.WriteU16((ushort)OperationLengthInBytes); + } + else + { + writer.WriteULEB128(OperationLengthInBytes); + } + + foreach (var op in Operations) + { + op.WriteInternal(writer); + } + + Debug.Assert(writer.Offset - startExpressionOffset == Size); + } + + internal void UpdateLayoutInternal(DwarfLayoutContext layoutContext, bool inLocationSection = false) + { + var endOffset = Offset; + foreach (var op in _operations) + { + op.Offset = endOffset; + op.UpdateLayoutInternal(layoutContext); + endOffset += op.Size; + } + + OperationLengthInBytes = endOffset - Offset; + + // We need to shift the expression which is prefixed by its size encoded in LEB128, + // or fixed-size U2 in .debug_loc section + var deltaLength = inLocationSection ? sizeof(ushort) : DwarfHelper.SizeOfULEB128(Size); + foreach (var op in InternalOperations) + { + op.Offset += deltaLength; + } + + Size = OperationLengthInBytes + deltaLength; + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + UpdateLayoutInternal(layoutContext, inLocationSection: false); + } + + protected override void Read(DwarfReader reader) + { + ReadInternal(reader, inLocationSection: false); + } + + protected override void Write(DwarfWriter writer) + { + WriteInternal(writer, inLocationSection: false); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs new file mode 100644 index 00000000000000..0d37d0deab81f4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs @@ -0,0 +1,456 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using LibObjectFile.Elf; + +namespace LibObjectFile.Dwarf +{ + public class DwarfFile : DwarfContainer + { + private DwarfAbbreviationTable _abbreviationTable; + private DwarfStringTable _stringTable; + private DwarfLineSection _lineSection; + private DwarfInfoSection _infoSection; + private DwarfAddressRangeTable _addressRangeTable; + private DwarfLocationSection _locationSection; + + public DwarfFile() + { + AbbreviationTable = new DwarfAbbreviationTable(); + StringTable = new DwarfStringTable(); + LineSection = new DwarfLineSection(); + InfoSection = new DwarfInfoSection(); + LocationSection = new DwarfLocationSection(); + AddressRangeTable = new DwarfAddressRangeTable(); + } + + public DwarfAbbreviationTable AbbreviationTable + { + get => _abbreviationTable; + set => AttachChild(this, value, ref _abbreviationTable, false); + } + + public DwarfStringTable StringTable + { + get => _stringTable; + set => AttachChild(this, value, ref _stringTable, false); + } + + public DwarfLineSection LineSection + { + get => _lineSection; + set => AttachChild(this, value, ref _lineSection, false); + } + + public DwarfAddressRangeTable AddressRangeTable + { + get => _addressRangeTable; + set => AttachChild(this, value, ref _addressRangeTable, false); + } + + public DwarfInfoSection InfoSection + { + get => _infoSection; + set => AttachChild(this, value, ref _infoSection, false); + } + + public DwarfLocationSection LocationSection + { + get => _locationSection; + set => AttachChild(this, value, ref _locationSection, false); + } + + protected override void Read(DwarfReader reader) + { + throw new NotImplementedException(); + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + LineSection.Verify(diagnostics); + AbbreviationTable.Verify(diagnostics); + AddressRangeTable.Verify(diagnostics); + StringTable.Verify(diagnostics); + InfoSection.Verify(diagnostics); + } + + public void UpdateLayout(DwarfLayoutConfig config, DiagnosticBag diagnostics) + { + if (config == null) throw new ArgumentNullException(nameof(config)); + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + var layoutContext = new DwarfLayoutContext(this, config, diagnostics); + + LineSection.Offset = 0; + LineSection.UpdateLayoutInternal(layoutContext); + if (layoutContext.HasErrors) + { + return; + } + + // Reset the abbreviation table + // TODO: Make this configurable via the DwarfWriterContext + AbbreviationTable.Offset = 0; + AbbreviationTable.Reset(); + + InfoSection.Offset = 0; + InfoSection.UpdateLayoutInternal(layoutContext); + if (layoutContext.HasErrors) + { + return; + } + + // Update AddressRangeTable layout after Info + AddressRangeTable.Offset = 0; + AddressRangeTable.UpdateLayoutInternal(layoutContext); + if (layoutContext.HasErrors) + { + return; + } + + // Update string table right after updating the layout of Info + StringTable.Offset = 0; + StringTable.UpdateLayoutInternal(layoutContext); + if (layoutContext.HasErrors) + { + return; + } + + // Update the abbrev table right after we have computed the entire layout of Info + AbbreviationTable.Offset = 0; + AbbreviationTable.UpdateLayoutInternal(layoutContext); + + LocationSection.Offset = 0; + LocationSection.UpdateLayoutInternal(layoutContext); + } + + public void Write(DwarfWriterContext writerContext) + { + if (writerContext == null) throw new ArgumentNullException(nameof(writerContext)); + + var diagnostics = new DiagnosticBag(); + + // Verify correctness + Verify(diagnostics); + CheckErrors(diagnostics); + + // Update the layout of all section and tables + UpdateLayout(writerContext.LayoutConfig, diagnostics); + CheckErrors(diagnostics); + + // Write all section and stables + var writer = new DwarfWriter(this, writerContext.IsLittleEndian, diagnostics); + writer.AddressSize = writerContext.AddressSize; + writer.EnableRelocation = writerContext.EnableRelocation; + + writer.Log = writerContext.DebugLinePrinter; + writer.Stream = writerContext.DebugLineStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = LineSection; + LineSection.Relocations.Clear(); + LineSection.WriteInternal(writer); + } + + writer.Log = null; + writer.Stream = writerContext.DebugAbbrevStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = AbbreviationTable; + AbbreviationTable.WriteInternal(writer); + } + + writer.Stream = writerContext.DebugAddressRangeStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = AddressRangeTable; + AddressRangeTable.Relocations.Clear(); + AddressRangeTable.WriteInternal(writer); + } + + writer.Stream = writerContext.DebugStringStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = StringTable; + StringTable.WriteInternal(writer); + } + + writer.Stream = writerContext.DebugInfoStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = InfoSection; + InfoSection.Relocations.Clear(); + InfoSection.WriteInternal(writer); + } + + writer.Stream = writerContext.DebugLocationStream; + if (writer.Stream != null) + { + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = LocationSection; + LocationSection.Relocations.Clear(); + LocationSection.WriteInternal(writer); + } + + CheckErrors(diagnostics); + } + + public void WriteToElf(DwarfElfContext elfContext, DwarfLayoutConfig layoutConfig = null) + { + if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); + + var diagnostics = new DiagnosticBag(); + + layoutConfig ??= new DwarfLayoutConfig(); + + // Verify correctness + Verify(diagnostics); + CheckErrors(diagnostics); + + // Update the layout of all section and tables + UpdateLayout(layoutConfig, diagnostics); + CheckErrors(diagnostics); + + // Setup the output based on actual content of Dwarf infos + var writer = new DwarfWriter(this, elfContext.IsLittleEndian, diagnostics) + { + AddressSize = elfContext.AddressSize, + EnableRelocation = elfContext.Elf.FileType == ElfFileType.Relocatable + }; + + // Pre-create table/sections to create symbols as well + if (StringTable.Size > 0) elfContext.GetOrCreateStringTable(); + if (AbbreviationTable.Size > 0) elfContext.GetOrCreateAbbreviationTable(); + if (LineSection.Size > 0) elfContext.GetOrCreateLineSection(); + if (AddressRangeTable.Size > 0) elfContext.GetOrCreateAddressRangeTable(); + if (InfoSection.Size > 0) elfContext.GetOrCreateInfoSection(); + + // String table + if (StringTable.Size > 0) + { + writer.Stream = elfContext.GetOrCreateStringTable().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = StringTable; + StringTable.WriteInternal(writer); + } + else + { + elfContext.RemoveStringTable(); + } + + // Abbreviation table + if (AbbreviationTable.Size > 0) + { + writer.Stream = elfContext.GetOrCreateAbbreviationTable().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = AbbreviationTable; + AbbreviationTable.WriteInternal(writer); + } + else + { + elfContext.RemoveAbbreviationTable(); + } + + // Line table + if (LineSection.Size > 0) + { + writer.Stream = elfContext.GetOrCreateLineSection().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = LineSection; + LineSection.Relocations.Clear(); + LineSection.WriteInternal(writer); + if (writer.EnableRelocation && LineSection.Relocations.Count > 0) + { + LineSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocLineSection()); + } + else + { + elfContext.RemoveRelocLineTable(); + } + } + else + { + elfContext.RemoveLineTable(); + } + + // AddressRange table + if (AddressRangeTable.Size > 0) + { + writer.Stream = elfContext.GetOrCreateAddressRangeTable().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = AddressRangeTable; + AddressRangeTable.Relocations.Clear(); + AddressRangeTable.WriteInternal(writer); + + if (writer.EnableRelocation && AddressRangeTable.Relocations.Count > 0) + { + AddressRangeTable.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocAddressRangeTable()); + } + else + { + elfContext.RemoveAddressRangeTable(); + } + } + else + { + elfContext.RemoveAddressRangeTable(); + } + + // InfoSection + if (InfoSection.Size > 0) + { + writer.Stream = elfContext.GetOrCreateInfoSection().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = InfoSection; + InfoSection.Relocations.Clear(); + InfoSection.WriteInternal(writer); + + if (writer.EnableRelocation && InfoSection.Relocations.Count > 0) + { + InfoSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocInfoSection()); + } + else + { + elfContext.RemoveRelocInfoSection(); + } + } + else + { + elfContext.RemoveInfoSection(); + } + + // LocationSection + if (LocationSection.Size > 0) + { + writer.Stream = elfContext.GetOrCreateLocationSection().Stream; + writer.Stream.Position = 0; + writer.Stream.SetLength(0); + writer.CurrentSection = LocationSection; + LocationSection.Relocations.Clear(); + LocationSection.WriteInternal(writer); + + if (writer.EnableRelocation && LocationSection.Relocations.Count > 0) + { + LocationSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocLocationSection()); + } + else + { + elfContext.RemoveRelocLocationSection(); + } + } + else + { + elfContext.RemoveLocationSection(); + } + + CheckErrors(diagnostics); + } + + public static DwarfFile Read(DwarfReaderContext readerContext) + { + if (readerContext == null) throw new ArgumentNullException(nameof(readerContext)); + + var dwarf = new DwarfFile(); + var reader = new DwarfReader(readerContext, dwarf, new DiagnosticBag()); + + reader.Log = null; + reader.Stream = readerContext.DebugAbbrevStream; + if (reader.Stream != null) + { + reader.CurrentSection = dwarf.AbbreviationTable; + dwarf.AbbreviationTable.ReadInternal(reader); + } + + reader.Stream = readerContext.DebugStringStream; + if (reader.Stream != null) + { + reader.CurrentSection = dwarf.StringTable; + dwarf.StringTable.ReadInternal(reader); + } + + reader.Log = readerContext.DebugLinePrinter; + reader.Stream = readerContext.DebugLineStream; + if (reader.Stream != null) + { + reader.CurrentSection = dwarf.LineSection; + dwarf.LineSection.ReadInternal(reader); + } + + reader.Log = null; + reader.Stream = readerContext.DebugAddressRangeStream; + if (reader.Stream != null) + { + reader.CurrentSection = dwarf.AddressRangeTable; + dwarf.AddressRangeTable.ReadInternal(reader); + } + + reader.Log = null; + reader.Stream = readerContext.DebugLocationStream; + if (reader.Stream != null) + { + reader.CurrentSection = dwarf.LocationSection; + dwarf.LocationSection.ReadInternal(reader); + } + + reader.Log = null; + reader.Stream = readerContext.DebugInfoStream; + if (reader.Stream != null) + { + reader.DefaultUnitKind = DwarfUnitKind.Compile; + reader.CurrentSection = dwarf.InfoSection; + dwarf.InfoSection.ReadInternal(reader); + } + + CheckErrors(reader.Diagnostics); + + return dwarf; + } + + public static DwarfFile ReadFromElf(DwarfElfContext elfContext) + { + if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); + return Read(new DwarfReaderContext(elfContext)); + } + + public static DwarfFile ReadFromElf(ElfObjectFile elf) + { + return ReadFromElf(new DwarfElfContext(elf)); + } + + private static void CheckErrors(DiagnosticBag diagnostics) + { + if (diagnostics.HasErrors) + { + throw new ObjectFileException("Unexpected errors while verifying and updating the layout", diagnostics); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + } + + protected override void Write(DwarfWriter writer) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs new file mode 100644 index 00000000000000..ece43bc820f493 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs @@ -0,0 +1,30 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfFileName + { + public string Name { get; set; } + + public string Directory { get; set; } + + public ulong Time { get; set; } + + public ulong Size { get; set; } + + public override string ToString() + { + if (string.IsNullOrEmpty(Name)) return ""; + if (Directory != null) + { + return Directory.Contains(Path.AltDirectorySeparatorChar) ? $"{Directory}{Path.AltDirectorySeparatorChar}{Name}" : $"{Directory}{Path.DirectorySeparatorChar}{Name}"; + } + + return Name; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs new file mode 100644 index 00000000000000..eedb5fc5a226ed --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs @@ -0,0 +1,127 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Text; + +namespace LibObjectFile.Dwarf +{ + public static partial class DwarfHelper + { + public static ulong SizeOfStringUTF8NullTerminated(string text) + { + if (text == null) return 0; + return (ulong)Encoding.UTF8.GetByteCount(text) + 1; + } + + public static uint SizeOfUnitLength(bool is64Bit) + { + return is64Bit ? 12U : 4U; + } + + public static uint SizeOfUInt(bool is64Bit) + { + return is64Bit ? 8U : 4U; + } + + public static uint SizeOfUInt(DwarfAddressSize addressSize) + { + return (uint)(addressSize); + } + + public static uint SizeOfULEB128(ulong value) + { + if (value == 0) return 1; + + uint sizeOf = 0; + while (value != 0) + { + value >>= 7; + sizeOf++; + } + + return sizeOf; + } + + public static uint SizeOfILEB128(long value) + { + if (value == 0) return 1; + uint sizeOf = 0; + while (true) + { + sizeOf++; + var b = (byte) value; + value >>= 7; + bool isSignBitSet = (b & 0x40) != 0; + if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) + { + break; + } + } + + return sizeOf; + } + + public static DwarfAttributeEncoding GetAttributeEncoding(DwarfAttributeKindEx kind) + { + if ((uint)kind.Value >= AttributeToEncoding.Length) return DwarfAttributeEncoding.None; + return AttributeToEncoding[(int) kind.Value]; + } + + private static readonly DwarfAttributeEncoding[] Encodings = new DwarfAttributeEncoding[] + { + DwarfAttributeEncoding.None , // 0 + DwarfAttributeEncoding.Address , // DW_FORM_addr 0x01 + DwarfAttributeEncoding.None , // Reserved 0x02 + DwarfAttributeEncoding.Block , // DW_FORM_block2 0x03 + DwarfAttributeEncoding.Block , // DW_FORM_block4 0x04 + DwarfAttributeEncoding.Constant , // DW_FORM_data2 0x05 + DwarfAttributeEncoding.Constant , // DW_FORM_data4 0x06 + DwarfAttributeEncoding.Constant , // DW_FORM_data8 0x07 + DwarfAttributeEncoding.String , // DW_FORM_string 0x08 + DwarfAttributeEncoding.Block , // DW_FORM_block 0x09 + DwarfAttributeEncoding.Block , // DW_FORM_block1 0x0a + DwarfAttributeEncoding.Constant , // DW_FORM_data1 0x0b + DwarfAttributeEncoding.Flag , // DW_FORM_flag 0x0c + DwarfAttributeEncoding.Constant , // DW_FORM_sdata 0x0d + DwarfAttributeEncoding.String , // DW_FORM_strp 0x0e + DwarfAttributeEncoding.Constant , // DW_FORM_udata 0x0f + DwarfAttributeEncoding.Reference , // DW_FORM_ref_addr 0x10 + DwarfAttributeEncoding.Reference , // DW_FORM_ref1 0x11 + DwarfAttributeEncoding.Reference , // DW_FORM_ref2 0x12 + DwarfAttributeEncoding.Reference , // DW_FORM_ref4 0x13 + DwarfAttributeEncoding.Reference , // DW_FORM_ref8 0x14 + DwarfAttributeEncoding.Reference , // DW_FORM_ref_udata 0x15 + DwarfAttributeEncoding.Indirect , // DW_FORM_indirect 0x16 + DwarfAttributeEncoding.AddressPointer | + DwarfAttributeEncoding.LinePointer | + DwarfAttributeEncoding.LocationList | + DwarfAttributeEncoding.LocationListsPointer | + DwarfAttributeEncoding.MacroPointer | + DwarfAttributeEncoding.RangeList | + DwarfAttributeEncoding.RangeListsPointer | + DwarfAttributeEncoding.StringOffsetPointer, // DW_FORM_sec_offset 0x17 + DwarfAttributeEncoding.ExpressionLocation , // DW_FORM_exprloc 0x18 + DwarfAttributeEncoding.Flag , // DW_FORM_flag_present 0x19 + DwarfAttributeEncoding.String , // DW_FORM_strx 0x1a + DwarfAttributeEncoding.Address , // DW_FORM_addrx 0x1b + DwarfAttributeEncoding.Reference , // DW_FORM_ref_sup4 0x1c + DwarfAttributeEncoding.String , // DW_FORM_strp_sup 0x1d + DwarfAttributeEncoding.Constant , // DW_FORM_data16 0x1e + DwarfAttributeEncoding.String , // DW_FORM_line_strp 0x1f + DwarfAttributeEncoding.Reference , // DW_FORM_ref_sig8 0x20 + DwarfAttributeEncoding.Constant , // DW_FORM_implicit_const 0x21 + DwarfAttributeEncoding.LocationList , // DW_FORM_loclistx 0x22 + DwarfAttributeEncoding.RangeList , // DW_FORM_rnglistx 0x23 + DwarfAttributeEncoding.Reference , // DW_FORM_ref_sup8 0x24 + DwarfAttributeEncoding.String , // DW_FORM_strx1 0x25 + DwarfAttributeEncoding.String , // DW_FORM_strx2 0x26 + DwarfAttributeEncoding.String , // DW_FORM_strx3 0x27 + DwarfAttributeEncoding.String , // DW_FORM_strx4 0x28 + DwarfAttributeEncoding.Address , // DW_FORM_addrx1 0x29 + DwarfAttributeEncoding.Address , // DW_FORM_addrx2 0x2a + DwarfAttributeEncoding.Address , // DW_FORM_addrx3 0x2b + DwarfAttributeEncoding.Address , // DW_FORM_addrx4 0x2c + }; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs new file mode 100644 index 00000000000000..5358d883940dec --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs @@ -0,0 +1,17 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfIdentifierCaseKind : byte + { + Sensitive = DwarfNative.DW_ID_case_sensitive, + + UpCase = DwarfNative.DW_ID_up_case, + + DownCase = DwarfNative.DW_ID_down_case, + + Insensitive = DwarfNative.DW_ID_case_insensitive, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs new file mode 100644 index 00000000000000..5f727a1e09614c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs @@ -0,0 +1,105 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfInfoSection : DwarfRelocatableSection + { + private readonly List _units; + + public DwarfInfoSection() + { + _units = new List(); + } + + public IReadOnlyList Units => _units; + + public void AddUnit(DwarfUnit unit) + { + _units.Add(this, unit); + } + + public void RemoveUnit(DwarfUnit unit) + { + _units.Remove(this, unit); + } + + public DwarfUnit RemoveUnitAt(int index) + { + return _units.RemoveAt(this, index); + } + + protected override void Read(DwarfReader reader) + { + var addressRangeTable = reader.File.AddressRangeTable; + + while (reader.Offset < reader.Length) + { + // 7.5 Format of Debugging Information + // - Each such contribution consists of a compilation unit header + + var startOffset = Offset; + + reader.ClearResolveAttributeReferenceWithinCompilationUnit(); + + var cu = DwarfUnit.ReadInstance(reader, out var offsetEndOfUnit); + if (cu == null) + { + reader.Offset = offsetEndOfUnit; + continue; + } + + reader.CurrentUnit = cu; + + // Link AddressRangeTable to Unit + if (addressRangeTable.DebugInfoOffset == cu.Offset) + { + addressRangeTable.Unit = cu; + } + + AddUnit(cu); + } + + reader.ResolveAttributeReferenceWithinSection(); + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var unit in _units) + { + unit.Verify(diagnostics); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var offset = Offset; + foreach (var unit in Units) + { + layoutContext.CurrentUnit = unit; + unit.Offset = offset; + unit.UpdateLayoutInternal(layoutContext); + offset += unit.Size; + } + Size = offset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + Debug.Assert(Offset == writer.Offset); + foreach (var unit in _units) + { + writer.CurrentUnit = unit; + unit.WriteInternal(writer); + } + writer.CurrentUnit = null; + Debug.Assert(Size == writer.Offset - Offset); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs new file mode 100644 index 00000000000000..a7b48d88db1e02 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs @@ -0,0 +1,17 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfInlineKind : byte + { + NotInlined = DwarfNative.DW_INL_not_inlined, + + Inlined = DwarfNative.DW_INL_inlined, + + DeclaredNotInlined = DwarfNative.DW_INL_declared_not_inlined, + + DeclaredInlined = DwarfNative.DW_INL_declared_inlined, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs new file mode 100644 index 00000000000000..e00d5d24c8a32a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs @@ -0,0 +1,41 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Runtime.InteropServices; + +namespace LibObjectFile.Dwarf +{ + [StructLayout(LayoutKind.Explicit)] + public struct DwarfInteger + { + [FieldOffset(0)] + public ulong U64; + + [FieldOffset(0)] + public long I64; + + [FieldOffset(0)] + public sbyte I8; + + [FieldOffset(0)] + public byte U8; + + [FieldOffset(0)] + public short I16; + + [FieldOffset(0)] + public ushort U16; + + [FieldOffset(0)] + public int I32; + + [FieldOffset(0)] + public uint U32; + + public override string ToString() + { + return $"0x{U64:x16}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs new file mode 100644 index 00000000000000..511fd5720c60cb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs @@ -0,0 +1,59 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public readonly partial struct DwarfLanguageKindEx : IEquatable + { + public DwarfLanguageKindEx(ushort value) + { + Value = (DwarfLanguageKind)value; + } + + public DwarfLanguageKindEx(DwarfLanguageKind value) + { + Value = value; + } + + public readonly DwarfLanguageKind Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfLanguageKind)} (0x{Value:x4})"; + } + + public bool Equals(DwarfLanguageKindEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfLanguageKindEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(DwarfLanguageKindEx left, DwarfLanguageKindEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfLanguageKindEx left, DwarfLanguageKindEx right) + { + return !left.Equals(right); + } + + public static explicit operator uint(DwarfLanguageKindEx kind) => (uint)kind.Value; + + public static implicit operator DwarfLanguageKindEx(DwarfLanguageKind kind) => new DwarfLanguageKindEx(kind); + + public static implicit operator DwarfLanguageKind(DwarfLanguageKindEx kind) => kind.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs new file mode 100644 index 00000000000000..728d7f6e5ca7b3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs @@ -0,0 +1,37 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public class DwarfLayoutConfig + { + private DwarfAttributeForm _defaultAttributeFormForReference; + + public DwarfLayoutConfig() + { + DefaultAttributeFormForReference = DwarfAttributeForm.Ref4; + } + + public DwarfAttributeFormEx DefaultAttributeFormForReference + { + get => _defaultAttributeFormForReference; + set + { + switch (value.Value) + { + case DwarfAttributeForm.Ref1: + case DwarfAttributeForm.Ref2: + case DwarfAttributeForm.Ref4: + break; + default: + throw new ArgumentOutOfRangeException(nameof(value)); + } + + _defaultAttributeFormForReference = value; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs new file mode 100644 index 00000000000000..66977b60f757f7 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs @@ -0,0 +1,26 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfLayoutContext + { + internal DwarfLayoutContext(DwarfFile file, DwarfLayoutConfig config, DiagnosticBag diagnostics) + { + File = file; + Config = config; + Diagnostics = diagnostics; + } + + public DwarfFile File { get; } + + public DiagnosticBag Diagnostics { get; } + + public DwarfLayoutConfig Config { get; } + + public bool HasErrors => Diagnostics.HasErrors; + + public DwarfUnit CurrentUnit { get; internal set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs new file mode 100644 index 00000000000000..e6965b7118affb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs @@ -0,0 +1,184 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Globalization; + +namespace LibObjectFile.Dwarf +{ + public class DwarfLine : DwarfObject + { + public DwarfLine() + { + IsStatement = true; + } + + // ----------------------- + // DWARF 2 + // ----------------------- + + /// + /// The program-counter value corresponding to a machine instruction generated by the compiler. + /// + public ulong Address { get; set; } + + /// + /// An unsigned integer representing the index of an operation within a VLIW instruction. + /// The index of the first operation is 0. For non-VLIW architectures, this register will always be 0. + /// + public byte OperationIndex { get; set; } + + /// + /// The identity of the source file corresponding to a machine instruction. + /// + public DwarfFileName File { get; set; } + + /// + /// An unsigned integer indicating a source line number. + /// Lines are numbered beginning at 1. + /// The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. + /// + public uint Line { get; set; } + + /// + /// An unsigned integer indicating a column number within a source line. + /// Columns are numbered beginning at 1. The value 0 is reserved to indicate that a statement begins at the “left edge” of the line. + /// + public uint Column { get; set; } + + /// + /// A boolean indicating that the current instruction is a recommended breakpoint location. + /// A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement. + /// + public bool IsStatement { get; set; } + + /// + /// A boolean indicating that the current instruction is the beginning of a basic block. + /// + public bool IsBasicBlock { get; set; } + + // ----------------------- + // DWARF 3 + // ----------------------- + + /// + /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an entry breakpoint of a function. + /// + public bool IsPrologueEnd { get; set; } + + /// + /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an exit breakpoint of a function. + /// + public bool IsEpilogueBegin { get; set; } + + /// + /// An unsigned integer whose value encodes the applicable instruction set architecture for the current instruction. + /// + public ulong Isa { get; set; } + + // ----------------------- + // DWARF 4 + // ----------------------- + + /// + /// An unsigned integer identifying the block to which the current instruction belongs. + /// Discriminator values are assigned arbitrarily by the DWARF producer and serve to distinguish among multiple blocks that may all be + /// associated with the same source file, line, and column. + /// Where only one block exists for a given source position, the discriminator value should be zero. + /// + public ulong Discriminator { get; set; } + + public DwarfLine Clone() + { + return (DwarfLine) MemberwiseClone(); + } + + internal void Delta(DwarfLine against, out ulong deltaAddress, + out byte deltaOperationIndex, + out bool fileNameChanged, + out int deltaLine, + out int deltaColumn, + out bool isStatementChanged, + out bool isBasicBlockChanged, + out bool isPrologueEndChanged, + out bool isEpilogueBeginChanged, + out bool isaChanged, + out bool isDiscriminatorChanged) + { + deltaAddress = against.Address - this.Address; + deltaOperationIndex = (byte)(against.OperationIndex - this.OperationIndex); + fileNameChanged = !ReferenceEquals(this.File, against.File); + deltaLine = (int) ((long) against.Line - (long) this.Line); + deltaColumn = (int) ((long) against.Column - (long) this.Column); + isStatementChanged = against.IsStatement != this.IsStatement; + isBasicBlockChanged = against.IsBasicBlock != this.IsBasicBlock; + isPrologueEndChanged = against.IsPrologueEnd != this.IsPrologueEnd; + isEpilogueBeginChanged = against.IsEpilogueBegin != this.IsEpilogueBegin; + isaChanged = against.Isa != this.Isa; + isDiscriminatorChanged = against.Discriminator != this.Discriminator; + } + + internal void Reset(DwarfFileName firstFile, bool isStatement) + { + Address = 0; + File = firstFile; + Line = 1; + Column = 0; + this.IsStatement = isStatement; + IsBasicBlock = false; + + // DWARF 3 + IsPrologueEnd = false; + IsEpilogueBegin = false; + Isa = 0; + + // DWARF 5 + Discriminator = 0; + } + + internal void SpecialReset() + { + IsBasicBlock = false; + IsPrologueEnd = false; + IsEpilogueBegin = false; + Discriminator = 0; + } + + internal DwarfLineState ToState() + { + return new DwarfLineState() + { + Address = Address, + Column = Column, + Discriminator = Discriminator, + File = File, + Isa = Isa, + IsBasicBlock = IsBasicBlock, + IsEpilogueBegin = IsEpilogueBegin, + IsPrologueEnd = IsPrologueEnd, + IsStatement = IsStatement, + OperationIndex = OperationIndex, + Line = Line, + }; + } + + public override string ToString() + { + return $"{nameof(Offset)}: 0x{Offset:x8}, {nameof(Address)}: 0x{Address:x16}, {nameof(File)}: {File}, {nameof(Line)}: {Line,4}, {nameof(Column)}: {Column,2}, {nameof(IsStatement)}: {Bool2Str(IsStatement),5}, {nameof(IsBasicBlock)}: {Bool2Str(IsBasicBlock),5}, {nameof(IsPrologueEnd)}: {Bool2Str(IsPrologueEnd),5}, {nameof(IsEpilogueBegin)}: {Bool2Str(IsEpilogueBegin),5}, {nameof(Isa)}: {Isa,3}, {nameof(Discriminator)}: {Discriminator,3}"; + } + + private static string Bool2Str(bool value) => value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + } + + protected override void Read(DwarfReader reader) + { + } + + protected override void Write(DwarfWriter writer) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs new file mode 100644 index 00000000000000..57fb761dafc699 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs @@ -0,0 +1,1368 @@ + +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("Count = {LineSequences.Count,nq}")] + public sealed class DwarfLineProgramTable : DwarfObject + { + private readonly Dictionary _directoryNameToIndex; + private readonly Dictionary _fileNameToIndex; + private readonly List _directoryNames; + private readonly List _lineSequences; + private readonly DwarfLine _stateLine; + private byte _minimumInstructionLength; + private byte _maximumOperationsPerInstruction; + private readonly List _standardOpCodeLengths; + + public DwarfLineProgramTable() + { + FileNames = new List(); + _lineSequences = new List(); + _directoryNameToIndex = new Dictionary(); + _fileNameToIndex = new Dictionary(); + _directoryNames = new List(); + _stateLine = new DwarfLine(); + Version = 2; + LineBase = -5; + LineRange = 14; + _minimumInstructionLength = 1; + _maximumOperationsPerInstruction = 1; + _standardOpCodeLengths = new List(); + foreach (var stdOpCode in DefaultStandardOpCodeLengths) + { + _standardOpCodeLengths.Add(stdOpCode); + } + } + + public bool Is64BitEncoding { get; set; } + + public DwarfAddressSize AddressSize { get; set; } + + public ushort Version { get; set; } + + public sbyte LineBase { get; set; } + + public byte LineRange { get; set; } + + public ulong HeaderLength { get; private set; } + + public List StandardOpCodeLengths => _standardOpCodeLengths; + + public byte OpCodeBase + { + get => (byte)(StandardOpCodeLengths.Count + 1); + } + + public byte MinimumInstructionLength + { + get => _minimumInstructionLength; + set + { + if (value == 0) throw new ArgumentOutOfRangeException(nameof(value), "Must be > 0"); + _minimumInstructionLength = value; + } + } + + public byte MaximumOperationsPerInstruction + { + get => _maximumOperationsPerInstruction; + set + { + if (value == 0) throw new ArgumentOutOfRangeException(nameof(value), "Must be > 0"); + _maximumOperationsPerInstruction = value; + } + } + + public List FileNames { get; } + + public IReadOnlyList LineSequences => _lineSequences; + + public void AddLineSequence(DwarfLineSequence line) + { + _lineSequences.Add(this, line); + } + + public void RemoveLineSequence(DwarfLineSequence line) + { + _lineSequences.Remove(this, line); + } + + public DwarfLineSequence RemoveLineSequenceAt(int index) + { + return _lineSequences.RemoveAt(this, index); + } + + protected override void Read(DwarfReader reader) + { + var log = reader.Log; + var startOfSection = reader.Offset; + + reader.OffsetToLineProgramTable.Add(startOfSection, this); + + var unitLength = reader.ReadUnitLength(); + Is64BitEncoding = reader.Is64BitEncoding; + AddressSize = reader.AddressSize; + var startPosition = reader.Offset; + var version = reader.ReadU16(); + + if (version < 2 || version >= 5) + { + throw new NotSupportedException($"Version .debug_line {version} not supported"); + } + + Version = version; + + var header_length = reader.ReadUIntFromEncoding(); + HeaderLength = header_length; + var minimum_instruction_length = reader.ReadU8(); + MinimumInstructionLength = minimum_instruction_length; + + byte maximum_operations_per_instruction = 1; + if (version >= 4) + { + maximum_operations_per_instruction = reader.ReadU8(); + } + MaximumOperationsPerInstruction = maximum_operations_per_instruction; + + var default_is_stmt = reader.ReadU8(); + var line_base = reader.ReadI8(); + LineBase = line_base; + var line_range = reader.ReadU8(); + LineRange = line_range; + var opcode_base = reader.ReadU8(); + + if (log != null) + { + log.WriteLine(); + log.WriteLine($" Offset: 0x{startOfSection:x}"); + log.WriteLine($" Length: {unitLength}"); + log.WriteLine($" DWARF Version: {Version}"); + log.WriteLine($" Prologue Length: {header_length}"); + log.WriteLine($" Minimum Instruction Length: {minimum_instruction_length}"); + if (Version >= 4) + { + log.WriteLine($" Maximum Operations Per Instruction: {maximum_operations_per_instruction}"); + } + log.WriteLine($" Initial value of 'is_stmt': {default_is_stmt}"); + log.WriteLine($" Line Base: {line_base}"); + log.WriteLine($" Line Range: {line_range}"); + log.WriteLine($" Opcode Base: {opcode_base}"); + } + + _standardOpCodeLengths.Clear(); + for (int i = 1; i < opcode_base; i++) + { + var opcode_length = reader.ReadULEB128AsU32(); + _standardOpCodeLengths.Add((uint)opcode_length); + if (i - 1 <= DefaultStandardOpCodeLengths.Length && opcode_length != DefaultStandardOpCodeLengths[i - 1]) + { + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The standard opcode length at [{i}] = {opcode_length} is different from the expected length {DefaultStandardOpCodeLengths[i - 1]}"); + } + } + + if (log != null && opcode_base > 0) + { + log.WriteLine(); + log.WriteLine(" Opcodes:"); + for (int i = 0; i < _standardOpCodeLengths.Count; i++) + { + var argCount = _standardOpCodeLengths[i]; + log.WriteLine($" Opcode {i + 1} has {argCount} {((argCount == 0 || argCount > 1) ? "args" : "arg")}"); + } + } + + var directoriesOffset = reader.Offset; + var directories = new List(); + while (true) + { + var dir = reader.ReadStringUTF8NullTerminated(); + if (string.IsNullOrEmpty(dir)) + { + break; + } + + directories.Add(dir); + } + + if (log != null) + { + log.WriteLine(); + if (directories.Count > 0) + { + log.WriteLine($" The Directory Table (offset 0x{directoriesOffset:x}):"); + for (int i = 0; i < directories.Count; i++) + { + log.WriteLine($" {i + 1}\t{directories[i]}"); + } + } + else + { + log.WriteLine(" The Directory Table is empty."); + } + } + + var fileNamesOffset = reader.Offset; + bool printDumpHeader = true; + while (true) + { + var name = reader.ReadStringUTF8NullTerminated(); + + if (string.IsNullOrEmpty(name)) + { + break; + } + + var fileName = new DwarfFileName {Name = name}; + + var directoryIndex = reader.ReadULEB128(); + if (!name.Contains('/') && !name.Contains('\\') && directoryIndex > 0 && (directoryIndex - 1) < (ulong) directories.Count) + { + fileName.Directory = directories[(int) directoryIndex - 1]; + } + else + { + // log error + } + + fileName.Time = reader.ReadULEB128(); + fileName.Size = reader.ReadULEB128(); + + if (log != null) + { + if (printDumpHeader) + { + log.WriteLine(); + log.WriteLine($" The File Name Table (offset 0x{fileNamesOffset:x}):"); + log.WriteLine($" Entry\tDir\tTime\tSize\tName"); + printDumpHeader = false; + } + log.WriteLine($" {FileNames.Count + 1}\t{directoryIndex}\t{fileName.Time}\t{fileName.Size}\t{name}"); + } + + FileNames.Add(fileName); + } + + if (log != null && printDumpHeader) + { + log.WriteLine(); + log.WriteLine(" The File Name Table is empty."); + } + + var state = _stateLine; + state.Offset = reader.Offset; + var firstFileName = FileNames.Count > 0 ? FileNames[0] : null; + state.Reset(firstFileName, default_is_stmt != 0); + + var intFileNameCount = FileNames.Count; + + printDumpHeader = true; + var currentSequence = new DwarfLineSequence {Offset = state.Offset}; + + while (true) + { + var currentLength = reader.Offset - startPosition; + if (currentLength >= unitLength) + { + break; + } + + if (log != null) + { + if (printDumpHeader) + { + log.WriteLine(); + log.WriteLine(" Line Number Statements:"); + printDumpHeader = false; + } + + log.Write($" [0x{reader.Offset:x8}]"); + } + + var opcode = reader.ReadU8(); + switch (opcode) + { + case DwarfNative.DW_LNS_copy: + currentSequence.Add(state.Clone()); + state.Offset = reader.Offset; + state.SpecialReset(); + if (log != null) + { + log.WriteLine(" Copy"); + } + break; + case DwarfNative.DW_LNS_advance_pc: + { + var operation_advance = reader.ReadULEB128() * minimum_instruction_length; + + ulong deltaAddress = operation_advance; + if (version >= 4) + { + deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); + state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); + } + state.Address += deltaAddress; + + if (log != null) + { + if (minimum_instruction_length == 1) + { + log.WriteLine($" Advance PC by {deltaAddress} to 0x{state.Address:x}"); + } + else + { + log.WriteLine($" Advance PC by {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); + } + } + break; + } + case DwarfNative.DW_LNS_advance_line: + var deltaLine = reader.ReadILEB128(); + state.Line = (uint) (state.Line + deltaLine); + if (log != null) + { + log.WriteLine($" Advance Line by {deltaLine} to {state.Line}"); + } + break; + case DwarfNative.DW_LNS_set_file: + var fileIndex = reader.ReadLEB128AsI32(); + if (fileIndex == 0 || (fileIndex - 1) >= FileNames.Count ) + { + state.File = null; + } + else + { + state.File = FileNames[fileIndex - 1]; + } + if (log != null) + { + log.WriteLine($" Set File Name to entry {fileIndex} in the File Name Table"); + } + break; + case DwarfNative.DW_LNS_set_column: + state.Column = reader.ReadULEB128AsU32(); + if (log != null) + { + log.WriteLine($" Set column to {state.Column}"); + } + break; + case DwarfNative.DW_LNS_negate_stmt: + state.IsStatement = !state.IsStatement; + if (log != null) + { + log.WriteLine($" Set is_stmt to {(state.IsStatement ? 1 : 0)}"); + } + break; + case DwarfNative.DW_LNS_set_basic_block: + state.IsBasicBlock = true; + if (log != null) + { + log.WriteLine($" Set basic block"); + } + break; + case DwarfNative.DW_LNS_const_add_pc: + { + // Advance by opcode 255 + var adjusted_opcode = 255 - opcode_base; + var operation_advance = (ulong) adjusted_opcode / line_range; + + ulong deltaAddress = operation_advance; + if (version >= 4) + { + deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); + state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); + } + else + { + deltaAddress *= minimum_instruction_length; + } + state.Address += deltaAddress; + + if (log != null) + { + if (minimum_instruction_length == 1) + { + log.WriteLine($" Advance PC by constant {deltaAddress} to 0x{state.Address:x}"); + } + else + { + log.WriteLine($" Advance PC by constant {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); + } + } + break; + } + case DwarfNative.DW_LNS_fixed_advance_pc: + var fixedDelta = reader.ReadU16(); + state.Address += fixedDelta; + state.OperationIndex = 0; + if (log != null) + { + log.WriteLine($" Advance PC by fixed size amount {fixedDelta} to 0x{state.Address:x}"); + } + break; + case DwarfNative.DW_LNS_set_prologue_end: // DWARF 3 + state.IsPrologueEnd = true; + if (log != null) + { + log.WriteLine($" Set prologue_end to true"); + } + break; + case DwarfNative.DW_LNS_set_epilogue_begin: // DWARF 3 + state.IsEpilogueBegin = true; + if (log != null) + { + log.WriteLine($" Set epilogue_begin to true"); + } + break; + case DwarfNative.DW_LNS_set_isa: // DWARF 3 + state.Isa = reader.ReadULEB128(); + if (log != null) + { + log.WriteLine($" Set ISA to {state.Isa}"); + } + break; + case 0: + var sizeOfExtended = reader.ReadULEB128(); + var lengthOffset = reader.Offset; + var endOffset = reader.Offset + sizeOfExtended; + bool hasValidOpCode = true; + if (reader.Offset < endOffset) + { + var sub_opcode = reader.ReadU8(); + + // extended opcode + if (log != null) + { + log.Write($" Extended opcode {sub_opcode}: "); + } + + switch (sub_opcode) + { + case DwarfNative.DW_LNE_end_sequence: + currentSequence.Add(state.Clone()); + currentSequence.Size = reader.Offset - currentSequence.Offset; + AddLineSequence(currentSequence); + + currentSequence = new DwarfLineSequence() {Offset = reader.Offset}; + + state.Offset = reader.Offset; + state.Reset(firstFileName, default_is_stmt != 0); + if (log != null) + { + log.WriteLine("End of Sequence"); + log.WriteLine(); + } + break; + case DwarfNative.DW_LNE_set_address: + state.Address = reader.ReadUInt(); + state.OperationIndex = 0; + if (log != null) + { + log.WriteLine($"set Address to 0x{state.Address:x}"); + } + break; + case DwarfNative.DW_LNE_define_file: + var fileName = reader.ReadStringUTF8NullTerminated(); + var fileDirectoryIndex = reader.ReadLEB128AsI32(); + var fileTime = reader.ReadULEB128(); + var fileSize = reader.ReadULEB128(); + + var debugFileName = new DwarfFileName() {Name = fileName}; + debugFileName.Directory = fileDirectoryIndex == 0 || fileDirectoryIndex >= directories.Count ? null : directories[fileDirectoryIndex - 1]; + debugFileName.Time = fileTime; + debugFileName.Size = fileSize; + + state.File = debugFileName; + + if (log != null) + { + log.WriteLine("define new File Table entry"); + log.WriteLine($" Entry\tDir\tTime\tSize\tName"); + intFileNameCount++; + log.WriteLine($" {intFileNameCount + 1}\t{fileDirectoryIndex}\t{debugFileName.Time}\t{debugFileName.Size,-7}\t{fileName}"); + log.WriteLine(); + } + break; + case DwarfNative.DW_LNE_set_discriminator: // DWARF 4 + state.Discriminator = reader.ReadULEB128(); + if (log != null) + { + log.WriteLine($"set Discriminator to {state.Discriminator}"); + } + break; + default: + if (log != null) + { + log.WriteLine($"Unknown opcode"); + } + + hasValidOpCode = false; + // TODO: Add support for pluggable handling of extensions + reader.Diagnostics.Warning(DiagnosticId.DWARF_WRN_UnsupportedLineExtendedCode, $"Unsupported line extended opcode 0x{sub_opcode:x}"); + break; + } + + } + + // Log a warning if the end offset doesn't match what we are expecting + if (hasValidOpCode && reader.Offset != endOffset) + { + reader.Diagnostics.Warning(DiagnosticId.DWARF_WRN_InvalidExtendedOpCodeLength, $"Invalid length {sizeOfExtended} at offset 0x{lengthOffset:x}"); + } + + reader.Offset = endOffset; + break; + default: + if (opcode < opcode_base) + { + // If this is a standard opcode but not part of DWARF ("extension") + // we still want to be able to continue debugging + Debug.Assert(opcode > 0); + var numberOfLEB128Args = _standardOpCodeLengths[opcode - 1]; + for (ulong i = 0; i < numberOfLEB128Args; i++) + { + reader.ReadULEB128(); + } + + if (log != null) + { + log.WriteLine("Unsupported standard opcode with {numberOfLEB128Args} LEB128 args skipped"); + } + } + else + { + // Special opcode + var adjusted_opcode = opcode - opcode_base; + var operation_advance = (ulong)adjusted_opcode / line_range; + var line_inc = line_base + (adjusted_opcode % line_range); + state.Line = (uint)(state.Line + line_inc); + + ulong deltaAddress; + + if (version >= 4) + { + deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); + state.Address += deltaAddress; + state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); + } + else + { + deltaAddress = operation_advance; + state.Address = state.Address + operation_advance; + } + + if (log != null) + { + if (minimum_instruction_length == 1) + { + log.Write($" Special opcode {adjusted_opcode}: advance Address by {deltaAddress} to 0x{state.Address:x}"); + } + else + { + log.Write($" Special opcode {adjusted_opcode}: advance Address by {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); + } + + // TODO: Make verbose version + log.WriteLine($" and Line by {line_inc} to {state.Line}"); + } + + currentSequence.Add(state.Clone()); + state.Offset = reader.Offset; + state.SpecialReset(); + } + + break; + } + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + if (Version < 2 || Version >= 5) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version .debug_line {Version} not supported"); + } + + if (AddressSize == DwarfAddressSize.None) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Address size for .debug_line cannot be None/0"); + } + + if (StandardOpCodeLengths.Count < DefaultStandardOpCodeLengths.Length) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNumberOfStandardOpCodeLengths, $"Invalid length {StandardOpCodeLengths.Count} of {nameof(StandardOpCodeLengths)}. Expecting standard opcode length >= {DefaultStandardOpCodeLengths.Length} for {this}."); + } + else + { + for (int i = 0; i < DefaultStandardOpCodeLengths.Length; i++) + { + var opCodeLength = StandardOpCodeLengths[i]; + var expectedOpCodeLength = DefaultStandardOpCodeLengths[i]; + + if (opCodeLength != expectedOpCodeLength) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidStandardOpCodeLength, $"Invalid Standard OpCode Length {opCodeLength} for OpCode {i+1}. Expecting {expectedOpCodeLength} for {this}."); + } + } + } + + var startLine = LineBase; + var endLine = LineBase + LineRange; + if (startLine > 0 || endLine <= 0) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidStandardOpCodeLength, $"Invalid value for {nameof(LineBase)} = {LineBase} and/or {nameof(LineRange)} = {LineRange}. Expecting the range to cover the Line 0 for {this}"); + } + else + { + // TODO: take into account MaximumOperationsPerInstruction + var maxAdjustedOpCode = 255 - OpCodeBase; + int maxAddressIncrement = maxAdjustedOpCode / LineRange; + if (maxAdjustedOpCode <= 0 || maxAddressIncrement < MinimumInstructionLength) + { + diagnostics.Error(DiagnosticId.DWARF_WRN_CannotEncodeAddressIncrement, $"Cannot encode properly address increment with {nameof(LineBase)} = {LineBase}, {nameof(LineRange)} = {LineRange} and {nameof(StandardOpCodeLengths)}. The combination of {nameof(LineRange)} and {nameof(OpCodeBase)} are not making enough room for encoding address increment for {this}"); + } + } + + if (MaximumOperationsPerInstruction > 1 && Version < 4) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidMaximumOperationsPerInstruction, $"Invalid {nameof(MaximumOperationsPerInstruction)} = {MaximumOperationsPerInstruction}. Must be == 1 for {this}"); + } + + for (var i = 0; i < FileNames.Count; i++) + { + var fileName = FileNames[i]; + if (fileName == null) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNullFileNameEntry, $"Invalid null {nameof(FileNames)} entry at [{i}] for {this}"); + } + else + { + if (fileName.Name == null) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidFileName, $"Invalid null filename for {nameof(FileNames)} entry at [{i}] for {this}"); + } + } + } + + // Check that address increment is positive + foreach (var lineSequence in _lineSequences) + { + var lines = lineSequence.Lines; + ulong previousAddress = 0; + for (var i = 0; i < lines.Count; i++) + { + var line = lines[i]; + var deltaAddress = (long)line.Address - (long)previousAddress; + if (deltaAddress < 0) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNegativeAddressDelta, $"Invalid address 0x{line.Address:x} after previous 0x{previousAddress:x} for debug line entry at [{i}]. The increment must be positive. for {this}"); + } + previousAddress = line.Address; + + if (line.OperationIndex >= MaximumOperationsPerInstruction) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidOperationIndex, $"Invalid operation index {line.OperationIndex} must be < {MaximumOperationsPerInstruction} for debug line entry at [{i}] for {this}"); + } + } + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + ulong sizeOf = 0; + + // unit_length + sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); + + sizeOf += 2; // version (uhalf) + + // header length (calculated just after file names and size added as well) + sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); + ulong headerLengthStart = sizeOf; + + // minimum_instruction_length + // default_is_stmt + // line_base + // line_range + // opcode_base + sizeOf += 5; + + // StandardOpCodeLengths + foreach (var opcodeLength in _standardOpCodeLengths) + { + sizeOf += DwarfHelper.SizeOfULEB128(opcodeLength); + } + + // Write directory names + _directoryNameToIndex.Clear(); + _directoryNames.Clear(); + _fileNameToIndex.Clear(); + + foreach (var fileName in FileNames) + { + uint dirIndex = 0; + if (fileName.Directory != null) + { + var directoryName = fileName.Directory; + RecordDirectory(directoryName, ref sizeOf, out dirIndex); + } + + _fileNameToIndex.Add(fileName, (uint)_fileNameToIndex.Count + 1); + + sizeOf += (ulong)Encoding.UTF8.GetByteCount(fileName.Name) + 1; + sizeOf += DwarfHelper.SizeOfULEB128(dirIndex); + sizeOf += DwarfHelper.SizeOfULEB128(fileName.Time); + sizeOf += DwarfHelper.SizeOfULEB128(fileName.Size); + } + // byte 0 => end of directory names + end of file names + sizeOf += 2; + + HeaderLength = sizeOf - headerLengthStart; + + LayoutDebugLineOpCodes(ref sizeOf, OpCodeBase); + + Size = sizeOf; + } + + private void RecordDirectory(string directoryName, ref ulong sizeOf, out uint dirIndex) + { + if (!_directoryNameToIndex.TryGetValue(directoryName, out dirIndex)) + { + uint directoryIndex = (uint) _directoryNames.Count + 1; + _directoryNameToIndex.Add(directoryName, directoryIndex); + sizeOf += (ulong) Encoding.UTF8.GetByteCount(directoryName) + 1; + _directoryNames.Add(directoryName); + } + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + + writer.Is64BitEncoding = Is64BitEncoding; + writer.WriteUnitLength(Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding)); + + writer.WriteU16(Version); + writer.WriteUIntFromEncoding(HeaderLength); + + var startOfHeader = writer.Offset; + + writer.WriteU8(MinimumInstructionLength); + + if (Version >= 4) + { + writer.WriteU8(MaximumOperationsPerInstruction); + } + + // default_is_stmt + writer.WriteU8(1); + + // line_base + writer.WriteI8(LineBase); + + // line_range + writer.WriteU8(LineRange); + + // opcode_base + writer.WriteU8(OpCodeBase); + + // standard_opcode_lengths + foreach (var opcodeLength in StandardOpCodeLengths) + { + writer.WriteULEB128(opcodeLength); + } + + // Write directory names + foreach (var directoryName in _directoryNames) + { + writer.WriteStringUTF8NullTerminated(directoryName); + } + // empty string + writer.WriteU8(0); + + // Write filenames + foreach (var fileName in FileNames) + { + writer.WriteStringUTF8NullTerminated(fileName.Name); + + uint directoryIndex = 0; + if (fileName.Directory != null) + { + directoryIndex = _directoryNameToIndex[fileName.Directory]; + } + + writer.WriteULEB128(directoryIndex); + writer.WriteULEB128(fileName.Time); + writer.WriteULEB128(fileName.Size); + } + // empty string + writer.WriteU8(0); + + var headSizeWritten = writer.Offset - startOfHeader; + Debug.Assert(HeaderLength == headSizeWritten, $"Expected Header Length: {HeaderLength} != Written Header Length: {headSizeWritten}"); + + WriteDebugLineOpCodes(writer, OpCodeBase); + + Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); + } + + private void WriteDebugLineOpCodes(DwarfWriter writer, uint opCodeBase) + { + var previousLineState = new DwarfLineState(); + var firstFile = FileNames.Count > 0 ? FileNames[0] : null; + previousLineState.Reset(firstFile, true); + var initialState = previousLineState; + + uint maxDeltaAddressPerSpecialCode; + byte maxOperationAdvance = (byte) ((255 - OpCodeBase) / LineRange); + if (Version >= 4) + { + maxDeltaAddressPerSpecialCode = (uint)maxOperationAdvance / MaximumOperationsPerInstruction; + } + else + { + maxDeltaAddressPerSpecialCode = maxOperationAdvance; + } + maxDeltaAddressPerSpecialCode *= MinimumInstructionLength; + + bool hasSetAddress; + + foreach (var lineSequence in _lineSequences) + { + var lines = lineSequence.Lines; + + hasSetAddress = false; + + for (var lineIndex = 0; lineIndex < lines.Count; lineIndex++) + { + var debugLine = lines[lineIndex]; + ulong deltaAddress; + int deltaOperationIndex; + bool fileNameChanged; + int deltaLine; + int deltaColumn; + bool isStatementChanged; + bool isBasicBlockChanged; + bool isEndSequenceChanged; + bool isPrologueEndChanged; + bool isEpilogueBeginChanged; + bool isaChanged; + bool isDiscriminatorChanged; + + bool hasGeneratedRow = false; + + var debugLineState = debugLine.ToState(); + + previousLineState.Delta(debugLineState, out deltaAddress, + out deltaOperationIndex, + out fileNameChanged, + out deltaLine, + out deltaColumn, + out isStatementChanged, + out isBasicBlockChanged, + out isEndSequenceChanged, + out isPrologueEndChanged, + out isEpilogueBeginChanged, + out isaChanged, + out isDiscriminatorChanged); + + Debug.Assert(debugLine.Offset == writer.Offset, $"Expected Debug Line Offset: {debugLine.Offset} != Written Offset: {writer.Offset}"); + + // DW_LNS_set_column + if (deltaColumn != 0) + { + writer.WriteU8(DwarfNative.DW_LNS_set_column); + writer.WriteULEB128(debugLine.Column); + } + + // DW_LNS_set_file or DW_LNE_define_file + if (fileNameChanged) + { + var fileName = debugLine.File; + + // DW_LNS_set_file + if (_fileNameToIndex.TryGetValue(fileName, out var fileIndex)) + { + writer.WriteU8(DwarfNative.DW_LNS_set_file); + writer.WriteULEB128(fileIndex); + } + else + { + // DW_LNE_define_file + writer.WriteU8(0); + uint dirIndex = fileName.Directory != null && _directoryNameToIndex.ContainsKey(fileName.Directory) ? _directoryNameToIndex[fileName.Directory] : 0; + + ulong sizeOfInlineFileName = 1; + sizeOfInlineFileName += (ulong) Encoding.UTF8.GetByteCount(fileName.Name) + 1; + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(dirIndex); + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Time); + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Size); + + writer.WriteULEB128(sizeOfInlineFileName); + + writer.WriteU8(DwarfNative.DW_LNE_define_file); + writer.WriteStringUTF8NullTerminated(fileName.Name); + writer.WriteULEB128(dirIndex); + writer.WriteULEB128(fileName.Time); + writer.WriteULEB128(fileName.Size); + } + } + + // DW_LNS_copy + if (isBasicBlockChanged && !debugLine.IsBasicBlock || + isPrologueEndChanged && !debugLine.IsPrologueEnd || + isEpilogueBeginChanged && !debugLine.IsEpilogueBegin) + { + writer.WriteU8(DwarfNative.DW_LNS_copy); + isDiscriminatorChanged = debugLine.Discriminator != 0; + hasGeneratedRow = true; + } + + // DW_LNS_set_basic_block + if (isBasicBlockChanged && debugLine.IsBasicBlock) + { + writer.WriteU8(DwarfNative.DW_LNS_set_basic_block); + } + + // DW_LNS_set_prologue_end + if (isPrologueEndChanged && debugLine.IsPrologueEnd) + { + writer.WriteU8(DwarfNative.DW_LNS_set_prologue_end); + } + + // DW_LNS_set_epilogue_begin + if (isEpilogueBeginChanged && debugLine.IsEpilogueBegin) + { + writer.WriteU8(DwarfNative.DW_LNS_set_epilogue_begin); + } + + // DW_LNS_set_isa + if (isaChanged) + { + writer.WriteU8(DwarfNative.DW_LNS_set_isa); + writer.WriteULEB128(debugLine.Isa); + } + + // DW_LNE_set_discriminator + if (isDiscriminatorChanged) + { + writer.WriteU8(0); + writer.WriteULEB128(1 + DwarfHelper.SizeOfULEB128(debugLine.Discriminator)); + writer.WriteU8(DwarfNative.DW_LNE_set_discriminator); + writer.WriteULEB128(debugLine.Discriminator); + } + + // DW_LNS_negate_stmt + if (isStatementChanged) + { + writer.WriteU8(DwarfNative.DW_LNS_negate_stmt); + } + + bool isEndOfSequence = lineIndex + 1 == lines.Count; + bool canEncodeSpecial = !isEndOfSequence; + bool canEncodeLineInSpecialCode = canEncodeSpecial && deltaLine >= LineBase && deltaLine < LineBase + LineRange; + + bool operationAdvancedEncoded = false; + + // Pre-encode address if necessary + if (!hasSetAddress) + { + writer.WriteU8(0); + writer.WriteULEB128(1 + DwarfHelper.SizeOfUInt(writer.AddressSize)); + writer.WriteU8(DwarfNative.DW_LNE_set_address); + writer.WriteAddress(DwarfRelocationTarget.Code, debugLine.Address); + operationAdvancedEncoded = true; + deltaAddress = 0; + hasSetAddress = true; + } + + // DW_LNS_advance_line + // In case we can't encode the line advance via special code + if (!canEncodeLineInSpecialCode) + { + if (deltaLine != 0) + { + writer.WriteU8(DwarfNative.DW_LNS_advance_line); + writer.WriteILEB128(deltaLine); + deltaLine = 0; + } + } + + + if (deltaAddress > maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * maxDeltaAddressPerSpecialCode)) + { + ulong deltaAddressSpecialOpCode255; + + if (Version >= 4) + { + deltaAddressSpecialOpCode255 = (((ulong) previousLineState.OperationIndex + maxOperationAdvance) / MaximumOperationsPerInstruction); + deltaOperationIndex = debugLine.OperationIndex - (byte) ((previousLineState.OperationIndex + maxOperationAdvance) % MaximumOperationsPerInstruction); + } + else + { + deltaAddressSpecialOpCode255 = maxOperationAdvance; + deltaOperationIndex = 0; + } + + Debug.Assert(deltaAddressSpecialOpCode255 * MinimumInstructionLength < deltaAddress); + deltaAddress -= deltaAddressSpecialOpCode255 * MinimumInstructionLength; + + writer.WriteU8(DwarfNative.DW_LNS_const_add_pc); + } + + var operation_advance = deltaAddress * MaximumOperationsPerInstruction / MinimumInstructionLength + debugLine.OperationIndex; + + bool canEncodeAddressInSpecialCode = false; + ulong opcode = 256; + if (canEncodeSpecial && (operation_advance > 0 || deltaOperationIndex != 0 || deltaLine != 0)) + { + opcode = operation_advance * LineRange + opCodeBase + (ulong) (deltaLine - LineBase); + if (opcode > 255) + { + if (deltaLine != 0) + { + opcode = opCodeBase + (ulong) (deltaLine - LineBase); + } + } + else + { + canEncodeAddressInSpecialCode = true; + } + } + + if (!operationAdvancedEncoded && !canEncodeAddressInSpecialCode) + { + if (deltaAddress > 0 || deltaOperationIndex != 0) + { + writer.WriteU8(DwarfNative.DW_LNS_advance_pc); + writer.WriteULEB128(operation_advance); + } + } + + // Special opcode + if (opcode <= 255) + { + writer.WriteU8((byte) opcode); + debugLineState.SpecialReset(); + hasGeneratedRow = true; + } + + if (isEndOfSequence) + { + writer.WriteU8(0); + writer.WriteULEB128(1); + writer.WriteU8(DwarfNative.DW_LNE_end_sequence); + + hasGeneratedRow = true; + + hasSetAddress = false; + previousLineState = initialState; + previousLineState.Reset(firstFile, true); + } + else + { + previousLineState = debugLineState; + } + + if (!hasGeneratedRow) + { + writer.WriteU8(DwarfNative.DW_LNS_copy); + } + + Debug.Assert(debugLine.Size == writer.Offset - debugLine.Offset, $"Expected Debug Line Size: {debugLine.Size} != Written Size: {writer.Offset - debugLine.Offset}"); + } + } + } + + private void LayoutDebugLineOpCodes(ref ulong sizeOf, uint opCodeBase) + { + var previousLineState = new DwarfLineState(); + var firstFile = FileNames.Count > 0 ? FileNames[0] : null; + previousLineState.Reset(firstFile, true); + var initialState = previousLineState; + + uint maxDeltaAddressPerSpecialCode; + byte maxOperationAdvance = (byte)((255 - OpCodeBase) / LineRange); + if (Version >= 4) + { + maxDeltaAddressPerSpecialCode = (uint)maxOperationAdvance / MaximumOperationsPerInstruction; + } + else + { + maxDeltaAddressPerSpecialCode = maxOperationAdvance; + } + maxDeltaAddressPerSpecialCode *= MinimumInstructionLength; + + bool hasSetAddress; + + foreach (var lineSequence in _lineSequences) + { + var lines = lineSequence.Lines; + + lineSequence.Offset = Offset + sizeOf; + hasSetAddress = false; + + for (var lineIndex = 0; lineIndex < lines.Count; lineIndex++) + { + var debugLine = lines[lineIndex]; + ulong deltaAddress; + int deltaOperationIndex; + bool fileNameChanged; + int deltaLine; + int deltaColumn; + bool isStatementChanged; + bool isBasicBlockChanged; + bool isEndSequenceChanged; + bool isPrologueEndChanged; + bool isEpilogueBeginChanged; + bool isaChanged; + bool isDiscriminatorChanged; + + bool hasGeneratedRow = false; + + var debugLineState = debugLine.ToState(); + + previousLineState.Delta(debugLineState, out deltaAddress, + out deltaOperationIndex, + out fileNameChanged, + out deltaLine, + out deltaColumn, + out isStatementChanged, + out isBasicBlockChanged, + out isEndSequenceChanged, + out isPrologueEndChanged, + out isEpilogueBeginChanged, + out isaChanged, + out isDiscriminatorChanged); + + debugLine.Offset = Offset + sizeOf; + + // DW_LNS_set_column + if (deltaColumn != 0) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_column); + sizeOf += DwarfHelper.SizeOfULEB128(debugLine.Column); //writer.WriteLEB128(debugLine.Column)); + } + + // DW_LNS_set_file or DW_LNE_define_file + if (fileNameChanged) + { + var fileName = debugLine.File; + + // DW_LNS_set_file + if (_fileNameToIndex.TryGetValue(fileName, out var fileIndex)) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_file); + sizeOf += DwarfHelper.SizeOfULEB128(fileIndex); // writer.WriteLEB128(fileIndex); + } + else + { + // DW_LNE_define_file + sizeOf += 1; // writer.WriteU8(0); + uint dirIndex = fileName.Directory != null && _directoryNameToIndex.ContainsKey(fileName.Directory) ? _directoryNameToIndex[fileName.Directory] : 0; + + ulong sizeOfInlineFileName = 1; + sizeOfInlineFileName += (ulong) Encoding.UTF8.GetByteCount(fileName.Name) + 1; + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(dirIndex); + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Time); + sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Size); + + sizeOf += DwarfHelper.SizeOfULEB128(sizeOfInlineFileName); + sizeOf += sizeOfInlineFileName; + } + } + + // DW_LNS_copy + if (isBasicBlockChanged && !debugLine.IsBasicBlock || + isPrologueEndChanged && !debugLine.IsPrologueEnd || + isEpilogueBeginChanged && !debugLine.IsEpilogueBegin) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_copy); + isDiscriminatorChanged = debugLine.Discriminator != 0; + hasGeneratedRow = true; + } + + // DW_LNS_set_basic_block + if (isBasicBlockChanged && debugLine.IsBasicBlock) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_basic_block); + } + + // DW_LNS_set_prologue_end + if (isPrologueEndChanged && debugLine.IsPrologueEnd) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_prologue_end); + } + + // DW_LNS_set_epilogue_begin + if (isEpilogueBeginChanged && debugLine.IsEpilogueBegin) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_epilogue_begin); + } + + // DW_LNS_set_isa + if (isaChanged) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_isa); + sizeOf += DwarfHelper.SizeOfULEB128(debugLine.Isa); // writer.WriteLEB128(debugLine.Isa); + } + + // DW_LNE_set_discriminator + if (isDiscriminatorChanged) + { + sizeOf += 1; // writer.WriteU8(0); + var sizeOfDiscriminator = DwarfHelper.SizeOfULEB128(debugLine.Discriminator); + sizeOf += DwarfHelper.SizeOfULEB128(1 + sizeOfDiscriminator); // writer.WriteLEB128(1 + DwarfHelper.SizeOfLEB128(debugLine.Discriminator)); + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNE_set_discriminator); + sizeOf += sizeOfDiscriminator; // writer.WriteLEB128(debugLine.Discriminator); + } + + // DW_LNS_negate_stmt + if (isStatementChanged) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_negate_stmt); + } + + bool isEndOfSequence = lineIndex + 1 == lines.Count; + bool canEncodeSpecial = !isEndOfSequence; + bool canEncodeLineInSpecialCode = canEncodeSpecial && deltaLine >= LineBase && deltaLine < LineBase + LineRange; + bool operationAdvancedEncoded = false; + + if (!hasSetAddress) + { + sizeOf += 1; // writer.WriteU8(0); + var sizeOfAddress = DwarfHelper.SizeOfUInt(AddressSize); + sizeOf += DwarfHelper.SizeOfULEB128(1 + sizeOfAddress); // writer.WriteLEB128(DwarfHelper.SizeOfNativeInt(writer.IsTargetAddress64Bit)); + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNE_set_address); + sizeOf += sizeOfAddress; // writer.WriteLEB128(debugLine.Address); + operationAdvancedEncoded = true; + deltaAddress = 0; + hasSetAddress = true; + } + else if (deltaAddress > maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * maxDeltaAddressPerSpecialCode)) + { + ulong deltaAddressSpecialOpCode255; + + if (Version >= 4) + { + deltaAddressSpecialOpCode255 = (((ulong) previousLineState.OperationIndex + maxOperationAdvance) / MaximumOperationsPerInstruction); + deltaOperationIndex = debugLine.OperationIndex - (byte) ((previousLineState.OperationIndex + maxOperationAdvance) % MaximumOperationsPerInstruction); + } + else + { + deltaAddressSpecialOpCode255 = maxOperationAdvance; + deltaOperationIndex = 0; + } + + Debug.Assert(deltaAddressSpecialOpCode255 * MinimumInstructionLength < deltaAddress); + deltaAddress -= deltaAddressSpecialOpCode255 * MinimumInstructionLength; + + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_const_add_pc); + } + + // DW_LNS_advance_line + if (!canEncodeLineInSpecialCode) + { + if (deltaLine != 0) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_advance_line); + sizeOf += DwarfHelper.SizeOfILEB128(deltaLine); // writer.WriteSignedLEB128(deltaLine); + deltaLine = 0; + } + } + + var operation_advance = deltaAddress * MaximumOperationsPerInstruction / MinimumInstructionLength + debugLine.OperationIndex; + + bool canEncodeAddress = false; + ulong opcode = 256; + if (canEncodeSpecial && (operation_advance > 0 || deltaOperationIndex > 0 || deltaLine != 0)) + { + opcode = operation_advance * LineRange + opCodeBase + (ulong) (deltaLine - LineBase); + if (opcode > 255) + { + if (deltaLine != 0) + { + opcode = opCodeBase + (ulong) (deltaLine - LineBase); + } + } + else + { + canEncodeAddress = true; + } + } + + if (!operationAdvancedEncoded && !canEncodeAddress) + { + if (deltaAddress > 0 || deltaOperationIndex > 0) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_advance_pc); + sizeOf += DwarfHelper.SizeOfULEB128(operation_advance); // writer.WriteLEB128(operation_advance); + } + } + + // Special opcode + if (opcode <= 255) + { + sizeOf += 1; // writer.WriteU8((byte)opcode); + debugLineState.SpecialReset(); + hasGeneratedRow = true; + } + + if (isEndOfSequence) + { + sizeOf += 3; // writer.WriteU8(0); + // writer.WriteLEB128(1); + // writer.WriteU8(DwarfNative.DW_LNE_end_sequence); + previousLineState = initialState; + previousLineState.Reset(firstFile, true); + hasGeneratedRow = true; + hasSetAddress = false; + } + else + { + previousLineState = debugLineState; + } + + if (!hasGeneratedRow) + { + sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_copy); + } + + debugLine.Size = Offset + sizeOf - debugLine.Offset; + } + lineSequence.Size = Offset + sizeOf - lineSequence.Offset; + } + } + + private static ReadOnlySpan DefaultStandardOpCodeLengths => new ReadOnlySpan(new byte[12] + { + 0, // DwarfNative.DW_LNS_copy + 1, // DwarfNative.DW_LNS_advance_pc + 1, // DwarfNative.DW_LNS_advance_line + 1, // DwarfNative.DW_LNS_set_file + 1, // DwarfNative.DW_LNS_set_column + 0, // DwarfNative.DW_LNS_negate_stmt + 0, // DwarfNative.DW_LNS_set_basic_block + 0, // DwarfNative.DW_LNS_const_add_pc + 1, // DwarfNative.DW_LNS_fixed_advance_pc + 0, // DwarfNative.DW_LNS_set_prologue_end + 0, // DwarfNative.DW_LNS_set_epilogue_begin + 1, // DwarfNative.DW_LNS_set_isa + }); + + public override string ToString() + { + return $"Section .debug_line, {nameof(Version)}: {Version}, {nameof(Is64BitEncoding)}: {Is64BitEncoding}, {nameof(FileNames)}: {FileNames.Count}, {nameof(LineSequences)}: {LineSequences.Count}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs new file mode 100644 index 00000000000000..a259852175b8d4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs @@ -0,0 +1,90 @@ + +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("Count = {LineTables.Count,nq}")] + public sealed class DwarfLineSection : DwarfRelocatableSection + { + private readonly List _tables; + + + public DwarfLineSection() + { + _tables = new List(); + } + + public IReadOnlyList LineTables => _tables; + + public void AddLineProgramTable(DwarfLineProgramTable line) + { + _tables.Add(this, line); + } + + public void RemoveLineProgramTable(DwarfLineProgramTable line) + { + _tables.Remove(this, line); + } + + public DwarfLineProgramTable RemoveLineProgramTableAt(int index) + { + return _tables.RemoveAt(this, index); + } + + protected override void Read(DwarfReader reader) + { + while (reader.Offset < reader.Length) + { + var programTable = new DwarfLineProgramTable(); + programTable.Offset = reader.Offset; + programTable.ReadInternal(reader); + AddLineProgramTable(programTable); + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var dwarfLineProgramTable in _tables) + { + dwarfLineProgramTable.Verify(diagnostics); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + ulong sizeOf = 0; + + foreach (var dwarfLineProgramTable in _tables) + { + dwarfLineProgramTable.Offset = Offset + sizeOf; + dwarfLineProgramTable.UpdateLayoutInternal(layoutContext); + sizeOf += dwarfLineProgramTable.Size; + } + Size = sizeOf; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + + foreach (var dwarfLineProgramTable in _tables) + { + dwarfLineProgramTable.WriteInternal(writer); + } + + Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); + } + + public override string ToString() + { + return $"Section .debug_line, Entries: {_tables.Count}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs new file mode 100644 index 00000000000000..8846b710dcb13c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs @@ -0,0 +1,71 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + /// + /// A sequence of + /// + [DebuggerDisplay("Count = {Lines.Count,nq}")] + public class DwarfLineSequence : DwarfObject, IEnumerable + { + private readonly List _lines; + + public DwarfLineSequence() + { + _lines = new List(); + } + + public IReadOnlyList Lines => _lines; + + public void Add(DwarfLine line) + { + _lines.Add(this, line); + } + + public void Remove(DwarfLine line) + { + _lines.Remove(this, line); + } + + public DwarfLine RemoveAt(int index) + { + return _lines.RemoveAt(this, index); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + // This is implemented in DwarfLineSection + } + + protected override void Read(DwarfReader reader) + { + // This is implemented in DwarfLineSection + } + + protected override void Write(DwarfWriter writer) + { + // This is implemented in DwarfLineSection + } + + public List.Enumerator GetEnumerator() + { + return _lines.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable) _lines).GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs new file mode 100644 index 00000000000000..aebdab8c71baa0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs @@ -0,0 +1,157 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Globalization; + +namespace LibObjectFile.Dwarf +{ + /// + /// Internal struct used to track line state via a struct, created via + /// + internal struct DwarfLineState + { + // ----------------------- + // DWARF 2 + // ----------------------- + + /// + /// The program-counter value corresponding to a machine instruction generated by the compiler. + /// + public ulong Address { get; set; } + + /// + /// An unsigned integer representing the index of an operation within a VLIW instruction. + /// The index of the first operation is 0. For non-VLIW architectures, this register will always be 0. + /// + public byte OperationIndex { get; set; } + + /// + /// The identity of the source file corresponding to a machine instruction. + /// + public DwarfFileName File { get; set; } + + /// + /// An unsigned integer indicating a source line number. + /// Lines are numbered beginning at 1. + /// The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. + /// + public uint Line { get; set; } + + /// + /// An unsigned integer indicating a column number within a source line. + /// Columns are numbered beginning at 1. The value 0 is reserved to indicate that a statement begins at the “left edge” of the line. + /// + public uint Column { get; set; } + + /// + /// A boolean indicating that the current instruction is a recommended breakpoint location. + /// A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement. + /// + public bool IsStatement { get; set; } + + /// + /// A boolean indicating that the current instruction is the beginning of a basic block. + /// + public bool IsBasicBlock { get; set; } + + /// + /// A boolean indicating that the current address is that of the first byte after the end of a sequence of target machine instructions. + /// IsEndSequence terminates a sequence of lines; therefore other information in the same row is not meaningful. + /// + public bool IsEndSequence { get; set; } + + // ----------------------- + // DWARF 3 + // ----------------------- + + /// + /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an entry breakpoint of a function. + /// + public bool IsPrologueEnd { get; set; } + + /// + /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an exit breakpoint of a function. + /// + public bool IsEpilogueBegin { get; set; } + + /// + /// An unsigned integer whose value encodes the applicable instruction set architecture for the current instruction. + /// + public ulong Isa { get; set; } + + // ----------------------- + // DWARF 4 + // ----------------------- + + /// + /// An unsigned integer identifying the block to which the current instruction belongs. + /// Discriminator values are assigned arbitrarily by the DWARF producer and serve to distinguish among multiple blocks that may all be + /// associated with the same source file, line, and column. + /// Where only one block exists for a given source position, the discriminator value should be zero. + /// + public ulong Discriminator { get; set; } + + internal void Delta(in DwarfLineState against, + out ulong deltaAddress, + out int deltaOperationIndex, + out bool fileNameChanged, + out int deltaLine, + out int deltaColumn, + out bool isStatementChanged, + out bool isBasicBlockChanged, + out bool isEndSequenceChanged, + out bool isPrologueEndChanged, + out bool isEpilogueBeginChanged, + out bool isaChanged, + out bool isDiscriminatorChanged) + { + deltaAddress = against.Address - this.Address; + deltaOperationIndex = against.OperationIndex - this.OperationIndex; + fileNameChanged = !ReferenceEquals(this.File, against.File); + deltaLine = (int)((long)against.Line - (long)this.Line); + deltaColumn = (int)((long)against.Column - (long)this.Column); + isStatementChanged = against.IsStatement != this.IsStatement; + isBasicBlockChanged = against.IsBasicBlock != this.IsBasicBlock; + isEndSequenceChanged = against.IsEndSequence != this.IsEndSequence; + isPrologueEndChanged = against.IsPrologueEnd != this.IsPrologueEnd; + isEpilogueBeginChanged = against.IsEpilogueBegin != this.IsEpilogueBegin; + isaChanged = against.Isa != this.Isa; + isDiscriminatorChanged = against.Discriminator != this.Discriminator; + } + + internal void Reset(DwarfFileName firstFile, bool isStatement) + { + Address = 0; + File = firstFile; + Line = 1; + Column = 0; + this.IsStatement = isStatement; + IsBasicBlock = false; + IsEndSequence = false; + + // DWARF 3 + IsPrologueEnd = false; + IsEpilogueBegin = false; + Isa = 0; + + // DWARF 5 + Discriminator = 0; + } + + internal void SpecialReset() + { + IsBasicBlock = false; + IsPrologueEnd = false; + IsEpilogueBegin = false; + Discriminator = 0; + } + + public override string ToString() + { + return $"{nameof(Address)}: 0x{Address:x16}, {nameof(File)}: {File}, {nameof(Line)}: {Line,4}, {nameof(Column)}: {Column,2}, {nameof(IsStatement)}: {Bool2Str(IsStatement),5}, {nameof(IsBasicBlock)}: {Bool2Str(IsBasicBlock),5}, {nameof(IsEndSequence)}: {Bool2Str(IsEndSequence),5}, {nameof(IsPrologueEnd)}: {Bool2Str(IsPrologueEnd),5}, {nameof(IsEpilogueBegin)}: {Bool2Str(IsEpilogueBegin),5}, {nameof(Isa)}: {Isa,3}, {nameof(Discriminator)}: {Discriminator,3}"; + } + + private static string Bool2Str(bool value) => value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs new file mode 100644 index 00000000000000..e6a9f46cd65400 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs @@ -0,0 +1,55 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public struct DwarfLocation + { + public DwarfLocation(int value) + { + AsValue = new DwarfInteger() { I64 = value }; + AsObject = null; + } + + public DwarfLocation(DwarfExpression expression) + { + AsValue = default; + AsObject = expression; + } + + public DwarfLocation(DwarfLocationList locationList) + { + AsValue = default; + AsObject = locationList; + } + + public DwarfInteger AsValue; + + public object AsObject; + + public DwarfExpression AsExpression => AsObject as DwarfExpression; + + public DwarfLocationList AsLocationList => AsObject as DwarfLocationList; + + public DwarfDIE AsReference => AsObject as DwarfDIE; + + public override string ToString() + { + if (AsExpression != null) return $"Location Expression: {AsExpression}"; + if (AsLocationList != null) return $"Location List: {AsLocationList}"; + if (AsReference != null) return $"Location Reference: {AsReference}"; + return $"Location Constant: {AsValue}"; + } + + public static implicit operator DwarfLocation(DwarfExpression value) + { + return new DwarfLocation(value); + } + + public static implicit operator DwarfLocation(DwarfLocationList value) + { + return new DwarfLocation(value); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs new file mode 100644 index 00000000000000..8a5f373647df92 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs @@ -0,0 +1,84 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; + +namespace LibObjectFile.Dwarf +{ + + public class DwarfLocationList : DwarfContainer + { + private readonly List _locationListEntries; + + public DwarfLocationList() + { + _locationListEntries = new List(); + } + + public IReadOnlyList LocationListEntries => _locationListEntries; + + public void AddLocationListEntry(DwarfLocationListEntry locationListEntry) + { + _locationListEntries.Add(this, locationListEntry); + } + + public void RemoveLocationList(DwarfLocationListEntry locationListEntry) + { + _locationListEntries.Remove(this, locationListEntry); + } + + public DwarfLocationListEntry RemoveLocationListEntryAt(int index) + { + return _locationListEntries.RemoveAt(this, index); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var endOffset = Offset; + + foreach (var locationListEntry in _locationListEntries) + { + locationListEntry.Offset = endOffset; + locationListEntry.UpdateLayoutInternal(layoutContext); + endOffset += locationListEntry.Size; + } + + // End of list + endOffset += 2 * DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); + + Size = endOffset - Offset; + } + + protected override void Read(DwarfReader reader) + { + reader.OffsetToLocationList.Add(reader.Offset, this); + + while (reader.Offset < reader.Length) + { + var locationListEntry = new DwarfLocationListEntry(); + locationListEntry.ReadInternal(reader); + + if (locationListEntry.Start == 0 && locationListEntry.End == 0) + { + // End of list + return; + } + + _locationListEntries.Add(locationListEntry); + } + } + + protected override void Write(DwarfWriter writer) + { + foreach (var locationListEntry in _locationListEntries) + { + locationListEntry.WriteInternal(writer); + } + + // End of list + writer.WriteUInt(0); + writer.WriteUInt(0); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs new file mode 100644 index 00000000000000..3c1d8910cf3c30 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs @@ -0,0 +1,69 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public class DwarfLocationListEntry : DwarfObject + { + public ulong Start; + + public ulong End; + + public DwarfExpression Expression; + + public DwarfLocationListEntry() + { + } + + protected override void Read(DwarfReader reader) + { + Start = reader.ReadUInt(); + End = reader.ReadUInt(); + + if (Start == 0 && End == 0) + { + // End of list + return; + } + + bool isBaseAddress = + (reader.AddressSize == DwarfAddressSize.Bit64 && Start == ulong.MaxValue) || + (reader.AddressSize == DwarfAddressSize.Bit32 && Start == uint.MaxValue); + if (isBaseAddress) + { + // Sets new base address for following entries + return; + } + + Expression = new DwarfExpression(); + Expression.ReadInternal(reader, inLocationSection: true); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var endOffset = Offset; + + endOffset += 2 * DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); + if (Expression != null) + { + Expression.Offset = endOffset; + Expression.UpdateLayoutInternal(layoutContext, inLocationSection: true); + endOffset += Expression.Size; + } + + Size = endOffset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + writer.WriteUInt(Start); + writer.WriteUInt(End); + + if (Expression != null) + { + Expression.WriteInternal(writer, inLocationSection: true); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs new file mode 100644 index 00000000000000..e2057af19437b2 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs @@ -0,0 +1,89 @@ + +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("Count = {LineTables.Count,nq}")] + public sealed class DwarfLocationSection : DwarfRelocatableSection + { + private readonly List _locationLists; + + public DwarfLocationSection() + { + _locationLists = new List(); + } + + public IReadOnlyList LocationLists => _locationLists; + + public void AddLocationList(DwarfLocationList locationList) + { + _locationLists.Add(this, locationList); + } + + public void RemoveLocationList(DwarfLocationList locationList) + { + _locationLists.Remove(this, locationList); + } + + public DwarfLocationList RemoveLineProgramTableAt(int index) + { + return _locationLists.RemoveAt(this, index); + } + + protected override void Read(DwarfReader reader) + { + while (reader.Offset < reader.Length) + { + var locationList = new DwarfLocationList(); + locationList.Offset = reader.Offset; + locationList.ReadInternal(reader); + AddLocationList(locationList); + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var locationList in _locationLists) + { + locationList.Verify(diagnostics); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + ulong sizeOf = 0; + + foreach (var locationList in _locationLists) + { + locationList.Offset = Offset + sizeOf; + locationList.UpdateLayoutInternal(layoutContext); + sizeOf += locationList.Size; + } + Size = sizeOf; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + + foreach (var locationList in _locationLists) + { + locationList.WriteInternal(writer); + } + + Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); + } + + public override string ToString() + { + return $"Section .debug_loc, Entries: {_locationLists.Count}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs new file mode 100644 index 00000000000000..4ebbe5874bf1ac --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs @@ -0,0 +1,92 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + + public abstract class DwarfObject : ObjectFileNode + { + public DwarfFile GetParentFile() + { + var check = (ObjectFileNode)this; + while (check != null) + { + if (check is DwarfFile dwarfFile) return dwarfFile; + check = check.Parent; + } + return null; + } + + public DwarfUnit GetParentUnit() + { + var check = (ObjectFileNode)this; + while (check != null) + { + if (check is DwarfUnit dwarfUnit) return dwarfUnit; + check = check.Parent; + } + return null; + } + + public DwarfSection GetParentSection() + { + var check = (ObjectFileNode)this; + while (check != null) + { + if (check is DwarfSection dwarfSection) return dwarfSection; + check = check.Parent; + } + return null; + } + } + + public abstract class DwarfObject : DwarfObject where TContainer : ObjectFileNode + { + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is TContainer)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(TContainer)}"); + } + } + + + /// + /// Gets the containing . Might be null if this section or segment + /// does not belong to an existing . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + public new TContainer Parent + { + get => (TContainer)base.Parent; + internal set => base.Parent = value; + } + + internal void UpdateLayoutInternal(DwarfLayoutContext layoutContext) + { + UpdateLayout(layoutContext); + } + + protected abstract void UpdateLayout(DwarfLayoutContext layoutContext); + + + internal void ReadInternal(DwarfReader reader) + { + Read(reader); + } + + protected abstract void Read(DwarfReader reader); + + + internal void WriteInternal(DwarfWriter writer) + { + Write(writer); + } + + protected abstract void Write(DwarfWriter writer); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs new file mode 100644 index 00000000000000..241d89b2ad29c4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs @@ -0,0 +1,1172 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class DwarfOperation : DwarfObject + { + public DwarfOperationKindEx Kind { get; set; } + + public object Operand0 { get; set; } + + public DwarfInteger Operand1; + + public DwarfInteger Operand2; + + private string DebuggerDisplay => $"{Kind} {Operand1} {Operand2} {Operand0}"; + + protected override void Read(DwarfReader reader) + { + Offset = reader.Offset; + var kind = new DwarfOperationKindEx(reader.ReadU8()); + Kind = kind; + + switch (kind.Value) + { + case DwarfOperationKind.Addr: + Operand1.U64 = reader.ReadUInt(); + break; + case DwarfOperationKind.Const1u: + Operand1.U64 = reader.ReadU8(); + break; + case DwarfOperationKind.Const1s: + Operand1.I64 = reader.ReadI8(); + break; + case DwarfOperationKind.Const2u: + Operand1.U64 = reader.ReadU16(); + break; + case DwarfOperationKind.Const2s: + Operand1.I64 = reader.ReadI16(); + break; + + case DwarfOperationKind.Const4u: + Operand1.U64 = reader.ReadU32(); + break; + case DwarfOperationKind.Const4s: + Operand1.I64 = reader.ReadU32(); + break; + + case DwarfOperationKind.Const8u: + Operand1.U64 = reader.ReadU64(); + break; + + case DwarfOperationKind.Const8s: + Operand1.I64 = reader.ReadI64(); + break; + + case DwarfOperationKind.Constu: + Operand1.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.Consts: + Operand1.I64 = reader.ReadILEB128(); + break; + + case DwarfOperationKind.Deref: + case DwarfOperationKind.Dup: + case DwarfOperationKind.Drop: + case DwarfOperationKind.Over: + case DwarfOperationKind.Swap: + case DwarfOperationKind.Rot: + case DwarfOperationKind.Xderef: + case DwarfOperationKind.Abs: + case DwarfOperationKind.And: + case DwarfOperationKind.Div: + case DwarfOperationKind.Minus: + case DwarfOperationKind.Mod: + case DwarfOperationKind.Mul: + case DwarfOperationKind.Neg: + case DwarfOperationKind.Not: + case DwarfOperationKind.Or: + case DwarfOperationKind.Plus: + case DwarfOperationKind.Shl: + case DwarfOperationKind.Shr: + case DwarfOperationKind.Shra: + case DwarfOperationKind.Xor: + case DwarfOperationKind.Eq: + case DwarfOperationKind.Ge: + case DwarfOperationKind.Gt: + case DwarfOperationKind.Le: + case DwarfOperationKind.Lt: + case DwarfOperationKind.Ne: + case DwarfOperationKind.Nop: + case DwarfOperationKind.PushObjectAddress: + case DwarfOperationKind.FormTlsAddress: + case DwarfOperationKind.CallFrameCfa: + break; + + case DwarfOperationKind.Pick: + Operand1.U64 = reader.ReadU8(); + break; + + case DwarfOperationKind.PlusUconst: + Operand1.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.Bra: + case DwarfOperationKind.Skip: + // TODO: resolve branches to DwarfOperation + Operand1.I64 = reader.ReadI16(); + break; + + case DwarfOperationKind.Lit0: + case DwarfOperationKind.Lit1: + case DwarfOperationKind.Lit2: + case DwarfOperationKind.Lit3: + case DwarfOperationKind.Lit4: + case DwarfOperationKind.Lit5: + case DwarfOperationKind.Lit6: + case DwarfOperationKind.Lit7: + case DwarfOperationKind.Lit8: + case DwarfOperationKind.Lit9: + case DwarfOperationKind.Lit10: + case DwarfOperationKind.Lit11: + case DwarfOperationKind.Lit12: + case DwarfOperationKind.Lit13: + case DwarfOperationKind.Lit14: + case DwarfOperationKind.Lit15: + case DwarfOperationKind.Lit16: + case DwarfOperationKind.Lit17: + case DwarfOperationKind.Lit18: + case DwarfOperationKind.Lit19: + case DwarfOperationKind.Lit20: + case DwarfOperationKind.Lit21: + case DwarfOperationKind.Lit22: + case DwarfOperationKind.Lit23: + case DwarfOperationKind.Lit24: + case DwarfOperationKind.Lit25: + case DwarfOperationKind.Lit26: + case DwarfOperationKind.Lit27: + case DwarfOperationKind.Lit28: + case DwarfOperationKind.Lit29: + case DwarfOperationKind.Lit30: + case DwarfOperationKind.Lit31: + Operand1.U64 = (ulong)((byte)kind.Value - (byte)DwarfOperationKind.Lit0); + break; + + case DwarfOperationKind.Reg0: + case DwarfOperationKind.Reg1: + case DwarfOperationKind.Reg2: + case DwarfOperationKind.Reg3: + case DwarfOperationKind.Reg4: + case DwarfOperationKind.Reg5: + case DwarfOperationKind.Reg6: + case DwarfOperationKind.Reg7: + case DwarfOperationKind.Reg8: + case DwarfOperationKind.Reg9: + case DwarfOperationKind.Reg10: + case DwarfOperationKind.Reg11: + case DwarfOperationKind.Reg12: + case DwarfOperationKind.Reg13: + case DwarfOperationKind.Reg14: + case DwarfOperationKind.Reg15: + case DwarfOperationKind.Reg16: + case DwarfOperationKind.Reg17: + case DwarfOperationKind.Reg18: + case DwarfOperationKind.Reg19: + case DwarfOperationKind.Reg20: + case DwarfOperationKind.Reg21: + case DwarfOperationKind.Reg22: + case DwarfOperationKind.Reg23: + case DwarfOperationKind.Reg24: + case DwarfOperationKind.Reg25: + case DwarfOperationKind.Reg26: + case DwarfOperationKind.Reg27: + case DwarfOperationKind.Reg28: + case DwarfOperationKind.Reg29: + case DwarfOperationKind.Reg30: + case DwarfOperationKind.Reg31: + Operand1.U64 = (ulong)kind.Value - (ulong)DwarfOperationKind.Reg0; + break; + + case DwarfOperationKind.Breg0: + case DwarfOperationKind.Breg1: + case DwarfOperationKind.Breg2: + case DwarfOperationKind.Breg3: + case DwarfOperationKind.Breg4: + case DwarfOperationKind.Breg5: + case DwarfOperationKind.Breg6: + case DwarfOperationKind.Breg7: + case DwarfOperationKind.Breg8: + case DwarfOperationKind.Breg9: + case DwarfOperationKind.Breg10: + case DwarfOperationKind.Breg11: + case DwarfOperationKind.Breg12: + case DwarfOperationKind.Breg13: + case DwarfOperationKind.Breg14: + case DwarfOperationKind.Breg15: + case DwarfOperationKind.Breg16: + case DwarfOperationKind.Breg17: + case DwarfOperationKind.Breg18: + case DwarfOperationKind.Breg19: + case DwarfOperationKind.Breg20: + case DwarfOperationKind.Breg21: + case DwarfOperationKind.Breg22: + case DwarfOperationKind.Breg23: + case DwarfOperationKind.Breg24: + case DwarfOperationKind.Breg25: + case DwarfOperationKind.Breg26: + case DwarfOperationKind.Breg27: + case DwarfOperationKind.Breg28: + case DwarfOperationKind.Breg29: + case DwarfOperationKind.Breg30: + case DwarfOperationKind.Breg31: + Operand1.U64 = (ulong)kind.Value - (ulong)DwarfOperationKind.Breg0; + Operand2.I64 = reader.ReadILEB128(); + break; + + case DwarfOperationKind.Regx: + Operand1.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.Fbreg: + Operand1.I64 = reader.ReadILEB128(); + break; + + case DwarfOperationKind.Bregx: + Operand1.U64 = reader.ReadULEB128(); + Operand2.I64 = reader.ReadILEB128(); + break; + + case DwarfOperationKind.Piece: + Operand1.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.DerefSize: + Operand1.U64 = reader.ReadU8(); + break; + + case DwarfOperationKind.XderefSize: + Operand1.U64 = reader.ReadU8(); + break; + + case DwarfOperationKind.Call2: + { + var offset = reader.ReadU16(); + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinSection(dieRef, false); + break; + } + + case DwarfOperationKind.Call4: + { + var offset = reader.ReadU32(); + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinSection(dieRef, false); + break; + } + + case DwarfOperationKind.CallRef: + { + var offset = reader.ReadUIntFromEncoding(); + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinSection(dieRef, false); + break; + } + + case DwarfOperationKind.BitPiece: + Operand1.U64 = reader.ReadULEB128(); + Operand2.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.ImplicitValue: + { + var length = reader.ReadULEB128(); + Operand0 = reader.ReadAsStream(length); + break; + } + + case DwarfOperationKind.StackValue: + break; + + case DwarfOperationKind.ImplicitPointer: + case DwarfOperationKind.GNUImplicitPointer: + { + ulong offset; + // a reference to a debugging information entry that describes the dereferenced object’s value + if (reader.CurrentUnit.Version == 2) + { + offset = reader.ReadUInt(); + } + else + { + offset = reader.ReadUIntFromEncoding(); + } + // a signed number that is treated as a byte offset from the start of that value + Operand1.I64 = reader.ReadILEB128(); + + if (offset != 0) + { + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinSection(dieRef, false); + } + break; + } + + case DwarfOperationKind.Addrx: + case DwarfOperationKind.GNUAddrIndex: + case DwarfOperationKind.Constx: + case DwarfOperationKind.GNUConstIndex: + Operand1.U64 = reader.ReadULEB128(); + break; + + case DwarfOperationKind.EntryValue: + case DwarfOperationKind.GNUEntryValue: + { + var subExpression = new DwarfExpression(); + subExpression.ReadInternal(reader); + Operand0 = subExpression; + break; + } + + case DwarfOperationKind.ConstType: + case DwarfOperationKind.GNUConstType: + { + // The DW_OP_const_type operation takes three operands + + // The first operand is an unsigned LEB128 integer that represents the offset + // of a debugging information entry in the current compilation unit, which + // must be a DW_TAG_base_type entry that provides the type of the constant provided + var offset = reader.ReadULEB128(); + if (offset != 0) + { + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); + } + Operand1.U64 = ReadEncodedValue(reader, kind, out var sizeOfEncodedValue); + // Encode size of encoded value in Operand1 + Operand2.U64 = sizeOfEncodedValue; + break; + } + + case DwarfOperationKind.RegvalType: + case DwarfOperationKind.GNURegvalType: + { + // The DW_OP_regval_type operation provides the contents of a given register + // interpreted as a value of a given type + + // The first operand is an unsigned LEB128 number, which identifies a register + // whose contents is to be pushed onto the stack + Operand1.U64 = reader.ReadULEB128(); + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + var offset = reader.ReadULEB128(); + if (offset != 0) + { + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); + } + break; + } + + case DwarfOperationKind.DerefType: + case DwarfOperationKind.GNUDerefType: + case DwarfOperationKind.XderefType: + { + // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: + // it pops the top stack entry and treats it as an address. + + // This operand is a 1-byte unsigned integral constant whose value which is the + // same as the size of the base type referenced by the second operand + Operand1.U64 = reader.ReadU8(); + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + var offset = reader.ReadULEB128(); + if (offset != 0) + { + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); + } + break; + } + + case DwarfOperationKind.Convert: + case DwarfOperationKind.GNUConvert: + case DwarfOperationKind.Reinterpret: + case DwarfOperationKind.GNUReinterpret: + { + ulong offset = reader.ReadULEB128(); + if (offset != 0) + { + var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); + reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); + } + break; + } + + case DwarfOperationKind.GNUPushTlsAddress: + case DwarfOperationKind.GNUUninit: + break; + + case DwarfOperationKind.GNUEncodedAddr: + { + Operand1.U64 = ReadEncodedValue(reader, kind, out var sizeOfEncodedValue); + Operand2.U64 = sizeOfEncodedValue; + break; + } + + case DwarfOperationKind.GNUParameterRef: + Operand1.U64 = reader.ReadU32(); + break; + + default: + throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {kind} is not supported"); + } + + // Store the size of the current op + Size = reader.Offset - Offset; + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var endOffset = Offset; + // 1 byte per opcode + endOffset += 1; + + switch (Kind.Value) + { + case DwarfOperationKind.Addr: + endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); + break; + case DwarfOperationKind.Const1u: + case DwarfOperationKind.Const1s: + case DwarfOperationKind.Pick: + case DwarfOperationKind.DerefSize: + case DwarfOperationKind.XderefSize: + endOffset += 1; + break; + case DwarfOperationKind.Const2u: + case DwarfOperationKind.Const2s: + case DwarfOperationKind.Bra: + case DwarfOperationKind.Skip: + case DwarfOperationKind.Call2: + endOffset += 2; + break; + case DwarfOperationKind.Const4u: + case DwarfOperationKind.Const4s: + case DwarfOperationKind.Call4: + endOffset += 4; + break; + case DwarfOperationKind.Const8u: + case DwarfOperationKind.Const8s: + endOffset += 8; + break; + + case DwarfOperationKind.Constu: + case DwarfOperationKind.PlusUconst: + case DwarfOperationKind.Regx: + case DwarfOperationKind.Piece: + case DwarfOperationKind.Addrx: + case DwarfOperationKind.GNUAddrIndex: + case DwarfOperationKind.Constx: + case DwarfOperationKind.GNUConstIndex: + endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); + break; + + case DwarfOperationKind.Consts: + case DwarfOperationKind.Fbreg: + endOffset += DwarfHelper.SizeOfILEB128(Operand1.I64); + break; + + case DwarfOperationKind.Deref: + case DwarfOperationKind.Dup: + case DwarfOperationKind.Drop: + case DwarfOperationKind.Over: + case DwarfOperationKind.Swap: + case DwarfOperationKind.Rot: + case DwarfOperationKind.Xderef: + case DwarfOperationKind.Abs: + case DwarfOperationKind.And: + case DwarfOperationKind.Div: + case DwarfOperationKind.Minus: + case DwarfOperationKind.Mod: + case DwarfOperationKind.Mul: + case DwarfOperationKind.Neg: + case DwarfOperationKind.Not: + case DwarfOperationKind.Or: + case DwarfOperationKind.Plus: + case DwarfOperationKind.Shl: + case DwarfOperationKind.Shr: + case DwarfOperationKind.Shra: + case DwarfOperationKind.Xor: + case DwarfOperationKind.Eq: + case DwarfOperationKind.Ge: + case DwarfOperationKind.Gt: + case DwarfOperationKind.Le: + case DwarfOperationKind.Lt: + case DwarfOperationKind.Ne: + case DwarfOperationKind.Nop: + case DwarfOperationKind.PushObjectAddress: + case DwarfOperationKind.FormTlsAddress: + case DwarfOperationKind.CallFrameCfa: + case DwarfOperationKind.Lit0: + case DwarfOperationKind.Lit1: + case DwarfOperationKind.Lit2: + case DwarfOperationKind.Lit3: + case DwarfOperationKind.Lit4: + case DwarfOperationKind.Lit5: + case DwarfOperationKind.Lit6: + case DwarfOperationKind.Lit7: + case DwarfOperationKind.Lit8: + case DwarfOperationKind.Lit9: + case DwarfOperationKind.Lit10: + case DwarfOperationKind.Lit11: + case DwarfOperationKind.Lit12: + case DwarfOperationKind.Lit13: + case DwarfOperationKind.Lit14: + case DwarfOperationKind.Lit15: + case DwarfOperationKind.Lit16: + case DwarfOperationKind.Lit17: + case DwarfOperationKind.Lit18: + case DwarfOperationKind.Lit19: + case DwarfOperationKind.Lit20: + case DwarfOperationKind.Lit21: + case DwarfOperationKind.Lit22: + case DwarfOperationKind.Lit23: + case DwarfOperationKind.Lit24: + case DwarfOperationKind.Lit25: + case DwarfOperationKind.Lit26: + case DwarfOperationKind.Lit27: + case DwarfOperationKind.Lit28: + case DwarfOperationKind.Lit29: + case DwarfOperationKind.Lit30: + case DwarfOperationKind.Lit31: + case DwarfOperationKind.Reg0: + case DwarfOperationKind.Reg1: + case DwarfOperationKind.Reg2: + case DwarfOperationKind.Reg3: + case DwarfOperationKind.Reg4: + case DwarfOperationKind.Reg5: + case DwarfOperationKind.Reg6: + case DwarfOperationKind.Reg7: + case DwarfOperationKind.Reg8: + case DwarfOperationKind.Reg9: + case DwarfOperationKind.Reg10: + case DwarfOperationKind.Reg11: + case DwarfOperationKind.Reg12: + case DwarfOperationKind.Reg13: + case DwarfOperationKind.Reg14: + case DwarfOperationKind.Reg15: + case DwarfOperationKind.Reg16: + case DwarfOperationKind.Reg17: + case DwarfOperationKind.Reg18: + case DwarfOperationKind.Reg19: + case DwarfOperationKind.Reg20: + case DwarfOperationKind.Reg21: + case DwarfOperationKind.Reg22: + case DwarfOperationKind.Reg23: + case DwarfOperationKind.Reg24: + case DwarfOperationKind.Reg25: + case DwarfOperationKind.Reg26: + case DwarfOperationKind.Reg27: + case DwarfOperationKind.Reg28: + case DwarfOperationKind.Reg29: + case DwarfOperationKind.Reg30: + case DwarfOperationKind.Reg31: + case DwarfOperationKind.StackValue: + case DwarfOperationKind.GNUPushTlsAddress: + case DwarfOperationKind.GNUUninit: + break; + + case DwarfOperationKind.Breg0: + case DwarfOperationKind.Breg1: + case DwarfOperationKind.Breg2: + case DwarfOperationKind.Breg3: + case DwarfOperationKind.Breg4: + case DwarfOperationKind.Breg5: + case DwarfOperationKind.Breg6: + case DwarfOperationKind.Breg7: + case DwarfOperationKind.Breg8: + case DwarfOperationKind.Breg9: + case DwarfOperationKind.Breg10: + case DwarfOperationKind.Breg11: + case DwarfOperationKind.Breg12: + case DwarfOperationKind.Breg13: + case DwarfOperationKind.Breg14: + case DwarfOperationKind.Breg15: + case DwarfOperationKind.Breg16: + case DwarfOperationKind.Breg17: + case DwarfOperationKind.Breg18: + case DwarfOperationKind.Breg19: + case DwarfOperationKind.Breg20: + case DwarfOperationKind.Breg21: + case DwarfOperationKind.Breg22: + case DwarfOperationKind.Breg23: + case DwarfOperationKind.Breg24: + case DwarfOperationKind.Breg25: + case DwarfOperationKind.Breg26: + case DwarfOperationKind.Breg27: + case DwarfOperationKind.Breg28: + case DwarfOperationKind.Breg29: + case DwarfOperationKind.Breg30: + case DwarfOperationKind.Breg31: + endOffset += DwarfHelper.SizeOfILEB128(Operand2.I64); + break; + + case DwarfOperationKind.Bregx: + endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); + endOffset += DwarfHelper.SizeOfILEB128(Operand2.I64); + break; + + case DwarfOperationKind.CallRef: + endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); + break; + + case DwarfOperationKind.BitPiece: + endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); + endOffset += DwarfHelper.SizeOfULEB128(Operand2.U64); + break; + + case DwarfOperationKind.ImplicitValue: + if (Operand0 == null) + { + layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of implicit value operation {this} from DIE cannot be null."); + } + else if (Operand0 is Stream stream) + { + var streamSize = (ulong)stream.Length; + endOffset += DwarfHelper.SizeOfULEB128(streamSize); + endOffset += streamSize; + } + else + { + layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of implicit value operation {this} must be a System.IO.Stream."); + } + + break; + + case DwarfOperationKind.ImplicitPointer: + case DwarfOperationKind.GNUImplicitPointer: + // a reference to a debugging information entry that describes the dereferenced object’s value + if (layoutContext.CurrentUnit.Version == 2) + { + endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); + } + else + { + endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.Is64BitEncoding); + } + + // a signed number that is treated as a byte offset from the start of that value + endOffset += DwarfHelper.SizeOfILEB128(Operand1.I64); + break; + + case DwarfOperationKind.EntryValue: + case DwarfOperationKind.GNUEntryValue: + if (Operand0 == null) + { + endOffset += DwarfHelper.SizeOfULEB128(0); + } + else if (Operand0 is DwarfExpression expr) + { + expr.Offset = endOffset; + expr.UpdateLayoutInternal(layoutContext); + endOffset += DwarfHelper.SizeOfULEB128(expr.Size); + } + else + { + layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of EntryValue operation {this} must be a {nameof(DwarfExpression)} instead of {Operand0.GetType()}."); + } + + break; + + case DwarfOperationKind.ConstType: + case DwarfOperationKind.GNUConstType: + { + // The DW_OP_const_type operation takes three operands + + // The first operand is an unsigned LEB128 integer that represents the offset + // of a debugging information entry in the current compilation unit, which + // must be a DW_TAG_base_type entry that provides the type of the constant provided + + endOffset += SizeOfDIEReference(layoutContext); + endOffset += SizeOfEncodedValue(Kind, Operand1.U64, (byte)Operand2.U64, layoutContext.CurrentUnit.AddressSize); + break; + } + + case DwarfOperationKind.RegvalType: + case DwarfOperationKind.GNURegvalType: + { + // The DW_OP_regval_type operation provides the contents of a given register + // interpreted as a value of a given type + + // The first operand is an unsigned LEB128 number, which identifies a register + // whose contents is to be pushed onto the stack + endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + endOffset += SizeOfDIEReference(layoutContext); + break; + } + + case DwarfOperationKind.DerefType: + case DwarfOperationKind.GNUDerefType: + case DwarfOperationKind.XderefType: + { + // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: + // it pops the top stack entry and treats it as an address. + + // This operand is a 1-byte unsigned integral constant whose value which is the + // same as the size of the base type referenced by the second operand + endOffset += 1; + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + endOffset += SizeOfDIEReference(layoutContext); + break; + } + + case DwarfOperationKind.Convert: + case DwarfOperationKind.GNUConvert: + case DwarfOperationKind.Reinterpret: + case DwarfOperationKind.GNUReinterpret: + endOffset += SizeOfDIEReference(layoutContext); + break; + + case DwarfOperationKind.GNUEncodedAddr: + endOffset += SizeOfEncodedValue(Kind, Operand1.U64, (byte)Operand2.U64, layoutContext.CurrentUnit.AddressSize); + break; + + case DwarfOperationKind.GNUParameterRef: + endOffset += 4; + break; + + default: + throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {Kind} is not supported"); + } + + Size = endOffset - Offset; + } + + private ulong SizeOfDIEReference(DwarfLayoutContext context) + { + if (Operand0 == null) + { + return DwarfHelper.SizeOfULEB128(0); + } + else if (Operand0 is DwarfDIE die) + { + // TODO: check that die reference is within this section + + if (die.Offset < Offset) + { + return DwarfHelper.SizeOfULEB128(die.Offset); + } + else + { + // TODO: encode depending on Context.DefaultAttributeFormForReference + return DwarfHelper.SizeOfILEB128(uint.MaxValue); + } + } + else + { + context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of {Kind} operation {this} must be a {nameof(DwarfDIE)} instead of {Operand0.GetType()}."); + } + + return 0U; + } + + private ulong SizeOfEncodedValue(DwarfOperationKindEx kind, ulong value, byte size, DwarfAddressSize addressSize) + { + switch (size) + { + case 0: + return 1 + DwarfHelper.SizeOfUInt(addressSize); + case 1: + return 1 + 1; + case 2: + return 1 + 2; + case 4: + return 1 + 4; + case 8: + return 1 + 8; + default: + // TODO: report via diagnostics in Verify + throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); + } + } + + protected override void Write(DwarfWriter writer) + { + var startOpOffset = Offset; + Debug.Assert(startOpOffset == Offset); + + writer.WriteU8((byte)Kind); + + switch (Kind.Value) + { + case DwarfOperationKind.Addr: + writer.WriteAddress(DwarfRelocationTarget.Code, Operand1.U64); + break; + case DwarfOperationKind.Const1u: + case DwarfOperationKind.Const1s: + case DwarfOperationKind.Pick: + case DwarfOperationKind.DerefSize: + case DwarfOperationKind.XderefSize: + writer.WriteU8((byte)Operand1.U64); + break; + + case DwarfOperationKind.Const2u: + case DwarfOperationKind.Const2s: + writer.WriteU16((ushort)Operand1.U64); + break; + + case DwarfOperationKind.Const4u: + case DwarfOperationKind.Const4s: + writer.WriteU32((uint)Operand1.U64); + break; + + case DwarfOperationKind.Const8u: + case DwarfOperationKind.Const8s: + writer.WriteU64(Operand1.U64); + break; + + case DwarfOperationKind.Constu: + case DwarfOperationKind.PlusUconst: + case DwarfOperationKind.Regx: + case DwarfOperationKind.Piece: + case DwarfOperationKind.Addrx: + case DwarfOperationKind.GNUAddrIndex: + case DwarfOperationKind.Constx: + case DwarfOperationKind.GNUConstIndex: + writer.WriteULEB128(Operand1.U64); + break; + + case DwarfOperationKind.Consts: + case DwarfOperationKind.Fbreg: + writer.WriteILEB128(Operand1.I64); + break; + + case DwarfOperationKind.Deref: + case DwarfOperationKind.Dup: + case DwarfOperationKind.Drop: + case DwarfOperationKind.Over: + case DwarfOperationKind.Swap: + case DwarfOperationKind.Rot: + case DwarfOperationKind.Xderef: + case DwarfOperationKind.Abs: + case DwarfOperationKind.And: + case DwarfOperationKind.Div: + case DwarfOperationKind.Minus: + case DwarfOperationKind.Mod: + case DwarfOperationKind.Mul: + case DwarfOperationKind.Neg: + case DwarfOperationKind.Not: + case DwarfOperationKind.Or: + case DwarfOperationKind.Plus: + case DwarfOperationKind.Shl: + case DwarfOperationKind.Shr: + case DwarfOperationKind.Shra: + case DwarfOperationKind.Xor: + case DwarfOperationKind.Eq: + case DwarfOperationKind.Ge: + case DwarfOperationKind.Gt: + case DwarfOperationKind.Le: + case DwarfOperationKind.Lt: + case DwarfOperationKind.Ne: + case DwarfOperationKind.Nop: + case DwarfOperationKind.PushObjectAddress: + case DwarfOperationKind.FormTlsAddress: + case DwarfOperationKind.CallFrameCfa: + break; + + case DwarfOperationKind.Bra: + case DwarfOperationKind.Skip: + writer.WriteU16((ushort)((long)Offset + 2 - (long)((DwarfOperation)Operand0).Offset)); + break; + + case DwarfOperationKind.Lit0: + case DwarfOperationKind.Lit1: + case DwarfOperationKind.Lit2: + case DwarfOperationKind.Lit3: + case DwarfOperationKind.Lit4: + case DwarfOperationKind.Lit5: + case DwarfOperationKind.Lit6: + case DwarfOperationKind.Lit7: + case DwarfOperationKind.Lit8: + case DwarfOperationKind.Lit9: + case DwarfOperationKind.Lit10: + case DwarfOperationKind.Lit11: + case DwarfOperationKind.Lit12: + case DwarfOperationKind.Lit13: + case DwarfOperationKind.Lit14: + case DwarfOperationKind.Lit15: + case DwarfOperationKind.Lit16: + case DwarfOperationKind.Lit17: + case DwarfOperationKind.Lit18: + case DwarfOperationKind.Lit19: + case DwarfOperationKind.Lit20: + case DwarfOperationKind.Lit21: + case DwarfOperationKind.Lit22: + case DwarfOperationKind.Lit23: + case DwarfOperationKind.Lit24: + case DwarfOperationKind.Lit25: + case DwarfOperationKind.Lit26: + case DwarfOperationKind.Lit27: + case DwarfOperationKind.Lit28: + case DwarfOperationKind.Lit29: + case DwarfOperationKind.Lit30: + case DwarfOperationKind.Lit31: + case DwarfOperationKind.Reg0: + case DwarfOperationKind.Reg1: + case DwarfOperationKind.Reg2: + case DwarfOperationKind.Reg3: + case DwarfOperationKind.Reg4: + case DwarfOperationKind.Reg5: + case DwarfOperationKind.Reg6: + case DwarfOperationKind.Reg7: + case DwarfOperationKind.Reg8: + case DwarfOperationKind.Reg9: + case DwarfOperationKind.Reg10: + case DwarfOperationKind.Reg11: + case DwarfOperationKind.Reg12: + case DwarfOperationKind.Reg13: + case DwarfOperationKind.Reg14: + case DwarfOperationKind.Reg15: + case DwarfOperationKind.Reg16: + case DwarfOperationKind.Reg17: + case DwarfOperationKind.Reg18: + case DwarfOperationKind.Reg19: + case DwarfOperationKind.Reg20: + case DwarfOperationKind.Reg21: + case DwarfOperationKind.Reg22: + case DwarfOperationKind.Reg23: + case DwarfOperationKind.Reg24: + case DwarfOperationKind.Reg25: + case DwarfOperationKind.Reg26: + case DwarfOperationKind.Reg27: + case DwarfOperationKind.Reg28: + case DwarfOperationKind.Reg29: + case DwarfOperationKind.Reg30: + case DwarfOperationKind.Reg31: + case DwarfOperationKind.StackValue: + break; + + case DwarfOperationKind.Breg0: + case DwarfOperationKind.Breg1: + case DwarfOperationKind.Breg2: + case DwarfOperationKind.Breg3: + case DwarfOperationKind.Breg4: + case DwarfOperationKind.Breg5: + case DwarfOperationKind.Breg6: + case DwarfOperationKind.Breg7: + case DwarfOperationKind.Breg8: + case DwarfOperationKind.Breg9: + case DwarfOperationKind.Breg10: + case DwarfOperationKind.Breg11: + case DwarfOperationKind.Breg12: + case DwarfOperationKind.Breg13: + case DwarfOperationKind.Breg14: + case DwarfOperationKind.Breg15: + case DwarfOperationKind.Breg16: + case DwarfOperationKind.Breg17: + case DwarfOperationKind.Breg18: + case DwarfOperationKind.Breg19: + case DwarfOperationKind.Breg20: + case DwarfOperationKind.Breg21: + case DwarfOperationKind.Breg22: + case DwarfOperationKind.Breg23: + case DwarfOperationKind.Breg24: + case DwarfOperationKind.Breg25: + case DwarfOperationKind.Breg26: + case DwarfOperationKind.Breg27: + case DwarfOperationKind.Breg28: + case DwarfOperationKind.Breg29: + case DwarfOperationKind.Breg30: + case DwarfOperationKind.Breg31: + writer.WriteILEB128(Operand2.I64); + break; + + case DwarfOperationKind.Bregx: + writer.WriteULEB128(Operand1.U64); + writer.WriteILEB128(Operand2.I64); + break; + + case DwarfOperationKind.Call2: + writer.WriteU16((ushort)((DwarfDIE)Operand0).Offset); + break; + + case DwarfOperationKind.Call4: + writer.WriteU32((uint)((DwarfDIE)Operand0).Offset); + break; + + case DwarfOperationKind.CallRef: + writer.WriteUInt(((DwarfDIE)Operand0).Offset); + break; + + case DwarfOperationKind.BitPiece: + writer.WriteULEB128(Operand1.U64); + writer.WriteULEB128(Operand2.U64); + break; + + case DwarfOperationKind.ImplicitValue: + { + var stream = (Stream)Operand0; + writer.WriteULEB128((ulong)stream.Position); + writer.Write(stream); + break; + } + + case DwarfOperationKind.ImplicitPointer: + case DwarfOperationKind.GNUImplicitPointer: + { + ulong offset = ((DwarfDIE)Operand0).Offset; + // a reference to a debugging information entry that describes the dereferenced object’s value + if (writer.CurrentUnit.Version == 2) + { + writer.WriteUInt(offset); + } + else + { + writer.WriteUIntFromEncoding(offset); + } + // a signed number that is treated as a byte offset from the start of that value + writer.WriteILEB128(Operand1.I64); + break; + } + + case DwarfOperationKind.EntryValue: + case DwarfOperationKind.GNUEntryValue: + { + var expression = (DwarfExpression)Operand0; + writer.WriteULEB128(expression.Size); + expression.WriteInternal(writer); + break; + } + + case DwarfOperationKind.ConstType: + case DwarfOperationKind.GNUConstType: + { + // The DW_OP_const_type operation takes three operands + + // The first operand is an unsigned LEB128 integer that represents the offset + // of a debugging information entry in the current compilation unit, which + // must be a DW_TAG_base_type entry that provides the type of the constant provided + writer.WriteULEB128(((DwarfDIE)Operand0).Offset); + WriteEncodedValue(writer, Kind, Operand1.U64, (byte)Operand2.U64); + break; + } + + case DwarfOperationKind.RegvalType: + case DwarfOperationKind.GNURegvalType: + { + // The DW_OP_regval_type operation provides the contents of a given register + // interpreted as a value of a given type + + // The first operand is an unsigned LEB128 number, which identifies a register + // whose contents is to be pushed onto the stack + writer.WriteULEB128(Operand1.U64); + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + writer.WriteULEB128(((DwarfDIE)Operand0).Offset); + break; + } + + case DwarfOperationKind.DerefType: + case DwarfOperationKind.GNUDerefType: + case DwarfOperationKind.XderefType: + { + // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: + // it pops the top stack entry and treats it as an address. + + // This operand is a 1-byte unsigned integral constant whose value which is the + // same as the size of the base type referenced by the second operand + writer.WriteU8((byte)Operand1.U64); + + // The second operand is an unsigned LEB128 number that represents the offset + // of a debugging information entry in the current compilation unit + writer.WriteULEB128(((DwarfDIE)Operand0).Offset); + break; + } + + case DwarfOperationKind.Convert: + case DwarfOperationKind.GNUConvert: + case DwarfOperationKind.Reinterpret: + case DwarfOperationKind.GNUReinterpret: + writer.WriteULEB128(((DwarfDIE)Operand0).Offset); + break; + + case DwarfOperationKind.GNUPushTlsAddress: + case DwarfOperationKind.GNUUninit: + break; + + case DwarfOperationKind.GNUEncodedAddr: + WriteEncodedValue(writer, Kind, Operand1.U64, (byte)Operand2.U64); + break; + + case DwarfOperationKind.GNUParameterRef: + writer.WriteU32((uint)Operand1.U64); + break; + + default: + throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {Kind} is not supported"); + } + + Debug.Assert(writer.Offset - startOpOffset == Size); + } + + private static ulong ReadEncodedValue(DwarfReader reader, DwarfOperationKind kind, out byte size) + { + size = reader.ReadU8(); + switch (size) + { + case 0: + return reader.ReadUInt(); + case 1: + return reader.ReadU8(); + case 2: + return reader.ReadU16(); + case 4: + return reader.ReadU32(); + case 8: + return reader.ReadU64(); + default: + throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); + } + } + + private static void WriteEncodedValue(DwarfWriter writer, DwarfOperationKindEx kind, ulong value, byte size) + { + writer.WriteU8(size); + switch (size) + { + case 0: + writer.WriteUInt(value); + break; + case 1: + writer.WriteU8((byte)value); + break; + case 2: + writer.WriteU16((ushort)value); + break; + case 4: + writer.WriteU32((uint)value); + break; + case 8: + writer.WriteU64(value); + break; + default: + // TODO: report via diagnostics in Verify + throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); + } + } + + private static readonly DwarfReader.DwarfDIEReferenceResolver DwarfExpressionLocationDIEReferenceResolverInstance = DwarfExpressionLocationDIEReferenceResolver; + + private static void DwarfExpressionLocationDIEReferenceResolver(ref DwarfReader.DwarfDIEReference dieRef) + { + var op = (DwarfOperation)dieRef.DwarfObject; + op.Operand0 = dieRef.Resolved; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs new file mode 100644 index 00000000000000..7f91c06c3b6d94 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs @@ -0,0 +1,59 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public readonly partial struct DwarfOperationKindEx : IEquatable + { + public DwarfOperationKindEx(byte value) + { + Value = (DwarfOperationKind)value; + } + + public DwarfOperationKindEx(DwarfOperationKind value) + { + Value = value; + } + + public readonly DwarfOperationKind Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfOperationKindEx)} ({(uint)Value:x2})"; + } + + public bool Equals(DwarfOperationKindEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfOperationKindEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(DwarfOperationKindEx left, DwarfOperationKindEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfOperationKindEx left, DwarfOperationKindEx right) + { + return !left.Equals(right); + } + + public static explicit operator uint(DwarfOperationKindEx kind) => (uint)kind.Value; + + public static implicit operator DwarfOperationKindEx(DwarfOperationKind kind) => new DwarfOperationKindEx(kind); + + public static implicit operator DwarfOperationKind(DwarfOperationKindEx kind) => kind.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs new file mode 100644 index 00000000000000..a1b1eb5acc51b7 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs @@ -0,0 +1,234 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; +using System.Linq; + +namespace LibObjectFile.Dwarf +{ + public static class DwarfPrinter + { + public static void Print(this DwarfAbbreviationTable abbrevTable, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine("Contents of the .debug_abbrev section:"); + + foreach (var abbreviation in abbrevTable.Abbreviations) + { + Print(abbreviation, writer); + } + } + + public static void Print(this DwarfAbbreviation abbreviation, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine(); + + writer.WriteLine($" Number TAG (0x{abbreviation.Offset})"); + + foreach (var item in abbreviation.Items) + { + writer.WriteLine($" {item.Code} {item.Tag} [{(item.HasChildren ? "has children" : "no children")}]"); + var descriptors = item.Descriptors; + for (int i = 0; i < descriptors.Length; i++) + { + var descriptor = descriptors[i]; + writer.WriteLine($" {descriptor.Kind.ToString(),-18} {descriptor.Form}"); + } + writer.WriteLine(" DW_AT value: 0 DW_FORM value: 0"); + } + } + + public static void PrintRelocations(this DwarfRelocatableSection relocSection, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine(); + if (relocSection.Relocations.Count == 0) + { + writer.WriteLine(" There are no relocations in this section."); + return; + } + + writer.WriteLine($" Relocations of this section contains {(relocSection.Relocations.Count > 1 ? $"{relocSection.Relocations.Count} entries" : "1 entry")}:"); + writer.WriteLine(); + writer.WriteLine(" Offset Target Size Addend"); + foreach (var reloc in relocSection.Relocations) + { + writer.WriteLine($"{reloc.Offset:x16} {reloc.Target,-24} {(uint)reloc.Size,-6} {reloc.Addend:x}"); + } + } + + public static void Print(this DwarfInfoSection debugInfo, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + foreach (var unit in debugInfo.Units) + { + Print(unit, writer); + } + } + + public static void Print(this DwarfUnit unit, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + writer.WriteLine("Contents of the .debug_info section:"); + writer.WriteLine(); + writer.WriteLine($" Compilation Unit @ offset 0x{unit.Offset:x}:"); + writer.WriteLine($" Length: 0x{unit.UnitLength:x}"); + writer.WriteLine($" Version: {unit.Version}"); + writer.WriteLine($" Abbrev Offset: 0x{unit.Abbreviation?.Offset ?? 0:x}"); + writer.WriteLine($" Pointer Size: {(uint)unit.AddressSize}"); + if (unit.Root != null) + { + Print(unit.Root, writer); + } + } + + public static void Print(this DwarfDIE die, TextWriter writer, int level = 0) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine($" <{level}><{die.Offset:x}>: Abbrev Number: {die.Abbrev.Code} ({die.Tag})"); + + foreach (var attr in die.Attributes) + { + string attrValue = null; + switch (attr.ValueAsObject) + { + case DwarfDIE dieRef: + attrValue = $"<0x{dieRef.Offset:x}>"; + break; + case string str: + attrValue = str; + break; + case DwarfExpression expr: + attrValue = $"{expr.Operations.Count} OpCodes ({string.Join(", ", expr.Operations.Select(x => x.Kind))})"; + break; + } + + switch (attr.Kind.Value) + { + case DwarfAttributeKind.Language: + + attrValue = $"{attr.ValueAsU64} {GetLanguageKind((DwarfLanguageKind)attr.ValueAsU64)}"; + break; + } + + if (attrValue == null) + { + + var encoding = DwarfHelper.GetAttributeEncoding(attr.Kind); + if ((encoding & DwarfAttributeEncoding.Address) != 0) + { + attrValue = $"0x{attr.ValueAsU64:x}"; + } + else + { + attrValue = $"{attr.ValueAsU64}"; + } + } + + writer.WriteLine($" <{attr.Offset:x}> {attr.Kind,-18} : {attrValue}"); + } + + foreach (var child in die.Children) + { + Print(child, writer, level + 1); + } + } + + public static void Print(this DwarfAddressRangeTable addressRangeTable, TextWriter writer) + { + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine("Contents of the .debug_aranges section:"); + writer.WriteLine(); + writer.WriteLine($" Length: {addressRangeTable.HeaderLength}"); + writer.WriteLine($" Version: {addressRangeTable.Version}"); + writer.WriteLine($" Offset into .debug_info: 0x{addressRangeTable.DebugInfoOffset:x}"); + writer.WriteLine($" Pointer Size: {(byte)addressRangeTable.AddressSize}"); + writer.WriteLine($" Segment Size: {(byte)addressRangeTable.SegmentSelectorSize}"); + writer.WriteLine(); + var addressSize = (uint)addressRangeTable.AddressSize; + if (addressSize > 4) + { + writer.WriteLine(" Address Length"); + } + else + { + writer.WriteLine(" Address Length"); + } + + var formatStyle = "x" + (addressSize * 2); + foreach (var range in addressRangeTable.Ranges) + { + writer.WriteLine($" {range.Address.ToString(formatStyle)} {range.Length.ToString(formatStyle)}"); + } + writer.WriteLine($" {((ulong)0).ToString(formatStyle)} {((ulong)0).ToString(formatStyle)}"); + } + + private static string GetLanguageKind(DwarfLanguageKind kind) + { + var rawKind = (uint) kind; + switch (rawKind) + { + case DwarfNative.DW_LANG_C89: return "(ANSI C)"; + case DwarfNative.DW_LANG_C: return "(non-ANSI C)"; + case DwarfNative.DW_LANG_Ada83: return "(Ada)"; + case DwarfNative.DW_LANG_C_plus_plus: return "(C++)"; + case DwarfNative.DW_LANG_Cobol74: return "(Cobol 74)"; + case DwarfNative.DW_LANG_Cobol85: return "(Cobol 85)"; + case DwarfNative.DW_LANG_Fortran77: return "(FORTRAN 77)"; + case DwarfNative.DW_LANG_Fortran90: return "(Fortran 90)"; + case DwarfNative.DW_LANG_Pascal83: return "(ANSI Pascal)"; + case DwarfNative.DW_LANG_Modula2: return "(Modula 2)"; + // DWARF 2.1 + case DwarfNative.DW_LANG_Java: return "(Java)"; + case DwarfNative.DW_LANG_C99: return "(ANSI C99)"; + case DwarfNative.DW_LANG_Ada95: return "(ADA 95)"; + case DwarfNative.DW_LANG_Fortran95: return "(Fortran 95)"; + // DWARF 3 + case DwarfNative.DW_LANG_PLI: return "(PLI)"; + case DwarfNative.DW_LANG_ObjC: return "(Objective C)"; + case DwarfNative.DW_LANG_ObjC_plus_plus: return "(Objective C++)"; + case DwarfNative.DW_LANG_UPC: return "(Unified Parallel C)"; + case DwarfNative.DW_LANG_D: return "(D)"; + // DWARF 4 + case DwarfNative.DW_LANG_Python: return "(Python)"; + // DWARF 5 + case DwarfNative.DW_LANG_OpenCL: return "(OpenCL)"; + case DwarfNative.DW_LANG_Go: return "(Go)"; + case DwarfNative.DW_LANG_Modula3: return "(Modula 3)"; + case DwarfNative.DW_LANG_Haskel: return "(Haskell)"; + case DwarfNative.DW_LANG_C_plus_plus_03: return "(C++03)"; + case DwarfNative.DW_LANG_C_plus_plus_11: return "(C++11)"; + case DwarfNative.DW_LANG_OCaml: return "(OCaml)"; + case DwarfNative.DW_LANG_Rust: return "(Rust)"; + case DwarfNative.DW_LANG_C11: return "(C11)"; + case DwarfNative.DW_LANG_Swift: return "(Swift)"; + case DwarfNative.DW_LANG_Julia: return "(Julia)"; + case DwarfNative.DW_LANG_Dylan: return "(Dylan)"; + case DwarfNative.DW_LANG_C_plus_plus_14: return "(C++14)"; + case DwarfNative.DW_LANG_Fortran03: return "(Fortran 03)"; + case DwarfNative.DW_LANG_Fortran08: return "(Fortran 08)"; + case DwarfNative.DW_LANG_RenderScript: return "(RenderScript)"; + + case DwarfNative.DW_LANG_Mips_Assembler: return "(MIPS assembler)"; + + case DwarfNative.DW_LANG_Upc: return "(Unified Parallel C)"; + + default: + if (rawKind >= DwarfNative.DW_LANG_lo_user && rawKind <= DwarfNative.DW_LANG_hi_user) + return $"(implementation defined: {rawKind:x})"; + break; + } + + return $"(Unknown: {rawKind:x})"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs new file mode 100644 index 00000000000000..306939b11c9939 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs @@ -0,0 +1,170 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfReader : DwarfReaderWriter + { + private readonly Dictionary _registeredDIEPerCompilationUnit; + private readonly Dictionary _registeredDIEPerSection; + private readonly List _unresolvedDIECompilationUnitReference; + private readonly List _attributesWithUnresolvedDIESectionReference; + private readonly Stack _stack; + private readonly Stack _stackWithLineProgramTable; + + internal DwarfReader(DwarfReaderContext context, DwarfFile file, DiagnosticBag diagnostics) : base(file, diagnostics) + { + IsReadOnly = context.IsInputReadOnly; + AddressSize = context.AddressSize; + IsLittleEndian = context.IsLittleEndian; + _registeredDIEPerCompilationUnit = new Dictionary(); + _registeredDIEPerSection = new Dictionary(); + _unresolvedDIECompilationUnitReference = new List(); + _attributesWithUnresolvedDIESectionReference = new List(); + OffsetToLineProgramTable = new Dictionary(); + OffsetToLocationList = new Dictionary(); + _stack = new Stack(); + _stackWithLineProgramTable = new Stack(); + } + + public override bool IsReadOnly { get; } + + public DwarfUnitKind DefaultUnitKind { get; internal set; } + + internal int DIELevel { get; set; } + + internal DwarfDIE CurrentDIE => _stack.Count > 0 ? _stack.Peek() : null; + + internal DwarfLineProgramTable CurrentLineProgramTable => _stackWithLineProgramTable.Count > 0 ? _stackWithLineProgramTable.Peek().CurrentLineProgramTable : null; + + internal DwarfAttributeDescriptor CurrentAttributeDescriptor { get; set; } + + internal Dictionary OffsetToLineProgramTable { get; } + + internal Dictionary OffsetToLocationList { get; } + + internal void PushDIE(DwarfDIE die) + { + _registeredDIEPerCompilationUnit.Add(die.Offset - CurrentUnit.Offset, die); + _registeredDIEPerSection.Add(die.Offset, die); + _stack.Push(die); + } + + internal void PushLineProgramTable(DwarfLineProgramTable lineTable) + { + var dieWithLineProgramTable = CurrentDIE; + if (_stackWithLineProgramTable.Count > 0 && ReferenceEquals(_stackWithLineProgramTable.Peek(), dieWithLineProgramTable)) + { + return; + } + + _stackWithLineProgramTable.Push(dieWithLineProgramTable); + dieWithLineProgramTable.CurrentLineProgramTable = lineTable; + } + + internal void PopDIE() + { + var die = _stack.Pop(); + if (die.CurrentLineProgramTable != null) + { + var dieWithProgramLineTable = _stackWithLineProgramTable.Pop(); + Debug.Assert(ReferenceEquals(die, dieWithProgramLineTable)); + dieWithProgramLineTable.CurrentLineProgramTable = null; + } + } + + internal void ClearResolveAttributeReferenceWithinCompilationUnit() + { + _registeredDIEPerCompilationUnit.Clear(); + _unresolvedDIECompilationUnitReference.Clear(); + } + + internal void ResolveAttributeReferenceWithinCompilationUnit() + { + // Resolve attribute reference within the CU + foreach (var unresolvedAttrRef in _unresolvedDIECompilationUnitReference) + { + ResolveAttributeReferenceWithinCompilationUnit(unresolvedAttrRef, true); + } + } + + internal void ResolveAttributeReferenceWithinSection() + { + // Resolve attribute reference within the section + foreach (var unresolvedAttrRef in _attributesWithUnresolvedDIESectionReference) + { + ResolveAttributeReferenceWithinSection(unresolvedAttrRef, true); + } + } + + internal void ResolveAttributeReferenceWithinCompilationUnit(DwarfDIEReference dieRef, bool errorIfNotFound) + { + if (_registeredDIEPerCompilationUnit.TryGetValue(dieRef.Offset, out var die)) + { + dieRef.Resolved = die; + dieRef.Resolver(ref dieRef); + } + else + { + if (errorIfNotFound) + { + if (dieRef.Offset != 0) + { + Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidReference, $"Unable to resolve DIE reference (0x{dieRef.Offset:x}, section 0x{(dieRef.Offset):x}) for {dieRef.DwarfObject} at offset 0x{dieRef.Offset:x}"); + } + } + else + { + _unresolvedDIECompilationUnitReference.Add(dieRef); + } + } + } + + internal void ResolveAttributeReferenceWithinSection(DwarfDIEReference dieRef, bool errorIfNotFound) + { + if (_registeredDIEPerSection.TryGetValue(dieRef.Offset, out var die)) + { + dieRef.Resolved = die; + dieRef.Resolver(ref dieRef); + } + else + { + if (errorIfNotFound) + { + if (dieRef.Offset != 0) + { + Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidReference, $"Unable to resolve DIE reference (0x{dieRef.Offset:x}) for {dieRef.DwarfObject} at offset 0x{dieRef.Offset:x}"); + } + } + else + { + _attributesWithUnresolvedDIESectionReference.Add(dieRef); + } + } + } + + internal struct DwarfDIEReference + { + public DwarfDIEReference(ulong offset, object dwarfObject, DwarfDIEReferenceResolver resolver) : this() + { + Offset = offset; + DwarfObject = dwarfObject; + Resolver = resolver; + } + + public readonly ulong Offset; + + public readonly object DwarfObject; + + public readonly DwarfDIEReferenceResolver Resolver; + + public DwarfDIE Resolved; + } + + internal delegate void DwarfDIEReferenceResolver(ref DwarfDIEReference reference); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs new file mode 100644 index 00000000000000..6d4fa71be9cf58 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs @@ -0,0 +1,30 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public class DwarfReaderContext : DwarfReaderWriterContext + { + public DwarfReaderContext() + { + } + + public DwarfReaderContext(DwarfElfContext elfContext) + { + if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); + IsLittleEndian = elfContext.IsLittleEndian; + AddressSize = elfContext.AddressSize; + DebugLineStream = elfContext.LineTable?.Stream; + DebugStringStream = elfContext.StringTable?.Stream; + DebugAbbrevStream = elfContext.AbbreviationTable?.Stream; + DebugInfoStream = elfContext.InfoSection?.Stream; + DebugAddressRangeStream = elfContext.AddressRangeTable?.Stream; + DebugLocationStream = elfContext.LocationSection?.Stream; + } + + public bool IsInputReadOnly { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs new file mode 100644 index 00000000000000..049ebd62104dd4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs @@ -0,0 +1,173 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfReaderWriter : ObjectFileReaderWriter + { + internal DwarfReaderWriter(DwarfFile file, DiagnosticBag diagnostics) : base(null, diagnostics) + { + File = file; + } + + public DwarfFile File { get; } + + public bool Is64BitEncoding { get; set; } + + public DwarfAddressSize AddressSize { get; internal set; } + + public DwarfSection CurrentSection { get; internal set; } + + public DwarfUnit CurrentUnit { get; internal set; } + + public DwarfAddressSize SizeOfUIntEncoding() + { + return Is64BitEncoding ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; + } + + public DwarfAddressSize ReadAddressSize() + { + var address_size = (DwarfAddressSize)ReadU8(); + switch (address_size) + { + case DwarfAddressSize.Bit8: + case DwarfAddressSize.Bit16: + case DwarfAddressSize.Bit32: + case DwarfAddressSize.Bit64: + break; + default: + Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Unsupported address size {(uint)address_size}."); + break; + } + + return address_size; + } + + public void WriteAddressSize(DwarfAddressSize addressSize) + { + WriteU8((byte)addressSize); + } + + public ulong ReadUnitLength() + { + Is64BitEncoding = false; + uint length = ReadU32(); + if (length >= 0xFFFFFFF0) + { + if (length != 0xFFFFFFFF) + { + throw new InvalidOperationException($"Unsupported unit length prefix 0x{length:x8}"); + } + + Is64BitEncoding = true; + return ReadU64(); + } + return length; + } + + public void WriteUnitLength(ulong length) + { + if (Is64BitEncoding) + { + WriteU32(0xFFFFFFFF); + WriteU64(length); + } + else + { + if (length >= 0xFFFFFFF0) + { + throw new ArgumentOutOfRangeException(nameof(length), $"Must be < 0xFFFFFFF0 but is 0x{length:X}"); + } + WriteU32((uint)length); + } + } + + public ulong ReadUIntFromEncoding() + { + return Is64BitEncoding ? ReadU64() : ReadU32(); + } + + public void WriteUIntFromEncoding(ulong value) + { + if (Is64BitEncoding) + { + WriteU64(value); + } + else + { + WriteU32((uint)value); + } + } + + public ulong ReadUInt() + { + switch (AddressSize) + { + case DwarfAddressSize.Bit8: + return ReadU8(); + case DwarfAddressSize.Bit16: + return ReadU16(); + case DwarfAddressSize.Bit32: + return ReadU32(); + case DwarfAddressSize.Bit64: + return ReadU64(); + default: + throw new ArgumentOutOfRangeException($"Invalid AddressSize {AddressSize}"); + } + } + + public void WriteUInt(ulong target) + { + switch (AddressSize) + { + case DwarfAddressSize.Bit8: + WriteU8((byte)target); + break; + case DwarfAddressSize.Bit16: + WriteU16((ushort)target); + break; + case DwarfAddressSize.Bit32: + WriteU32((uint)target); + break; + case DwarfAddressSize.Bit64: + WriteU64(target); + break; + default: + throw new ArgumentOutOfRangeException($"Invalid AddressSize {AddressSize}"); + } + } + + public ulong ReadULEB128() + { + return Stream.ReadULEB128(); + } + + public uint ReadULEB128AsU32() + { + return Stream.ReadULEB128AsU32(); + } + + public int ReadLEB128AsI32() + { + return Stream.ReadLEB128AsI32(); + } + + public long ReadILEB128() + { + return Stream.ReadSignedLEB128(); + } + + public void WriteULEB128(ulong value) + { + Stream.WriteULEB128(value); + } + public void WriteILEB128(long value) + { + Stream.WriteILEB128(value); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs new file mode 100644 index 00000000000000..97d3bf3a6618f5 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs @@ -0,0 +1,29 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfReaderWriterContext + { + public bool IsLittleEndian { get; set; } + + public DwarfAddressSize AddressSize { get; set; } + + public Stream DebugAbbrevStream { get; set; } + + public Stream DebugStringStream { get; set; } + + public Stream DebugAddressRangeStream { get; set; } + + public Stream DebugLineStream { get; set; } + + public TextWriter DebugLinePrinter { get; set; } + + public Stream DebugInfoStream { get; set; } + + public Stream DebugLocationStream { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs new file mode 100644 index 00000000000000..09084726ea57ac --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs @@ -0,0 +1,67 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using LibObjectFile.Elf; + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfRelocatableSection : DwarfSection + { + protected DwarfRelocatableSection() + { + Relocations = new List(); + } + + + public List Relocations { get; } + } + + public static class DwarfRelocationSectionExtensions + { + public static void CopyRelocationsTo(this DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) + { + if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); + if (relocTable == null) throw new ArgumentNullException(nameof(relocTable)); + + switch (elfContext.Elf.Arch.Value) + { + case ElfArch.X86_64: + CopyRelocationsX86_64(dwarfRelocSection, elfContext, relocTable); + break; + default: + throw new NotImplementedException($"The relocation for architecture {relocTable.Parent.Arch} is not supported/implemented."); + } + + } + + private static void CopyRelocationsX86_64(DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) + { + relocTable.Entries.Clear(); + foreach (var reloc in dwarfRelocSection.Relocations) + { + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; + switch (reloc.Target) + { + case DwarfRelocationTarget.Code: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.CodeSectionSymbolIndex, (long) reloc.Addend)); + break; + case DwarfRelocationTarget.DebugString: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.StringTableSymbolIndex, (long)reloc.Addend)); + break; + case DwarfRelocationTarget.DebugAbbrev: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.AbbreviationTableSymbolIndex, (long)reloc.Addend)); + break; + case DwarfRelocationTarget.DebugInfo: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.InfoSectionSymbolIndex, (long)reloc.Addend)); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs new file mode 100644 index 00000000000000..237d81c94ee225 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs @@ -0,0 +1,33 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + [DebuggerDisplay("{" + nameof(ToString) + "(),nq}")] + public struct DwarfRelocation + { + public DwarfRelocation(ulong offset, DwarfRelocationTarget target, DwarfAddressSize size, ulong addend) + { + Offset = offset; + Target = target; + Size = size; + Addend = addend; + } + + public ulong Offset { get; set; } + + public DwarfRelocationTarget Target { get; set; } + + public DwarfAddressSize Size { get; set; } + + public ulong Addend { get; set; } + + public override string ToString() + { + return $"{nameof(Offset)}: {Offset}, {nameof(Target)}: {Target}, {nameof(Size)}: {Size}, {nameof(Addend)}: {Addend}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs new file mode 100644 index 00000000000000..bcec19fda54d73 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs @@ -0,0 +1,17 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfRelocationTarget + { + Code, + + DebugString, + + DebugAbbrev, + + DebugInfo, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs new file mode 100644 index 00000000000000..408c726f25e530 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs @@ -0,0 +1,31 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + public abstract class DwarfSection : DwarfContainer + { + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is DwarfFile)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(DwarfFile)}"); + } + } + + /// + /// Gets the containing . Might be null if this section or segment + /// does not belong to an existing . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + public new DwarfFile Parent + { + get => (DwarfFile)base.Parent; + internal set => base.Parent = value; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs new file mode 100644 index 00000000000000..3f92cef19edc1f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs @@ -0,0 +1,48 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public struct DwarfSectionLink : IEquatable + { + public DwarfSectionLink(ulong offset) + { + Offset = offset; + } + + public readonly ulong Offset; + + public override string ToString() + { + return $"SectionLink {nameof(Offset)}: 0x{Offset:x}"; + } + + public bool Equals(DwarfSectionLink other) + { + return Offset == other.Offset; + } + + public override bool Equals(object obj) + { + return obj is DwarfSectionLink other && Equals(other); + } + + public override int GetHashCode() + { + return Offset.GetHashCode(); + } + + public static bool operator ==(DwarfSectionLink left, DwarfSectionLink right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfSectionLink left, DwarfSectionLink right) + { + return !left.Equals(right); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs new file mode 100644 index 00000000000000..5bbde3539cafbf --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs @@ -0,0 +1,97 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public static class DwarfStreamExtensions + { + public static ulong ReadULEB128(this Stream stream) + { + ulong value = 0; + int shift = 0; + while (true) + { + var b = stream.ReadU8(); + value = ((ulong)(b & 0x7f) << shift) | value; + if ((b & 0x80) == 0) + { + break; + } + shift += 7; + } + return value; + } + + public static void WriteULEB128(this Stream stream, ulong value) + { + do + { + var b = (byte)(value & 0x7f); + value >>= 7; + if (value != 0) + b |= 0x80; + stream.WriteU8(b); + } while (value != 0); + } + + public static void WriteILEB128(this Stream stream, long value) + { + bool cont = true; + while (cont) + { + var b = (byte)((byte)value & 0x7f); + value >>= 7; + bool isSignBitSet = (b & 0x40) != 0; + if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) + { + cont = false; + } + else + { + b |= 0x80; + } + stream.WriteU8(b); + } + } + + public static uint ReadULEB128AsU32(this Stream stream) + { + var offset = stream.Position; + var value = stream.ReadULEB128(); + if (value >= uint.MaxValue) throw new InvalidOperationException($"The LEB128 0x{value:x16} read from stream at offset {offset} is out of range of uint >= {uint.MaxValue}"); + return (uint)value; + } + + public static int ReadLEB128AsI32(this Stream stream) + { + var offset = stream.Position; + var value = stream.ReadULEB128(); + if (value >= int.MaxValue) throw new InvalidOperationException($"The LEB128 0x{value:x16} read from stream at offset {offset} is out of range of int >= {int.MaxValue}"); + return (int)value; + } + + public static long ReadSignedLEB128(this Stream stream) + { + long value = 0; + int shift = 0; + byte b = 0; + do + { + b = stream.ReadU8(); + value |= ((long) (b & 0x7f) << shift); + shift += 7; + } while ((b & 0x80) != 0); + + if (shift < 64 && (b & 0x40) != 0) + { + value |= (long)(~0UL << shift); + } + + return value; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs new file mode 100644 index 00000000000000..f2a9abf54573e0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs @@ -0,0 +1,89 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +namespace LibObjectFile.Dwarf +{ + public class DwarfStringTable : DwarfSection + { + private readonly Dictionary _stringToOffset; + private readonly Dictionary _offsetToString; + private Stream _stream; + + public DwarfStringTable() : this(new MemoryStream()) + { + } + + public DwarfStringTable(Stream stream) + { + Stream = stream ?? throw new ArgumentNullException(nameof(stream)); + _stringToOffset = new Dictionary(); + _offsetToString = new Dictionary(); + } + + public Stream Stream + { + get => _stream; + set => _stream = value ?? throw new ArgumentNullException(nameof(value)); + } + + public string GetStringFromOffset(ulong offset) + { + if (_offsetToString.TryGetValue(offset, out var text)) + { + return text; + } + + Stream.Position = (long) offset; + text = Stream.ReadStringUTF8NullTerminated(); + _offsetToString[offset] = text; + _stringToOffset[text] = offset; + return text; + } + + public bool Contains(string text) + { + if (text == null) return false; + return _stringToOffset.ContainsKey(text); + } + + public ulong GetOrCreateString(string text) + { + if (text == null) return 0; + + ulong offset; + if (_stringToOffset.TryGetValue(text, out offset)) + { + return offset; + } + + Stream.Position = Stream.Length; + offset = (ulong)Stream.Position; + Stream.WriteStringUTF8NullTerminated(text); + _offsetToString[offset] = text; + _stringToOffset[text] = offset; + return offset; + } + + protected override void Read(DwarfReader reader) + { + Stream = reader.ReadAsStream((ulong) reader.Stream.Length); + Size = reader.Offset - Offset; + } + + protected override void Write(DwarfWriter writer) + { + writer.Write(Stream); + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + Size = (ulong?)(Stream?.Length) ?? 0UL; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs new file mode 100644 index 00000000000000..5681d8577e9cac --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs @@ -0,0 +1,62 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + /// + /// Defines the tag of an . + /// + public readonly partial struct DwarfTagEx : IEquatable + { + public DwarfTagEx(uint value) + { + Value = (DwarfTag)value; + } + + public DwarfTagEx(DwarfTag value) + { + Value = value; + } + + public readonly DwarfTag Value; + + public bool Equals(DwarfTagEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfTagEx other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(DwarfTagEx left, DwarfTagEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfTagEx left, DwarfTagEx right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(DwarfTagEx)} (0x{Value:X4})"; + } + + public static explicit operator uint(DwarfTagEx tag) => (uint)tag.Value; + + public static implicit operator DwarfTagEx(DwarfTag tag) => new DwarfTagEx(tag); + + public static implicit operator DwarfTag(DwarfTagEx tag) => tag.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs new file mode 100644 index 00000000000000..12978e593a27a4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs @@ -0,0 +1,241 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Dwarf +{ + /// + /// Base class for a Dwarf Unit. + /// + public abstract class DwarfUnit : DwarfContainer + { + private DwarfDIE _root; + + /// + /// Gets or sets the encoding of this unit. + /// + public bool Is64BitEncoding { get; set; } + + /// + /// Gets or sets the address size used by this unit. + /// + public DwarfAddressSize AddressSize { get; set; } + + /// + /// Gets or sets the version of this unit. + /// + public ushort Version { get; set; } + + /// + /// Gets or sets the kind of this unit. + /// + public DwarfUnitKindEx Kind { get; set; } + + /// + /// Gets the abbreviation offset, only valid once the layout has been calculated through . + /// + public ulong DebugAbbreviationOffset { get; internal set; } + + /// + /// Gets the unit length, only valid once the layout has been calculated through . + /// + public ulong UnitLength { get; internal set; } + + /// + /// Gets or sets the root of this compilation unit. + /// + public DwarfDIE Root + { + get => _root; + set => AttachChild(this, value, ref _root, true); + } + + /// + /// Gets the abbreviation associated with the . + /// + /// + /// This abbreviation is automatically setup after reading or after updating the layout through . + /// + public DwarfAbbreviation Abbreviation { get; internal set; } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + if (Version < 2 || Version > 5) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version .debug_info {Version} not supported"); + } + + if (AddressSize == DwarfAddressSize.None) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Address size for .debug_info cannot be None/0"); + } + + Root?.Verify(diagnostics); + } + + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is DwarfSection)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(DwarfSection)}"); + } + } + + protected override void UpdateLayout(DwarfLayoutContext layoutContext) + { + var offset = this.Offset; + + // 1. unit_length + offset += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); + + var offsetAfterUnitLength = offset; + + // 2. version (uhalf) + offset += sizeof(ushort); // WriteU16(unit.Version); + + if (Version >= 5) + { + // 3. unit_type (ubyte) + offset += 1; // WriteU8(unit.Kind.Value); + } + + // Update the layout specific to the Unit instance + offset += GetLayoutHeaderSize(); + + Abbreviation = null; + + // Compute the full layout of all DIE and attributes (once abbreviation are calculated) + if (Root != null) + { + // Before updating the layout, we need to compute the abbreviation + Abbreviation = new DwarfAbbreviation(); + layoutContext.File.AbbreviationTable.AddAbbreviation(Abbreviation); + + Root.UpdateAbbreviationItem(layoutContext); + + DebugAbbreviationOffset = Abbreviation.Offset; + + Root.Offset = offset; + Root.UpdateLayoutInternal(layoutContext); + offset += Root.Size; + } + + Size = offset - Offset; + UnitLength = offset - offsetAfterUnitLength; + } + + protected abstract ulong GetLayoutHeaderSize(); + + protected abstract void ReadHeader(DwarfReader reader); + + protected abstract void WriteHeader(DwarfWriter writer); + + protected override void Read(DwarfReader reader) + { + reader.CurrentUnit = this; + + foreach (var abbreviation in reader.File.AbbreviationTable.Abbreviations) + { + if (abbreviation.Offset == DebugAbbreviationOffset) + { + Abbreviation = abbreviation; + break; + } + } + + Root = DwarfDIE.ReadInstance(reader); + + reader.ResolveAttributeReferenceWithinCompilationUnit(); + + Size = reader.Offset - Offset; + } + + internal static DwarfUnit ReadInstance(DwarfReader reader, out ulong offsetEndOfUnit) + { + var startOffset = reader.Offset; + + DwarfUnit unit = null; + + // 1. unit_length + var unit_length = reader.ReadUnitLength(); + + offsetEndOfUnit = (ulong)reader.Offset + unit_length; + + // 2. version (uhalf) + var version = reader.ReadU16(); + + DwarfUnitKindEx unitKind = reader.DefaultUnitKind; + + if (version <= 2 || version > 5) + { + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version {version} is not supported"); + return null; + } + + if (version >= 5) + { + // 3. unit_type (ubyte) + unitKind = new DwarfUnitKindEx(reader.ReadU8()); + } + + switch (unitKind.Value) + { + case DwarfUnitKind.Compile: + case DwarfUnitKind.Partial: + unit = new DwarfCompilationUnit(); + break; + + default: + reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_UnsupportedUnitType, $"Unit Type {unitKind} is not supported"); + return null; + } + + unit.UnitLength = unit_length; + unit.Kind = unitKind; + unit.Is64BitEncoding = reader.Is64BitEncoding; + unit.Offset = startOffset; + unit.Version = version; + + unit.ReadHeader(reader); + + unit.ReadInternal(reader); + + return unit; + } + + protected override void Write(DwarfWriter writer) + { + var startOffset = writer.Offset; + Debug.Assert(Offset == writer.Offset); + + // 1. unit_length + Is64BitEncoding = Is64BitEncoding; + writer.WriteUnitLength(UnitLength); + + var offsetAfterUnitLength = writer.Offset; + + // 2. version (uhalf) + writer.WriteU16(Version); + + if (Version >= 5) + { + // 3. unit_type (ubyte) + writer.WriteU8((byte)Kind.Value); + } + + WriteHeader(writer); + writer.AddressSize = AddressSize; + + Root?.WriteInternal(writer); + // TODO: check size of unit length + + Debug.Assert(Size == writer.Offset - startOffset); + Debug.Assert(UnitLength == writer.Offset - offsetAfterUnitLength); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs new file mode 100644 index 00000000000000..07a6b8fb939585 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs @@ -0,0 +1,63 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public readonly partial struct DwarfUnitKindEx : IEquatable + { + public DwarfUnitKindEx(byte value) + { + Value = (DwarfUnitKind)value; + } + + public DwarfUnitKindEx(DwarfUnitKind value) + { + Value = value; + } + + public readonly DwarfUnitKind Value; + + public override string ToString() + { + if ((byte)Value >= DwarfNative.DW_UT_lo_user) + { + return $"User {nameof(DwarfUnitKindEx)} (0x{Value:x2})"; + } + return ToStringInternal() ?? $"Unknown {nameof(DwarfUnitKindEx)} (0x{Value:x2})"; + } + + public bool Equals(DwarfUnitKindEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is DwarfUnitKindEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(DwarfUnitKindEx left, DwarfUnitKindEx right) + { + return left.Equals(right); + } + + public static bool operator !=(DwarfUnitKindEx left, DwarfUnitKindEx right) + { + return !left.Equals(right); + } + + public static explicit operator uint(DwarfUnitKindEx kind) => (uint)kind.Value; + + public static implicit operator DwarfUnitKindEx(DwarfUnitKind kind) => new DwarfUnitKindEx(kind); + + public static implicit operator DwarfUnitKind(DwarfUnitKindEx kind) => kind.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs new file mode 100644 index 00000000000000..167b04af09d8fa --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs @@ -0,0 +1,15 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfVirtuality : byte + { + None = DwarfNative.DW_VIRTUALITY_none, + + Virtual = DwarfNative.DW_VIRTUALITY_virtual, + + PureVirtual = DwarfNative.DW_VIRTUALITY_pure_virtual, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs new file mode 100644 index 00000000000000..ea7e430ba977c8 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs @@ -0,0 +1,15 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Dwarf +{ + public enum DwarfVisibility : byte + { + Local = DwarfNative.DW_VIS_local, + + Exported = DwarfNative.DW_VIS_exported, + + Qualified = DwarfNative.DW_VIS_qualified, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs new file mode 100644 index 00000000000000..d12d32fd83b251 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs @@ -0,0 +1,45 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Dwarf +{ + public sealed class DwarfWriter : DwarfReaderWriter + { + internal DwarfWriter(DwarfFile file, bool isLittleEndian, DiagnosticBag diagnostics) : base(file, diagnostics) + { + IsLittleEndian = isLittleEndian; + } + + public override bool IsReadOnly => false; + + public bool EnableRelocation { get; internal set; } + + public void RecordRelocation(DwarfRelocationTarget target, DwarfAddressSize addressSize, ulong address) + { + if (CurrentSection is DwarfRelocatableSection relocSection) + { + + relocSection.Relocations.Add(new DwarfRelocation(Offset, target, addressSize, address)); + + } + else + { + throw new InvalidOperationException($"Invalid {nameof(CurrentSection)} in {nameof(DwarfWriter)}. It must be a {nameof(DwarfRelocatableSection)}."); + } + } + + public void WriteAddress(DwarfRelocationTarget target, ulong address) + { + if (EnableRelocation) + { + RecordRelocation(target, AddressSize, address); + // If the relocation is recorded, we write 0 as an address + address = 0; + } + WriteUInt(address); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs new file mode 100644 index 00000000000000..577293a9be9234 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs @@ -0,0 +1,26 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using LibObjectFile.Elf; + +namespace LibObjectFile.Dwarf +{ + public class DwarfWriterContext : DwarfReaderWriterContext + { + public DwarfWriterContext() : this(new DwarfLayoutConfig()) + { + } + + public DwarfWriterContext(DwarfLayoutConfig layoutConfig) + { + LayoutConfig = layoutConfig ?? throw new ArgumentNullException(nameof(layoutConfig)); + EnableRelocation = true; + } + + public DwarfLayoutConfig LayoutConfig { get; } + + public bool EnableRelocation { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd new file mode 100644 index 00000000000000..c409a3ecd340c5 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd @@ -0,0 +1,154 @@ + + + + + + + + Elf\ElfObjectFile.cs + + + + + IIAMBiAQAAAEAYCAAAAEHAAggCAoQAkIEUgAiAUBACA= + Elf\ElfObjectFile.cs + + + + + + + + + + EAABhAAAAAAAAQSEgCAAAAQgEEAABIAAARAAQEEEIAA= + Elf\ElfSection.cs + + + + + + AAAABAAAAAAACQAEgCAAAAAIAIAAAAAAAQAAIAAAAAA= + Elf\ElfSegment.cs + + + + + + AAAAAAAAAAAAAACAAAAAAAAgAAAIAAAAAQAAIAEAAAA= + Elf\Sections\ElfCustomSection.cs + + + + + + gAAAAAAAAAAAgCAAAAEAAAAgAAAAAAAAAQAAAAMAAAA= + Elf\Sections\ElfNoteTable.cs + + + + + + + + + AAAABAAAAAAAgAAAgCAAAAQgAAAAAQAAARAAQEEAgAA= + Elf\Sections\ElfNullSection.cs + + + + + + + + + + + + + + AAAAAAAAAIgAgSCAAEAAAAAgEAIAAAAAAcAAAAEAFAA= + Elf\Sections\ElfRelocationTable.cs + + + + + + + + + AAAABAAAAAAACAAAgCAAAAAAAAAAAAAAAQAAAAAAAAA= + Elf\Sections\ElfShadowSection.cs + + + + + + AAAAAAgAAAAAjgAAEAAAAAAgAAAAAAAAAYAAgAEGAAA= + Elf\Sections\ElfStringTable.cs + + + + + + AAAAAAAAAIAAgSCAAEAAAAAgEAAAAAAAAYAAAAEAFAA= + Elf\Sections\ElfSymbolTable.cs + + + + + + + + + QAACAAAAAAAAAAAEAABAAAAAAAAAAAAAIAACAAIBBAA= + Elf\Sections\ElfNote.cs + + + + + + + + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAgAAAIAAAAAAAAIAEAAAA= + Elf\Sections\ElfCustomShadowSection.cs + + + + + + + + + + + + + + AAAAEAAAAAAAAACAAAAAAAAgAAAAAAAAAgAAIAEAAAA= + Elf\Sections\ElfProgramHeaderTable.cs + + + + + + AAAAAAAAAAAAAAAEABAQACAAAAAAAAAAAYAAAAAAgAA= + Elf\Sections\ElfRelocation.cs + + + + + + AEAAgAAAAAAAgAAEgAIAAAQAAAAAAIAAAQAgAIAAAiA= + Elf\Sections\ElfSymbol.cs + + + + + \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs new file mode 100644 index 00000000000000..2b2cb73b7940b6 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs @@ -0,0 +1,67 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a machine architecture. + /// This is the value seen in or + /// as well as the various machine defines (e.g ). + /// + public readonly partial struct ElfArchEx : IEquatable + { + public ElfArchEx(ushort value) + { + Value = (ElfArch)value; + } + + public ElfArchEx(ElfArch value) + { + Value = value; + } + + /// + /// Raw value. + /// + public readonly ElfArch Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(ElfArchEx)} (0x{Value:X4})"; + } + + public bool Equals(ElfArchEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfArchEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(ElfArchEx left, ElfArchEx right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfArchEx left, ElfArchEx right) + { + return !left.Equals(right); + } + + public static explicit operator uint(ElfArchEx arch) => (uint)arch.Value; + + public static implicit operator ElfArchEx(ElfArch arch) => new ElfArchEx(arch); + + public static implicit operator ElfArch(ElfArchEx arch) => arch.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs new file mode 100644 index 00000000000000..e5d25d90a7ee82 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs @@ -0,0 +1,102 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// A decoder for the various Elf types that doesn't change LSB/MSB ordering from the current machine. + /// + public struct ElfDecoderDirect : IElfDecoder + { + public ushort Decode(ElfNative.Elf32_Half src) + { + return src.Value; + } + + public ushort Decode(ElfNative.Elf64_Half src) + { + return src.Value; + } + + public uint Decode(ElfNative.Elf32_Word src) + { + return src.Value; + } + + public uint Decode(ElfNative.Elf64_Word src) + { + return src.Value; + } + + public int Decode(ElfNative.Elf32_Sword src) + { + return src.Value; + } + + public int Decode(ElfNative.Elf64_Sword src) + { + return src.Value; + } + + public ulong Decode(ElfNative.Elf32_Xword src) + { + return src.Value; + } + + public long Decode(ElfNative.Elf32_Sxword src) + { + return src.Value; + } + + public ulong Decode(ElfNative.Elf64_Xword src) + { + return src.Value; + } + + public long Decode(ElfNative.Elf64_Sxword src) + { + return src.Value; + } + + public uint Decode(ElfNative.Elf32_Addr src) + { + return src.Value; + } + + public ulong Decode(ElfNative.Elf64_Addr src) + { + return src.Value; + } + + public uint Decode(ElfNative.Elf32_Off src) + { + return src.Value; + } + + public ulong Decode(ElfNative.Elf64_Off src) + { + return src.Value; + } + + public ushort Decode(ElfNative.Elf32_Section src) + { + return src.Value; + } + + public ushort Decode(ElfNative.Elf64_Section src) + { + return src.Value; + } + + public ushort Decode(ElfNative.Elf32_Versym src) + { + return src.Value; + } + + public ushort Decode(ElfNative.Elf64_Versym src) + { + return src.Value; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs new file mode 100644 index 00000000000000..bdae1529be5018 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs @@ -0,0 +1,104 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Buffers.Binary; + +namespace LibObjectFile.Elf +{ + /// + /// A decoder for the various Elf types that swap LSB/MSB ordering based on a mismatch between the current machine and file ordering. + /// + public readonly struct ElfDecoderSwap : IElfDecoder + { + public ushort Decode(ElfNative.Elf32_Half src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ushort Decode(ElfNative.Elf64_Half src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public uint Decode(ElfNative.Elf32_Word src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public uint Decode(ElfNative.Elf64_Word src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public int Decode(ElfNative.Elf32_Sword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public int Decode(ElfNative.Elf64_Sword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ulong Decode(ElfNative.Elf32_Xword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public long Decode(ElfNative.Elf32_Sxword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ulong Decode(ElfNative.Elf64_Xword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public long Decode(ElfNative.Elf64_Sxword src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public uint Decode(ElfNative.Elf32_Addr src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ulong Decode(ElfNative.Elf64_Addr src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public uint Decode(ElfNative.Elf32_Off src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ulong Decode(ElfNative.Elf64_Off src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ushort Decode(ElfNative.Elf32_Section src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ushort Decode(ElfNative.Elf64_Section src) + { + return BinaryPrimitives.ReverseEndianness(src); + } + + public ushort Decode(ElfNative.Elf32_Versym src) + { + return BinaryPrimitives.ReverseEndianness((ElfNative.Elf32_Half)src); + } + + public ushort Decode(ElfNative.Elf64_Versym src) + { + return BinaryPrimitives.ReverseEndianness((ElfNative.Elf64_Half)src); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs new file mode 100644 index 00000000000000..35df4067727401 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs @@ -0,0 +1,102 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// An encoder for the various Elf types that doesn't change LSB/MSB ordering from the current machine. + /// + internal readonly struct ElfEncoderDirect : IElfEncoder + { + public void Encode(out ElfNative.Elf32_Half dest, ushort value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Half dest, ushort value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Word dest, uint value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Word dest, uint value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Sword dest, int value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Sword dest, int value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Xword dest, ulong value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Sxword dest, long value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Xword dest, ulong value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Sxword dest, long value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Addr dest, uint value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf64_Addr dest, ulong value) + { + dest = value; + } + + public void Encode(out ElfNative.Elf32_Off dest, uint offset) + { + dest = offset; + } + + public void Encode(out ElfNative.Elf64_Off dest, ulong offset) + { + dest = offset; + } + + public void Encode(out ElfNative.Elf32_Section dest, ushort index) + { + dest = index; + } + + public void Encode(out ElfNative.Elf64_Section dest, ushort index) + { + dest = index; + } + + public void Encode(out ElfNative.Elf32_Versym dest, ushort value) + { + dest = (ElfNative.Elf32_Half)value; + } + + public void Encode(out ElfNative.Elf64_Versym dest, ushort value) + { + dest = (ElfNative.Elf64_Half)value; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs new file mode 100644 index 00000000000000..7d6f4f4a7d32fb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs @@ -0,0 +1,104 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Buffers.Binary; + +namespace LibObjectFile.Elf +{ + /// + /// An encoder for the various Elf types that swap LSB/MSB ordering based on a mismatch between the current machine and file ordering. + /// + internal readonly struct ElfEncoderSwap : IElfEncoder + { + public void Encode(out ElfNative.Elf32_Half dest, ushort value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Half dest, ushort value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Word dest, uint value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Word dest, uint value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Sword dest, int value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Sword dest, int value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Xword dest, ulong value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Sxword dest, long value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Xword dest, ulong value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Sxword dest, long value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Addr dest, uint value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Addr dest, ulong value) + { + dest = BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf32_Off dest, uint offset) + { + dest = BinaryPrimitives.ReverseEndianness(offset); + } + + public void Encode(out ElfNative.Elf64_Off dest, ulong offset) + { + dest = BinaryPrimitives.ReverseEndianness(offset); + } + + public void Encode(out ElfNative.Elf32_Section dest, ushort index) + { + dest = BinaryPrimitives.ReverseEndianness(index); + } + + public void Encode(out ElfNative.Elf64_Section dest, ushort index) + { + dest = BinaryPrimitives.ReverseEndianness(index); + } + + public void Encode(out ElfNative.Elf32_Versym dest, ushort value) + { + dest = (ElfNative.Elf32_Half)BinaryPrimitives.ReverseEndianness(value); + } + + public void Encode(out ElfNative.Elf64_Versym dest, ushort value) + { + dest = (ElfNative.Elf64_Half)BinaryPrimitives.ReverseEndianness(value); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs new file mode 100644 index 00000000000000..f7997e692b2d63 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs @@ -0,0 +1,29 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Encoding of an . + /// This is the value seen in the ident part of an Elf header at index + /// It is associated with , and + /// + public enum ElfEncoding : byte + { + /// + /// Invalid data encoding. Equivalent of + /// + None = ElfNative.ELFDATANONE, + + /// + /// 2's complement, little endian. Equivalent of + /// + Lsb = ElfNative.ELFDATA2LSB, + + /// + /// 2's complement, big endian. Equivalent of + /// + Msb = ElfNative.ELFDATA2MSB, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs new file mode 100644 index 00000000000000..6824a530594cfb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs @@ -0,0 +1,30 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + + /// + /// Defines the File class byte index (32bit or 64bits) of an . + /// This is the value seen in the ident part of an Elf header at index + /// It is associated with , and + /// + public enum ElfFileClass : byte + { + /// + /// Invalid class. Equivalent of . + /// + None = ElfNative.ELFCLASSNONE, + + /// + /// 32-bit objects. Equivalent of . + /// + Is32 = ElfNative.ELFCLASS32, + + /// + /// 64-bit objects. Equivalent of . + /// + Is64 = ElfNative.ELFCLASS64, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs new file mode 100644 index 00000000000000..ca8607a87639f2 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs @@ -0,0 +1,93 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Elf +{ + /// + /// Internal struct used to identify which part of the file is attached to a section or not. + /// It is used while reading back an ELF file from the disk to create + /// + [DebuggerDisplay("{StartOffset,nq} - {EndOffset,nq} : {Section,nq}")] + internal readonly struct ElfFilePart : IComparable, IEquatable + { + /// + /// Creates an instance that is not yet bound to a section for which an + /// will be created + /// + /// Start of the offset in the file + /// End of the offset in the file (inclusive) + public ElfFilePart(ulong startOffset, ulong endOffset) + { + StartOffset = startOffset; + EndOffset = endOffset; + Section = null; + } + + /// + /// Creates an instance that is bound to a section + /// + /// A section of the file + public ElfFilePart(ElfSection section) + { + Section = section ?? throw new ArgumentNullException(nameof(section)); + Debug.Assert(section.Size > 0); + StartOffset = section.Offset; + EndOffset = StartOffset + Section.Size - 1; + } + + public readonly ulong StartOffset; + + public readonly ulong EndOffset; + + public readonly ElfSection Section; + + public int CompareTo(ElfFilePart other) + { + if (EndOffset < other.StartOffset) + { + return -1; + } + + if (StartOffset > other.EndOffset) + { + return 1; + } + + // May overlap or not + return 0; + } + + + public bool Equals(ElfFilePart other) + { + return StartOffset == other.StartOffset && EndOffset == other.EndOffset; + } + + public override bool Equals(object obj) + { + return obj is ElfFilePart other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + return (StartOffset.GetHashCode() * 397) ^ EndOffset.GetHashCode(); + } + } + + public static bool operator ==(ElfFilePart left, ElfFilePart right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfFilePart left, ElfFilePart right) + { + return !left.Equals(right); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs new file mode 100644 index 00000000000000..8625bb1ed24d1b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs @@ -0,0 +1,82 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Collections.Generic; + +namespace LibObjectFile.Elf +{ + /// + /// Internal list used to keep an ordered list of based on offsets. + /// It is used to track region of the file that are actually referenced by a + /// but are not declared as a + /// + internal struct ElfFilePartList + { + private readonly List _parts; + + public ElfFilePartList(int capacity) + { + _parts = new List(capacity); + } + + public int Count => _parts.Count; + + public ElfFilePart this[int index] + { + get => _parts[index]; + set => _parts[index] = value; + } + + public void Insert(ElfFilePart part) + { + for (int i = 0; i < _parts.Count; i++) + { + var against = _parts[i]; + var delta = part.CompareTo(against); + if (delta < 0) + { + _parts.Insert(i, part); + return; + } + + // Don't add an overlap + if (delta == 0) + { + // do nothing + return; + } + } + _parts.Add(part); + } + + public void CreateParts(ulong startOffset, ulong endOffset) + { + var offset = startOffset; + for (int i = 0; i < _parts.Count && offset < endOffset; i++) + { + var part = _parts[i]; + if (offset < part.StartOffset) + { + if (endOffset < part.StartOffset) + { + var newPart = new ElfFilePart(offset, endOffset); + _parts.Insert(i, newPart); + offset = endOffset + 1; + break; + } + + // Don't merge parts, so that we will create a single ElfInlineShadowSection per parts + _parts.Insert(i, new ElfFilePart(offset, part.StartOffset - 1)); + } + + offset = part.EndOffset + 1; + } + + if (offset < endOffset) + { + _parts.Add(new ElfFilePart(offset, endOffset)); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs new file mode 100644 index 00000000000000..57e2f2b9e88ed0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs @@ -0,0 +1,39 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines the file type of an . + /// This is the value seen in or + /// as well as the various machine defines (e.g ). + /// + public enum ElfFileType : ushort + { + /// + /// No file type + /// + None = ElfNative.ET_NONE, + + /// + /// Relocatable file + /// + Relocatable = ElfNative.ET_REL, + + /// + /// Executable file + /// + Executable = ElfNative.ET_EXEC, + + /// + /// Shared object file + /// + Dynamic = ElfNative.ET_DYN, + + /// + /// Core file + /// + Core = ElfNative.ET_CORE, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs new file mode 100644 index 00000000000000..70347e218537a8 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs @@ -0,0 +1,58 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines the flags of an . + /// This is the value seen in or . + /// This is currently not used. + /// + public readonly struct ElfHeaderFlags : IEquatable + { + public ElfHeaderFlags(uint value) + { + Value = value; + } + + public readonly uint Value; + + + public bool Equals(ElfHeaderFlags other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfHeaderFlags other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(ElfHeaderFlags left, ElfHeaderFlags right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfHeaderFlags left, ElfHeaderFlags right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return $"0x{Value:x}"; + } + + public static explicit operator uint(ElfHeaderFlags flags) => flags.Value; + + public static implicit operator ElfHeaderFlags(uint flags) => new ElfHeaderFlags(flags); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs new file mode 100644 index 00000000000000..4ae30ced5d3aa5 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs @@ -0,0 +1,104 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Contains all the low-level structures used for reading/writing ELF data, automatically generated from C headers. + /// + public static partial class ElfNative + { + public partial struct Elf32_Shdr: IEquatable + { + public static readonly Elf32_Shdr Null = new Elf32_Shdr(); + + public bool IsNull => this == Null; + + public bool Equals(Elf32_Shdr other) + { + return sh_name.Equals(other.sh_name) && sh_type.Equals(other.sh_type) && sh_flags.Equals(other.sh_flags) && sh_addr.Equals(other.sh_addr) && sh_offset.Equals(other.sh_offset) && sh_size.Equals(other.sh_size) && sh_link.Equals(other.sh_link) && sh_info.Equals(other.sh_info) && sh_addralign.Equals(other.sh_addralign) && sh_entsize.Equals(other.sh_entsize); + } + + public override bool Equals(object obj) + { + return obj is Elf32_Shdr other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = sh_name.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_type.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_flags.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_addr.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_offset.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_size.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_link.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_info.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_addralign.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_entsize.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(Elf32_Shdr left, Elf32_Shdr right) + { + return left.Equals(right); + } + + public static bool operator !=(Elf32_Shdr left, Elf32_Shdr right) + { + return !left.Equals(right); + } + } + + public partial struct Elf64_Shdr : IEquatable + { + public static readonly Elf64_Shdr Null = new Elf64_Shdr(); + + public bool IsNull => this == Null; + + public bool Equals(Elf64_Shdr other) + { + return sh_name.Equals(other.sh_name) && sh_type.Equals(other.sh_type) && sh_flags.Equals(other.sh_flags) && sh_addr.Equals(other.sh_addr) && sh_offset.Equals(other.sh_offset) && sh_size.Equals(other.sh_size) && sh_link.Equals(other.sh_link) && sh_info.Equals(other.sh_info) && sh_addralign.Equals(other.sh_addralign) && sh_entsize.Equals(other.sh_entsize); + } + + public override bool Equals(object obj) + { + return obj is Elf64_Shdr other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = sh_name.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_type.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_flags.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_addr.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_offset.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_size.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_link.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_info.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_addralign.GetHashCode(); + hashCode = (hashCode * 397) ^ sh_entsize.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(Elf64_Shdr left, Elf64_Shdr right) + { + return left.Equals(right); + } + + public static bool operator !=(Elf64_Shdr left, Elf64_Shdr right) + { + return !left.Equals(right); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs new file mode 100644 index 00000000000000..7d5f4b0f9c91e8 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs @@ -0,0 +1,64 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines an OS ABI. + /// This is the value seen in the ident part of an Elf header at index + /// as well as the various machine defines (e.g ). + /// + public readonly partial struct ElfOSABIEx : IEquatable + { + public ElfOSABIEx(byte value) + { + Value = (ElfOSABI)value; + } + + public ElfOSABIEx(ElfOSABI value) + { + Value = value; + } + + public readonly ElfOSABI Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(ElfOSABIEx)} (0x{Value:X4})"; + } + + public bool Equals(ElfOSABIEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfOSABIEx other && Equals(other); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(ElfOSABIEx left, ElfOSABIEx right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfOSABIEx left, ElfOSABIEx right) + { + return !left.Equals(right); + } + + public static explicit operator byte(ElfOSABIEx osABI) => (byte)osABI.Value; + + public static implicit operator ElfOSABIEx(ElfOSABI osABI) => new ElfOSABIEx(osABI); + + public static implicit operator ElfOSABI(ElfOSABIEx osABI) => osABI.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs new file mode 100644 index 00000000000000..d02d710c17270a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs @@ -0,0 +1,37 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Elf +{ + /// + /// Base class for an and . + /// + public abstract class ElfObject : ObjectFileNode + { + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is ElfObjectFile)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(ElfObjectFile)}"); + } + } + + + /// + /// Gets the containing . Might be null if this section or segment + /// does not belong to an existing . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + public new ElfObjectFile Parent + { + get => (ElfObjectFile)base.Parent; + internal set => base.Parent = value; + } + + public abstract void UpdateLayout(DiagnosticBag diagnostics); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs new file mode 100644 index 00000000000000..fc0b979339692b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs @@ -0,0 +1,761 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using LibObjectFile.Utils; + +namespace LibObjectFile.Elf +{ + using static ElfNative; + + /// + /// Defines an ELF object file that can be manipulated in memory. + /// + public sealed class ElfObjectFile : ObjectFileNode + { + private readonly List _sections; + private ElfSectionHeaderStringTable _sectionHeaderStringTable; + private readonly List _segments; + + public const int IdentSizeInBytes = ElfNative.EI_NIDENT; + + /// + /// Creates a new instance with the default sections (null and a shadow program header table). + /// + public ElfObjectFile(ElfArch arch) : this(true) + { + Arch = arch; + switch (arch) + { + case ElfArch.I386: + FileClass = ElfFileClass.Is32; + Encoding = ElfEncoding.Lsb; + break; + case ElfArch.X86_64: + FileClass = ElfFileClass.Is64; + Encoding = ElfEncoding.Lsb; + break; + case ElfArch.ARM: + FileClass = ElfFileClass.Is32; + Encoding = ElfEncoding.Lsb; // not 100% valid, but ok for a default + break; + case ElfArch.AARCH64: + FileClass = ElfFileClass.Is64; + Encoding = ElfEncoding.Lsb; // not 100% valid, but ok for a default + break; + + // TODO: Add support for more arch + } + Version = ElfNative.EV_CURRENT; + FileType = ElfFileType.Relocatable; + } + + internal ElfObjectFile(bool addDefaultSections) + { + _segments = new List(); + _sections = new List(); + Layout = new ElfObjectLayout(); + + if (addDefaultSections) + { + AddSection(new ElfNullSection()); + AddSection(new ElfProgramHeaderTable()); + } + } + + /// + /// Gets or sets the file class (i.e. 32 or 64 bits) + /// + public ElfFileClass FileClass { get; set; } + + /// + /// Gets or sets the file encoding (i.e. LSB or MSB) + /// + public ElfEncoding Encoding { get; set; } + + /// + /// Gets or sets the version of this file. + /// + public uint Version { get; set; } + + /// + /// Gets or sets the OS ABI. + /// + public ElfOSABIEx OSABI { get; set; } + + /// + /// Gets or sets the OS ABI version. + /// + public byte AbiVersion { get; set; } + + /// + /// Gets or sets the file type (e.g executable, relocatable...) + /// From Elf Header equivalent of or . + /// + public ElfFileType FileType { get; set; } + + /// + /// Gets or sets the file flags (not used). + /// + public ElfHeaderFlags Flags { get; set; } + + /// + /// Gets or sets the machine architecture (e.g 386, X86_64...) + /// From Elf Header equivalent of or . + /// + public ElfArchEx Arch { get; set; } + + /// + /// Entry point virtual address. + /// From Elf Header equivalent of or . + /// + public ulong EntryPointAddress { get; set; } + + /// + /// List of the segments - program headers defined by this instance. + /// + public IReadOnlyList Segments => _segments; + + /// + /// List of the sections - program headers defined by this instance. + /// + public IReadOnlyList Sections => _sections; + + /// + /// Number of visible sections excluding in the . + /// + public uint VisibleSectionCount { get; private set; } + + /// + /// Number of in the + /// + public uint ShadowSectionCount { get; private set; } + + /// + /// Gets or sets the section header string table used to store the names of the sections. + /// Must have been added to . + /// + public ElfSectionHeaderStringTable SectionHeaderStringTable + { + get => _sectionHeaderStringTable; + set + { + if (value != null) + { + if (value.Parent == null) + { + throw new InvalidOperationException($"The {nameof(ElfSectionHeaderStringTable)} must have been added via `this.{nameof(AddSection)}(section)` before setting {nameof(SectionHeaderStringTable)}"); + } + + if (value.Parent != this) + { + throw new InvalidOperationException($"This {nameof(ElfSectionHeaderStringTable)} belongs already to another {nameof(ElfObjectFile)}. It must be removed from the other instance before adding it to this instance."); + } + } + _sectionHeaderStringTable = value; + } + } + + /// + /// Gets the current calculated layout of this instance (e.g offset of the program header table) + /// + public ElfObjectLayout Layout { get; } + + /// + /// Verifies the integrity of this ELF object file. + /// + /// A DiagnosticBag instance to receive the diagnostics. + public override void Verify(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + if (FileClass == ElfFileClass.None) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderFileClassNone, $"Cannot compute the layout with an {nameof(ElfObjectFile)} having a {nameof(FileClass)} == {ElfFileClass.None}"); + } + + foreach (var segment in Segments) + { + segment.Verify(diagnostics); + } + + // Verify all sections before doing anything else + foreach (var section in Sections) + { + section.Verify(diagnostics); + } + } + + public List GetSectionsOrderedByStreamIndex() + { + var orderedSections = new List(Sections.Count); + orderedSections.AddRange(Sections); + orderedSections.Sort(CompareStreamIndexAndIndexDelegate); + return orderedSections; + } + + /// + /// Tries to update and calculate the layout of the sections, segments and . + /// + /// A DiagnosticBag instance to receive the diagnostics. + /// true if the calculation of the layout is successful. otherwise false + public unsafe void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + Size = 0; + + ulong offset = FileClass == ElfFileClass.Is32 ? (uint)sizeof(ElfNative.Elf32_Ehdr) : (uint)sizeof(ElfNative.Elf64_Ehdr); + Layout.SizeOfElfHeader = (ushort)offset; + Layout.OffsetOfProgramHeaderTable = 0; + Layout.OffsetOfSectionHeaderTable = 0; + Layout.SizeOfProgramHeaderEntry = FileClass == ElfFileClass.Is32 ? (ushort)sizeof(ElfNative.Elf32_Phdr) : (ushort)sizeof(ElfNative.Elf64_Phdr); + Layout.SizeOfSectionHeaderEntry = FileClass == ElfFileClass.Is32 ? (ushort)sizeof(ElfNative.Elf32_Shdr) : (ushort)sizeof(ElfNative.Elf64_Shdr); + Layout.TotalSize = offset; + + bool programHeaderTableFoundAndUpdated = false; + + // If we have any sections, prepare their offsets + var sections = GetSectionsOrderedByStreamIndex(); + if (sections.Count > 0) + { + // Calculate offsets of all sections in the stream + for (var i = 0; i < sections.Count; i++) + { + var section = sections[i]; + if (i == 0 && section.Type == ElfSectionType.Null) + { + continue; + } + + var align = section.Alignment == 0 ? 1 : section.Alignment; + offset = AlignHelper.AlignToUpper(offset, align); + section.Offset = offset; + + if (section is ElfProgramHeaderTable programHeaderTable) + { + if (Segments.Count > 0) + { + Layout.OffsetOfProgramHeaderTable = section.Offset; + Layout.SizeOfProgramHeaderEntry = (ushort) section.TableEntrySize; + programHeaderTableFoundAndUpdated = true; + } + } + + if (section == SectionHeaderStringTable) + { + var shstrTable = SectionHeaderStringTable; + shstrTable.Reset(); + + // Prepare all section names (to calculate the name indices and the size of the SectionNames) + for (var j = 0; j < sections.Count; j++) + { + var otherSection = sections[j]; + if ((j == 0 && otherSection.Type == ElfSectionType.Null)) continue; + if (otherSection.IsShadow) continue; + otherSection.Name = otherSection.Name.WithIndex(shstrTable.GetOrCreateIndex(otherSection.Name)); + } + } + + section.UpdateLayout(diagnostics); + + // Console.WriteLine($"{section.ToString(),-50} Offset: {section.Offset:x4} Size: {section.Size:x4}"); + + // A section without content doesn't count with its size + if (!section.HasContent) + { + continue; + } + + offset += section.Size; + } + + // The Section Header Table will be put just after all the sections + Layout.OffsetOfSectionHeaderTable = offset; + + Layout.TotalSize = offset + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; + } + + // Update program headers with offsets from auto layout + if (Segments.Count > 0) + { + // Write program headers + if (!programHeaderTableFoundAndUpdated) + { + diagnostics.Error(DiagnosticId.ELF_ERR_MissingProgramHeaderTableSection, $"Missing {nameof(ElfProgramHeaderTable)} shadow section for writing program headers / segments from this object file"); + } + + for (int i = 0; i < Segments.Count; i++) + { + var programHeader = Segments[i]; + programHeader.UpdateLayout(diagnostics); + } + } + + Size = offset + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; + } + + /// + /// Adds a segment to . + /// + /// A segment + public void AddSegment(ElfSegment segment) + { + if (segment == null) throw new ArgumentNullException(nameof(segment)); + if (segment.Parent != null) + { + if (segment.Parent == this) throw new InvalidOperationException("Cannot add the segment as it is already added"); + if (segment.Parent != this) throw new InvalidOperationException($"Cannot add the segment as it is already added to another {nameof(ElfObjectFile)} instance"); + } + + segment.Parent = this; + segment.Index = (uint)_segments.Count; + _segments.Add(segment); + } + + /// + /// Inserts a segment into at the specified index. + /// + /// Index into to insert the specified segment + /// The segment to insert + public void InsertSegmentAt(int index, ElfSegment segment) + { + if (index < 0 || index > _segments.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_segments.Count}"); + if (segment == null) throw new ArgumentNullException(nameof(segment)); + if (segment.Parent != null) + { + if (segment.Parent == this) throw new InvalidOperationException("Cannot add the segment as it is already added"); + if (segment.Parent != this) throw new InvalidOperationException($"Cannot add the segment as it is already added to another {nameof(ElfObjectFile)} instance"); + } + + segment.Index = (uint)index; + _segments.Insert(index, segment); + segment.Parent = this; + + // Update the index of following segments + for(int i = index + 1; i < _segments.Count; i++) + { + var nextSegment = _segments[i]; + nextSegment.Index++; + } + } + + /// + /// Removes a segment from + /// + /// The segment to remove + public void RemoveSegment(ElfSegment segment) + { + if (segment == null) throw new ArgumentNullException(nameof(segment)); + if (segment.Parent != this) + { + throw new InvalidOperationException($"Cannot remove this segment as it is not part of this {nameof(ElfObjectFile)} instance"); + } + + var i = (int)segment.Index; + _segments.RemoveAt(i); + segment.Index = 0; + + // Update indices for other sections + for (int j = i + 1; j < _segments.Count; j++) + { + var nextSegments = _segments[j]; + nextSegments.Index--; + } + + segment.Parent = null; + } + + /// + /// Removes a segment from at the specified index. + /// + /// Index into to remove the specified segment + public ElfSegment RemoveSegmentAt(int index) + { + if (index < 0 || index > _segments.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_segments.Count}"); + var segment = _segments[index]; + RemoveSegment(segment); + return segment; + } + + /// + /// Adds a section to . + /// + /// A section + public TSection AddSection(TSection section) where TSection : ElfSection + { + if (section == null) throw new ArgumentNullException(nameof(section)); + if (section.Parent != null) + { + if (section.Parent == this) throw new InvalidOperationException("Cannot add the section as it is already added"); + if (section.Parent != this) throw new InvalidOperationException($"Cannot add the section as it is already added to another {nameof(ElfObjectFile)} instance"); + } + + section.Parent = this; + section.Index = (uint)_sections.Count; + _sections.Add(section); + + if (section.IsShadow) + { + section.SectionIndex = 0; + ShadowSectionCount++; + } + else + { + section.SectionIndex = VisibleSectionCount; + VisibleSectionCount++; + } + + // Setup the ElfSectionHeaderStringTable if not already set + if (section is ElfSectionHeaderStringTable sectionHeaderStringTable && SectionHeaderStringTable == null) + { + SectionHeaderStringTable = sectionHeaderStringTable; + } + + return section; + } + + /// + /// Inserts a section into at the specified index. + /// + /// Index into to insert the specified section + /// The section to insert + public void InsertSectionAt(int index, ElfSection section) + { + if (index < 0 || index > _sections.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_sections.Count}"); + if (section == null) throw new ArgumentNullException(nameof(section)); + if (section.Parent != null) + { + if (section.Parent == this) throw new InvalidOperationException("Cannot add the section as it is already added"); + if (section.Parent != this) throw new InvalidOperationException($"Cannot add the section as it is already added to another {nameof(ElfObjectFile)} instance"); + } + + section.Parent = this; + section.Index = (uint)index; + _sections.Insert(index, section); + + if (section.IsShadow) + { + section.SectionIndex = 0; + ShadowSectionCount++; + + // Update the index of the following sections + for (int j = index + 1; j < _sections.Count; j++) + { + var sectionAfter = _sections[j]; + sectionAfter.Index++; + } + } + else + { + ElfSection previousSection = null; + for (int j = 0; j < index; j++) + { + var sectionBefore = _sections[j]; + if (!sectionBefore.IsShadow) + { + previousSection = sectionBefore; + } + } + section.SectionIndex = previousSection != null ? previousSection.SectionIndex + 1 : 0; + + // Update the index of the following sections + for (int j = index + 1; j < _sections.Count; j++) + { + var sectionAfter = _sections[j]; + if (!sectionAfter.IsShadow) + { + sectionAfter.SectionIndex++; + } + sectionAfter.Index++; + } + + VisibleSectionCount++; + } + + // Setup the ElfSectionHeaderStringTable if not already set + if (section is ElfSectionHeaderStringTable sectionHeaderStringTable && SectionHeaderStringTable == null) + { + SectionHeaderStringTable = sectionHeaderStringTable; + } + } + + /// + /// Removes a section from + /// + /// The section to remove + public void RemoveSection(ElfSection section) + { + if (section == null) throw new ArgumentNullException(nameof(section)); + if (section.Parent != this) + { + throw new InvalidOperationException($"Cannot remove the section as it is not part of this {nameof(ElfObjectFile)} instance"); + } + + var i = (int)section.Index; + _sections.RemoveAt(i); + section.Index = 0; + + bool wasShadow = section.IsShadow; + + // Update indices for other sections + for (int j = i + 1; j < _sections.Count; j++) + { + var nextSection = _sections[j]; + nextSection.Index--; + + // Update section index as well for following non-shadow sections + if (!wasShadow && !nextSection.IsShadow) + { + nextSection.SectionIndex--; + } + } + + if (wasShadow) + { + ShadowSectionCount--; + } + else + { + VisibleSectionCount--; + } + + section.Parent = null; + + // Automatically replace the current ElfSectionHeaderStringTable with another existing one if any + if (section is ElfSectionHeaderStringTable && SectionHeaderStringTable == section) + { + SectionHeaderStringTable = null; + foreach (var nextSection in _sections) + { + if (nextSection is ElfSectionHeaderStringTable nextSectionHeaderStringTable) + { + SectionHeaderStringTable = nextSectionHeaderStringTable; + break; + } + } + } + } + + /// + /// Removes a section from at the specified index. + /// + /// Index into to remove the specified section + public ElfSection RemoveSectionAt(int index) + { + if (index < 0 || index > _sections.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_sections.Count}"); + var section = _sections[index]; + RemoveSection(section); + return section; + } + + /// + /// Writes this ELF object file to the specified stream. + /// + /// The stream to write to. + public void Write(Stream stream) + { + if (!TryWrite(stream, out var diagnostics)) + { + throw new ObjectFileException($"Invalid {nameof(ElfObjectFile)}", diagnostics); + } + } + + /// + /// Tries to write this ELF object file to the specified stream. + /// + /// The stream to write to. + /// The output diagnostics + /// true if writing was successful. otherwise false + public bool TryWrite(Stream stream, out DiagnosticBag diagnostics) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + var elfWriter = ElfWriter.Create(this, stream); + diagnostics = elfWriter.Diagnostics; + + Verify(diagnostics); + if (diagnostics.HasErrors) + { + return false; + } + + UpdateLayout(diagnostics); + if (diagnostics.HasErrors) + { + return false; + } + + elfWriter.Write(); + + return !diagnostics.HasErrors; + } + + /// + /// Checks if a stream contains an ELF file by checking the magic signature. + /// + /// The stream containing potentially an ELF file + /// true if the stream contains an ELF file. otherwise returns false + public static bool IsElf(Stream stream) + { + return IsElf(stream, out _); + } + + /// + /// Checks if a stream contains an ELF file by checking the magic signature. + /// + /// The stream containing potentially an ELF file + /// Output the encoding if ELF is true. + /// true if the stream contains an ELF file. otherwise returns false + public static bool IsElf(Stream stream, out ElfEncoding encoding) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + + var ident = ArrayPool.Shared.Rent(EI_NIDENT); + encoding = ElfEncoding.None; + try + { + var startPosition = stream.Position; + var length = stream.Read(ident, 0, EI_NIDENT); + stream.Position = startPosition; + + if (length == EI_NIDENT && (ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 && ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) + { + encoding = (ElfEncoding)ident[EI_DATA]; + return true; + } + } + finally + { + ArrayPool.Shared.Return(ident); + } + + return false; + } + + private static bool TryReadElfObjectFileHeader(Stream stream, out ElfObjectFile file) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + + var ident = ArrayPool.Shared.Rent(EI_NIDENT); + file = null; + try + { + var startPosition = stream.Position; + var length = stream.Read(ident, 0, EI_NIDENT); + stream.Position = startPosition; + + if (length == EI_NIDENT && (ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 && ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) + { + file =new ElfObjectFile(false); + file.CopyIndentFrom(ident); + return true; + } + } + finally + { + ArrayPool.Shared.Return(ident); + } + + return false; + } + + /// + /// Reads an from the specified stream. + /// + /// The stream to read ELF object file from + /// The options for the reader + /// An instance of if the read was successful. + public static ElfObjectFile Read(Stream stream, ElfReaderOptions options = null) + { + if (!TryRead(stream, out var objectFile, out var diagnostics, options)) + { + throw new ObjectFileException($"Unexpected error while reading ELF object file", diagnostics); + } + return objectFile; + } + + /// + /// Tries to read an from the specified stream. + /// + /// The stream to read ELF object file from + /// instance of if the read was successful. + /// A instance + /// The options for the reader + /// true An instance of if the read was successful. + public static bool TryRead(Stream stream, out ElfObjectFile objectFile, out DiagnosticBag diagnostics, ElfReaderOptions options = null) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + + if (!TryReadElfObjectFileHeader(stream, out objectFile)) + { + diagnostics = new DiagnosticBag(); + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderMagic, "ELF magic header not found"); + return false; + } + + options ??= new ElfReaderOptions(); + var reader = ElfReader.Create(objectFile, stream, options); + diagnostics = reader.Diagnostics; + + reader.Read(); + + return !reader.Diagnostics.HasErrors; + } + + /// + /// Contains the layout of an object available after reading an + /// or after calling or + /// + public sealed class ElfObjectLayout + { + internal ElfObjectLayout() + { + } + + /// + /// Size of ELF Header. + /// + public ushort SizeOfElfHeader { get; internal set; } + + /// + /// Offset of the program header table. + /// + public ulong OffsetOfProgramHeaderTable { get; internal set; } + + /// + /// Size of a program header entry. + /// + public ushort SizeOfProgramHeaderEntry { get; internal set; } + + /// + /// Offset of the section header table. + /// + public ulong OffsetOfSectionHeaderTable { get; internal set; } + + /// + /// Size of a section header entry. + /// + public ushort SizeOfSectionHeaderEntry { get; internal set; } + + /// + /// Size of the entire file + /// + public ulong TotalSize { get; internal set; } + + } + + private static readonly Comparison CompareStreamIndexAndIndexDelegate = new Comparison(CompareStreamIndexAndIndex); + + private static int CompareStreamIndexAndIndex(ElfSection left, ElfSection right) + { + var delta = left.StreamIndex.CompareTo(right.StreamIndex); + if (delta != 0) return delta; + return left.Index.CompareTo(right.Index); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs new file mode 100644 index 00000000000000..34eb6ceb97eb3a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs @@ -0,0 +1,83 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + using static ElfNative; + + /// + /// Extensions for + /// + public static class ElfObjectFileExtensions + { + /// + /// Copy to an array buffer the ident array as found in ELF header + /// or . + /// + /// The object file to copy the ident from. + /// A span receiving the ident. Must be >= 16 bytes length + public static void CopyIdentTo(this ElfObjectFile objectFile, Span ident) + { + if (objectFile == null) throw new ArgumentNullException(nameof(objectFile)); + if (ident.Length < EI_NIDENT) + { + throw new ArgumentException($"Expecting span length to be >= {EI_NIDENT}"); + } + + // Clear ident + for (int i = 0; i < EI_NIDENT; i++) + { + ident[i] = 0; + } + + ident[EI_MAG0] = ELFMAG0; + ident[EI_MAG1] = ELFMAG1; + ident[EI_MAG2] = ELFMAG2; + ident[EI_MAG3] = ELFMAG3; + ident[EI_CLASS] = (byte) objectFile.FileClass; + ident[EI_DATA] = (byte) objectFile.Encoding; + ident[EI_VERSION] = (byte)objectFile.Version; + ident[EI_OSABI] = (byte)objectFile.OSABI.Value; + ident[EI_ABIVERSION] = objectFile.AbiVersion; + } + + /// + /// Tries to copy from an ident array as found in ELF header to this ELF object file instance. + /// or . + /// + /// The object file to receive the ident from. + /// A span to read from. Must be >= 16 bytes length + /// The diagnostics + /// true if copying the ident was successful. false otherwise + public static bool TryCopyIdentFrom(this ElfObjectFile objectFile, ReadOnlySpan ident, DiagnosticBag diagnostics) + { + if (objectFile == null) throw new ArgumentNullException(nameof(objectFile)); + if (ident.Length < EI_NIDENT) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderIdentLength, $"Invalid ELF Ident length found. Must be >= {EI_NIDENT}"); + return false; + } + + if (ident[EI_MAG0] != ELFMAG0 || ident[EI_MAG1] != ELFMAG1 || ident[EI_MAG2] != ELFMAG2 || ident[EI_MAG3] != ELFMAG3) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderMagic, "Invalid ELF Magic found"); + return false; + } + + CopyIndentFrom(objectFile, ident); + return true; + } + + internal static void CopyIndentFrom(this ElfObjectFile objectFile, ReadOnlySpan ident) + { + objectFile.FileClass = (ElfFileClass)ident[EI_CLASS]; + objectFile.Encoding = (ElfEncoding)ident[EI_DATA]; + objectFile.Version = ident[EI_VERSION]; + objectFile.OSABI = new ElfOSABIEx(ident[EI_OSABI]); + objectFile.AbiVersion = ident[EI_ABIVERSION]; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs new file mode 100644 index 00000000000000..631b1b2123af69 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs @@ -0,0 +1,810 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.IO; +using System.Text; +using System.Xml; + +namespace LibObjectFile.Elf +{ + /// + /// Extensions methods for to print their layout in text forms, similar to readelf. + /// + public static class ElfPrinter + { + /// + /// Prints an to the specified writer. + /// + /// The object file to print. + /// The destination text writer. + public static void Print(this ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + PrintElfHeader(elf, writer); + PrintSectionHeaders(elf, writer); + PrintSectionGroups(elf, writer); + PrintProgramHeaders(elf, writer); + PrintDynamicSections(elf, writer); + PrintRelocations(elf, writer); + PrintUnwind(elf, writer); + PrintSymbolTables(elf, writer); + PrintVersionInformation(elf, writer); + PrintNotes(elf, writer); + } + + public static void PrintElfHeader(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + Span ident = stackalloc byte[ElfObjectFile.IdentSizeInBytes]; + elf.CopyIdentTo(ident); + + writer.WriteLine("ELF Header:"); + + writer.Write(" Magic: "); + foreach (var b in ident) + { + writer.Write($"{b:x2} "); + } + writer.WriteLine(); + writer.WriteLine($" Class: {GetElfFileClass(elf.FileClass)}"); + writer.WriteLine($" Data: {GetElfEncoding(elf.Encoding)}"); + writer.WriteLine($" Version: {GetElfVersion((byte)elf.Version)}"); + writer.WriteLine($" OS/ABI: {GetElfOsAbi(elf.OSABI)}"); + writer.WriteLine($" ABI Version: {elf.AbiVersion}"); + writer.WriteLine($" Type: {GetElfFileType(elf.FileType)}"); + writer.WriteLine($" Machine: {GetElfArch(elf.Arch)}"); + writer.WriteLine($" Version: 0x{elf.Version:x}"); + writer.WriteLine($" Entry point address: 0x{elf.EntryPointAddress:x}"); + writer.WriteLine($" Start of program headers: {elf.Layout.OffsetOfProgramHeaderTable} (bytes into file)"); + writer.WriteLine($" Start of section headers: {elf.Layout.OffsetOfSectionHeaderTable} (bytes into file)"); + writer.WriteLine($" Flags: {elf.Flags}"); + writer.WriteLine($" Size of this header: {elf.Layout.SizeOfElfHeader} (bytes)"); + writer.WriteLine($" Size of program headers: {elf.Layout.SizeOfProgramHeaderEntry} (bytes)"); + writer.WriteLine($" Number of program headers: {elf.Segments.Count}"); + writer.WriteLine($" Size of section headers: {elf.Layout.SizeOfSectionHeaderEntry} (bytes)"); + writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}"); + writer.WriteLine($" Section header string table index: {elf.SectionHeaderStringTable?.SectionIndex ?? 0}"); + } + + public static void PrintSectionHeaders(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine(); + if (elf.VisibleSectionCount == 0) + { + writer.WriteLine("There are no sections in this file."); + return; + } + + writer.WriteLine(elf.VisibleSectionCount > 1 ? "Section Headers:" : "Section Header:"); + + writer.WriteLine(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al"); + for (int i = 0; i < elf.Sections.Count; i++) + { + var section = elf.Sections[i]; + if (section.IsShadow) continue; + writer.WriteLine($" [{section.SectionIndex,2:#0}] {GetElfSectionName(section),-17} {GetElfSectionType(section.Type),-15} {section.VirtualAddress:x16} {section.Offset:x6} {section.Size:x6} {section.TableEntrySize:x2} {GetElfSectionFlags(section.Flags),3} {section.Link.GetIndex(),2} {section.Info.GetIndex(),3} {section.Alignment,2}"); + } + writer.WriteLine(@"Key to Flags: + W (write), A (alloc), X (execute), M (merge), S (strings), I (info), + L (link order), O (extra OS processing required), G (group), T (TLS), + C (compressed), x (unknown), o (OS specific), E (exclude), + l (large), p (processor specific)"); + } + + public static void PrintSectionGroups(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + if (elf.Sections.Count == 0) + { + writer.WriteLine(); + writer.WriteLine("There are no sections to group in this file."); + return; + } + + writer.WriteLine(); + writer.WriteLine("There are no section groups in this file."); + // TODO + } + + private static string GetElfSectionName(ElfSection section) + { + return section.Parent.SectionHeaderStringTable == null ? "" : section.Name.Value; + } + + public static void PrintProgramHeaders(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine(); + + if (elf.Segments.Count == 0) + { + writer.WriteLine("There are no program headers in this file."); + return; + } + + writer.WriteLine(elf.Segments.Count > 1 ? "Program Headers:" : "Program Header:"); + + writer.WriteLine(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align"); + for (int i = 0; i < elf.Segments.Count; i++) + { + var phdr = elf.Segments[i]; + writer.WriteLine($" {GetElfSegmentType(phdr.Type),-14} 0x{phdr.Offset:x6} 0x{phdr.VirtualAddress:x16} 0x{phdr.PhysicalAddress:x16} 0x{phdr.Size:x6} 0x{phdr.SizeInMemory:x6} {GetElfSegmentFlags(phdr.Flags),3} 0x{phdr.Alignment:x}"); + } + + if (elf.Segments.Count > 0 && elf.VisibleSectionCount > 0 && elf.SectionHeaderStringTable != null) + { + writer.WriteLine(); + writer.WriteLine(" Section to Segment mapping:"); + writer.WriteLine(" Segment Sections..."); + + for (int i = 0; i < elf.Segments.Count; i++) + { + var segment = elf.Segments[i]; + writer.Write($" {i:00} "); + + foreach (var section in elf.Sections) + { + if (IsSectionInSegment(section, segment, true, true)) + { + writer.Write($"{GetElfSectionName(section)} "); + } + } + + writer.WriteLine(); + } + } + } + + public static void PrintRelocations(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + bool hasRelocations = false; + + foreach (var section in elf.Sections) + { + if (section.Type == ElfSectionType.Relocation || section.Type == ElfSectionType.RelocationAddends) + { + hasRelocations = true; + var relocTable = (ElfRelocationTable) section; + + writer.WriteLine(); + writer.WriteLine($"Relocation section {(elf.SectionHeaderStringTable == null ? "0" : $"'{section.Name}'")} at offset 0x{section.Offset:x} contains {relocTable.Entries.Count} {(relocTable.Entries.Count > 1 ? "entries" : "entry")}:"); + + if (elf.FileClass == ElfFileClass.Is32) + { + // TODO + writer.WriteLine(" Offset Info Type Symbol's Value Symbol's Name + Addend"); + } + else + { + writer.WriteLine(" Offset Info Type Symbol's Value Symbol's Name + Addend"); + } + foreach (var entry in relocTable.Entries) + { + var symbolTable = relocTable.Link.Section as ElfSymbolTable; + if (symbolTable == null) continue; + string symbolName = string.Empty; + ulong symbolValue = 0; + if (entry.SymbolIndex < symbolTable.Entries.Count) + { + var symbolEntry = symbolTable.Entries[(int) entry.SymbolIndex]; + symbolName = symbolEntry.Name; + symbolValue = symbolEntry.Value; + + if (string.IsNullOrEmpty(symbolName)) + { + switch (symbolEntry.Type) + { + case ElfSymbolType.Section: + if (symbolEntry.Section.Section != null) + { + symbolName = symbolEntry.Section.Section.Name; + } + break; + } + } + } + + if (elf.FileClass == ElfFileClass.Is32) + { + writer.WriteLine($"{entry.Offset:x8} {entry.Info32:x8} {entry.Type.Name,-22} {symbolValue:x8} {symbolName} + {entry.Addend:x}"); + } + else + { + if (string.IsNullOrEmpty(symbolName)) + { + writer.WriteLine($"{entry.Offset:x16} {entry.Info64:x16} {entry.Type.Name,-22} {"",16} {entry.Addend:x}"); + } + else + { + writer.WriteLine($"{entry.Offset:x16} {entry.Info64:x16} {entry.Type.Name,-22} {symbolValue:x16} {symbolName} + {entry.Addend:x}"); + } + } + } + + } + } + + if (!hasRelocations) + { + writer.WriteLine(); + writer.WriteLine("There are no relocations in this file."); + } + } + + public static void PrintUnwind(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + writer.WriteLine(); + writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported."); + } + + + public static void PrintSymbolTables(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + if (elf.VisibleSectionCount == 0) + { + writer.WriteLine(); + writer.WriteLine("Dynamic symbol information is not available for displaying symbols."); + return; + } + + foreach (var section in elf.Sections) + { + if (!(section is ElfSymbolTable symbolTable)) continue; + + writer.WriteLine(); + writer.WriteLine(symbolTable.Entries.Count <= 1 + ? $"Symbol table '{GetElfSectionName(symbolTable)}' contains {symbolTable.Entries.Count} entry:" + : $"Symbol table '{GetElfSectionName(symbolTable)}' contains {symbolTable.Entries.Count} entries:" + ); + + if (elf.FileClass == ElfFileClass.Is32) + { + writer.WriteLine(" Num: Value Size Type Bind Vis Ndx Name"); + } + else + { + writer.WriteLine(" Num: Value Size Type Bind Vis Ndx Name"); + } + + for (var i = 0; i < symbolTable.Entries.Count; i++) + { + var symbol = symbolTable.Entries[i]; + writer.WriteLine($"{i,6}: {symbol.Value:x16} {symbol.Size,5} {GetElfSymbolType(symbol.Type),-7} {GetElfSymbolBind(symbol.Bind),-6} {GetElfSymbolVisibility(symbol.Visibility),-7} {GetElfSymbolLink(symbol.Section),4} {symbol.Name.Value}"); + } + } + } + + private static string GetElfSymbolLink(ElfSectionLink link) + { + var index = link.GetIndex(); + switch (index) + { + case 0: + return "UND"; + case ElfNative.SHN_ABS: + return "ABS"; + case ElfNative.SHN_COMMON: + return "COMMON"; + } + return index.ToString(); + } + + public static void PrintNotes(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + + foreach (var section in elf.Sections) + { + if (!(section is ElfNoteTable noteTable)) continue; + + writer.WriteLine(); + writer.WriteLine($"Displaying notes found in: {noteTable.Name}"); + + writer.WriteLine(" Owner\t\tData size\tDescription"); + foreach (var note in noteTable.Entries) + { + writer.WriteLine($" {note.GetName()}\t\t0x{(note.GetDescriptorSize()):x8}\t{GetElfNoteDescription(note)}"); + } + } + } + + private static string GetElfNoteDescription(ElfNote note) + { + var builder = new StringBuilder(); + + if (note.GetName() == "GNU") + { + switch (note.GetNoteType().Value) + { + case ElfNoteType.GNU_ABI_TAG: + builder.Append("NT_GNU_ABI_TAG (ABI version tag)"); + break; + case ElfNoteType.GNU_HWCAP: + builder.Append("NT_GNU_HWCAP (DSO-supplied software HWCAP info)"); + break; + case ElfNoteType.GNU_BUILD_ID: + builder.Append("NT_GNU_BUILD_ID (unique build ID bitstring)"); + break; + case ElfNoteType.GNU_GOLD_VERSION: + builder.Append("NT_GNU_GOLD_VERSION (gold version)"); + break; + } + } + else + { + switch (note.GetNoteType().Value) + { + case ElfNoteType.VERSION: + builder.Append("NT_VERSION (version)"); + break; + } + } + + if (builder.Length == 0) + { + builder.Append($"Unknown note type: (0x{(uint)note.GetNoteType().Value:x8})"); + } + + builder.Append("\t\t"); + + builder.Append(note.GetDescriptorAsText()); + return builder.ToString(); + } + + public static void PrintVersionInformation(ElfObjectFile elf, TextWriter writer) + { + if (elf == null) throw new ArgumentNullException(nameof(elf)); + if (writer == null) throw new ArgumentNullException(nameof(writer)); + writer.WriteLine(); + writer.WriteLine("No version information found in this file."); + } + + private static string GetElfSymbolType(ElfSymbolType symbolType) + { + switch (symbolType) + { + case ElfSymbolType.NoType: return "NOTYPE"; + case ElfSymbolType.Object: return "OBJECT"; + case ElfSymbolType.Function: return "FUNC"; + case ElfSymbolType.Section: return "SECTION"; + case ElfSymbolType.File: return "FILE"; + case ElfSymbolType.Common: return "COMMON"; + case ElfSymbolType.Tls: return "TLS"; + case ElfSymbolType.GnuIndirectFunction: + case ElfSymbolType.SpecificOS1: + case ElfSymbolType.SpecificOS2: + return $": {(uint)symbolType}"; + case ElfSymbolType.SpecificProcessor0: + case ElfSymbolType.SpecificProcessor1: + case ElfSymbolType.SpecificProcessor2: + return $": {(uint)symbolType}"; + default: + return $": {(uint)symbolType}"; + } + } + + private static string GetElfSymbolBind(ElfSymbolBind symbolBind) + { + switch (symbolBind) + { + case ElfSymbolBind.Local: + return "LOCAL"; + case ElfSymbolBind.Global: + return "GLOBAL"; + case ElfSymbolBind.Weak: + return "WEAK"; + case ElfSymbolBind.SpecificOS1: + case ElfSymbolBind.SpecificOS2: + return $": {(uint)symbolBind}"; + case ElfSymbolBind.SpecificProcessor0: + case ElfSymbolBind.SpecificProcessor1: + case ElfSymbolBind.SpecificProcessor2: + return $": {(uint)symbolBind}"; + default: + return $": {(uint)symbolBind}"; + } + } + + private static string GetElfSymbolVisibility(ElfSymbolVisibility symbolVisibility) + { + return symbolVisibility switch + { + ElfSymbolVisibility.Default => "DEFAULT", + ElfSymbolVisibility.Internal => "INTERNAL", + ElfSymbolVisibility.Hidden => "HIDDEN", + ElfSymbolVisibility.Protected => "PROTECTED", + _ => $"Unrecognized visibility value: {(uint) symbolVisibility}" + }; + } + + private static bool IsTlsSpecial(ElfSection section, ElfSegment segment) + { + return (((section).Flags & ElfSectionFlags.Tls) != 0 + && (section).Type == ElfSectionType.NoBits + && (segment).Type != ElfSegmentTypeCore.Tls); + } + + private static ulong GetSectionSize(ElfSection section, ElfSegment segment) + { + return IsTlsSpecial(section, segment) ? 0 : section.Size; + } + + private static bool IsSectionInSegment(ElfSection section, ElfSegment segment, bool checkVirtualAddress, bool isStrict) + { + return (( /* Only PT_LOAD, PT_GNU_RELRO and PT_TLS segments can contain SHF_TLS sections. */ + ((((section).Flags & ElfSectionFlags.Tls) != 0) + && (segment.Type == ElfSegmentTypeCore.Tls + //|| segment.Type == ElfSegmentTypeCore.GnuRelPro + || segment.Type == ElfSegmentTypeCore.Load)) + /* PT_TLS segment contains only SHF_TLS sections, PT_PHDR no + sections at all. */ + || (((section).Flags & ElfSectionFlags.Tls) == 0 + + && segment.Type != ElfSegmentTypeCore.Tls + + && segment.Type != ElfSegmentTypeCore.ProgramHeader)) + /* PT_LOAD and similar segments only have SHF_ALLOC sections. */ + && !((section.Flags & ElfSectionFlags.Alloc) == 0 + + && (segment.Type == ElfSegmentTypeCore.Load + + || segment.Type == ElfSegmentTypeCore.Dynamic + //|| segment.Type == PT_GNU_EH_FRAME + //|| segment.Type == PT_GNU_STACK + //|| segment.Type == PT_GNU_RELRO + //|| (segment.Type >= PT_GNU_MBIND_LO + //&& segment.Type <= PT_GNU_MBIND_HI + ))) + /* Any section besides one of type SHT_NOBITS must have file + offsets within the segment. */ + && (section.Type == ElfSectionType.NoBits + || ((section).Offset >= segment.Offset + + && (!(isStrict) + + || (section.Offset - segment.Offset + + <= segment.Size - 1)) + + && ((section.Offset - segment.Offset + + GetSectionSize(section, segment)) + + <= segment.Size))) + /* SHF_ALLOC sections must have VMAs within the segment. */ + && (!(checkVirtualAddress) + || (section.Flags & ElfSectionFlags.Alloc) == 0 + || (section.VirtualAddress >= segment.VirtualAddress + + && (!(isStrict) + + || (section.VirtualAddress - segment.VirtualAddress + + <= segment.SizeInMemory - 1)) + + && ((section.VirtualAddress - segment.VirtualAddress + + GetSectionSize(section, segment)) + + <= segment.SizeInMemory))) + /* No zero size sections at start or end of PT_DYNAMIC nor + PT_NOTE. */ + && ((segment.Type != ElfSegmentTypeCore.Dynamic + + && segment.Type != ElfSegmentTypeCore.Note) + || section.Size != 0 + || segment.SizeInMemory == 0 + || ((section.Type == ElfSectionType.NoBits + + || (section.Offset > segment.Offset + + && (section.Offset - segment.Offset + + < segment.Size))) + + && ((section.Flags & ElfSectionFlags.Alloc) == 0 + + || (section.VirtualAddress > segment.VirtualAddress + + && (section.VirtualAddress - segment.VirtualAddress + + < segment.SizeInMemory))))); + } + + public static void PrintDynamicSections(ElfObjectFile elf, TextWriter writer) + { + writer.WriteLine(); + writer.WriteLine("There is no dynamic section in this file."); + // TODO + } + + private static string GetElfSegmentFlags(ElfSegmentFlags flags) + { + if (flags.Value == 0) return string.Empty; + + var builder = new StringBuilder(); + builder.Append((flags.Value & ElfNative.PF_R) != 0 ? 'R' : ' '); + builder.Append((flags.Value & ElfNative.PF_W) != 0 ? 'W' : ' '); + builder.Append((flags.Value & ElfNative.PF_X) != 0 ? 'E' : ' '); + // TODO: other flags + return builder.ToString(); + } + + public static string GetElfSegmentType(ElfSegmentType segmentType) + { + return segmentType.Value switch + { + ElfNative.PT_NULL => "NULL", + ElfNative.PT_LOAD => "LOAD", + ElfNative.PT_DYNAMIC => "DYNAMIC", + ElfNative.PT_INTERP => "INTERP", + ElfNative.PT_NOTE => "NOTE", + ElfNative.PT_SHLIB => "SHLIB", + ElfNative.PT_PHDR => "PHDR", + ElfNative.PT_TLS => "TLS", + ElfNative.PT_GNU_EH_FRAME => "GNU_EH_FRAME", + ElfNative.PT_GNU_STACK => "GNU_STACK", + ElfNative.PT_GNU_RELRO => "GNU_RELRO", + _ => $": {segmentType.Value:x}" + }; + } + + private static string GetElfSectionFlags(ElfSectionFlags flags) + { + if (flags == ElfSectionFlags.None) return string.Empty; + + var builder = new StringBuilder(); + if ((flags & ElfSectionFlags.Write) != 0) builder.Append('W'); + if ((flags & ElfSectionFlags.Alloc) != 0) builder.Append('A'); + if ((flags & ElfSectionFlags.Executable) != 0) builder.Append('X'); + if ((flags & ElfSectionFlags.Merge) != 0) builder.Append('M'); + if ((flags & ElfSectionFlags.Strings) != 0) builder.Append('S'); + if ((flags & ElfSectionFlags.InfoLink) != 0) builder.Append('I'); + if ((flags & ElfSectionFlags.LinkOrder) != 0) builder.Append('L'); + if ((flags & ElfSectionFlags.OsNonConforming) != 0) builder.Append('O'); + if ((flags & ElfSectionFlags.Group) != 0) builder.Append('G'); + if ((flags & ElfSectionFlags.Tls) != 0) builder.Append('T'); + if ((flags & ElfSectionFlags.Compressed) != 0) builder.Append('C'); + + // TODO: unknown, OS specific, Exclude...etc. + return builder.ToString(); + } + + private static string GetElfSectionType(ElfSectionType sectionType) + { + switch (sectionType) + { + case ElfSectionType.Null: + return "NULL"; + case ElfSectionType.ProgBits: + return "PROGBITS"; + case ElfSectionType.SymbolTable: + return "SYMTAB"; + case ElfSectionType.StringTable: + return "STRTAB"; + case ElfSectionType.RelocationAddends: + return "RELA"; + case ElfSectionType.SymbolHashTable: + return "HASH"; + case ElfSectionType.DynamicLinking: + return "DYNAMIC"; + case ElfSectionType.Note: + return "NOTE"; + case ElfSectionType.NoBits: + return "NOBITS"; + case ElfSectionType.Relocation: + return "REL"; + case ElfSectionType.Shlib: + return "SHLIB"; + case ElfSectionType.DynamicLinkerSymbolTable: + return "DYNSYM"; + case ElfSectionType.InitArray: + return "INIT_ARRAY"; + case ElfSectionType.FiniArray: + return "FINI_ARRAY"; + case ElfSectionType.PreInitArray: + return "PREINIT_ARRAY"; + case ElfSectionType.Group: + return "GROUP"; + case ElfSectionType.SymbolTableSectionHeaderIndices: + return "SYMTAB SECTION INDICIES"; + case ElfSectionType.GnuHash: + return "GNU_HASH"; + case ElfSectionType.GnuLibList: + return "GNU_LIBLIST"; + case ElfSectionType.GnuAttributes: + return "GNU_ATTRIBUTES"; + case ElfSectionType.Checksum: + return "CHECKSUM"; + case ElfSectionType.GnuVersionDefinition: + case (ElfSectionType)0x6ffffffc: + return "VERDEF"; + case ElfSectionType.GnuVersionNeedsSection: + return "VERNEED"; + case ElfSectionType.GnuVersionSymbolTable: + case (ElfSectionType)0x6ffffff0: + return "VERSYM"; + case (ElfSectionType)0x7ffffffd: + return "AUXILIARY"; + case (ElfSectionType)0x7fffffff: + return "FILTER"; + default: + return $"{(uint)sectionType:x8}: "; + } + } + + + private static string GetElfFileClass(ElfFileClass fileClass) + { + switch (fileClass) + { + case ElfFileClass.None: + return "none"; + case ElfFileClass.Is32: + return "ELF32"; + case ElfFileClass.Is64: + return "ELF64"; + default: + return $""; + } + } + + private static string GetElfEncoding(ElfEncoding encoding) + { + return encoding switch + { + ElfEncoding.None => "none", + ElfEncoding.Lsb => "2's complement, little endian", + ElfEncoding.Msb => "2's complement, big endian", + _ => $"" + }; + } + + private static string GetElfVersion(byte version) + { + return version switch + { + ElfNative.EV_CURRENT => $"{version} (current)", + ElfNative.EV_NONE => "", + _ => $"{version} ", + }; + } + + + private static string GetElfOsAbi(ElfOSABIEx osabi) + { + return osabi.Value switch + { + ElfOSABI.NONE => "UNIX - System V", + ElfOSABI.HPUX => "UNIX - HP-UX", + ElfOSABI.NETBSD => "UNIX - NetBSD", + ElfOSABI.GNU => "UNIX - GNU", + ElfOSABI.SOLARIS => "UNIX - Solaris", + ElfOSABI.AIX => "UNIX - AIX", + ElfOSABI.IRIX => "UNIX - IRIX", + ElfOSABI.FREEBSD => "UNIX - FreeBSD", + ElfOSABI.TRU64 => "UNIX - TRU64", + ElfOSABI.MODESTO => "Novell - Modesto", + ElfOSABI.OPENBSD => "UNIX - OpenBSD", + _ => $"= ElfNative.ET_LOPROC && e_type <= ElfNative.ET_HIPROC) return $"Processor Specific: ({e_type:x})"; + else if (e_type >= ElfNative.ET_LOOS && e_type <= ElfNative.ET_HIOS) + return $"OS Specific: ({e_type:x})"; + else + return $": {e_type:x}"; + } + } + + static string GetElfArch(ElfArchEx arch) + { + switch ((ushort)arch.Value) + { + case ElfNative.EM_NONE: return "None"; + case ElfNative.EM_M32: return "WE32100"; + case ElfNative.EM_SPARC: return "Sparc"; + case ElfNative.EM_386: return "Intel 80386"; + case ElfNative.EM_68K: return "MC68000"; + case ElfNative.EM_88K: return "MC88000"; + case ElfNative.EM_860: return "Intel 80860"; + case ElfNative.EM_MIPS: return "MIPS R3000"; + case ElfNative.EM_S370: return "IBM System/370"; + case ElfNative.EM_MIPS_RS3_LE: return "MIPS R4000 big-endian"; + case ElfNative.EM_PARISC: return "HPPA"; + case ElfNative.EM_SPARC32PLUS: return "Sparc v8+"; + case ElfNative.EM_960: return "Intel 80960"; + case ElfNative.EM_PPC: return "PowerPC"; + case ElfNative.EM_PPC64: return "PowerPC64"; + case ElfNative.EM_S390: return "IBM S/390"; + case ElfNative.EM_V800: return "Renesas V850 (using RH850 ABI)"; + case ElfNative.EM_FR20: return "Fujitsu FR20"; + case ElfNative.EM_RH32: return "TRW RH32"; + case ElfNative.EM_ARM: return "ARM"; + case ElfNative.EM_SH: return "Renesas / SuperH SH"; + case ElfNative.EM_SPARCV9: return "Sparc v9"; + case ElfNative.EM_TRICORE: return "Siemens Tricore"; + case ElfNative.EM_ARC: return "ARC"; + case ElfNative.EM_H8_300: return "Renesas H8/300"; + case ElfNative.EM_H8_300H: return "Renesas H8/300H"; + case ElfNative.EM_H8S: return "Renesas H8S"; + case ElfNative.EM_H8_500: return "Renesas H8/500"; + case ElfNative.EM_IA_64: return "Intel IA-64"; + case ElfNative.EM_MIPS_X: return "Stanford MIPS-X"; + case ElfNative.EM_COLDFIRE: return "Motorola Coldfire"; + case ElfNative.EM_68HC12: return "Motorola MC68HC12 Microcontroller"; + case ElfNative.EM_MMA: return "Fujitsu Multimedia Accelerator"; + case ElfNative.EM_PCP: return "Siemens PCP"; + case ElfNative.EM_NCPU: return "Sony nCPU embedded RISC processor"; + case ElfNative.EM_NDR1: return "Denso NDR1 microprocesspr"; + case ElfNative.EM_STARCORE: return "Motorola Star*Core processor"; + case ElfNative.EM_ME16: return "Toyota ME16 processor"; + case ElfNative.EM_ST100: return "STMicroelectronics ST100 processor"; + case ElfNative.EM_TINYJ: return "Advanced Logic Corp. TinyJ embedded processor"; + case ElfNative.EM_X86_64: return "Advanced Micro Devices X86-64"; + case ElfNative.EM_PDSP: return "Sony DSP processor"; + case ElfNative.EM_FX66: return "Siemens FX66 microcontroller"; + case ElfNative.EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller"; + case ElfNative.EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller"; + case ElfNative.EM_68HC16: return "Motorola MC68HC16 Microcontroller"; + case ElfNative.EM_68HC11: return "Motorola MC68HC11 Microcontroller"; + case ElfNative.EM_68HC08: return "Motorola MC68HC08 Microcontroller"; + case ElfNative.EM_68HC05: return "Motorola MC68HC05 Microcontroller"; + case ElfNative.EM_SVX: return "Silicon Graphics SVx"; + case ElfNative.EM_ST19: return "STMicroelectronics ST19 8-bit microcontroller"; + case ElfNative.EM_VAX: return "Digital VAX"; + case ElfNative.EM_CRIS: return "Axis Communications 32-bit embedded processor"; + case ElfNative.EM_JAVELIN: return "Infineon Technologies 32-bit embedded cpu"; + case ElfNative.EM_FIREPATH: return "Element 14 64-bit DSP processor"; + case ElfNative.EM_ZSP: return "LSI Logic's 16-bit DSP processor"; + case ElfNative.EM_MMIX: return "Donald Knuth's educational 64-bit processor"; + case ElfNative.EM_HUANY: return "Harvard Universitys's machine-independent object format"; + case ElfNative.EM_PRISM: return "Vitesse Prism"; + case ElfNative.EM_AVR: return "Atmel AVR 8-bit microcontroller"; + case ElfNative.EM_FR30: return "Fujitsu FR30"; + case ElfNative.EM_D10V: return "d10v"; + case ElfNative.EM_D30V: return "d30v"; + case ElfNative.EM_V850: return "Renesas V850"; + case ElfNative.EM_M32R: return "Renesas M32R (formerly Mitsubishi M32r)"; + case ElfNative.EM_MN10300: return "mn10300"; + case ElfNative.EM_MN10200: return "mn10200"; + case ElfNative.EM_PJ: return "picoJava"; + case ElfNative.EM_XTENSA: return "Tensilica Xtensa Processor"; + default: + return $": 0x{arch.Value:x}"; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs new file mode 100644 index 00000000000000..a548def7f2b223 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs @@ -0,0 +1,60 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Base class for reading and building an from a . + /// + public abstract class ElfReader : ObjectFileReaderWriter, IElfDecoder + { + private protected ElfReader(ElfObjectFile objectFile, Stream stream, ElfReaderOptions readerOptions) : base(stream) + { + ObjectFile = objectFile ?? throw new ArgumentNullException(nameof(objectFile)); + Options = readerOptions; + } + + private protected ElfObjectFile ObjectFile { get; } + + /// + /// Gets the used for reading the + /// + public ElfReaderOptions Options { get; } + + public override bool IsReadOnly => Options.ReadOnly; + + internal abstract void Read(); + + public abstract ElfSectionLink ResolveLink(ElfSectionLink link, string errorMessageFormat); + + internal static ElfReader Create(ElfObjectFile objectFile, Stream stream, ElfReaderOptions options) + { + var thisComputerEncoding = BitConverter.IsLittleEndian ? ElfEncoding.Lsb : ElfEncoding.Msb; + return objectFile.Encoding == thisComputerEncoding ? (ElfReader) new ElfReaderDirect(objectFile, stream, options) : new ElfReaderSwap(objectFile, stream, options); + } + + public abstract ushort Decode(ElfNative.Elf32_Half src); + public abstract ushort Decode(ElfNative.Elf64_Half src); + public abstract uint Decode(ElfNative.Elf32_Word src); + public abstract uint Decode(ElfNative.Elf64_Word src); + public abstract int Decode(ElfNative.Elf32_Sword src); + public abstract int Decode(ElfNative.Elf64_Sword src); + public abstract ulong Decode(ElfNative.Elf32_Xword src); + public abstract long Decode(ElfNative.Elf32_Sxword src); + public abstract ulong Decode(ElfNative.Elf64_Xword src); + public abstract long Decode(ElfNative.Elf64_Sxword src); + public abstract uint Decode(ElfNative.Elf32_Addr src); + public abstract ulong Decode(ElfNative.Elf64_Addr src); + public abstract uint Decode(ElfNative.Elf32_Off src); + public abstract ulong Decode(ElfNative.Elf64_Off src); + public abstract ushort Decode(ElfNative.Elf32_Section src); + public abstract ushort Decode(ElfNative.Elf64_Section src); + public abstract ushort Decode(ElfNative.Elf32_Versym src); + public abstract ushort Decode(ElfNative.Elf64_Versym src); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs new file mode 100644 index 00000000000000..a66822fea3d30a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs @@ -0,0 +1,18 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Internal implementation of with a . + /// + internal sealed class ElfReaderDirect : ElfReader + { + public ElfReaderDirect(ElfObjectFile elfObjectFile, Stream stream, ElfReaderOptions options) : base(elfObjectFile, stream, options) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs new file mode 100644 index 00000000000000..ea9f764a1e47af --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs @@ -0,0 +1,47 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Options used by and + /// + public class ElfReaderOptions + { + /// + /// Gets or sets a boolean indicating if the stream can be used in read-only mode, or false the resulting + /// will be modified. + /// + public bool ReadOnly { get; set; } + + /// + /// Gets or sets a delegate that can be used to replace the creation of when + /// reading from a Stream. + /// + public TryCreateNoteDelegate TryCreateNote { get; set; } + + /// + /// Gets or sets a delegate that can be used to replace the creation of when + /// reading from a Stream. + /// + public TryCreateSectionDelegate TryCreateSection { get; set; } + + /// + /// Tries to create a section instance from the specified type. Might return null. + /// + /// Type of the section to create. + /// The diagnostics + /// null if the section is not supported or an instance of for the specified type. + public delegate ElfSection TryCreateSectionDelegate(ElfSectionType sectionType, DiagnosticBag diagnostics); + + /// + /// Tries to create a note instance from the specified name and type. Might return null. + /// + /// Name of the note. + /// Type of the note + /// null if the note is not supported or an instance of for the specified name and type. + public delegate ElfNote TryCreateNoteDelegate(string noteName, ElfNoteType noteType); + + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs new file mode 100644 index 00000000000000..71cb8a3fbd2a02 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs @@ -0,0 +1,18 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Internal implementation of with a . + /// + internal sealed class ElfReaderSwap : ElfReader + { + public ElfReaderSwap(ElfObjectFile elfObjectFile, Stream stream, ElfReaderOptions options) : base(elfObjectFile, stream, options) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs new file mode 100644 index 00000000000000..6f5edecc11cb92 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs @@ -0,0 +1,764 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Internal implementation of to read from a stream to an instance. + /// + /// The decoder used for LSB/MSB conversion + internal abstract class ElfReader : ElfReader where TDecoder : struct, IElfDecoder + { + private TDecoder _decoder; + private ulong _startOfFile; + private ushort _programHeaderCount; + private ushort _sectionHeaderCount; + private ushort _sectionStringTableIndex; + private bool _isFirstSectionValidNull; + private bool _hasValidSectionStringTable; + + protected ElfReader(ElfObjectFile objectFile, Stream stream, ElfReaderOptions options) : base(objectFile, stream, options) + { + _decoder = new TDecoder(); + } + + private ElfObjectFile.ElfObjectLayout Layout => ObjectFile.Layout; + + internal override void Read() + { + if (ObjectFile.FileClass == ElfFileClass.None) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderFileClassNone, "Cannot read an ELF Class = None"); + throw new ObjectFileException($"Invalid {nameof(ElfObjectFile)}", Diagnostics); + } + + _startOfFile = (ulong)Stream.Position; + ReadElfHeader(); + ReadProgramHeaders(); + ReadSections(); + + VerifyAndFixProgramHeadersAndSections(); + } + + private void ReadElfHeader() + { + if (ObjectFile.FileClass == ElfFileClass.Is32) + { + ReadElfHeader32(); + } + else + { + ReadElfHeader64(); + } + + if (_sectionHeaderCount >= ElfNative.SHN_LORESERVE) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderCount, $"Invalid number `{_sectionHeaderCount}` of section headers found from Elf Header. Must be < {ElfNative.SHN_LORESERVE}"); + } + } + + private unsafe void ReadElfHeader32() + { + ElfNative.Elf32_Ehdr hdr; + ulong streamOffset = (ulong)Stream.Position; + if (!TryReadData(sizeof(ElfNative.Elf32_Ehdr), out hdr)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteHeader32Size, $"Unable to read entirely Elf header. Not enough data (size: {sizeof(ElfNative.Elf32_Ehdr)}) read at offset {streamOffset} from the stream"); + } + + ObjectFile.FileType = (ElfFileType)_decoder.Decode(hdr.e_type); + ObjectFile.Arch = new ElfArchEx(_decoder.Decode(hdr.e_machine)); + ObjectFile.Version = _decoder.Decode(hdr.e_version); + + ObjectFile.EntryPointAddress = _decoder.Decode(hdr.e_entry); + Layout.SizeOfElfHeader = _decoder.Decode(hdr.e_ehsize); + ObjectFile.Flags = _decoder.Decode(hdr.e_flags); + + // program headers + Layout.OffsetOfProgramHeaderTable = _decoder.Decode(hdr.e_phoff); + Layout.SizeOfProgramHeaderEntry = _decoder.Decode(hdr.e_phentsize); + _programHeaderCount = _decoder.Decode(hdr.e_phnum); + + // entries for sections + Layout.OffsetOfSectionHeaderTable = _decoder.Decode(hdr.e_shoff); + Layout.SizeOfSectionHeaderEntry = _decoder.Decode(hdr.e_shentsize); + _sectionHeaderCount = _decoder.Decode(hdr.e_shnum); + _sectionStringTableIndex = _decoder.Decode(hdr.e_shstrndx); + } + + private unsafe void ReadElfHeader64() + { + ElfNative.Elf64_Ehdr hdr; + ulong streamOffset = (ulong)Stream.Position; + if (!TryReadData(sizeof(ElfNative.Elf64_Ehdr), out hdr)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteHeader64Size, $"Unable to read entirely Elf header. Not enough data (size: {sizeof(ElfNative.Elf64_Ehdr)}) read at offset {streamOffset} from the stream"); + } + + ObjectFile.FileType = (ElfFileType)_decoder.Decode(hdr.e_type); + ObjectFile.Arch = new ElfArchEx(_decoder.Decode(hdr.e_machine)); + ObjectFile.Version = _decoder.Decode(hdr.e_version); + + ObjectFile.EntryPointAddress = _decoder.Decode(hdr.e_entry); + Layout.SizeOfElfHeader = _decoder.Decode(hdr.e_ehsize); + ObjectFile.Flags = _decoder.Decode(hdr.e_flags); + + // program headers + Layout.OffsetOfProgramHeaderTable = _decoder.Decode(hdr.e_phoff); + Layout.SizeOfProgramHeaderEntry = _decoder.Decode(hdr.e_phentsize); + _programHeaderCount = _decoder.Decode(hdr.e_phnum); + + // entries for sections + Layout.OffsetOfSectionHeaderTable = _decoder.Decode(hdr.e_shoff); + Layout.SizeOfSectionHeaderEntry = _decoder.Decode(hdr.e_shentsize); + _sectionHeaderCount = _decoder.Decode(hdr.e_shnum); + _sectionStringTableIndex = _decoder.Decode(hdr.e_shstrndx); + } + + private void ReadProgramHeaders() + { + if (Layout.SizeOfProgramHeaderEntry == 0) + { + if (_programHeaderCount > 0) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidZeroProgramHeaderTableEntrySize, $"Unable to read program header table as the size of program header entry ({nameof(ElfNative.Elf32_Ehdr.e_phentsize)}) == 0 in the Elf Header"); + } + return; + } + + for (int i = 0; i < _programHeaderCount; i++) + { + var offset = Layout.OffsetOfProgramHeaderTable + (ulong)i * Layout.SizeOfProgramHeaderEntry; + + if (offset >= (ulong)Stream.Length) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidProgramHeaderStreamOffset, $"Unable to read program header [{i}] as its offset {offset} is out of bounds"); + break; + } + + // Seek to the header position + Stream.Position = (long)offset; + + var segment = (ObjectFile.FileClass == ElfFileClass.Is32) ? ReadProgramHeader32(i) : ReadProgramHeader64(i); + ObjectFile.AddSegment(segment); + } + } + + private ElfSegment ReadProgramHeader32(int phdrIndex) + { + var streamOffset = Stream.Position; + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Phdr hdr)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteProgramHeader32Size, $"Unable to read entirely program header [{phdrIndex}]. Not enough data (size: {Layout.SizeOfProgramHeaderEntry}) read at offset {streamOffset} from the stream"); + } + + return new ElfSegment + { + Type = new ElfSegmentType(_decoder.Decode(hdr.p_type)), + Offset =_decoder.Decode(hdr.p_offset), + VirtualAddress = _decoder.Decode(hdr.p_vaddr), + PhysicalAddress = _decoder.Decode(hdr.p_paddr), + Size = _decoder.Decode(hdr.p_filesz), + SizeInMemory = _decoder.Decode(hdr.p_memsz), + Flags = new ElfSegmentFlags(_decoder.Decode(hdr.p_flags)), + Alignment = _decoder.Decode(hdr.p_align) + }; + } + + private ElfSegment ReadProgramHeader64(int phdrIndex) + { + var streamOffset = Stream.Position; + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Phdr hdr)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteProgramHeader64Size, $"Unable to read entirely program header [{phdrIndex}]. Not enough data (size: {Layout.SizeOfProgramHeaderEntry}) read at offset {streamOffset} from the stream"); + } + + return new ElfSegment + { + Type = new ElfSegmentType(_decoder.Decode(hdr.p_type)), + Offset = _decoder.Decode(hdr.p_offset), + VirtualAddress = _decoder.Decode(hdr.p_vaddr), + PhysicalAddress = _decoder.Decode(hdr.p_paddr), + Size = _decoder.Decode(hdr.p_filesz), + SizeInMemory = _decoder.Decode(hdr.p_memsz), + Flags = new ElfSegmentFlags(_decoder.Decode(hdr.p_flags)), + Alignment = _decoder.Decode(hdr.p_align) + }; + } + + private void ReadSections() + { + if (_sectionHeaderCount == 0) return; + + // Write section header table + ReadSectionHeaderTable(); + } + + private void ReadSectionHeaderTable() + { + if (Layout.SizeOfSectionHeaderEntry == 0) + { + if (_sectionHeaderCount > 0) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidZeroSectionHeaderTableEntrySize, $"Unable to read section header table as the size of section header entry ({nameof(ElfNative.Elf32_Ehdr.e_ehsize)}) == 0 in the Elf Header"); + } + return; + } + + for (int i = 0; i < _sectionHeaderCount; i++) + { + var offset = Layout.OffsetOfSectionHeaderTable + (ulong)i * Layout.SizeOfSectionHeaderEntry; + + if (offset >= (ulong)Stream.Length) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderStreamOffset, $"Unable to read section [{i}] as its offset {offset} is out of bounds"); + break; + } + + // Seek to the header position + Stream.Position = (long)offset; + + var section = ReadSectionTableEntry(i); + ObjectFile.AddSection(section); + } + } + + private ElfSection ReadSectionTableEntry(int sectionIndex) + { + return ObjectFile.FileClass == ElfFileClass.Is32 ? ReadSectionTableEntry32(sectionIndex) : ReadSectionTableEntry64(sectionIndex); + } + + private ElfSection ReadSectionTableEntry32(int sectionIndex) + { + var streamOffset = Stream.Position; + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Shdr rawSection)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader32Size, $"Unable to read entirely section header [{sectionIndex}]. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {streamOffset} from the stream"); + } + + if (sectionIndex == 0) + { + _isFirstSectionValidNull = rawSection.IsNull; + } + + var sectionType = (ElfSectionType)_decoder.Decode(rawSection.sh_type); + bool isValidNullSection = sectionIndex == 0 && rawSection.IsNull; + var section = CreateElfSection(sectionIndex, sectionType, isValidNullSection); + + if (!isValidNullSection) + { + section.Name = new ElfString(_decoder.Decode(rawSection.sh_name)); + section.Type = (ElfSectionType)_decoder.Decode(rawSection.sh_type); + section.Flags = (ElfSectionFlags)_decoder.Decode(rawSection.sh_flags); + section.VirtualAddress = _decoder.Decode(rawSection.sh_addr); + section.Offset = _decoder.Decode(rawSection.sh_offset); + section.Alignment = _decoder.Decode(rawSection.sh_addralign); + section.Link = new ElfSectionLink(_decoder.Decode(rawSection.sh_link)); + section.Info = new ElfSectionLink(_decoder.Decode(rawSection.sh_info)); + section.Size = _decoder.Decode(rawSection.sh_size); + section.OriginalTableEntrySize = _decoder.Decode(rawSection.sh_entsize); + } + + return section; + } + + private ElfSection ReadSectionTableEntry64(int sectionIndex) + { + var streamOffset = Stream.Position; + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Shdr rawSection)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader64Size, $"Unable to read entirely section header [{sectionIndex}]. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {streamOffset} from the stream"); + } + + if (sectionIndex == 0) + { + _isFirstSectionValidNull = rawSection.IsNull; + } + + var sectionType = (ElfSectionType)_decoder.Decode(rawSection.sh_type); + bool isValidNullSection = sectionIndex == 0 && rawSection.IsNull; + var section = CreateElfSection(sectionIndex, sectionType, sectionIndex == 0 && rawSection.IsNull); + + if (!isValidNullSection) + { + section.Name = new ElfString(_decoder.Decode(rawSection.sh_name)); + section.Type = (ElfSectionType)_decoder.Decode(rawSection.sh_type); + section.Flags = (ElfSectionFlags)_decoder.Decode(rawSection.sh_flags); + section.VirtualAddress = _decoder.Decode(rawSection.sh_addr); + section.Offset = _decoder.Decode(rawSection.sh_offset); + section.Alignment = _decoder.Decode(rawSection.sh_addralign); + section.Link = new ElfSectionLink(_decoder.Decode(rawSection.sh_link)); + section.Info = new ElfSectionLink(_decoder.Decode(rawSection.sh_info)); + section.Size = _decoder.Decode(rawSection.sh_size); + section.OriginalTableEntrySize = _decoder.Decode(rawSection.sh_entsize); + } + + return section; + } + + public override ElfSectionLink ResolveLink(ElfSectionLink link, string errorMessageFormat) + { + if (errorMessageFormat == null) throw new ArgumentNullException(nameof(errorMessageFormat)); + + // Connect section Link instance + if (!link.IsSpecial) + { + if (link.SpecialIndex == _sectionStringTableIndex) + { + link = new ElfSectionLink(ObjectFile.SectionHeaderStringTable); + } + else + { + var sectionIndex = link.SpecialIndex; + + bool sectionFound = false; + foreach (var section in ObjectFile.Sections) + { + if (section.SectionIndex == sectionIndex) + { + link = new ElfSectionLink(section); + sectionFound = true; + break; + } + } + + if (!sectionFound) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidResolvedLink, string.Format(errorMessageFormat, link.SpecialIndex)); + } + } + } + + return link; + } + + private void VerifyAndFixProgramHeadersAndSections() + { + if (!_isFirstSectionValidNull && ObjectFile.Sections.Count > 0) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSectionExpectingUndefined, $"Invalid Section [0] {ObjectFile.Sections[0].Type}. Expecting {ElfNative.SHN_UNDEF}"); + } + + if (_hasValidSectionStringTable) + { + Stream.Position = (long)ObjectFile.SectionHeaderStringTable.Offset; + ObjectFile.SectionHeaderStringTable.ReadInternal(this); + } + + for (var i = 0; i < ObjectFile.Sections.Count; i++) + { + var section = ObjectFile.Sections[i]; + if (section is ElfNullSection || section is ElfProgramHeaderTable) continue; + + // Resolve the name of the section + if (ObjectFile.SectionHeaderStringTable != null && ObjectFile.SectionHeaderStringTable.TryFind(section.Name.Index, out var sectionName)) + { + section.Name = section.Name.WithName(sectionName); + } + else + { + if (ObjectFile.SectionHeaderStringTable == null) + { + Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidStringIndexMissingStringHeaderTable, $"Unable to resolve string index [{section.Name.Index}] for section [{section.Index}] as section header string table does not exist"); + } + else + { + Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidStringIndex, $"Unable to resolve string index [{section.Name.Index}] for section [{section.Index}] from section header string table"); + } + } + + // Connect section Link instance + section.Link = ResolveLink(section.Link, $"Invalid section Link [{{0}}] for section [{i}]"); + + // Connect section Info instance + if (section.Type != ElfSectionType.DynamicLinkerSymbolTable && section.Type != ElfSectionType.SymbolTable) + { + section.Info = ResolveLink(section.Info, $"Invalid section Info [{{0}}] for section [{i}]"); + } + + if (i == 0 && _isFirstSectionValidNull) + { + continue; + } + + if (i == _sectionStringTableIndex && _hasValidSectionStringTable) + { + continue; + } + + if (section.HasContent) + { + Stream.Position = (long)section.Offset; + section.ReadInternal(this); + } + } + + foreach (var section in ObjectFile.Sections) + { + section.AfterReadInternal(this); + } + + var fileParts = new ElfFilePartList(ObjectFile.Sections.Count + ObjectFile.Segments.Count); + + if (_isFirstSectionValidNull) + { + var programHeaderTable = new ElfProgramHeaderTable() + { + Offset = Layout.OffsetOfProgramHeaderTable, + }; + + // Add the shadow section ElfProgramHeaderTable + ObjectFile.InsertSectionAt(1, programHeaderTable); + programHeaderTable.UpdateLayout(Diagnostics); + + if (programHeaderTable.Size > 0) + { + fileParts.Insert(new ElfFilePart(programHeaderTable)); + } + } + + // Make sure to pre-sort all sections by offset + var orderedSections = new List(ObjectFile.Sections.Count); + orderedSections.AddRange(ObjectFile.Sections); + orderedSections.Sort(CompareSectionOffsetsDelegate); + // Store the stream index to recover the same order when saving back. + for(int i = 0; i < orderedSections.Count; i++) + { + orderedSections[i].StreamIndex = (uint)i; + } + + // Lastly verify integrity of all sections + bool hasShadowSections = false; + + var lastOffset = fileParts.Count > 0 ? fileParts[fileParts.Count - 1].EndOffset : 0; + for (var i = 0; i < orderedSections.Count; i++) + { + var section = orderedSections[i]; + section.Verify(this.Diagnostics); + + if (lastOffset > 0 && section.Offset > lastOffset) + { + if (section.Offset > lastOffset) + { + // Create parts for the segment + fileParts.CreateParts(lastOffset + 1, section.Offset - 1); + hasShadowSections = true; + } + } + + if (section.Size == 0 || !section.HasContent) + { + continue; + } + + // Collect sections parts + fileParts.Insert(new ElfFilePart(section)); + lastOffset = section.Offset + section.Size - 1; + + // Verify overlapping sections and generate and error + for (int j = i + 1; j < orderedSections.Count; j++) + { + var otherSection = orderedSections[j]; + if (section.Contains(otherSection) || otherSection.Contains(section)) + { + Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidOverlappingSections, $"The section {section} [{section.Offset} : {section.Offset + section.Size - 1}] is overlapping with the section {otherSection} [{otherSection.Offset} : {otherSection.Offset + otherSection.Size - 1}]"); + } + } + } + + // Link segments to sections if we have an exact match. + // otherwise record any segments that are not bound to a section. + + foreach (var segment in ObjectFile.Segments) + { + if (segment.Size == 0) continue; + + var segmentEndOffset = segment.Offset + segment.Size - 1; + foreach (var section in orderedSections) + { + if (section.Size == 0 || !section.HasContent) continue; + + var sectionEndOffset = section.Offset + section.Size - 1; + if (segment.Offset == section.Offset && segmentEndOffset == sectionEndOffset) + { + // Single case: segment == section + // If we found a section, we will bind the program header to this section + // and switch the offset calculation to auto + segment.Range = section; + segment.OffsetKind = ValueKind.Auto; + break; + } + } + + if (segment.Range.IsEmpty) + { + var offset = segment.Offset; + + // If a segment offset is set to 0, we need to take into + // account the fact that the Elf header is already being handled + // so we should not try to create a shadow section for it + if (offset < Layout.SizeOfElfHeader) + { + offset = Layout.SizeOfElfHeader; + } + + // Create parts for the segment + fileParts.CreateParts(offset, segmentEndOffset); + hasShadowSections = true; + } + } + + // If the previous loop has created ElfFilePart, we have to + // create ElfCustomShadowSection and update the ElfSegment.Range + if (hasShadowSections) + { + int shadowCount = 0; + // If we have sections and the first section is NULL valid, we can start inserting + // shadow sections at index 1 (after null section), otherwise we can insert shadow + // sections before. + uint previousSectionIndex = _isFirstSectionValidNull ? 1U : 0U; + + // Create ElfCustomShadowSection for any parts in the file + // that are referenced by a segment but doesn't have a section + for (var i = 0; i < fileParts.Count; i++) + { + var part = fileParts[i]; + if (part.Section == null) + { + var shadowSection = new ElfBinaryShadowSection() + { + Name = ".shadow." + shadowCount, + Offset = part.StartOffset, + Size = part.EndOffset - part.StartOffset + 1 + }; + shadowCount++; + + Stream.Position = (long)shadowSection.Offset; + shadowSection.ReadInternal(this); + + // Insert the shadow section with this order + shadowSection.StreamIndex = previousSectionIndex; + for (int j = (int)previousSectionIndex; j < orderedSections.Count; j++) + { + var otherSection = orderedSections[j]; + otherSection.StreamIndex++; + } + // Update ordered sections + orderedSections.Insert((int)previousSectionIndex, shadowSection); + ObjectFile.AddSection(shadowSection); + + fileParts[i] = new ElfFilePart(shadowSection); + } + else + { + previousSectionIndex = part.Section.StreamIndex + 1; + } + } + + // Update all segment Ranges + foreach (var segment in ObjectFile.Segments) + { + if (segment.Size == 0) continue; + if (!segment.Range.IsEmpty) continue; + + var segmentEndOffset = segment.Offset + segment.Size - 1; + for (var i = 0; i < orderedSections.Count; i++) + { + var section = orderedSections[i]; + if (section.Size == 0 || !section.HasContent) continue; + + var sectionEndOffset = section.Offset + section.Size - 1; + if (segment.Offset >= section.Offset && segment.Offset <= sectionEndOffset) + { + ElfSection beginSection = section; + ElfSection endSection = null; + for (int j = i; j < orderedSections.Count; j++) + { + var nextSection = orderedSections[j]; + if (nextSection.Size == 0 || !nextSection.HasContent) continue; + + sectionEndOffset = nextSection.Offset + nextSection.Size - 1; + + if (segmentEndOffset >= nextSection.Offset && segmentEndOffset <= sectionEndOffset) + { + endSection = nextSection; + break; + } + } + + if (endSection == null) + { + // TODO: is it a throw/assert or a log? + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRange, $"Invalid range for {segment}. The range is set to empty"); + } + else + { + segment.Range = new ElfSegmentRange(beginSection, segment.Offset - beginSection.Offset, endSection, (long)(segmentEndOffset - endSection.Offset)); + } + + segment.OffsetKind = ValueKind.Auto; + break; + } + } + } + } + } + + private ElfSection CreateElfSection(int sectionIndex, ElfSectionType sectionType, bool isNullSection) + { + ElfSection section = null; + + switch (sectionType) + { + case ElfSectionType.Null: + if (isNullSection) + { + section = new ElfNullSection(); + } + break; + case ElfSectionType.DynamicLinkerSymbolTable: + case ElfSectionType.SymbolTable: + section = new ElfSymbolTable(); + break; + case ElfSectionType.StringTable: + + if (sectionIndex == _sectionStringTableIndex) + { + _hasValidSectionStringTable = true; + section = new ElfSectionHeaderStringTable(); + } + else + { + section = new ElfStringTable(); + } + break; + case ElfSectionType.Relocation: + case ElfSectionType.RelocationAddends: + section = new ElfRelocationTable(); + break; + case ElfSectionType.Note: + section = new ElfNoteTable(); + break; + } + + // If the section is not a builtin section, try to offload to a delegate + // or use the default ElfCustomSection. + if (section == null) + { + if (Options.TryCreateSection != null) + { + section = Options.TryCreateSection(sectionType, Diagnostics); + } + + if (section == null) + { + section = new ElfBinarySection(); + } + } + + return section; + } + + public override ushort Decode(ElfNative.Elf32_Half src) + { + return _decoder.Decode(src); + } + + public override ushort Decode(ElfNative.Elf64_Half src) + { + return _decoder.Decode(src); + } + + public override uint Decode(ElfNative.Elf32_Word src) + { + return _decoder.Decode(src); + } + + public override uint Decode(ElfNative.Elf64_Word src) + { + return _decoder.Decode(src); + } + + public override int Decode(ElfNative.Elf32_Sword src) + { + return _decoder.Decode(src); + } + + public override int Decode(ElfNative.Elf64_Sword src) + { + return _decoder.Decode(src); + } + + public override ulong Decode(ElfNative.Elf32_Xword src) + { + return _decoder.Decode(src); + } + + public override long Decode(ElfNative.Elf32_Sxword src) + { + return _decoder.Decode(src); + } + + public override ulong Decode(ElfNative.Elf64_Xword src) + { + return _decoder.Decode(src); + } + + public override long Decode(ElfNative.Elf64_Sxword src) + { + return _decoder.Decode(src); + } + + public override uint Decode(ElfNative.Elf32_Addr src) + { + return _decoder.Decode(src); + } + + public override ulong Decode(ElfNative.Elf64_Addr src) + { + return _decoder.Decode(src); + } + + public override uint Decode(ElfNative.Elf32_Off src) + { + return _decoder.Decode(src); + } + + public override ulong Decode(ElfNative.Elf64_Off src) + { + return _decoder.Decode(src); + } + + public override ushort Decode(ElfNative.Elf32_Section src) + { + return _decoder.Decode(src); + } + + public override ushort Decode(ElfNative.Elf64_Section src) + { + return _decoder.Decode(src); + } + + public override ushort Decode(ElfNative.Elf32_Versym src) + { + return _decoder.Decode(src); + } + + public override ushort Decode(ElfNative.Elf64_Versym src) + { + return _decoder.Decode(src); + } + + private static readonly Comparison CompareSectionOffsetsDelegate = new Comparison(CompareSectionOffsets); + + private static int CompareSectionOffsets(ElfSection left, ElfSection right) + { + return left.Offset.CompareTo(right.Offset); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs new file mode 100644 index 00000000000000..12fdae3478bac3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs @@ -0,0 +1,198 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile.Elf +{ + /// + /// Defines the base class for a section in an . + /// + [DebuggerDisplay("{ToString(),nq}")] + public abstract class ElfSection : ElfObject + { + private ElfSectionType _type; + + protected ElfSection() : this(ElfSectionType.Null) + { + } + + protected ElfSection(ElfSectionType sectionType) + { + _type = sectionType; + } + + public virtual ElfSectionType Type + { + get => _type; + set + { + _type = value; + } + } + + protected override void ValidateParent(ObjectFileNode parent) + { + if (!(parent is ElfObjectFile)) + { + throw new ArgumentException($"Parent must inherit from type {nameof(ElfObjectFile)}"); + } + } + + + /// + /// Gets the containing . Might be null if this section or segment + /// does not belong to an existing . + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + public new ElfObjectFile Parent + { + get => (ElfObjectFile)base.Parent; + internal set => base.Parent = value; + } + + /// + /// Gets or sets the of this section. + /// + public ElfSectionFlags Flags { get; set; } + + /// + /// Gets or sets the name of this section. + /// + public ElfString Name { get; set; } + + /// + /// Gets or sets the virtual address of this section. + /// + public ulong VirtualAddress { get; set; } + + /// + /// Gets or sets the alignment requirement of this section. + /// + public ulong Alignment { get; set; } + + /// + /// Gets or sets the link element of this section. + /// + public ElfSectionLink Link { get; set; } + + /// + /// Gets or sets the info element of this section. + /// + public ElfSectionLink Info { get; set; } + + /// + /// Gets the table entry size of this section. + /// + public virtual ulong TableEntrySize => 0; + + /// + /// Gets the index of the visible sections in (visible == not ) + /// + public uint SectionIndex { get; internal set; } + + /// + /// Gets or sets the ordering index used when writing back this section. + /// + public uint StreamIndex { get; set; } + + /// + /// Gets the size of the original table entry size of this section. + /// + public ulong OriginalTableEntrySize { get; internal set; } + + /// + /// Gets a boolean indicating if this section is a . + /// + public bool IsShadow => this is ElfShadowSection; + + /// + /// Gets a boolean indicating if this section has some content (Size should be taken into account). + /// + public bool HasContent => Type != ElfSectionType.NoBits && (Type != ElfSectionType.Null || this is ElfShadowSection); + + /// + /// Read data from the specified reader to this instance. + /// + /// The reader to read data from. + protected abstract void Read(ElfReader reader); + + /// + /// Writes data to the specified writer from this instance. + /// + /// The writer to write data to. + protected abstract void Write(ElfWriter writer); + + internal void WriteInternal(ElfWriter writer) + { + Write(writer); + } + + internal void ReadInternal(ElfReader reader) + { + Read(reader); + } + + public override void Verify(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + // Check parent for link section + if (Link.Section != null) + { + if (Link.Section.Parent != this.Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionLinkParent, $"Invalid parent for {nameof(Link)}: `{Link}` used by section `{this}`. The {nameof(Link)}.{nameof(ElfSectionLink.Section)} must have the same parent {nameof(ElfObjectFile)} than this section"); + } + } + + if (Info.Section != null) + { + if (Info.Section.Parent != this.Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionInfoParent, $"Invalid parent for {nameof(Info)}: `{Info}` used by section `{this}`. The {nameof(Info)}.{nameof(ElfSectionLink.Section)} must have the same parent {nameof(ElfObjectFile)} than this section"); + } + } + + // Verify that Link is correctly setup for this section + switch (Type) + { + case ElfSectionType.DynamicLinking: + case ElfSectionType.DynamicLinkerSymbolTable: + case ElfSectionType.SymbolTable: + Link.TryGetSectionSafe(this.GetType().Name, nameof(Link), this, diagnostics, out _, ElfSectionType.StringTable); + break; + case ElfSectionType.SymbolHashTable: + case ElfSectionType.Relocation: + case ElfSectionType.RelocationAddends: + Link.TryGetSectionSafe(this.GetType().Name, nameof(Link), this, diagnostics, out _, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); + break; + } + } + + protected virtual void AfterRead(ElfReader reader) + { + } + + protected virtual void BeforeWrite(ElfWriter writer) + { + } + + public override string ToString() + { + return $"Section [{SectionIndex}](Internal: {Index}) `{Name}` "; + } + + internal void BeforeWriteInternal(ElfWriter writer) + { + BeforeWrite(writer); + } + + internal void AfterReadInternal(ElfReader reader) + { + AfterRead(reader); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs new file mode 100644 index 00000000000000..86cae8d4f6f14d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs @@ -0,0 +1,154 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using LibObjectFile.Utils; + +namespace LibObjectFile.Elf +{ + /// + /// Extensions for + /// + public static class ElfSectionExtension + { + /// + /// Configure a section default name, type and flags with + /// + /// The type of the section to configure + /// The section to configure + /// The special type + /// The section configured + public static TElfSection ConfigureAs(this TElfSection section, ElfSectionSpecialType sectionSpecialType) where TElfSection : ElfSection + { + switch (sectionSpecialType) + { + case ElfSectionSpecialType.None: + break; + case ElfSectionSpecialType.Bss: + section.Name = ".bss"; + section.Type = ElfSectionType.NoBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; + break; + case ElfSectionSpecialType.Comment: + section.Name = ".comment"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Data: + section.Name = ".data"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; + break; + case ElfSectionSpecialType.Data1: + section.Name = ".data1"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; + break; + case ElfSectionSpecialType.Debug: + section.Name = ".debug"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Dynamic: + section.Name = ".dynamic"; + section.Type = ElfSectionType.DynamicLinking; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.DynamicStringTable: + section.Name = ".dynstr"; + section.Type = ElfSectionType.StringTable; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.DynamicSymbolTable: + section.Name = ".dynsym"; + section.Type = ElfSectionType.DynamicLinkerSymbolTable; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.Fini: + section.Name = ".fini"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; + break; + case ElfSectionSpecialType.Got: + section.Name = ".got"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Hash: + section.Name = ".hash"; + section.Type = ElfSectionType.SymbolHashTable; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Init: + section.Name = ".init"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; + break; + case ElfSectionSpecialType.Interp: + section.Name = ".interp"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.Line: + section.Name = ".line"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Note: + section.Name = ".note"; + section.Type = ElfSectionType.Note; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Plt: + section.Name = ".plt"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Relocation: + section.Name = ElfRelocationTable.DefaultName; + section.Type = ElfSectionType.Relocation; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.RelocationAddends: + section.Name = ElfRelocationTable.DefaultNameWithAddends; + section.Type = ElfSectionType.RelocationAddends; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.ReadOnlyData: + section.Name = ".rodata"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.ReadOnlyData1: + section.Name = ".rodata1"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc; + break; + case ElfSectionSpecialType.SectionHeaderStringTable: + section.Name = ".shstrtab"; + section.Type = ElfSectionType.StringTable; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.StringTable: + section.Name = ElfStringTable.DefaultName; + section.Type = ElfSectionType.StringTable; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.SymbolTable: + section.Name = ElfSymbolTable.DefaultName; + section.Type = ElfSectionType.SymbolTable; + section.Flags = ElfSectionFlags.None; + break; + case ElfSectionSpecialType.Text: + section.Name = ".text"; + section.Type = ElfSectionType.ProgBits; + section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; + break; + default: + throw ThrowHelper.InvalidEnum(sectionSpecialType); + } + return section; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs new file mode 100644 index 00000000000000..d52c4ea5f5af14 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs @@ -0,0 +1,72 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines the flag of a section. + /// + [Flags] + public enum ElfSectionFlags : uint + { + None = 0, + + /// + /// Writable + /// + Write = ElfNative.SHF_WRITE, + + /// + /// Occupies memory during execution + /// + Alloc = ElfNative.SHF_ALLOC, + + /// + /// Executable + /// + Executable = ElfNative.SHF_EXECINSTR, + + /// + /// Might be merged + /// + Merge = ElfNative.SHF_MERGE, + + /// + /// Contains nul-terminated strings + /// + Strings = ElfNative.SHF_STRINGS, + + /// + /// `sh_info' contains SHT index + /// + InfoLink = ElfNative.SHF_INFO_LINK, + + /// + /// Preserve order after combining + /// + LinkOrder = ElfNative.SHF_LINK_ORDER, + + /// + /// Non-standard OS specific handling required + /// + OsNonConforming = ElfNative.SHF_OS_NONCONFORMING, + + /// + /// Section is member of a group. + /// + Group = ElfNative.SHF_GROUP, + + /// + /// Section hold thread-local data. + /// + Tls = ElfNative.SHF_TLS, + + /// + /// Section with compressed data. + /// + Compressed = ElfNative.SHF_COMPRESSED, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs new file mode 100644 index 00000000000000..2ffc79f2cb9ba3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs @@ -0,0 +1,147 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a link to a section, special section or an index (used by and ) + /// + public readonly struct ElfSectionLink : IEquatable + { + public static readonly ElfSectionLink Empty = new ElfSectionLink(ElfNative.SHN_UNDEF); + + public static readonly ElfSectionLink SectionAbsolute = new ElfSectionLink(ElfNative.SHN_ABS); + + public static readonly ElfSectionLink SectionCommon = new ElfSectionLink(ElfNative.SHN_COMMON); + + public ElfSectionLink(uint index) + { + Section = null; + SpecialIndex = index; + } + + public ElfSectionLink(ElfSection section) + { + Section = section; + SpecialIndex = 0; + } + + public readonly ElfSection Section; + + public readonly uint SpecialIndex; + + public bool IsEmpty => Section == null && SpecialIndex == 0; + + /// + /// true if this link to a section is a special section. + /// + public bool IsSpecial => Section == null && (SpecialIndex == ElfNative.SHN_UNDEF || SpecialIndex >= ElfNative.SHN_LORESERVE); + + public uint GetIndex() + { + return Section?.SectionIndex ?? SpecialIndex; + } + + public bool Equals(ElfSectionLink other) + { + return Equals(Section, other.Section) && SpecialIndex == other.SpecialIndex; + } + + public override bool Equals(object obj) + { + return obj is ElfSectionLink other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + return ((Section != null ? Section.GetHashCode() : 0) * 397) ^ SpecialIndex.GetHashCode(); + } + } + + public static bool operator ==(ElfSectionLink left, ElfSectionLink right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfSectionLink left, ElfSectionLink right) + { + return !left.Equals(right); + } + + public override string ToString() + { + if (Section != null) + { + return Section.ToString(); + } + + if (SpecialIndex == 0) return "Special Section Undefined"; + + if (SpecialIndex > ElfNative.SHN_BEFORE) + { + if (SpecialIndex == ElfNative.SHN_ABS) + { + return "Special Section Absolute"; + } + + if (SpecialIndex == ElfNative.SHN_COMMON) + { + return "Special Section Common"; + } + + if (SpecialIndex == ElfNative.SHN_XINDEX) + { + return "Special Section XIndex"; + } + } + + return $"Unknown Section Value 0x{SpecialIndex:X8}"; + } + + public static implicit operator ElfSectionLink(ElfSection section) + { + return new ElfSectionLink(section); + } + + + public bool TryGetSectionSafe(string className, string propertyName, object context, DiagnosticBag diagnostics, out TSection section, params ElfSectionType[] sectionTypes) where TSection : ElfSection + { + section = null; + + if (Section == null) + { + diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoSectionNull, $"`{className}.{propertyName}` cannot be null for this instance", context); + return false; + } + + bool foundValid = false; + foreach (var elfSectionType in sectionTypes) + { + if (Section.Type == elfSectionType) + { + foundValid = true; + break; + } + } + + if (!foundValid) + { + diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoInvalidSectionType, $"The type `{Section.Type}` of `{className}.{propertyName}` must be a {string.Join(" or ", sectionTypes)}", context); + return false; + } + section = Section as TSection; + + if (section == null) + { + diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoInvalidSectionInstance, $"The `{className}.{propertyName}` must be an instance of {typeof(TSection).Name}"); + return false; + } + return true; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs new file mode 100644 index 00000000000000..7a4aabaa8926a1 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs @@ -0,0 +1,38 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines special sections that can be configured via + /// + public enum ElfSectionSpecialType + { + None, + Bss, + Comment, + Data, + Data1, + Debug, + Dynamic, + DynamicStringTable, + DynamicSymbolTable, + Fini, + Got, + Hash, + Init, + Interp, + Line, + Note, + Plt, + Relocation, + RelocationAddends, + ReadOnlyData, + ReadOnlyData1, + SectionHeaderStringTable, + StringTable, + SymbolTable, + Text, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs new file mode 100644 index 00000000000000..ccc1c7e243ca3a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs @@ -0,0 +1,132 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines the type of a section. + /// + public enum ElfSectionType : uint + { + /// + /// Section header table entry unused + /// + Null = ElfNative.SHT_NULL, + + /// + /// Program data + /// + ProgBits = ElfNative.SHT_PROGBITS, + + /// + /// Symbol table + /// + SymbolTable = ElfNative.SHT_SYMTAB, + + /// + /// String table + /// + StringTable = ElfNative.SHT_STRTAB, + + /// + /// Relocation entries with addends + /// + RelocationAddends = ElfNative.SHT_RELA, + + /// + /// Symbol hash table + /// + SymbolHashTable = ElfNative.SHT_HASH, + + /// + /// Dynamic linking information + /// + DynamicLinking = ElfNative.SHT_DYNAMIC, + + /// + /// Notes + /// + Note = ElfNative.SHT_NOTE, + + /// + /// Program space with no data (bss) + /// + NoBits = ElfNative.SHT_NOBITS, + + /// + /// Relocation entries, no addends + /// + Relocation = ElfNative.SHT_REL, + + /// + /// Reserved + /// + Shlib = ElfNative.SHT_SHLIB, + + /// + /// Dynamic linker symbol table + /// + DynamicLinkerSymbolTable = ElfNative.SHT_DYNSYM, + + /// + /// Array of constructors + /// + InitArray = ElfNative.SHT_INIT_ARRAY, + + /// + /// Array of destructors + /// + FiniArray = ElfNative.SHT_FINI_ARRAY, + + /// + /// Array of pre-constructors + /// + PreInitArray = ElfNative.SHT_PREINIT_ARRAY, + + /// + /// Section group + /// + Group = ElfNative.SHT_GROUP, + + /// + /// Extended section indices + /// + SymbolTableSectionHeaderIndices = ElfNative.SHT_SYMTAB_SHNDX, + + /// + /// Object attributes. + /// + GnuAttributes = ElfNative.SHT_GNU_ATTRIBUTES, + + /// + /// GNU-style hash table. + /// + GnuHash = ElfNative.SHT_GNU_HASH, + + /// + /// Prelink library list + /// + GnuLibList = ElfNative.SHT_GNU_LIBLIST, + + /// + /// Checksum for DSO content. + /// + Checksum = ElfNative.SHT_CHECKSUM, + + /// + /// Version definition section. + /// + GnuVersionDefinition = ElfNative.SHT_GNU_verdef, + + /// + /// Version needs section. + /// + GnuVersionNeedsSection = ElfNative.SHT_GNU_verneed, + + /// + /// Version symbol table. + /// + GnuVersionSymbolTable = ElfNative.SHT_GNU_versym, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs new file mode 100644 index 00000000000000..57a809a72de52b --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs @@ -0,0 +1,140 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using LibObjectFile.Utils; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a segment or program header. + /// + public sealed class ElfSegment : ElfObject + { + public ValueKind OffsetKind { get; set; } + + /// + /// Gets or sets the type of this segment. + /// + public ElfSegmentType Type { get; set; } + + /// + /// Gets or sets the range of section this segment applies to. + /// It can applies to . + /// + public ElfSegmentRange Range { get; set; } + + /// + /// Gets or sets the virtual address. + /// + public ulong VirtualAddress { get; set; } + + /// + /// Gets or sets the physical address. + /// + public ulong PhysicalAddress { get; set; } + + /// + /// Gets or sets the size in bytes occupied in memory by this segment. + /// + public ulong SizeInMemory { get; set; } + + /// + /// Gets or sets the flags of this segment. + /// + public ElfSegmentFlags Flags { get; set; } + + /// + /// Gets the alignment requirement of this section. + /// + public ulong Alignment { get; set; } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + if (OffsetKind == ValueKind.Auto) + { + Offset = Range.Offset; + } + + if (Range.IsEmpty) + { + //diagnostics.Error($"Invalid empty {nameof(Range)} in {this}. An {nameof(ElfSegment)} requires to be attached to a section or a range of section or a {nameof(ElfShadowSection)}"); + } + else + { + Size = Range.Size; + + // TODO: Add checks that Alignment is Power Of 2 + var alignment = Alignment == 0 ? Alignment = 1 : Alignment; + if (!AlignHelper.IsPowerOfTwo(alignment)) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentAlignmentForLoad, $"Invalid segment alignment requirements: Alignment = {alignment} must be a power of 2"); + } + + if (Range.BeginSection.Parent == null) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeBeginSectionParent, $"Invalid null parent {nameof(Range)}.{nameof(Range.BeginSection)} in {this}. The section must be attached to the same {nameof(ElfObjectFile)} than this instance"); + } + + if (Range.EndSection.Parent == null) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndSectionParent, $"Invalid null parent {nameof(Range)}.{nameof(Range.EndSection)} in {this}. The section must be attached to the same {nameof(ElfObjectFile)} than this instance"); + } + + if (Type == ElfSegmentTypeCore.Load) + { + // Specs: + // As ‘‘Program Loading’’ later in this part describes, loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size. + // TODO: how to make this configurable? + if ((alignment % 4096) != 0) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentAlignmentForLoad, $"Invalid {nameof(ElfNative.PT_LOAD)} segment alignment requirements: {alignment} must be multiple of the Page Size {4096}"); + } + + var mod = (VirtualAddress - Range.Offset) & (alignment - 1); + if (mod != 0) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentVirtualAddressOrOffset, $"Invalid {nameof(ElfNative.PT_LOAD)} segment alignment requirements: (VirtualAddress - Range.Offset) & (Alignment - 1) == {mod} while it must be == 0"); + } + } + + if (Size > 0) + { + if (Range.BeginOffset >= Range.BeginSection.Size) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeBeginOffset, $"Invalid {nameof(Range)}.{nameof(Range.BeginOffset)}: {Range.BeginOffset} cannot be >= {nameof(Range.BeginSection)}.{nameof(ElfSection.Size)}: {Range.BeginSection.Size} in {this}. The offset must be within the section"); + } + if ((Range.EndOffset >= 0 && (ulong)Range.EndOffset >= Range.EndSection.Size)) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndOffset, $"Invalid {nameof(Range)}.{nameof(Range.EndOffset)}: {Range.EndOffset} cannot be >= {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSection.Size)}: {Range.EndSection.Size} in {this}. The offset must be within the section"); + } + else if (Range.EndOffset < 0) + { + var endOffset = (long)Range.EndSection.Size + Range.EndOffset; + if (endOffset < 0) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndOffset, $"Invalid relative {nameof(Range)}.{nameof(Range.EndOffset)}: {Range.EndOffset}. The resulting end offset {endOffset} with {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSection.Size)}: {Range.EndSection.Size} cannot be < 0 in {this}. The offset must be within the section"); + } + } + } + + if (Range.BeginSection.Parent != null && Range.EndSection.Parent != null) + { + if (Range.BeginSection.Index > Range.EndSection.Index) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeIndices, $"Invalid index order between {nameof(Range)}.{nameof(ElfSegmentRange.BeginSection)}.{nameof(ElfSegment.Index)}: {Range.BeginSection.Index} and {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSegment.Index)}: {Range.EndSection.Index} in {this}. The from index must be <= to the end index."); + } + } + } + } + + + public override string ToString() + { + return $"Segment [{Index}]"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs new file mode 100644 index 00000000000000..ccdf795eeb78f9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs @@ -0,0 +1,61 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a segment flags + /// + public readonly struct ElfSegmentFlags : IEquatable + { + public ElfSegmentFlags(uint value) + { + Value = value; + } + + public ElfSegmentFlags(ElfSegmentFlagsCore value) + { + Value = (uint)value; + } + + public readonly uint Value; + + public bool Equals(ElfSegmentFlags other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfSegmentFlags other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(ElfSegmentFlags left, ElfSegmentFlags right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfSegmentFlags left, ElfSegmentFlags right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return $"SegmentFlags {((ElfSegmentFlagsCore)(Value&3))} 0x{Value:X8}"; + } + + public static implicit operator ElfSegmentFlags(ElfSegmentFlagsCore segmentFlagsCore) + { + return new ElfSegmentFlags(segmentFlagsCore); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs new file mode 100644 index 00000000000000..8a67b0084a7efb --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs @@ -0,0 +1,35 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines the core part of + /// + [Flags] + public enum ElfSegmentFlagsCore : uint + { + /// + /// Segment flags is undefined + /// + None = 0, + + /// + /// Segment is executable + /// + Executable = ElfNative.PF_X, + + /// + /// Segment is writable + /// + Writable = ElfNative.PF_W, + + /// + /// Segment is readable + /// + Readable = ElfNative.PF_R, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs new file mode 100644 index 00000000000000..4ad4805136558d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs @@ -0,0 +1,156 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines the range of section a segment is bound to. + /// + public readonly struct ElfSegmentRange : IEquatable + { + public static readonly ElfSegmentRange Empty = new ElfSegmentRange(); + + /// + /// Creates a new instance that is bound to an entire section/ + /// + /// The section to be bound to + public ElfSegmentRange(ElfSection section) + { + BeginSection = section ?? throw new ArgumentNullException(nameof(section)); + BeginOffset = 0; + EndSection = section; + EndOffset = -1; + } + + /// + /// Creates a new instance that is bound to a range of section. + /// + /// The first section. + /// The offset inside the first section. + /// The last section. + /// The offset in the last section + public ElfSegmentRange(ElfSection beginSection, ulong beginOffset, ElfSection endSection, long endOffset) + { + BeginSection = beginSection ?? throw new ArgumentNullException(nameof(beginSection)); + BeginOffset = beginOffset; + EndSection = endSection ?? throw new ArgumentNullException(nameof(endSection)); + EndOffset = endOffset; + if (BeginSection.Index > EndSection.Index) + { + throw new ArgumentOutOfRangeException(nameof(beginSection), $"The {nameof(beginSection)}.{nameof(ElfSection.Index)} = {BeginSection.Index} is > {nameof(endSection)}.{nameof(ElfSection.Index)} = {EndSection.Index}, while it must be <="); + } + } + + /// + /// The first section. + /// + public readonly ElfSection BeginSection; + + /// + /// The relative offset in . + /// + public readonly ulong BeginOffset; + + /// + /// The last section. + /// + public readonly ElfSection EndSection; + + /// + /// The offset in the last section. If the offset is < 0, then the actual offset starts from end of the section where finalEndOffset = section.Size + EndOffset. + /// + public readonly long EndOffset; + + /// + /// Gets a boolean indicating if this section is empty. + /// + public bool IsEmpty => this == Empty; + + /// + /// Returns the absolute offset of this range taking into account the .. + /// + public ulong Offset + { + get + { + // If this Begin/End section are not attached we can't calculate any meaningful size + if (BeginSection?.Parent == null || EndSection?.Parent == null || BeginSection?.Parent != EndSection?.Parent) + { + return 0; + } + + return BeginSection.Offset + BeginOffset; + } + } + + /// + /// Returns the size of this range taking into account the size of each section involved in this range. + /// + public ulong Size + { + get + { + // If this Begin/End section are not attached we can't calculate any meaningful size + if (BeginSection?.Parent == null || EndSection?.Parent == null || BeginSection?.Parent != EndSection?.Parent) + { + return 0; + } + + var parent = BeginSection.Parent; + ulong size = 0; + for (uint i = BeginSection.Index; i < EndSection.Index; i++) + { + var section = parent.Sections[(int)i]; + if (section.HasContent) + { + size += section.Size; + } + } + + size -= BeginOffset; + size += EndOffset < 0 ? (ulong)((long)EndSection.Size + EndOffset + 1) : (ulong)(EndOffset + 1); + return size; + } + } + + public bool Equals(ElfSegmentRange other) + { + return Equals(BeginSection, other.BeginSection) && BeginOffset == other.BeginOffset && Equals(EndSection, other.EndSection) && EndOffset == other.EndOffset; + } + + public override bool Equals(object obj) + { + return obj is ElfSegmentRange other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = (BeginSection != null ? BeginSection.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ BeginOffset.GetHashCode(); + hashCode = (hashCode * 397) ^ (EndSection != null ? EndSection.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ EndOffset.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(ElfSegmentRange left, ElfSegmentRange right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfSegmentRange left, ElfSegmentRange right) + { + return !left.Equals(right); + } + + public static implicit operator ElfSegmentRange(ElfSection section) + { + return section == null ? Empty : new ElfSegmentRange(section); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs new file mode 100644 index 00000000000000..88fdba7d22d1cd --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs @@ -0,0 +1,61 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a segment type + /// + public readonly struct ElfSegmentType : IEquatable + { + public ElfSegmentType(uint value) + { + Value = value; + } + + public ElfSegmentType(ElfSegmentTypeCore value) + { + Value = (uint)value; + } + + public readonly uint Value; + + public bool Equals(ElfSegmentType other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfSegmentType other && Equals(other); + } + + public override int GetHashCode() + { + return (int) Value; + } + + public static bool operator ==(ElfSegmentType left, ElfSegmentType right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfSegmentType left, ElfSegmentType right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return Value < ElfNative.PT_NUM ? $"SegmentType {((ElfSegmentTypeCore) Value)}" : $"SegmentType 0x{Value:X8}"; + } + + public static implicit operator ElfSegmentType(ElfSegmentTypeCore segmentTypeCore) + { + return new ElfSegmentType(segmentTypeCore); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs new file mode 100644 index 00000000000000..469dc418f87fbc --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs @@ -0,0 +1,52 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines a core + /// + public enum ElfSegmentTypeCore : uint + { + /// + /// Program header table entry unused + /// + Null = ElfNative.PT_NULL, + + /// + /// Loadable program segment + /// + Load = ElfNative.PT_LOAD, + + /// + /// Dynamic linking information + /// + Dynamic = ElfNative.PT_DYNAMIC, + + /// + /// Program interpreter + /// + Interpreter = ElfNative.PT_INTERP, + + /// + /// Auxiliary information + /// + Note = ElfNative.PT_NOTE, + + /// + /// Reserved + /// + SectionHeaderLib = ElfNative.PT_SHLIB, + + /// + /// Entry for header table itself + /// + ProgramHeader = ElfNative.PT_PHDR, + + /// + /// Thread-local storage segment + /// + Tls = ElfNative.PT_TLS, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs new file mode 100644 index 00000000000000..435febba7c5e3a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs @@ -0,0 +1,111 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Defines a string with the associated index in the string table. + /// + public readonly struct ElfString : IEquatable + { + private ElfString(string value, uint index) + { + Value = value; + Index = index; + } + + public ElfString(string value) + { + Value = value; + Index = 0; + } + + public ElfString(uint index) + { + Value = null; + Index = index; + } + + public readonly string Value; + + public readonly uint Index; + + public bool IsEmpty => Value == null && Index == 0; + + public bool Equals(ElfString other) + { + return (Value ?? string.Empty) == (other.Value ?? string.Empty) && Index == other.Index; + } + + public override bool Equals(object obj) + { + return obj is ElfString other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + return ((Value ?? string.Empty).GetHashCode() * 397) ^ (int) Index; + } + } + + public static bool operator ==(ElfString left, ElfString right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfString left, ElfString right) + { + return !left.Equals(right); + } + + public static bool operator ==(string left, ElfString right) + { + return string.Equals(left, right.Value); + } + + public static bool operator !=(ElfString left, string right) + { + return !string.Equals(left.Value, right); + } + + public static bool operator ==(ElfString right, string left) + { + return string.Equals(left, right.Value); + } + + public static bool operator !=(string right, ElfString left) + { + return !string.Equals(left.Value, right); + } + + public static implicit operator string(ElfString elfString) + { + return elfString.Value; + } + + public static implicit operator ElfString(string text) + { + return new ElfString(text); + } + + public ElfString WithName(string name) + { + return new ElfString(name, Index); + } + + public ElfString WithIndex(uint index) + { + return new ElfString(Value, index); + } + + public override string ToString() + { + return Value ?? $"0x{Index:x8}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs new file mode 100644 index 00000000000000..46740c15c2db79 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs @@ -0,0 +1,52 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Base class for writing an to a . + /// + public abstract class ElfWriter : ObjectFileReaderWriter, IElfEncoder + { + private protected ElfWriter(ElfObjectFile objectFile, Stream stream) : base(stream) + { + ObjectFile = objectFile ?? throw new ArgumentNullException(nameof(objectFile)); + } + + private protected ElfObjectFile ObjectFile { get; } + + internal abstract void Write(); + + public override bool IsReadOnly => false; + + internal static ElfWriter Create(ElfObjectFile objectFile, Stream stream) + { + var thisComputerEncoding = BitConverter.IsLittleEndian ? ElfEncoding.Lsb : ElfEncoding.Msb; + return objectFile.Encoding == thisComputerEncoding ? (ElfWriter) new ElfWriterDirect(objectFile, stream) : new ElfWriterSwap(objectFile, stream); + } + + public abstract void Encode(out ElfNative.Elf32_Half dest, ushort value); + public abstract void Encode(out ElfNative.Elf64_Half dest, ushort value); + public abstract void Encode(out ElfNative.Elf32_Word dest, uint value); + public abstract void Encode(out ElfNative.Elf64_Word dest, uint value); + public abstract void Encode(out ElfNative.Elf32_Sword dest, int value); + public abstract void Encode(out ElfNative.Elf64_Sword dest, int value); + public abstract void Encode(out ElfNative.Elf32_Xword dest, ulong value); + public abstract void Encode(out ElfNative.Elf32_Sxword dest, long value); + public abstract void Encode(out ElfNative.Elf64_Xword dest, ulong value); + public abstract void Encode(out ElfNative.Elf64_Sxword dest, long value); + public abstract void Encode(out ElfNative.Elf32_Addr dest, uint value); + public abstract void Encode(out ElfNative.Elf64_Addr dest, ulong value); + public abstract void Encode(out ElfNative.Elf32_Off dest, uint offset); + public abstract void Encode(out ElfNative.Elf64_Off dest, ulong offset); + public abstract void Encode(out ElfNative.Elf32_Section dest, ushort index); + public abstract void Encode(out ElfNative.Elf64_Section dest, ushort index); + public abstract void Encode(out ElfNative.Elf32_Versym dest, ushort value); + public abstract void Encode(out ElfNative.Elf64_Versym dest, ushort value); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs new file mode 100644 index 00000000000000..329195f4be202a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs @@ -0,0 +1,18 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Internal implementation of with a . + /// + internal sealed class ElfWriterDirect : ElfWriter + { + public ElfWriterDirect(ElfObjectFile elfObjectFile, Stream stream) : base(elfObjectFile, stream) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs new file mode 100644 index 00000000000000..3bd6fc26bd022a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs @@ -0,0 +1,18 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Internal implementation of with a . + /// + internal sealed class ElfWriterSwap : ElfWriter + { + public ElfWriterSwap(ElfObjectFile elfObjectFile, Stream stream) : base(elfObjectFile, stream) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs new file mode 100644 index 00000000000000..163adaf6c3ac7c --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs @@ -0,0 +1,289 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Elf +{ + using static ElfNative; + + /// + /// Internal implementation of to write to a stream an instance. + /// + /// The encoder used for LSB/MSB conversion + internal abstract class ElfWriter : ElfWriter where TEncoder : struct, IElfEncoder + { + private TEncoder _encoder; + private ulong _startOfFile; + + protected ElfWriter(ElfObjectFile objectFile, Stream stream) : base(objectFile, stream) + { + _encoder = new TEncoder(); + } + + internal override void Write() + { + _startOfFile = (ulong)Stream.Position; + WriteHeader(); + CheckProgramHeaders(); + WriteSections(); + } + + private ElfObjectFile.ElfObjectLayout Layout => ObjectFile.Layout; + + private void WriteHeader() + { + if (ObjectFile.FileClass == ElfFileClass.Is32) + { + WriteSectionHeader32(); + } + else + { + WriteSectionHeader64(); + } + } + + public override void Encode(out Elf32_Half dest, ushort value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Half dest, ushort value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Word dest, uint value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Word dest, uint value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Sword dest, int value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Sword dest, int value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Xword dest, ulong value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Sxword dest, long value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Xword dest, ulong value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Sxword dest, long value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Addr dest, uint value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Addr dest, ulong value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf32_Off dest, uint offset) + { + _encoder.Encode(out dest, offset); + } + + public override void Encode(out Elf64_Off dest, ulong offset) + { + _encoder.Encode(out dest, offset); + } + + public override void Encode(out Elf32_Section dest, ushort index) + { + _encoder.Encode(out dest, index); + } + + public override void Encode(out Elf64_Section dest, ushort index) + { + _encoder.Encode(out dest, index); + } + + public override void Encode(out Elf32_Versym dest, ushort value) + { + _encoder.Encode(out dest, value); + } + + public override void Encode(out Elf64_Versym dest, ushort value) + { + _encoder.Encode(out dest, value); + } + + private unsafe void WriteSectionHeader32() + { + var hdr = new Elf32_Ehdr(); + ObjectFile.CopyIdentTo(new Span(hdr.e_ident, EI_NIDENT)); + + _encoder.Encode(out hdr.e_type, (ushort)ObjectFile.FileType); + _encoder.Encode(out hdr.e_machine, (ushort)ObjectFile.Arch.Value); + _encoder.Encode(out hdr.e_version, EV_CURRENT); + _encoder.Encode(out hdr.e_entry, (uint)ObjectFile.EntryPointAddress); + _encoder.Encode(out hdr.e_ehsize, Layout.SizeOfElfHeader); + _encoder.Encode(out hdr.e_flags, (uint)ObjectFile.Flags); + + // program headers + _encoder.Encode(out hdr.e_phoff, (uint)Layout.OffsetOfProgramHeaderTable); + _encoder.Encode(out hdr.e_phentsize, Layout.SizeOfProgramHeaderEntry); + _encoder.Encode(out hdr.e_phnum, (ushort) ObjectFile.Segments.Count); + + // entries for sections + _encoder.Encode(out hdr.e_shoff, (uint)Layout.OffsetOfSectionHeaderTable); + _encoder.Encode(out hdr.e_shentsize, Layout.SizeOfSectionHeaderEntry); + _encoder.Encode(out hdr.e_shnum, (ushort)ObjectFile.VisibleSectionCount); + _encoder.Encode(out hdr.e_shstrndx, (ushort)(ObjectFile.SectionHeaderStringTable?.SectionIndex ?? (ushort)0)); + + Write(hdr); + } + + private unsafe void WriteSectionHeader64() + { + var hdr = new Elf64_Ehdr(); + ObjectFile.CopyIdentTo(new Span(hdr.e_ident, EI_NIDENT)); + + _encoder.Encode(out hdr.e_type, (ushort)ObjectFile.FileType); + _encoder.Encode(out hdr.e_machine, (ushort)ObjectFile.Arch.Value); + _encoder.Encode(out hdr.e_version, EV_CURRENT); + _encoder.Encode(out hdr.e_entry, ObjectFile.EntryPointAddress); + _encoder.Encode(out hdr.e_ehsize, Layout.SizeOfElfHeader); + _encoder.Encode(out hdr.e_flags, (uint)ObjectFile.Flags); + + // program headers + _encoder.Encode(out hdr.e_phoff, Layout.OffsetOfProgramHeaderTable); + _encoder.Encode(out hdr.e_phentsize, Layout.SizeOfProgramHeaderEntry); + _encoder.Encode(out hdr.e_phnum, (ushort)ObjectFile.Segments.Count); + + // entries for sections + _encoder.Encode(out hdr.e_shoff, Layout.OffsetOfSectionHeaderTable); + _encoder.Encode(out hdr.e_shentsize, (ushort)sizeof(Elf64_Shdr)); + _encoder.Encode(out hdr.e_shnum, (ushort)ObjectFile.VisibleSectionCount); + _encoder.Encode(out hdr.e_shstrndx, (ushort)(ObjectFile.SectionHeaderStringTable?.SectionIndex ?? (ushort)0)); + + Write(hdr); + } + private void CheckProgramHeaders() + { + if (ObjectFile.Segments.Count == 0) + { + return; + } + + var offset = (ulong)Stream.Position - _startOfFile; + if (offset != Layout.OffsetOfProgramHeaderTable) + { + throw new InvalidOperationException("Internal error. Unexpected offset for ProgramHeaderTable"); + } + } + + private void WriteSections() + { + var sections = ObjectFile.Sections; + if (sections.Count == 0) return; + + sections = ObjectFile.GetSectionsOrderedByStreamIndex(); + + // We write the content all sections including shadows + for (var i = 0; i < sections.Count; i++) + { + var section = sections[i]; + + // Write only section with content + if (section.HasContent) + { + Stream.Position = (long)(_startOfFile + section.Offset); + section.WriteInternal(this); + } + } + + // Write section header table + WriteSectionHeaderTable(); + } + + private void WriteSectionHeaderTable() + { + var offset = (ulong)Stream.Position - _startOfFile; + if (offset != Layout.OffsetOfSectionHeaderTable) + { + throw new InvalidOperationException("Internal error. Unexpected offset for SectionHeaderTable"); + } + + // Then write all regular sections + var sections = ObjectFile.Sections; + for (var i = 0; i < sections.Count; i++) + { + var section = sections[i]; + if (section.IsShadow) continue; + WriteSectionTableEntry(section); + } + } + + private void WriteSectionTableEntry(ElfSection section) + { + if (ObjectFile.FileClass == ElfFileClass.Is32) + { + WriteSectionTableEntry32(section); + } + else + { + WriteSectionTableEntry64(section); + } + } + + private void WriteSectionTableEntry32(ElfSection section) + { + var shdr = new Elf32_Shdr(); + _encoder.Encode(out shdr.sh_name, ObjectFile.SectionHeaderStringTable?.GetOrCreateIndex(section.Name) ?? 0); + _encoder.Encode(out shdr.sh_type, (uint)section.Type); + _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); + _encoder.Encode(out shdr.sh_addr, (uint)section.VirtualAddress); + _encoder.Encode(out shdr.sh_offset, (uint)section.Offset); + _encoder.Encode(out shdr.sh_size, (uint)section.Size); + _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); + _encoder.Encode(out shdr.sh_addralign, (uint)section.Alignment); + _encoder.Encode(out shdr.sh_entsize, (uint)section.TableEntrySize); + Write(shdr); + } + + private void WriteSectionTableEntry64(ElfSection section) + { + var shdr = new Elf64_Shdr(); + _encoder.Encode(out shdr.sh_name, ObjectFile.SectionHeaderStringTable?.GetOrCreateIndex(section.Name) ?? 0); + _encoder.Encode(out shdr.sh_type, (uint)section.Type); + _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); + _encoder.Encode(out shdr.sh_addr, section.VirtualAddress); + _encoder.Encode(out shdr.sh_offset, section.Offset); + _encoder.Encode(out shdr.sh_size, section.Size); + _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); + _encoder.Encode(out shdr.sh_addralign, section.Alignment); + _encoder.Encode(out shdr.sh_entsize, section.TableEntrySize); + Write(shdr); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs new file mode 100644 index 00000000000000..eba5309fcb134f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs @@ -0,0 +1,49 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// A decoder interface for the various Elf types that provides decoding of data based on LSB/MSB. + /// + /// + public interface IElfDecoder + { + ushort Decode(ElfNative.Elf32_Half src); + + ushort Decode(ElfNative.Elf64_Half src); + + uint Decode(ElfNative.Elf32_Word src); + + uint Decode(ElfNative.Elf64_Word src); + + int Decode(ElfNative.Elf32_Sword src); + + int Decode(ElfNative.Elf64_Sword src); + + ulong Decode(ElfNative.Elf32_Xword src); + + long Decode(ElfNative.Elf32_Sxword src); + + ulong Decode(ElfNative.Elf64_Xword src); + + long Decode(ElfNative.Elf64_Sxword src); + + uint Decode(ElfNative.Elf32_Addr src); + + ulong Decode(ElfNative.Elf64_Addr src); + + uint Decode(ElfNative.Elf32_Off src); + + ulong Decode(ElfNative.Elf64_Off src); + + ushort Decode(ElfNative.Elf32_Section src); + + ushort Decode(ElfNative.Elf64_Section src); + + ushort Decode(ElfNative.Elf32_Versym src); + + ushort Decode(ElfNative.Elf64_Versym src); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs new file mode 100644 index 00000000000000..702612ad5ba674 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs @@ -0,0 +1,49 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// An encoder interface for the various Elf types that provides encoding of data based on LSB/MSB. + /// + /// + public interface IElfEncoder + { + void Encode(out ElfNative.Elf32_Half dest, ushort value); + + void Encode(out ElfNative.Elf64_Half dest, ushort value); + + void Encode(out ElfNative.Elf32_Word dest, uint value); + + void Encode(out ElfNative.Elf64_Word dest, uint value); + + void Encode(out ElfNative.Elf32_Sword dest, int value); + + void Encode(out ElfNative.Elf64_Sword dest, int value); + + void Encode(out ElfNative.Elf32_Xword dest, ulong value); + + void Encode(out ElfNative.Elf32_Sxword dest, long value); + + void Encode(out ElfNative.Elf64_Xword dest, ulong value); + + void Encode(out ElfNative.Elf64_Sxword dest, long value); + + void Encode(out ElfNative.Elf32_Addr dest, uint value); + + void Encode(out ElfNative.Elf64_Addr dest, ulong value); + + void Encode(out ElfNative.Elf32_Off dest, uint offset); + + void Encode(out ElfNative.Elf64_Off dest, ulong offset); + + void Encode(out ElfNative.Elf32_Section dest, ushort index); + + void Encode(out ElfNative.Elf64_Section dest, ushort index); + + void Encode(out ElfNative.Elf32_Versym dest, ushort value); + + void Encode(out ElfNative.Elf64_Versym dest, ushort value); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs new file mode 100644 index 00000000000000..eb276b91105b3d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs @@ -0,0 +1,68 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using LibObjectFile.Utils; + +namespace LibObjectFile.Elf +{ + /// + /// A shadow section allowing to align the following section from + /// to respect the of this section. + /// This section is used to make sure the offset of the following section will be respect + /// a specific alignment. + /// + public sealed class ElfAlignedShadowSection : ElfShadowSection + { + public ElfAlignedShadowSection() : this(0x1000) + { + } + + public ElfAlignedShadowSection(uint upperAlignment) + { + UpperAlignment = upperAlignment; + } + + /// + /// Gets or sets teh alignment requirement that this section will ensure for the + /// following sections placed after this section, so that the offset of the following + /// section is respecting the alignment. + /// + public uint UpperAlignment { get; set; } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + var nextSectionOffset = AlignHelper.AlignToUpper(Offset, UpperAlignment); + Size = nextSectionOffset - Offset; + if (Size >= int.MaxValue) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidAlignmentOutOfRange, $"Invalid alignment 0x{UpperAlignment:x} resulting in an offset beyond int.MaxValue"); + } + } + + protected override void Read(ElfReader reader) + { + throw new NotSupportedException($"An {nameof(ElfAlignedShadowSection)} does not support read and is only used for writing"); + } + + protected override void Write(ElfWriter writer) + { + if (Size == 0) return; + + var sharedBuffer = ArrayPool.Shared.Rent((int)Size); + Array.Clear(sharedBuffer, 0, sharedBuffer.Length); + try + { + writer.Stream.Write(sharedBuffer, 0, (int) Size); + } + finally + { + ArrayPool.Shared.Return(sharedBuffer); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs new file mode 100644 index 00000000000000..4aeaf7b2905d4d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs @@ -0,0 +1,82 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// A custom section associated with its stream of data to read/write. + /// + public sealed class ElfBinarySection : ElfSection + { + public ElfBinarySection() + { + } + + public ElfBinarySection(Stream stream) + { + Stream = stream ?? throw new ArgumentNullException(nameof(stream)); + } + + public override ElfSectionType Type + { + get => base.Type; + set + { + // Don't allow relocation or symbol table to enforce proper usage + if (value == ElfSectionType.Relocation || value == ElfSectionType.RelocationAddends) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}]. Must be used on a `{nameof(ElfRelocationTable)}` instead"); + } + + if (value == ElfSectionType.SymbolTable || value == ElfSectionType.DynamicLinkerSymbolTable) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}]. Must be used on a `{nameof(ElfSymbolTable)}` instead"); + } + + base.Type = value; + } + } + + public override ulong TableEntrySize => OriginalTableEntrySize; + + /// + /// Gets or sets the associated stream to this section. + /// + public Stream Stream { get; set; } + + protected override void Read(ElfReader reader) + { + Stream = reader.ReadAsStream(Size); + } + + protected override void Write(ElfWriter writer) + { + if (Stream == null) return; + writer.Write(Stream); + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + if (Type != ElfSectionType.NoBits) + { + Size = Stream != null ? (ulong)Stream.Length : 0; + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + if (Type == ElfSectionType.NoBits && Stream != null) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidStreamForSectionNoBits, $"The {Type} section {this} must have a null stream"); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs new file mode 100644 index 00000000000000..e0d8435f80d104 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs @@ -0,0 +1,39 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// Equivalent of but used for shadow. + /// + public sealed class ElfBinaryShadowSection : ElfShadowSection + { + public ElfBinaryShadowSection() + { + } + + public Stream Stream { get; set; } + + protected override void Read(ElfReader reader) + { + Stream = reader.ReadAsStream(Size); + } + + protected override void Write(ElfWriter writer) + { + if (Stream == null) return; + writer.Write(Stream); + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + Size = Stream != null ? (ulong)Stream.Length : 0; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs new file mode 100644 index 00000000000000..27d614c59225f4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs @@ -0,0 +1,107 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Buffers; +using System.IO; +using System.Text; + +namespace LibObjectFile.Elf +{ + /// + /// A custom note entry in + /// + public class ElfCustomNote : ElfNote + { + /// + /// Gets or sets the name of this note. + /// + public string Name { get; set; } + + /// + /// Gets or sets the associated descriptor data. + /// + public Stream Descriptor { get; set; } + + /// + /// Gets or sets the type of this note. + /// + public ElfNoteTypeEx Type { get; set; } + + public override string GetName() + { + return Name; + } + + public override ElfNoteTypeEx GetNoteType() + { + return Type; + } + + public override uint GetDescriptorSize() + { + return Descriptor == null ? 0 : (uint)Descriptor.Length; + } + + public override string GetDescriptorAsText() + { + if (Descriptor == null || Descriptor.Length == 0) return string.Empty; + + Descriptor.Position = 0; + + var length = (int) Descriptor.Length; + var buffer = ArrayPool.Shared.Rent(length); + try + { + length = Descriptor.Read(buffer, 0, length); + Descriptor.Position = 0; + var hasBinary = false; + + // If we have any binary data (don't take into account a potential null terminated string) + for (int i = 0; i < length - 1; i++) + { + if (buffer[i] < ' ') + { + hasBinary = true; + break; + } + } + + if (hasBinary) + { + var builder = new StringBuilder(); + for (int i = 0; i < length; i++) + { + builder.Append($"{buffer[i]:x2}"); + } + + return builder.ToString(); + } + else + { + return Encoding.UTF8.GetString(buffer, 0, length); + } + } + finally + { + ArrayPool.Shared.Return(buffer); + } + } + + protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) + { + if (descriptorLength > 0) + { + Descriptor = reader.ReadAsStream(descriptorLength); + } + } + + protected override void WriteDescriptor(ElfWriter writer) + { + if (Descriptor != null) + { + writer.Write(Descriptor); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs new file mode 100644 index 00000000000000..07333293262efc --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs @@ -0,0 +1,14 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + public abstract class ElfGnuNote : ElfNote + { + public override string GetName() + { + return "GNU"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs new file mode 100644 index 00000000000000..20cd616e4a78f9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs @@ -0,0 +1,83 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Text; + +namespace LibObjectFile.Elf +{ + public class ElfGnuNoteABITag : ElfGnuNote + { + public ElfGnuNoteOSKind OSKind { get; set; } + + public uint MajorVersion { get; set; } + + public uint MinorVersion { get; set; } + + public uint SubMinorVersion { get; set; } + + public override ElfNoteTypeEx GetNoteType() => new ElfNoteTypeEx(ElfNoteType.GNU_ABI_TAG); + + public override uint GetDescriptorSize() => 4 * sizeof(int); + + public override string GetDescriptorAsText() + { + var builder = new StringBuilder(); + builder.Append("OS: "); + switch (OSKind) + { + case ElfGnuNoteOSKind.Linux: + builder.Append("Linux"); + break; + case ElfGnuNoteOSKind.Gnu: + builder.Append("Gnu"); + break; + case ElfGnuNoteOSKind.Solaris: + builder.Append("Solaris"); + break; + case ElfGnuNoteOSKind.FreeBSD: + builder.Append("FreeBSD"); + break; + default: + builder.Append($"0x{(uint) OSKind:x8}"); + break; + } + + builder.Append($", ABI: {MajorVersion}.{MinorVersion}.{SubMinorVersion}"); + return builder.ToString(); + } + + protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) + { + NativeGnuNoteOS nativeGnuNote; + if (!reader.TryReadData((int)descriptorLength, out nativeGnuNote)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleNoteGnuAbiTag, $"The {nameof(ElfGnuNoteABITag)} is incomplete in size. Expecting: {GetDescriptorSize()} but got {descriptorLength}"); + } + + OSKind = (ElfGnuNoteOSKind) reader.Decode(nativeGnuNote.OS); + MajorVersion = reader.Decode(nativeGnuNote.MajorVersion); + MinorVersion = reader.Decode(nativeGnuNote.MinorVersion); + SubMinorVersion = reader.Decode(nativeGnuNote.SubMinorVersion); + } + + protected override void WriteDescriptor(ElfWriter writer) + { + NativeGnuNoteOS nativeGnuNote; + writer.Encode(out nativeGnuNote.OS, (uint) OSKind); + writer.Encode(out nativeGnuNote.MajorVersion, (uint)MajorVersion); + writer.Encode(out nativeGnuNote.MinorVersion, (uint)MinorVersion); + writer.Encode(out nativeGnuNote.SubMinorVersion, (uint)SubMinorVersion); + writer.Write(nativeGnuNote); + } + + private struct NativeGnuNoteOS + { + public ElfNative.Elf32_Word OS; + public ElfNative.Elf32_Word MajorVersion; + public ElfNative.Elf32_Word MinorVersion; + public ElfNative.Elf32_Word SubMinorVersion; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs new file mode 100644 index 00000000000000..7976c743e639f3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs @@ -0,0 +1,58 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System.Buffers; +using System.IO; +using System.Text; + +namespace LibObjectFile.Elf +{ + public class ElfGnuNoteBuildId : ElfGnuNote + { + public override ElfNoteTypeEx GetNoteType() => new ElfNoteTypeEx(ElfNoteType.GNU_BUILD_ID); + + public Stream BuildId { get; set; } + + public override uint GetDescriptorSize() => BuildId != null ? (uint)BuildId.Length : 0; + + public override string GetDescriptorAsText() + { + var builder = new StringBuilder(); + builder.Append("Build ID: "); + + if (BuildId != null) + { + BuildId.Position = 0; + var length = (int)BuildId.Length; + var buffer = ArrayPool.Shared.Rent(length); + length = BuildId.Read(buffer, 0, length); + BuildId.Position = 0; + + for (int i = 0; i < length; i++) + { + builder.Append($"{buffer[i]:x2}"); + } + } + + return builder.ToString(); + } + + + protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) + { + if (descriptorLength > 0) + { + BuildId = reader.ReadAsStream(descriptorLength); + } + } + + protected override void WriteDescriptor(ElfWriter writer) + { + if (BuildId != null) + { + writer.Write(BuildId); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs new file mode 100644 index 00000000000000..e2ec7c7a90bfc3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs @@ -0,0 +1,32 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Type of Operating System for a + /// + public enum ElfGnuNoteOSKind : uint + { + /// + /// Linux operating system. + /// + Linux = ElfNative.ELF_NOTE_OS_LINUX, + + /// + /// A Gnu operating system. + /// + Gnu = ElfNative.ELF_NOTE_OS_GNU, + + /// + /// Solaris operating system. + /// + Solaris = ElfNative.ELF_NOTE_OS_SOLARIS2, + + /// + /// FreeBSD operating system. + /// + FreeBSD = ElfNative.ELF_NOTE_OS_FREEBSD, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs new file mode 100644 index 00000000000000..19842c15060bbc --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs @@ -0,0 +1,48 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// A Note entry in + /// + public abstract class ElfNote + { + protected ElfNote() + { + } + + /// + /// Gets or sets the name of this note. + /// + public abstract string GetName(); + + /// + /// Gets or sets the type of this note. + /// + public abstract ElfNoteTypeEx GetNoteType(); + + public abstract uint GetDescriptorSize(); + + public abstract string GetDescriptorAsText(); + + public override string ToString() + { + return $"{nameof(ElfNote)} {GetName()}, Type: {GetNoteType()}"; + } + + internal void ReadDescriptorInternal(ElfReader reader, uint descriptorLength) + { + ReadDescriptor(reader, descriptorLength); + } + + internal void WriteDescriptorInternal(ElfWriter writer) + { + WriteDescriptor(writer); + } + protected abstract void ReadDescriptor(ElfReader reader, uint descriptorLength); + + protected abstract void WriteDescriptor(ElfWriter writer); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs new file mode 100644 index 00000000000000..7f79618a8cf81e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs @@ -0,0 +1,175 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using LibObjectFile.Utils; + +namespace LibObjectFile.Elf +{ + /// + /// A note section with the type . + /// + public sealed class ElfNoteTable : ElfSection + { + public ElfNoteTable() : base(ElfSectionType.Note) + { + Entries = new List(); + } + + /// + /// Gets a list of entries. + /// + public List Entries { get; } + + public override ElfSectionType Type + { + get => base.Type; + set + { + if (value != ElfSectionType.Note) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfNoteTable)}` while `{ElfSectionType.Note}` is expected"); + } + base.Type = value; + } + } + + public override unsafe void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + ulong size = 0; + ulong entrySize = (ulong)sizeof(ElfNative.Elf32_Nhdr); + + foreach (var elfNote in Entries) + { + var name = elfNote.GetName(); + if (name != null) + { + size += (ulong)Encoding.UTF8.GetByteCount(name) + 1; + size = AlignHelper.AlignToUpper(size, 4); + } + + size += (ulong)elfNote.GetDescriptorSize(); + size = AlignHelper.AlignToUpper(size, 4); + + size += entrySize; + } + Size = size; + } + + protected override unsafe void Read(ElfReader reader) + { + var sizeToRead = (long)base.Size; + + var entrySize = (long)sizeof(ElfNative.Elf32_Nhdr); + + var startPosition = (ulong)reader.Stream.Position; + while (sizeToRead >= entrySize) + { + ElfNative.Elf32_Nhdr nativeNote; + ulong noteStartOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)entrySize, out nativeNote)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteNoteEntrySize, $"Unable to read entirely the note entry [{Entries.Count}] from {Type} section [{Index}]. Not enough data (size: {entrySize}) read at offset {noteStartOffset} from the stream"); + break; + } + + var nameLength = reader.Decode(nativeNote.n_namesz); + var descriptorLength = reader.Decode(nativeNote.n_descsz); + + var noteType = new ElfNoteTypeEx(reader.Decode(nativeNote.n_type)); + var noteName = reader.ReadStringUTF8NullTerminated(nameLength); + SkipPaddingAlignedTo4Bytes(reader, (ulong)reader.Stream.Position - startPosition); + + var note = CreateNote(reader, noteName, noteType); + + note.ReadDescriptorInternal(reader, descriptorLength); + + SkipPaddingAlignedTo4Bytes(reader, (ulong)reader.Stream.Position - startPosition); + + Entries.Add(note); + + ulong noteEndOffset = (ulong)reader.Stream.Position; + sizeToRead = sizeToRead - (long)(noteEndOffset - noteStartOffset); + } + } + + private void SkipPaddingAlignedTo4Bytes(ElfReader reader, ulong offset) + { + if ((offset & 3) != 0) + { + var toWrite = 4 - (int)(offset & 3); + reader.Stream.Position += toWrite; + } + } + + protected override void Write(ElfWriter writer) + { + var expectedSizeWritten = Size; + var startPosition = (ulong) writer.Stream.Position; + foreach (var elfNote in Entries) + { + ElfNative.Elf32_Nhdr nativeNote; + + var noteName = elfNote.GetName(); + writer.Encode(out nativeNote.n_namesz, noteName == null ? 0 : ((uint) Encoding.UTF8.GetByteCount(noteName) + 1)); + writer.Encode(out nativeNote.n_descsz, elfNote.GetDescriptorSize()); + writer.Encode(out nativeNote.n_type, (uint)elfNote.GetNoteType().Value); + + writer.Write(nativeNote); + + if (noteName != null) + { + writer.WriteStringUTF8NullTerminated(noteName); + WritePaddingAlignedTo4Bytes(writer, (ulong)writer.Stream.Position - startPosition); + } + + elfNote.WriteDescriptorInternal(writer); + WritePaddingAlignedTo4Bytes(writer, (ulong)writer.Stream.Position - startPosition); + } + + var sizeWritten = (ulong) writer.Stream.Position - startPosition; + Debug.Assert(expectedSizeWritten == sizeWritten); + } + + private void WritePaddingAlignedTo4Bytes(ElfWriter writer, ulong offset) + { + if ((offset & 3) != 0) + { + var toWrite = 4 - (int)(offset & 3); + for (int i = 0; i < toWrite; i++) writer.Stream.WriteByte(0); + } + } + + private static ElfNote CreateNote(ElfReader reader, string name, ElfNoteType type) + { + if (name == "GNU") + { + switch (type) + { + case ElfNoteType.GNU_ABI_TAG: + return new ElfGnuNoteABITag(); + case ElfNoteType.GNU_BUILD_ID: + return new ElfGnuNoteBuildId(); + } + } + + ElfNote note = null; + + if (reader.Options.TryCreateNote != null) + { + note = reader.Options.TryCreateNote(name, type); + } + + return note ?? new ElfCustomNote() + { + Name = name, + Type = type + }; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs new file mode 100644 index 00000000000000..2baa9cfc54be84 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs @@ -0,0 +1,65 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Gets the type of a . + /// + public readonly partial struct ElfNoteTypeEx : IEquatable + { + public ElfNoteTypeEx(uint value) + { + Value = (ElfNoteType)value; + } + + public ElfNoteTypeEx(ElfNoteType value) + { + Value = value; + } + + /// + /// The value of this note type. + /// + public readonly ElfNoteType Value; + + public override string ToString() + { + return ToStringInternal() ?? $"Unknown {nameof(ElfNoteTypeEx)} (0x{(uint)Value:X4})"; + } + + public bool Equals(ElfNoteTypeEx other) + { + return Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfNoteTypeEx other && Equals(other); + } + + public override int GetHashCode() + { + return (int)Value; + } + + public static bool operator ==(ElfNoteTypeEx left, ElfNoteTypeEx right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfNoteTypeEx left, ElfNoteTypeEx right) + { + return !left.Equals(right); + } + + public static explicit operator byte(ElfNoteTypeEx noteType) => (byte)noteType.Value; + + public static implicit operator ElfNoteTypeEx(ElfNoteType noteType) => new ElfNoteTypeEx(noteType); + + public static implicit operator ElfNoteType(ElfNoteTypeEx noteType) => noteType.Value; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs new file mode 100644 index 00000000000000..89f92a948afd8e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs @@ -0,0 +1,45 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// A null section with the type . + /// + public sealed class ElfNullSection : ElfSection + { + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + if (Type != ElfSectionType.Null || + Flags != ElfSectionFlags.None || + !Name.IsEmpty || + VirtualAddress != 0 || + Alignment != 0 || + !Link.IsEmpty || + !Info.IsEmpty || + Offset != 0 || + Size != 0) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. This section should not be modified and all properties must be null"); + } + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + } + + protected override void Read(ElfReader reader) + { + } + + protected override void Write(ElfWriter writer) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs new file mode 100644 index 00000000000000..f1f7754915fad6 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs @@ -0,0 +1,93 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// The program header table as a . + /// + public sealed class ElfProgramHeaderTable : ElfShadowSection + { + public ElfProgramHeaderTable() + { + Name = ".shadow.phdrtab"; + } + + protected override void Read(ElfReader reader) + { + // This is not read by this instance but by ElfReader directly + } + + public override unsafe ulong TableEntrySize + { + get + { + if (Parent == null) return 0; + return Parent.FileClass == ElfFileClass.Is32 ? (ulong)sizeof(ElfNative.Elf32_Phdr) : (ulong)sizeof(ElfNative.Elf64_Phdr); + } + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + Size = 0; + + if (Parent == null) return; + + Size = (ulong) Parent.Segments.Count * Parent.Layout.SizeOfProgramHeaderEntry; + } + + + protected override void Write(ElfWriter writer) + { + for (int i = 0; i < Parent.Segments.Count; i++) + { + var header = Parent.Segments[i]; + if (Parent.FileClass == ElfFileClass.Is32) + { + WriteProgramHeader32(writer, ref header); + } + else + { + WriteProgramHeader64(writer, ref header); + } + } + } + + private void WriteProgramHeader32(ElfWriter writer, ref ElfSegment segment) + { + var hdr = new ElfNative.Elf32_Phdr(); + + writer.Encode(out hdr.p_type, segment.Type.Value); + writer.Encode(out hdr.p_offset, (uint)segment.Offset); + writer.Encode(out hdr.p_vaddr, (uint)segment.VirtualAddress); + writer.Encode(out hdr.p_paddr, (uint)segment.PhysicalAddress); + writer.Encode(out hdr.p_filesz, (uint)segment.Size); + writer.Encode(out hdr.p_memsz, (uint)segment.SizeInMemory); + writer.Encode(out hdr.p_flags, segment.Flags.Value); + writer.Encode(out hdr.p_align, (uint)segment.Alignment); + + writer.Write(hdr); + } + + private void WriteProgramHeader64(ElfWriter writer, ref ElfSegment segment) + { + var hdr = new ElfNative.Elf64_Phdr(); + + writer.Encode(out hdr.p_type, segment.Type.Value); + writer.Encode(out hdr.p_offset, segment.Offset); + writer.Encode(out hdr.p_vaddr, segment.VirtualAddress); + writer.Encode(out hdr.p_paddr, segment.PhysicalAddress); + writer.Encode(out hdr.p_filesz, segment.Size); + writer.Encode(out hdr.p_memsz, segment.SizeInMemory); + writer.Encode(out hdr.p_flags, segment.Flags.Value); + writer.Encode(out hdr.p_align, segment.Alignment); + + writer.Write(hdr); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs new file mode 100644 index 00000000000000..e76dd0fb146fd4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs @@ -0,0 +1,58 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// A relocation entry in the + /// This is the value seen in or + /// + public struct ElfRelocation + { + public ElfRelocation(ulong offset, ElfRelocationType type, uint symbolIndex, long addend) + { + Offset = offset; + Type = type; + SymbolIndex = symbolIndex; + Addend = addend; + } + + /// + /// Gets or sets the offset. + /// + public ulong Offset { get; set; } + + /// + /// Gets or sets the type of relocation. + /// + public ElfRelocationType Type { get; set; } + + /// + /// Gets or sets the symbol index associated with the symbol table. + /// + public uint SymbolIndex { get; set; } + + /// + /// Gets or sets the addend value. + /// + public long Addend { get; set; } + + /// + /// Gets the computed Info value as expected by + /// + public uint Info32 => + ((uint) SymbolIndex << 8) | ((Type.Value & 0xFF)); + + /// + /// Gets the computed Info value as expected by + /// + public ulong Info64 => + ((ulong)SymbolIndex << 32) | (Type.Value); + + public override string ToString() + { + return $"{nameof(Offset)}: 0x{Offset:X16}, {nameof(Type)}: {Type}, {nameof(SymbolIndex)}: {SymbolIndex}, {nameof(Addend)}: 0x{Addend:X16}"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs new file mode 100644 index 00000000000000..b2f82dfce73c64 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs @@ -0,0 +1,20 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Context used when applying relocation via . + /// + public struct ElfRelocationContext + { + public ulong BaseAddress { get; set; } + + public ulong GlobalObjectTableAddress { get; set; } + + public ulong GlobalObjectTableOffset { get; set; } + + public ulong ProcedureLinkageTableAddress { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs new file mode 100644 index 00000000000000..194d7afe43af10 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs @@ -0,0 +1,314 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; + +namespace LibObjectFile.Elf +{ + /// + /// A relocation section with the type or + /// + public sealed class ElfRelocationTable : ElfSection + { + private readonly List _entries; + public const string DefaultName = ".rel"; + public const string DefaultNameWithAddends = ".rela"; + + public ElfRelocationTable() : base(ElfSectionType.RelocationAddends) + { + Name = DefaultNameWithAddends; + _entries = new List(); + } + + /// + /// Gets a list of entries. + /// + public List Entries => _entries; + + private static string GetDefaultName(ElfSectionType type) + { + return type == ElfSectionType.Relocation? DefaultName : DefaultNameWithAddends; + } + + public override ElfSectionType Type + { + get => base.Type; + set + { + if (value != ElfSectionType.Relocation && value != ElfSectionType.RelocationAddends) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfRelocationTable)}` while `{ElfSectionType.Relocation}` or `{ElfSectionType.RelocationAddends}` are expected"); + } + base.Type = value; + } + } + + public bool IsRelocationWithAddends => this.Type == ElfSectionType.RelocationAddends; + + protected override void Read(ElfReader reader) + { + if (Parent.FileClass == ElfFileClass.Is32) + { + Read32(reader); + } + else + { + Read64(reader); + } + } + + protected override void Write(ElfWriter writer) + { + if (Parent.FileClass == ElfFileClass.Is32) + { + Write32(writer); + } + else + { + Write64(writer); + } + } + + public override unsafe ulong TableEntrySize => + Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : + Parent.FileClass == ElfFileClass.Is32 ? (ulong) (IsRelocationWithAddends ? sizeof(ElfNative.Elf32_Rela) : sizeof(ElfNative.Elf32_Rel)) : (ulong) (IsRelocationWithAddends ? sizeof(ElfNative.Elf64_Rela) : sizeof(ElfNative.Elf64_Rel)); + + private void Read32(ElfReader reader) + { + var numberOfEntries = base.Size / OriginalTableEntrySize; + if (IsRelocationWithAddends) + { + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf32_Rela rel; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationAddendsEntry32Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var offset = reader.Decode(rel.r_offset); + var r_info = reader.Decode(rel.r_info); + var type = new ElfRelocationType(Parent.Arch, r_info & 0xFF); + var symbolIndex = r_info >> 8; + var addend = reader.Decode(rel.r_addend); + + var entry = new ElfRelocation(offset, type, symbolIndex, addend); + _entries.Add(entry); + } + } + else + { + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf32_Rel rel; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationEntry32Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var offset = reader.Decode(rel.r_offset); + + var r_info = reader.Decode(rel.r_info); + var type = new ElfRelocationType(Parent.Arch, r_info & 0xFF); + var symbolIndex = r_info >> 8; + + var entry = new ElfRelocation(offset, type, symbolIndex, 0); + _entries.Add(entry); + } + } + } + + private void Read64(ElfReader reader) + { + var numberOfEntries = base.Size / OriginalTableEntrySize; + if (IsRelocationWithAddends) + { + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf64_Rela rel; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationAddendsEntry64Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var offset = reader.Decode(rel.r_offset); + + var r_info = reader.Decode(rel.r_info); + var type = new ElfRelocationType(Parent.Arch, (uint)(r_info & 0xFFFFFFFF)); + var symbolIndex = (uint)(r_info >> 32); + var addend = reader.Decode(rel.r_addend); + + var entry = new ElfRelocation(offset, type, symbolIndex, addend); + _entries.Add(entry); + } + } + else + { + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf64_Rel rel; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationEntry64Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var offset = reader.Decode(rel.r_offset); + + var r_info = reader.Decode(rel.r_info); + var type = new ElfRelocationType(Parent.Arch, (uint)(r_info & 0xFFFFFFFF)); + var symbolIndex = (uint)(r_info >> 32); + + var entry = new ElfRelocation(offset, type, symbolIndex, 0); + _entries.Add(entry); + } + } + } + + private void Write32(ElfWriter writer) + { + if (IsRelocationWithAddends) + { + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var rel = new ElfNative.Elf32_Rela(); + writer.Encode(out rel.r_offset, (uint)entry.Offset); + uint r_info = entry.Info32; + writer.Encode(out rel.r_info, r_info); + writer.Encode(out rel.r_addend, (int)entry.Addend); + writer.Write(rel); + } + } + else + { + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var rel = new ElfNative.Elf32_Rel(); + writer.Encode(out rel.r_offset, (uint)entry.Offset); + uint r_info = entry.Info32; + writer.Encode(out rel.r_info, r_info); + writer.Write(rel); + } + } + } + + private void Write64(ElfWriter writer) + { + if (IsRelocationWithAddends) + { + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var rel = new ElfNative.Elf64_Rela(); + writer.Encode(out rel.r_offset, entry.Offset); + ulong r_info = entry.Info64; + writer.Encode(out rel.r_info, r_info); + writer.Encode(out rel.r_addend, entry.Addend); + writer.Write(rel); + } + } + else + { + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var rel = new ElfNative.Elf64_Rel(); + writer.Encode(out rel.r_offset, (uint)entry.Offset); + ulong r_info = entry.Info64; + writer.Encode(out rel.r_info, r_info); + writer.Write(rel); + } + } + } + + protected override void AfterRead(ElfReader reader) + { + var name = Name.Value; + if (name == null) + { + return; + } + + var defaultName = GetDefaultName(Type); + + if (!name.StartsWith(defaultName)) + { + reader.Diagnostics.Warning(DiagnosticId.ELF_WRN_InvalidRelocationTablePrefixName, $"The name of the {Type} section `{this}` doesn't start with `{DefaultName}`"); + } + else + { + // Check the name of relocation + var currentTargetName = name.Substring(defaultName.Length); + var sectionTargetName = Info.Section?.Name.Value; + if (sectionTargetName != null && currentTargetName != sectionTargetName) + { + reader.Diagnostics.Warning(DiagnosticId.ELF_WRN_InvalidRelocationTablePrefixTargetName, $"Invalid name `{name}` for relocation table [{Index}] the current link section is named `{sectionTargetName}` so the expected name should be `{defaultName}{sectionTargetName}`", this); + } + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + //if (Info.Section == null) + //{ + // diagnostics.Error($"Invalid {nameof(Info)} of the section [{Index}] `{nameof(ElfRelocationTable)}` that cannot be null and must point to a valid section", this); + //} + //else + if (Info.Section != null && Info.Section.Parent != Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationInfoParent, $"Invalid parent for the {nameof(Info)} of the section [{Index}] `{nameof(ElfRelocationTable)}`. It must point to the same {nameof(ElfObjectFile)} parent instance than this section parent", this); + } + + var symbolTable = Link.Section as ElfSymbolTable; + + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + if (entry.Addend != 0 && !IsRelocationWithAddends) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationEntryAddend, $"Invalid relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`. The addend != 0 while the section is not a `{ElfSectionType.RelocationAddends}`", this); + } + + if (entry.Type.Arch != Parent.Arch) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationEntryArch, $"Invalid Arch `{entry.Type.Arch}` for relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`. The arch doesn't match the arch `{Parent.Arch}`", this); + } + + if (symbolTable != null && entry.SymbolIndex > (uint)symbolTable.Entries.Count) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationSymbolIndex, $"Out of range symbol index `{entry.SymbolIndex}` (max: {symbolTable.Entries.Count + 1} from symbol table {symbolTable}) for relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`", this); + } + } + } + + public override unsafe void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : + Parent.FileClass == ElfFileClass.Is32 + ? (ulong)Entries.Count * (IsRelocationWithAddends ? (ulong)sizeof(ElfNative.Elf32_Rela) : (ulong)sizeof(ElfNative.Elf32_Rel)) + : (ulong)Entries.Count * (IsRelocationWithAddends ? (ulong)sizeof(ElfNative.Elf64_Rela) : (ulong)sizeof(ElfNative.Elf64_Rel)); + + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs new file mode 100644 index 00000000000000..0b13a44bea43a8 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs @@ -0,0 +1,235 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using LibObjectFile.Dwarf; + +namespace LibObjectFile.Elf +{ + /// + /// Extension methods for + /// + public static class ElfRelocationTableExtensions + { + /// + /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. + /// + public static void Relocate(this ElfRelocationTable relocTable, in ElfRelocationContext context) + { + var relocTarget = relocTable.Info.Section; + if (!(relocTarget is ElfBinarySection relocTargetBinarySection)) + { + throw new InvalidOperationException($"Invalid ElfRelocationTable.Info section. Can only relocate a section that inherits from {nameof(ElfBinarySection)}."); + } + + Relocate(relocTable, relocTargetBinarySection.Stream, context); + } + + /// + /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. + /// + /// + public static void Relocate(this ElfRelocationTable relocTable, Stream stream, in ElfRelocationContext context) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + + switch (relocTable.Parent.Arch.Value) + { + case ElfArch.X86_64: + ApplyX86_64(relocTable, stream, context); + break; + default: + throw new NotImplementedException($"The relocation for architecture {relocTable.Parent.Arch} is not supported/implemented."); + } + stream.Position = 0; + } + + /// + /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. + /// + /// + private static void ApplyX86_64(this ElfRelocationTable relocTable, Stream stream, in ElfRelocationContext context) + { + if (stream == null) throw new ArgumentNullException(nameof(stream)); + bool isLsb = relocTable.Parent.Encoding == ElfEncoding.Lsb; + + var GOT = (long)context.GlobalObjectTableAddress; + var B = (long)context.BaseAddress; + var G = (long)context.GlobalObjectTableOffset; + + var symbolTable = (ElfSymbolTable)relocTable.Link.Section; + + foreach (var reloc in relocTable.Entries) + { + var P = (long)reloc.Offset; + var L = (long)context.ProcedureLinkageTableAddress + P; // TODO: Is it really that? + var A = reloc.Addend; + var symbol = symbolTable.Entries[(int)reloc.SymbolIndex - 1]; + var Z = (long)symbol.Size; + + var patchOffset = (long)reloc.Offset; + stream.Position = patchOffset; + + switch (reloc.Type.Value) + { + case ElfNative.R_X86_64_NONE: + case ElfNative.R_X86_64_COPY: + case ElfNative.R_X86_64_DTPMOD64: + case ElfNative.R_X86_64_DTPOFF64: + case ElfNative.R_X86_64_TPOFF64: + case ElfNative.R_X86_64_TLSGD: + case ElfNative.R_X86_64_TLSLD: + case ElfNative.R_X86_64_DTPOFF32: + case ElfNative.R_X86_64_GOTTPOFF: + case ElfNative.R_X86_64_TPOFF32: + break; + + case ElfNative.R_X86_64_64: // S + A + { + var S = (long) stream.ReadU64(isLsb); + stream.Position = patchOffset; + stream.WriteU64(isLsb, (ulong) (S + A)); + break; + } + case ElfNative.R_X86_64_PC32: // S + A - P + { + var S = (long) stream.ReadU32(isLsb); + stream.Position = patchOffset; + stream.WriteU32(isLsb, (uint) (S + A - P)); + break; + } + case ElfNative.R_X86_64_GOT32: // G + A + { + stream.WriteU32(isLsb, (uint) (G + A)); + break; + } + case ElfNative.R_X86_64_PLT32: // L + A - P + { + stream.WriteU32(isLsb, (uint) (L + A - P)); + break; + } + case ElfNative.R_X86_64_GLOB_DAT: // S + case ElfNative.R_X86_64_JUMP_SLOT: // S + break; + + case ElfNative.R_X86_64_RELATIVE: // B + A + { + stream.WriteU64(isLsb, (ulong) (B + A)); + break; + } + case ElfNative.R_X86_64_GOTPCREL: // G + GOT + A - P + { + stream.WriteU32(isLsb, (uint) (G + GOT + A - P)); + break; + } + case ElfNative.R_X86_64_32: // S + A + { + var S = (long) stream.ReadU32(isLsb); + stream.Position = patchOffset; + stream.WriteU32(isLsb, (uint) (S + A)); + break; + } + case ElfNative.R_X86_64_32S: // S + A + { + var S = (long) stream.ReadI32(isLsb); + stream.Position = patchOffset; + stream.WriteI32(isLsb, (int) (S + A)); + break; + } + case ElfNative.R_X86_64_16: // S + A + { + var S = (long) stream.ReadU16(isLsb); + stream.Position = patchOffset; + stream.WriteU16(isLsb, (ushort) (S + A)); + break; + } + case ElfNative.R_X86_64_PC16: // S + A - P + { + var S = (long) stream.ReadU16(isLsb); + stream.Position = patchOffset; + stream.WriteU16(isLsb, (ushort) (S + A - P)); + break; + } + case ElfNative.R_X86_64_8: // S + A + { + var S = (long) stream.ReadU8(); + stream.Position = patchOffset; + stream.WriteU8((byte) (S + A)); + break; + } + case ElfNative.R_X86_64_PC8: // S + A - P + { + var S = (long)stream.ReadU8(); + stream.Position = patchOffset; + stream.WriteU8((byte)(S + A - P)); + break; + } + + case ElfNative.R_X86_64_PC64: // S + A - P + { + var S = (long)stream.ReadU64(isLsb); + stream.Position = patchOffset; + stream.WriteU64(isLsb, (ulong)(S + A - P)); + break; + } + + case ElfNative.R_X86_64_GOTOFF64: // S + A - GOT + { + var S = (long)stream.ReadU64(isLsb); + stream.Position = patchOffset; + stream.WriteU64(isLsb, (ulong)(S + A - GOT)); + break; + } + case ElfNative.R_X86_64_GOTPC32: // GOT + A - P + stream.WriteU32(isLsb, (uint)(GOT + A - P)); + break; + + case ElfNative.R_X86_64_GOT64: // G + A + stream.WriteU64(isLsb, (ulong)(G + A)); + break; + + case ElfNative.R_X86_64_GOTPCREL64: // G + GOT - P + A + stream.WriteU64(isLsb, (ulong)(G + GOT - P + A)); + break; + + case ElfNative.R_X86_64_GOTPC64: // GOT - P + A + stream.WriteU64(isLsb, (ulong)(GOT - P + A)); + break; + + case ElfNative.R_X86_64_GOTPLT64: // G + A + stream.WriteU64(isLsb, (ulong)(G + A)); + break; + + case ElfNative.R_X86_64_PLTOFF64: // L - GOT + A + stream.WriteU64(isLsb, (ulong)(L - GOT + A)); + break; + + case ElfNative.R_X86_64_GOTPC32_TLSDESC: + case ElfNative.R_X86_64_TLSDESC_CALL: + case ElfNative.R_X86_64_TLSDESC: + break; + + case ElfNative.R_X86_64_RELATIVE64: // B + A + stream.WriteU64(isLsb, (ulong)(B + A)); + break; + + case ElfNative.R_X86_64_SIZE32: + stream.WriteU32(isLsb, (uint)(Z + A)); + break; + case ElfNative.R_X86_64_SIZE64: + stream.WriteU64(isLsb, (ulong)(Z + A)); + break; + + case ElfNative.R_X86_64_IRELATIVE: + default: + throw new NotImplementedException($"Relocation {reloc} not implemented/supported"); + } + } + + stream.Position = 0; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs new file mode 100644 index 00000000000000..da37e22810ac4a --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs @@ -0,0 +1,66 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// Gets the type of a . + /// + public readonly partial struct ElfRelocationType : IEquatable + { + public ElfRelocationType(ElfArchEx arch, uint value) + { + Arch = arch; + Value = value; + } + + /// + /// The associated the applies to. + /// + public readonly ElfArchEx Arch; + + /// + /// The value of this relocation type. + /// + public readonly uint Value; + + public bool Equals(ElfRelocationType other) + { + return Arch.Equals(other.Arch) && Value == other.Value; + } + + public override bool Equals(object obj) + { + return obj is ElfRelocationType other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + return (Arch.GetHashCode() * 397) ^ (int) Value; + } + } + + public static bool operator ==(ElfRelocationType left, ElfRelocationType right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfRelocationType left, ElfRelocationType right) + { + return !left.Equals(right); + } + + public string Name => ToStringInternal(); + + public override string ToString() + { + if (Arch.Value == 0 && Value == 0) return "Empty ElfRelocationType"; + return ToStringInternal() ?? $"Unknown {nameof(ElfRelocationType)} (0x{Value:X4})"; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs new file mode 100644 index 00000000000000..a0d41fe2283c92 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs @@ -0,0 +1,19 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// The Section Header String Table used by . + /// + public sealed class ElfSectionHeaderStringTable : ElfStringTable + { + public new const string DefaultName = ".shstrtab"; + + public ElfSectionHeaderStringTable() + { + Name = DefaultName; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs new file mode 100644 index 00000000000000..11fead1fbb9ce3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs @@ -0,0 +1,19 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// A shadow section is a section that will not be saved to the section header table but can contain data + /// that will be saved with the . + /// A shadow section is usually associated with an that is referencing a portion of + /// data that is not owned by a visible section. + /// + public abstract class ElfShadowSection : ElfSection + { + protected ElfShadowSection() : base(ElfSectionType.Null) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs new file mode 100644 index 00000000000000..447fd9db0820a2 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs @@ -0,0 +1,199 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +namespace LibObjectFile.Elf +{ + /// + /// A string table section with the type . + /// + public class ElfStringTable : ElfSection + { + private readonly MemoryStream _table; + private readonly Dictionary _mapStringToIndex; + private readonly Dictionary _mapIndexToString; + + public const string DefaultName = ".strtab"; + + public const int DefaultCapacity = 256; + + public ElfStringTable() : this(DefaultCapacity) + { + } + + public ElfStringTable(int capacityInBytes) : base(ElfSectionType.StringTable) + { + if (capacityInBytes < 0) throw new ArgumentOutOfRangeException(nameof(capacityInBytes)); + Name = DefaultName; + _table = new MemoryStream(capacityInBytes); + _mapStringToIndex = new Dictionary(); + _mapIndexToString = new Dictionary(); + // Always create an empty string + GetOrCreateIndex(string.Empty); + } + + public override ElfSectionType Type + { + get => base.Type; + set + { + if (value != ElfSectionType.StringTable) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfStringTable)}`. Only `{ElfSectionType.StringTable}` is valid"); + } + base.Type = value; + } + } + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + Size = (ulong)_table.Length; + } + + protected override void Read(ElfReader reader) + { + Debug.Assert(_table.Position == 1 && _table.Length == 1); + var length = (long) base.Size; + _table.SetLength(length); + var buffer = _table.GetBuffer(); + reader.Stream.Read(buffer, 0, (int)length); + _table.Position = _table.Length; + } + + protected override void Write(ElfWriter writer) + { + writer.Stream.Write(_table.GetBuffer(), 0, (int)_table.Length); + } + + public uint GetOrCreateIndex(string text) + { + // Same as empty string + if (text == null) return 0; + + if (_mapStringToIndex.TryGetValue(text, out uint index)) + { + return index; + } + + index = (uint) _table.Length; + _mapIndexToString.Add(index, text); + _mapStringToIndex.Add(text, index); + + if (text.Length == 0) + { + Debug.Assert(index == 0); + _table.WriteByte(0); + } + else + { + var reservedBytes = Encoding.UTF8.GetByteCount(text) + 1; + var buffer = ArrayPool.Shared.Rent(reservedBytes); + var span = new Span(buffer, 0, reservedBytes); + Encoding.UTF8.GetEncoder().GetBytes(text, span, true); + span[reservedBytes - 1] = 0; + if (_table.Position != index) + { + _table.Position = index; + } + _table.Write(span); + ArrayPool.Shared.Return(buffer); + + // Register all subsequent strings + while (text.Length > 0) + { + text = text.Substring(1); + if (_mapStringToIndex.ContainsKey(text)) + { + break; + } + var offset = reservedBytes - Encoding.UTF8.GetByteCount(text) - 1; + var subIndex = index + (uint) offset; + _mapStringToIndex.Add(text, subIndex); + _mapIndexToString.Add(subIndex, text); + } + } + + return index; + } + + public bool TryResolve(ElfString inStr, out ElfString outStr) + { + outStr = inStr; + if (inStr.Value != null) + { + outStr = inStr.WithIndex(GetOrCreateIndex(inStr.Value)); + } + else + { + if (TryFind(inStr.Index, out var text)) + { + outStr = inStr.WithName(text); + } + else + { + return false; + } + } + return true; + } + + public bool TryFind(uint index, out string text) + { + if (index == 0) + { + text = string.Empty; + return true; + } + + if (_mapIndexToString.TryGetValue(index, out text)) + { + return true; + } + + if (index >= _table.Length) + { + return false; + } + + _table.Position = index; + + var buffer = _table.GetBuffer(); + var indexOfByte0 = Array.IndexOf(buffer, (byte)0, (int)index); + + if (indexOfByte0 < 0 || indexOfByte0 >= _table.Length) + { + indexOfByte0 = (int)(_table.Length - 1); + } + + var strLength = (int)(indexOfByte0 - index); + text = Encoding.UTF8.GetString(buffer, (int)index, strLength); + _mapIndexToString.Add(index, text); + + // Don't try to override an existing mapping + if (!_mapStringToIndex.TryGetValue(text, out var existingIndex)) + { + _mapStringToIndex.Add(text, index); + } + + return true; + } + + public void Reset() + { + _table.SetLength(0); + _mapStringToIndex.Clear(); + _mapIndexToString.Clear(); + + // Always create an empty string + GetOrCreateIndex(string.Empty); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs new file mode 100644 index 00000000000000..1cf390b51d15b4 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs @@ -0,0 +1,92 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile.Elf +{ + /// + /// A symbol entry in the + /// This is the value seen in or + /// + public struct ElfSymbol : IEquatable + { + public static readonly ElfSymbol Empty = new ElfSymbol(); + + /// + /// Gets or sets the value associated to this symbol. + /// + public ulong Value { get; set; } + + /// + /// Gets or sets the size of this symbol. + /// + public ulong Size { get; set; } + + /// + /// Gets or sets the type of this symbol (e.g or ). + /// + public ElfSymbolType Type { get; set; } + + /// + /// Get or sets the binding applying to this symbol (e.g or ). + /// + public ElfSymbolBind Bind { get; set; } + + /// + /// Gets or sets the visibility of this symbol (e.g ) + /// + public ElfSymbolVisibility Visibility { get; set; } + + /// + /// Gets or sets the associated section to this symbol. + /// + public ElfSectionLink Section { get; set; } + + /// + /// Gets or sets the name of this symbol. + /// + public ElfString Name { get; set; } + + public override string ToString() + { + return $"{nameof(Value)}: 0x{Value:X16}, {nameof(Size)}: {Size:#####}, {nameof(Type)}: {Type}, {nameof(Bind)}: {Bind}, {nameof(Visibility)}: {Visibility}, {nameof(Section)}: {Section}, {nameof(Name)}: {Name}"; + } + + public bool Equals(ElfSymbol other) + { + return Value == other.Value && Size == other.Size && Type == other.Type && Bind == other.Bind && Visibility == other.Visibility && Section.Equals(other.Section) && Name == other.Name; + } + + public override bool Equals(object obj) + { + return obj is ElfSymbol other && Equals(other); + } + + public override int GetHashCode() + { + unchecked + { + var hashCode = Value.GetHashCode(); + hashCode = (hashCode * 397) ^ Size.GetHashCode(); + hashCode = (hashCode * 397) ^ (int) Type; + hashCode = (hashCode * 397) ^ (int) Bind; + hashCode = (hashCode * 397) ^ (int) Visibility; + hashCode = (hashCode * 397) ^ Section.GetHashCode(); + hashCode = (hashCode * 397) ^ Name.GetHashCode(); + return hashCode; + } + } + + public static bool operator ==(ElfSymbol left, ElfSymbol right) + { + return left.Equals(right); + } + + public static bool operator !=(ElfSymbol left, ElfSymbol right) + { + return !left.Equals(right); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs new file mode 100644 index 00000000000000..742af667ff2b35 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs @@ -0,0 +1,64 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines a symbol binding + /// This is the value seen compressed in or + /// as well as the various defines (e.g ). + /// + public enum ElfSymbolBind : byte + { + /// + /// Local symbol + /// + Local = ElfNative.STB_LOCAL, + + /// + /// Global symbol + /// + Global = ElfNative.STB_GLOBAL, + + /// + /// Weak symbol + /// + Weak = ElfNative.STB_WEAK, + + /// + /// Unique symbol + /// + GnuUnique = ElfNative.STB_GNU_UNIQUE, + + /// + /// OS-specific 0 + /// + SpecificOS0 = ElfNative.STB_GNU_UNIQUE, + + /// + /// OS-specific 1 + /// + SpecificOS1 = ElfNative.STB_GNU_UNIQUE + 1, + + /// + /// OS-specific 2 + /// + SpecificOS2 = ElfNative.STB_GNU_UNIQUE + 2, + + /// + /// Processor-specific 0 + /// + SpecificProcessor0 = ElfNative.STB_LOPROC, + + /// + /// Processor-specific 1 + /// + SpecificProcessor1 = ElfNative.STB_LOPROC + 1, + + /// + /// Processor-specific 2 + /// + SpecificProcessor2 = ElfNative.STB_LOPROC + 2, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs new file mode 100644 index 00000000000000..a23f823931ecb9 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs @@ -0,0 +1,256 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; + +namespace LibObjectFile.Elf +{ + /// + /// A symbol table section with the type or + /// + public sealed class ElfSymbolTable : ElfSection + { + public const string DefaultName = ".symtab"; + + public ElfSymbolTable() : base(ElfSectionType.SymbolTable) + { + Name = DefaultName; + Entries = new List(); + Entries.Add(new ElfSymbol()); + } + + public override ElfSectionType Type + { + get => base.Type; + set + { + if (value != ElfSectionType.SymbolTable && value != ElfSectionType.DynamicLinkerSymbolTable) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfSymbolTable)}`. Only `{ElfSectionType.SymbolTable}` or `{ElfSectionType.DynamicLinkerSymbolTable}` are valid"); + } + base.Type = value; + } + } + + /// + /// Gets a list of entries. + /// + public List Entries { get; } + + public override unsafe ulong TableEntrySize => + Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : + Parent.FileClass == ElfFileClass.Is32 ? (ulong) sizeof(ElfNative.Elf32_Sym) : (ulong) sizeof(ElfNative.Elf64_Sym); + + protected override void Read(ElfReader reader) + { + if (Parent.FileClass == ElfFileClass.Is32) + { + Read32(reader); + } + else + { + Read64(reader); + } + } + + protected override void Write(ElfWriter writer) + { + if (Parent.FileClass == ElfFileClass.Is32) + { + Write32(writer); + } + else + { + Write64(writer); + } + } + + private void Read32(ElfReader reader) + { + var numberOfEntries = base.Size / OriginalTableEntrySize; + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf32_Sym sym; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out sym)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSymbolEntry32Size, $"Unable to read entirely the symbol entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var entry = new ElfSymbol(); + entry.Name = new ElfString(reader.Decode(sym.st_name)); + entry.Value = reader.Decode(sym.st_value); + entry.Size = reader.Decode(sym.st_size); + + var st_info = sym.st_info; + entry.Type = (ElfSymbolType) (st_info & 0xF); + entry.Bind = (ElfSymbolBind)(st_info >> 4); + entry.Visibility = (ElfSymbolVisibility) sym.st_other; + entry.Section = new ElfSectionLink(reader.Decode(sym.st_shndx)); + + // If the entry 0 was validated + if (i == 0 && entry == ElfSymbol.Empty) + { + continue; + } + + Entries.Add(entry); + } + } + + private void Read64(ElfReader reader) + { + var numberOfEntries = base.Size / OriginalTableEntrySize; + for (ulong i = 0; i < numberOfEntries; i++) + { + ElfNative.Elf64_Sym sym; + ulong streamOffset = (ulong)reader.Stream.Position; + if (!reader.TryReadData((int)OriginalTableEntrySize, out sym)) + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSymbolEntry64Size, $"Unable to read entirely the symbol entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); + } + + var entry = new ElfSymbol(); + entry.Name = new ElfString(reader.Decode(sym.st_name)); + entry.Value = reader.Decode(sym.st_value); + entry.Size = reader.Decode(sym.st_size); + + var st_info = sym.st_info; + entry.Type = (ElfSymbolType)(st_info & 0xF); + entry.Bind = (ElfSymbolBind)(st_info >> 4); + entry.Visibility = (ElfSymbolVisibility)sym.st_other; + entry.Section = new ElfSectionLink(reader.Decode(sym.st_shndx)); + + // If the entry 0 was validated + if (i == 0 && entry == ElfSymbol.Empty) + { + continue; + } + + Entries.Add(entry); + } + } + + + private void Write32(ElfWriter writer) + { + var stringTable = (ElfStringTable)Link.Section; + + // Write all entries + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var sym = new ElfNative.Elf32_Sym(); + writer.Encode(out sym.st_name, (ushort)stringTable.GetOrCreateIndex(entry.Name)); + writer.Encode(out sym.st_value, (uint)entry.Value); + writer.Encode(out sym.st_size, (uint)entry.Size); + sym.st_info = (byte)(((byte) entry.Bind << 4) | (byte) entry.Type); + sym.st_other = (byte) ((byte) entry.Visibility & 3); + writer.Encode(out sym.st_shndx, (ElfNative.Elf32_Half) entry.Section.GetIndex()); + + writer.Write(sym); + } + } + + private void Write64(ElfWriter writer) + { + var stringTable = (ElfStringTable)Link.Section; + + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + var sym = new ElfNative.Elf64_Sym(); + writer.Encode(out sym.st_name, stringTable.GetOrCreateIndex(entry.Name)); + writer.Encode(out sym.st_value, entry.Value); + writer.Encode(out sym.st_size, entry.Size); + sym.st_info = (byte)(((byte)entry.Bind << 4) | (byte)entry.Type); + sym.st_other = (byte)((byte)entry.Visibility & 3); + writer.Encode(out sym.st_shndx, (ElfNative.Elf64_Half)entry.Section.GetIndex()); + + writer.Write(sym); + } + } + + protected override void AfterRead(ElfReader reader) + { + // Verify that the link is safe and configured as expected + Link.TryGetSectionSafe(nameof(ElfSymbolTable), nameof(Link), this, reader.Diagnostics, out var stringTable, ElfSectionType.StringTable); + + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + if (stringTable != null) + { + if (stringTable.TryResolve(entry.Name, out var newEntry)) + { + entry.Name = newEntry; + } + else + { + reader.Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntryNameIndex, $"Invalid name index [{entry.Name.Index}] for symbol [{i}] in section [{this}]"); + } + } + + entry.Section = reader.ResolveLink(entry.Section, $"Invalid link section index {entry.Section.SpecialIndex} for symbol table entry [{i}] from symbol table section [{this}]"); + + Entries[i] = entry; + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + // Verify that the link is safe and configured as expected + if (!Link.TryGetSectionSafe(nameof(ElfSymbolTable), nameof(Link), this, diagnostics, out var stringTable, ElfSectionType.StringTable)) + { + return; + } + + bool isAllowingLocal = true; + + for (int i = 0; i < Entries.Count; i++) + { + var entry = Entries[i]; + + if (i == 0 && entry != ElfSymbol.Empty) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSymbolEntryNonNull, $"Invalid entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The first entry must be null/undefined"); + } + + if (entry.Section.Section != null && entry.Section.Section.Parent != Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntrySectionParent, $"Invalid section for the symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The section of the entry `{entry}` must the same than this symbol table section"); + } + + stringTable.GetOrCreateIndex(entry.Name); + + // Update the last local index + if (entry.Bind == ElfSymbolBind.Local) + { + // + 1 For the plus one + Info = new ElfSectionLink((uint)(i + 1)); + if (!isAllowingLocal) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntryLocalPosition, $"Invalid position for the LOCAL symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. A LOCAL symbol entry must be before any other symbol entry"); + } + } + else + { + isAllowingLocal = false; + } + } + } + + public override unsafe void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : + Parent.FileClass == ElfFileClass.Is32 ? (ulong)(Entries.Count * sizeof(ElfNative.Elf32_Sym)) : (ulong)(Entries.Count * sizeof(ElfNative.Elf64_Sym)); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs new file mode 100644 index 00000000000000..df20d20575dedf --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs @@ -0,0 +1,84 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines a symbol type. + /// This is the value seen compressed in or + /// as well as the various defines (e.g ). + /// + public enum ElfSymbolType : byte + { + /// + /// Symbol type is unspecified + /// + NoType = ElfNative.STT_NOTYPE, + + /// + /// Symbol is a data object + /// + Object = ElfNative.STT_OBJECT, + + /// + /// Symbol is a code object + /// + Function = ElfNative.STT_FUNC, + + /// + /// Symbol associated with a section + /// + Section = ElfNative.STT_SECTION, + + /// + /// Symbol's name is file name + /// + File = ElfNative.STT_FILE, + + /// + /// Symbol is a common data object + /// + Common = ElfNative.STT_COMMON, + + /// + /// Symbol is thread-local data object + /// + Tls = ElfNative.STT_TLS, + + /// + /// Symbol is indirect code object + /// + GnuIndirectFunction = ElfNative.STT_GNU_IFUNC, + + /// + /// OS-specific 0 + /// + SpecificOS0 = ElfNative.STT_GNU_IFUNC, + + /// + /// OS-specific 1 + /// + SpecificOS1 = ElfNative.STT_GNU_IFUNC + 1, + + /// + /// OS-specific 2 + /// + SpecificOS2 = ElfNative.STT_GNU_IFUNC + 2, + + /// + /// Processor-specific 0 + /// + SpecificProcessor0 = ElfNative.STT_LOPROC, + + /// + /// Processor-specific 1 + /// + SpecificProcessor1 = ElfNative.STT_LOPROC + 1, + + /// + /// Processor-specific 2 + /// + SpecificProcessor2 = ElfNative.STT_LOPROC + 2, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs new file mode 100644 index 00000000000000..08d372528aa2df --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs @@ -0,0 +1,34 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile.Elf +{ + /// + /// Defines the visibility of a symbol + /// This is the value seen compressed in or + /// as well as the various defines (e.g ). + /// + public enum ElfSymbolVisibility : byte + { + /// + /// Default symbol visibility rules + /// + Default = ElfNative.STV_DEFAULT, + + /// + /// Processor specific hidden class + /// + Internal = ElfNative.STV_INTERNAL, + + /// + /// Sym unavailable in other modules + /// + Hidden = ElfNative.STV_HIDDEN, + + /// + /// Not preemptible, not exported + /// + Protected = ElfNative.STV_PROTECTED, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs new file mode 100644 index 00000000000000..5b8d364568ddcd --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs @@ -0,0 +1,13 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + public interface IObjectFileNodeLink + { + ulong GetRelativeOffset(); + + ObjectFileNode GetObjectFileNode(); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj new file mode 100644 index 00000000000000..d68d78241fb4f3 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj @@ -0,0 +1,41 @@ + + + + netstandard2.1 + 8.0 + true + + + + LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...) + Alexandre Mutel + en-US + Alexandre Mutel + ELF DWARF ar archive objectfile + BSD-2-Clause + readme.md + logo.png + https://github.com/xoofx/LibObjectFile + + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + + + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings new file mode 100644 index 00000000000000..02a34e61ff2c46 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs new file mode 100644 index 00000000000000..10f0b5838b1f31 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs @@ -0,0 +1,27 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; + +namespace LibObjectFile +{ + /// + /// An exception used when diagnostics error are happening during read/write. + /// + public class ObjectFileException : Exception + { + public ObjectFileException(string message, DiagnosticBag diagnostics) : base(message) + { + + Diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); + } + + public override string Message => base.Message + Environment.NewLine + Diagnostics; + + /// + /// The associated diagnostics messages. + /// + public DiagnosticBag Diagnostics { get; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs new file mode 100644 index 00000000000000..fda135aad89973 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs @@ -0,0 +1,141 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; + +namespace LibObjectFile +{ + public static class ObjectFileExtensions + { + /// + /// Adds an attribute to . + /// + /// A attribute + public static void Add(this List list, TParent parent, TChild element) where TChild : ObjectFileNode where TParent: ObjectFileNode + { + if (element == null) throw new ArgumentNullException(nameof(element)); + if (element.Parent != null) + { + if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); + if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); + } + + element.Parent = parent; + element.Index = (uint)list.Count; + list.Add(element); + } + + /// + /// Adds an element to the sorted list + /// + /// An element to add + public static void AddSorted(this List list, TParent parent, TChild element, bool requiresUnique = false) where TChild : ObjectFileNode, IComparable where TParent : ObjectFileNode + { + if (element == null) throw new ArgumentNullException(nameof(element)); + if (element.Parent != null) + { + if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); + if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); + } + + int index; + + // Optimistic case, we add in order + if (list.Count == 0 || list[^1].CompareTo(element) < 0) + { + element.Parent = parent; + index = list.Count; + list.Add(element); + } + else + { + index = list.BinarySearch(element); + if (index < 0) + index = ~index; + else if (requiresUnique && list[index].CompareTo(element) == 0) + { + throw new InvalidOperationException($"A similar element to `{element}` has been already added to this collection at index {index}"); + } + + element.Parent = parent; + list.Insert(index, element); + } + + element.Index = (uint)index; + + // Update the index of following attributes + for (int i = index + 1; i < list.Count; i++) + { + var nextAttribute = list[i]; + nextAttribute.Index++; + } + } + + /// + /// Inserts an attribute into at the specified index. + /// + /// Index into to insert the specified attribute + /// The attribute to insert + public static void InsertAt(this List list, TParent parent, int index, TChild element) where TChild : ObjectFileNode where TParent : ObjectFileNode + { + if (index < 0 || index > list.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {list.Count}"); + if (element == null) throw new ArgumentNullException(nameof(element)); + if (element.Parent != null) + { + if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); + if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); + } + + element.Index = (uint)index; + list.Insert(index, element); + element.Parent = parent; + + // Update the index of following attributes + for (int i = index + 1; i < list.Count; i++) + { + var nextAttribute = list[i]; + nextAttribute.Index++; + } + } + + /// + /// Removes an attribute from + /// + /// The attribute to remove + public static void Remove(this List list, TParent parent, TChild child) where TChild : ObjectFileNode where TParent : ObjectFileNode + { + if (child == null) throw new ArgumentNullException(nameof(child)); + if (!ReferenceEquals(child.Parent, parent)) + { + throw new InvalidOperationException($"Cannot remove the {nameof(TChild)} as it is not part of this {parent.GetType()} instance"); + } + + var i = (int)child.Index; + list.RemoveAt(i); + child.Index = 0; + + // Update indices for other sections + for (int j = i + 1; j < list.Count; j++) + { + var nextEntry = list[j]; + nextEntry.Index--; + } + + child.Parent = null; + } + + /// + /// Removes an attribute from at the specified index. + /// + /// Index into to remove the specified attribute + public static TChild RemoveAt(this List list, TParent parent, int index) where TChild : ObjectFileNode where TParent : ObjectFileNode + { + if (index < 0 || index > list.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {list.Count}"); + var child = list[index]; + Remove(list, parent, child); + return child; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs new file mode 100644 index 00000000000000..72030cffbc3143 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs @@ -0,0 +1,152 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Diagnostics; + +namespace LibObjectFile +{ + public abstract class ObjectFileNode + { + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private ObjectFileNode _parent; + + /// + /// Gets or sets the offset of this section or segment in the parent . + /// + public ulong Offset { get; set; } + + /// + /// Gets the containing parent. + /// + public ObjectFileNode Parent + { + get => _parent; + + internal set + { + if (value == null) + { + _parent = null; + } + else + { + ValidateParent(value); + } + + _parent = value; + } + } + + protected virtual void ValidateParent(ObjectFileNode parent) + { + } + + /// + /// Index within the containing list in the + /// + public uint Index { get; internal set; } + + /// + /// Gets or sets the size of this section or segment in the parent . + /// + public virtual ulong Size { get; set; } + + /// + /// Checks if the specified offset is contained by this instance. + /// + /// The offset to check if it belongs to this instance. + /// true if the offset is within the segment or section range. + public bool Contains(ulong offset) + { + return offset >= Offset && offset < Offset + Size; + } + + /// + /// Checks this instance contains either the beginning or the end of the specified section or segment. + /// + /// The specified section or segment. + /// true if the either the offset or end of the part is within this segment or section range. + public bool Contains(ObjectFileNode node) + { + if (node == null) throw new ArgumentNullException(nameof(node)); + return Contains((ulong)node.Offset) || node.Size != 0 && Contains((ulong)(node.Offset + node.Size - 1)); + } + + /// + /// Verifies the integrity of this file. + /// + /// The result of the diagnostics + public DiagnosticBag Verify() + { + var diagnostics = new DiagnosticBag(); + Verify(diagnostics); + return diagnostics; + } + + /// + /// Verifies the integrity of this file. + /// + /// A DiagnosticBag instance to receive the diagnostics. + public virtual void Verify(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + } + + protected static void AttachChild(TParent parent, T child, ref T field, bool allowNull) where T : ObjectFileNode where TParent : ObjectFileNode + { + if (parent == null) throw new ArgumentNullException(nameof(parent)); + if (!allowNull && child == null) throw new ArgumentNullException(nameof(child)); + + if (field != null) + { + field.Parent = null; + } + + if (child?.Parent != null) throw new InvalidOperationException($"Cannot set the {child.GetType()} as it already belongs to another {child.Parent.GetType()} instance"); + field = child; + + if (child != null) + { + child.Parent = parent; + } + } + } + + ///// + ///// Base class for a part of a file. + ///// + //public abstract class ObjectFileNode : ObjectFileNode where TParentFile : ObjectFileNode + //{ + // protected override void ValidateParent(ObjectFileNode parent) + // { + // if (!(parent is TParentFile)) + // { + // throw new ArgumentException($"Parent must inherit from type {nameof(TParentFile)}"); + // } + // } + + // internal void UpdateLayoutInternal(TLayoutContext layout) + // { + // UpdateLayoutImpl(layout); + // } + + // /// + // /// Updates the layout of this object. + // /// + // /// The layout context of this object. + // protected abstract void UpdateLayoutImpl(TLayoutContext layout); + + // /// + // /// Gets the containing . Might be null if this section or segment + // /// does not belong to an existing . + // /// + // [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] + // public new TParentFile Parent + // { + // get => (TParentFile) base.Parent; + // internal set => base.Parent = value; + // } + //} +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs new file mode 100644 index 00000000000000..3e6ff927e303b7 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs @@ -0,0 +1,341 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using LibObjectFile.Utils; + +namespace LibObjectFile +{ + /// + /// Base class used for reading / writing an object file to/from a stream. + /// + public abstract class ObjectFileReaderWriter + { + private Stream _stream; + + protected ObjectFileReaderWriter(Stream stream) : this(stream, new DiagnosticBag()) + { + } + + protected ObjectFileReaderWriter(Stream stream, DiagnosticBag diagnostics) + { + Stream = stream; + Diagnostics = diagnostics; + IsLittleEndian = true; + } + + /// + /// Gets or sets stream of the object file. + /// + public Stream Stream + { + get => _stream; + set => _stream = value; + } + + public ulong Offset + { + get => (ulong) Stream.Position; + set => Stream.Position = (long) value; + } + + public ulong Length + { + get => (ulong) Stream.Length; + } + + /// + /// The diagnostics while read/writing this object file. + /// + public DiagnosticBag Diagnostics { get; protected set; } + + /// + /// Gets a boolean indicating if this reader is operating in read-only mode. + /// + public abstract bool IsReadOnly { get; } + + public bool IsLittleEndian { get; protected set; } + + public TextWriter Log { get; set; } + + /// + /// Reads from the and current position to the specified buffer. + /// + /// The buffer to receive the content of the read. + /// The offset into the buffer. + /// The number of bytes to write from the buffer. + public int Read(byte[] buffer, int offset, int count) + { + return Stream.Read(buffer, offset, count); + } + + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// true if the string was successfully read from the stream, false otherwise + public string ReadStringUTF8NullTerminated() + { + return Stream.ReadStringUTF8NullTerminated(); + } + + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// The number of bytes to read including the null + /// A string + public string ReadStringUTF8NullTerminated(uint byteLength) + { + return Stream.ReadStringUTF8NullTerminated(byteLength); + } + + public byte ReadU8() + { + return Stream.ReadU8(); + } + + public sbyte ReadI8() + { + return Stream.ReadI8(); + } + + public short ReadI16() + { + return Stream.ReadI16(IsLittleEndian); + } + + public ushort ReadU16() + { + return Stream.ReadU16(IsLittleEndian); + } + + public int ReadI32() + { + return Stream.ReadI32(IsLittleEndian); + } + + public uint ReadU32() + { + return Stream.ReadU32(IsLittleEndian); + } + + public long ReadI64() + { + return Stream.ReadI64(IsLittleEndian); + } + + public ulong ReadU64() + { + return Stream.ReadU64(IsLittleEndian); + } + + public void WriteI8(sbyte value) + { + Stream.WriteI8(value); + } + + public void WriteU8(byte value) + { + Stream.WriteU8(value); + } + + public void WriteU16(ushort value) + { + Stream.WriteU16(IsLittleEndian, value); + } + + public void WriteU32(uint value) + { + Stream.WriteU32(IsLittleEndian, value); + } + + public void WriteU64(ulong value) + { + Stream.WriteU64(IsLittleEndian, value); + } + + /// + /// Writes a null terminated UTF8 string to the stream. + /// + public void WriteStringUTF8NullTerminated(string text) + { + Stream.WriteStringUTF8NullTerminated(text); + } + + /// + /// Tries to read an element of type with a specified size. + /// + /// Type of the element to read. + /// Size of the element to read (might be smaller or bigger). + /// The data read. + /// true if reading was successful. false otherwise. + public unsafe bool TryReadData(int sizeToRead, out T data) where T : unmanaged + { + if (sizeToRead <= 0) throw new ArgumentOutOfRangeException(nameof(sizeToRead)); + + int dataByteCount = sizeof(T); + int byteRead; + + // If we are requested to read more data than the sizeof(T) + // we need to read it to an intermediate buffer before transferring it to T data + if (sizeToRead > dataByteCount) + { + var buffer = ArrayPool.Shared.Rent(sizeToRead); + var span = new Span(buffer, 0, sizeToRead); + byteRead = Stream.Read(span); + data = MemoryMarshal.Cast(span)[0]; + ArrayPool.Shared.Return(buffer); + } + else + { + // Clear the data if the size requested is less than the expected struct to read + if (sizeToRead < dataByteCount) + { + data = default; + } + + fixed (void* pData = &data) + { + var span = new Span(pData, sizeToRead); + byteRead = Stream.Read(span); + } + } + return byteRead == sizeToRead; + } + + /// + /// Reads from the current bytes and return the data as + /// a if is false otherwise as a + /// . + /// + /// Size of the data to read. + /// A if is false otherwise as a + /// . + public Stream ReadAsStream(ulong size) + { + if (IsReadOnly) + { + var stream = ReadAsSliceStream(size); + Stream.Position += stream.Length; + return stream; + } + + return ReadAsMemoryStream(size); + } + + /// + /// Writes to the and current position from the specified buffer. + /// + /// The buffer to write the content from. + /// The offset into the buffer. + /// The number of bytes to read from the buffer and write to the stream. + public void Write(byte[] buffer, int offset, int count) + { + Stream.Write(buffer, offset, count); + } + + /// + /// Writes an element of type to the stream. + /// + /// Type of the element to read. + /// The data to write. + public unsafe void Write(in T data) where T : unmanaged + { + fixed (void* pData = &data) + { + var span = new ReadOnlySpan(pData, sizeof(T)); + Stream.Write(span); + } + } + + /// + /// Writes from the specified stream to the current of this instance. + /// The position of the input stream is set to 0 before writing and reset back to 0 after writing. + /// + /// The input stream to read from and write to + /// The amount of data to read from the input stream (if == 0, by default, it will read the entire input stream) + /// The size of the intermediate buffer used to transfer the data. + public void Write(Stream inputStream, ulong size = 0, int bufferSize = 4096) + { + if (inputStream == null) throw new ArgumentNullException(nameof(inputStream)); + if (bufferSize <= 0) throw new ArgumentOutOfRangeException(nameof(bufferSize)); + + inputStream.Position = 0; + size = size == 0 ? (ulong)inputStream.Length : size; + var buffer = ArrayPool.Shared.Rent(bufferSize); + + while (size != 0) + { + var sizeToRead = size >= (ulong)buffer.Length ? buffer.Length : (int)size; + var sizeRead = inputStream.Read(buffer, 0, sizeToRead); + if (sizeRead <= 0) break; + + Stream.Write(buffer, 0, sizeRead); + size -= (ulong)sizeRead; + } + + inputStream.Position = 0; + if (size != 0) + { + throw new InvalidOperationException("Unable to write stream entirely"); + } + } + + private SliceStream ReadAsSliceStream(ulong size) + { + var position = Stream.Position; + if (position + (long)size > Stream.Length) + { + if (position < Stream.Length) + { + size = Stream.Position < Stream.Length ? (ulong)(Stream.Length - Stream.Position) : 0; + Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Expecting to slice {size} bytes at offset {position} while remaining length is {size}"); + } + else + { + position = Stream.Length; + size = 0; + Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Position of slice {position} is outside of the stream length {Stream.Length} in bytes"); + } + } + + return new SliceStream(Stream, position, (long)size); + } + + private MemoryStream ReadAsMemoryStream(ulong size) + { + var memoryStream = new MemoryStream((int)size); + if (size == 0) return memoryStream; + + memoryStream.SetLength((long)size); + + var buffer = memoryStream.GetBuffer(); + while (size != 0) + { + var lengthToRead = size >= int.MaxValue ? int.MaxValue : (int)size; + var lengthRead = Stream.Read(buffer, 0, lengthToRead); + if (lengthRead < 0) break; + if ((uint)lengthRead >= size) + { + size -= (uint)lengthRead; + } + else + { + break; + } + } + + if (size != 0) + { + Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Expecting to read {size} bytes at offset {Stream.Position}"); + } + + return memoryStream; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs new file mode 100644 index 00000000000000..e35826d358560f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs @@ -0,0 +1,234 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.IO; +using System.Text; +using LibObjectFile.Utils; + +namespace LibObjectFile +{ + public static class ObjectFileStreamExtensions + { + public static byte ReadU8(this Stream stream) + { + int nextValue = stream.ReadByte(); + if (nextValue < 0) throw new EndOfStreamException(); + return (byte)nextValue; + } + + public static void WriteU8(this Stream stream, byte value) + { + stream.WriteByte(value); + } + + public static sbyte ReadI8(this Stream stream) + { + int nextValue = stream.ReadByte(); + if (nextValue < 0) throw new EndOfStreamException(); + return (sbyte)nextValue; + } + + public static void WriteI8(this Stream stream, sbyte value) + { + stream.WriteByte((byte)value); + } + + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// true if the string was successfully read from the stream, false otherwise + public static string ReadStringUTF8NullTerminated(this Stream stream) + { + var buffer = ArrayPool.Shared.Rent((int)128); + int textLength = 0; + try + { + while (true) + { + int nextByte = stream.ReadByte(); + if (nextByte < 0) + { + throw new EndOfStreamException("Unexpected end of stream while trying to read a null terminated UTF8 string"); + } + + if (nextByte == 0) + { + break; + } + + if (textLength > buffer.Length) + { + var newBuffer = ArrayPool.Shared.Rent((int)textLength * 2); + Array.Copy(buffer, 0, newBuffer, 0, buffer.Length); + ArrayPool.Shared.Return(buffer); + buffer = newBuffer; + } + + buffer[textLength++] = (byte)nextByte; + } + + return Encoding.UTF8.GetString(buffer, 0, textLength); + } + finally + { + ArrayPool.Shared.Return(buffer); + } + } + + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// The number of bytes to read including the null + /// A string + public static string ReadStringUTF8NullTerminated(this Stream stream, uint byteLength) + { + if (byteLength == 0) return string.Empty; + + var buffer = ArrayPool.Shared.Rent((int)byteLength); + try + { + var dataLength = stream.Read(buffer, 0, (int)byteLength); + if (dataLength < 0) throw new EndOfStreamException("Unexpected end of stream while trying to read data"); + + var byteReadLength = (uint)dataLength; + if (byteReadLength != byteLength) throw new EndOfStreamException($"Not enough data read {byteReadLength} bytes while expecting to read {byteLength} bytes"); + + var isNullTerminated = buffer[byteReadLength - 1] == 0; + + var text = Encoding.UTF8.GetString(buffer, 0, (int)(isNullTerminated ? byteReadLength - 1 : byteReadLength)); + return text; + } + finally + { + ArrayPool.Shared.Return(buffer); + } + } + + + public static short ReadI16(this Stream stream, bool isLittleEndian) + { + return (short) ReadU16(stream, isLittleEndian); + } + + public static ushort ReadU16(this Stream stream, bool isLittleEndian) + { + ushort value = 0; + int nextValue = stream.ReadByte(); + if (nextValue < 0) throw new EndOfStreamException(); + value = (byte)nextValue; + + nextValue = stream.ReadByte(); + if (nextValue < 0) throw new EndOfStreamException(); + value = (ushort)((nextValue << 8) | (byte)value); + + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + + return value; + } + + public static int ReadI32(this Stream stream, bool isLittleEndian) + { + return (int)ReadU32(stream, isLittleEndian); + } + + public static unsafe uint ReadU32(this Stream stream, bool isLittleEndian) + { + uint value = 0; + var span = new Span((byte*)&value, sizeof(uint)); + if (stream.Read(span) != sizeof(uint)) + { + throw new EndOfStreamException(); + } + + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + return value; + } + public static long ReadI64(this Stream stream, bool isLittleEndian) + { + return (long)ReadU64(stream, isLittleEndian); + } + + public static unsafe ulong ReadU64(this Stream stream, bool isLittleEndian) + { + ulong value = 0; + var span = new Span((byte*)&value, sizeof(ulong)); + if (stream.Read(span) != sizeof(ulong)) + { + throw new EndOfStreamException(); + } + + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + return value; + } + + public static unsafe void WriteU16(this Stream stream, bool isLittleEndian, ushort value) + { + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + var span = new Span((byte*)&value, sizeof(ushort)); + stream.Write(span); + } + + public static void WriteI32(this Stream stream, bool isLittleEndian, int value) + { + WriteU32(stream, isLittleEndian, (uint)value); + } + + public static unsafe void WriteU32(this Stream stream, bool isLittleEndian, uint value) + { + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + var span = new Span((byte*)&value, sizeof(uint)); + stream.Write(span); + } + + public static unsafe void WriteU64(this Stream stream, bool isLittleEndian, ulong value) + { + if (isLittleEndian != BitConverter.IsLittleEndian) + { + value = BinaryPrimitives.ReverseEndianness(value); + } + var span = new Span((byte*)&value, sizeof(ulong)); + stream.Write(span); + } + + /// + /// Writes a null terminated UTF8 string to the stream. + /// + public static void WriteStringUTF8NullTerminated(this Stream stream, string text) + { + if (text == null) throw new ArgumentNullException(nameof(text)); + + int byteLength = Encoding.UTF8.GetByteCount(text); + var buffer = ArrayPool.Shared.Rent(byteLength + 1); + try + { + Encoding.UTF8.GetBytes(text, 0, text.Length, buffer, 0); + buffer[byteLength] = 0; + stream.Write(buffer, 0, byteLength + 1); + } + finally + { + ArrayPool.Shared.Return(buffer); + } + } + + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs new file mode 100644 index 00000000000000..78cd8e593d244f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs @@ -0,0 +1,14 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + public enum RelocationSize + { + I8, + I16, + I32, + I64, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs new file mode 100644 index 00000000000000..e2daf539389b98 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs @@ -0,0 +1,41 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; + +namespace LibObjectFile.Utils +{ + /// + /// Helper class to perform alignment. + /// + public static class AlignHelper + { + /// + /// Returns true if alignment is a power of 2. + /// + /// The alignment + /// true if it is a power of 2. + public static bool IsPowerOfTwo(ulong align) + { + return (align & (align - 1)) == 0; + } + + /// + /// Aligns a value to the required alignment. + /// + /// The value to align. + /// The alignment. + /// The value aligned or unchanged it is was already aligned. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong AlignToUpper(ulong value, ulong align) + { + if (align == 0) throw new ArgumentOutOfRangeException(nameof(align), "Alignment must be > 0"); + if (!IsPowerOfTwo(align)) throw new ArgumentOutOfRangeException(nameof(align), "Alignment must be a power of 2"); + + var nextValue = ((value + align - 1) / align) * align; + return nextValue; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs new file mode 100644 index 00000000000000..c5c9765e3c0833 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs @@ -0,0 +1,148 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace LibObjectFile.Utils +{ + /// + /// Defines a stream as a slice of another existing stream. + /// + public class SliceStream : Stream + { + private Stream _baseStream; + private readonly long _length; + private readonly long _basePosition; + private long _localPosition; + + public SliceStream(Stream baseStream, long position, long length) + { + if (baseStream == null) throw new ArgumentNullException(nameof(baseStream)); + if (!baseStream.CanSeek) throw new ArgumentException("Invalid base stream that can't be seek."); + if (position < 0) throw new ArgumentOutOfRangeException(nameof(position)); + if (length < 0) throw new ArgumentOutOfRangeException(nameof(length)); + if (position + length > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(position), $"The position {position} + length {length} > baseStream.Length {baseStream.Length}"); + + _baseStream = baseStream; + _length = length; + _basePosition = position; + } + public override int Read(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + + long remaining = _length - _localPosition; + if (remaining <= 0) return 0; + if (remaining < count) count = (int)remaining; + + _baseStream.Position = _basePosition + _localPosition; + int read = _baseStream.Read(buffer, offset, count); + _localPosition += read; + + return read; + } + private void ThrowIfDisposed() + { + if (_baseStream == null) throw new ObjectDisposedException(GetType().Name); + } + public override long Length + { + get { ThrowIfDisposed(); return _length; } + } + public override bool CanRead + { + get { ThrowIfDisposed(); return _baseStream.CanRead; } + } + public override bool CanWrite + { + get { ThrowIfDisposed(); return _baseStream.CanWrite; } + } + public override bool CanSeek + { + get { ThrowIfDisposed(); return _baseStream.CanSeek; } + } + public override long Position + { + get + { + ThrowIfDisposed(); + return _localPosition; + } + set => Seek(value, SeekOrigin.Begin); + } + public override long Seek(long offset, SeekOrigin origin) + { + long newPosition = _localPosition; + switch (origin) + { + case SeekOrigin.Begin: + newPosition = offset; + break; + case SeekOrigin.Current: + newPosition += offset; + break; + case SeekOrigin.End: + newPosition = _length - offset; + break; + default: + throw new ArgumentOutOfRangeException(nameof(origin), origin, null); + } + + if (newPosition < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is < 0"); + if (newPosition > _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is > Length {_length}"); + + // Check that we can seek on the origin stream + _baseStream.Position = _basePosition + newPosition; + _localPosition = newPosition; + + return newPosition; + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Flush() + { + ThrowIfDisposed(); _baseStream.Flush(); + } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + if (_baseStream != null) + { + try + { + _baseStream.Dispose(); + } + catch + { + // ignored + } + _baseStream = null; + } + } + } + public override void Write(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); + if (count == 0) return; + + var isOverLength = _localPosition + count > Length; + var maxLength = isOverLength ? (int)(Length - _localPosition) : count; + _baseStream.Position = _basePosition + _localPosition; + _baseStream.Write(buffer, offset, maxLength); + _localPosition += maxLength; + if (isOverLength) + { + throw new InvalidOperationException("Cannot write outside of this stream slice"); + } + } + } +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs new file mode 100644 index 00000000000000..738239233fecef --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs @@ -0,0 +1,84 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.IO; +using System.Text; + +namespace LibObjectFile.Utils +{ + /// + /// Internal helper class for throwing exceptions. + /// + internal static class ThrowHelper + { + public static InvalidOperationException InvalidEnum(object v) + { + return new InvalidOperationException($"Invalid Enum {v.GetType()}.{v}"); + } + } + + public static class StreamExtensions + { + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// true if the string was successfully read from the stream, false otherwise + public static string ReadStringUTF8NullTerminated(this Stream stream) + { + if (!TryReadStringUTF8NullTerminated(stream, out var text)) + { + throw new EndOfStreamException(); + } + return text; + } + + /// + /// Reads a null terminated UTF8 string from the stream. + /// + /// true if the string was successfully read from the stream, false otherwise + public static bool TryReadStringUTF8NullTerminated(this Stream stream, out string text) + { + text = null; + var buffer = ArrayPool.Shared.Rent((int)128); + int textLength = 0; + try + { + while (true) + { + // TODO: not efficient to read byte by byte + int nextByte = stream.ReadByte(); + if (nextByte < 0) + { + return false; + } + + if (nextByte == 0) + { + break; + } + + if (textLength > buffer.Length) + { + var newBuffer = ArrayPool.Shared.Rent((int)textLength * 2); + Array.Copy(buffer, 0, newBuffer, 0, buffer.Length); + ArrayPool.Shared.Return(buffer); + buffer = newBuffer; + } + + buffer[textLength++] = (byte)nextByte; + } + + text = Encoding.UTF8.GetString(buffer, 0, textLength); + } + finally + { + ArrayPool.Shared.Return(buffer); + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs new file mode 100644 index 00000000000000..70aa41a73948ec --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs @@ -0,0 +1,22 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +namespace LibObjectFile +{ + /// + /// Defines the way a value is calculated. + /// + public enum ValueKind + { + /// + /// The associated value is automatically calculated by the system. + /// + Auto, + + /// + /// The associated value is set manually. + /// + Manual, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs new file mode 100644 index 00000000000000..cc065ac967cc0e --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs @@ -0,0 +1,15181 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; + +#pragma warning disable 1591 + +namespace LibObjectFile.Dwarf +{ + public static partial class DwarfNative + { + public const ushort DW_TAG_array_type = 1; + + public const ushort DW_TAG_class_type = 2; + + public const ushort DW_TAG_entry_point = 3; + + public const ushort DW_TAG_enumeration_type = 4; + + public const ushort DW_TAG_formal_parameter = 5; + + public const ushort DW_TAG_imported_declaration = 8; + + public const ushort DW_TAG_label = 10; + + public const ushort DW_TAG_lexical_block = 11; + + public const ushort DW_TAG_member = 13; + + public const ushort DW_TAG_pointer_type = 15; + + public const ushort DW_TAG_reference_type = 16; + + public const ushort DW_TAG_compile_unit = 17; + + public const ushort DW_TAG_string_type = 18; + + public const ushort DW_TAG_structure_type = 19; + + public const ushort DW_TAG_subroutine_type = 21; + + public const ushort DW_TAG_typedef = 22; + + public const ushort DW_TAG_union_type = 23; + + public const ushort DW_TAG_unspecified_parameters = 24; + + public const ushort DW_TAG_variant = 25; + + public const ushort DW_TAG_common_block = 26; + + public const ushort DW_TAG_common_inclusion = 27; + + public const ushort DW_TAG_inheritance = 28; + + public const ushort DW_TAG_inlined_subroutine = 29; + + public const ushort DW_TAG_module = 30; + + public const ushort DW_TAG_ptr_to_member_type = 31; + + public const ushort DW_TAG_set_type = 32; + + public const ushort DW_TAG_subrange_type = 33; + + public const ushort DW_TAG_with_stmt = 34; + + public const ushort DW_TAG_access_declaration = 35; + + public const ushort DW_TAG_base_type = 36; + + public const ushort DW_TAG_catch_block = 37; + + public const ushort DW_TAG_const_type = 38; + + public const ushort DW_TAG_constant = 39; + + public const ushort DW_TAG_enumerator = 40; + + public const ushort DW_TAG_file_type = 41; + + public const ushort DW_TAG_friend = 42; + + public const ushort DW_TAG_namelist = 43; + + /// + /// DWARF3/2 spelling + /// + public const ushort DW_TAG_namelist_item = 44; + + /// + /// SGI misspelling/typo + /// + public const ushort DW_TAG_namelist_items = 44; + + public const ushort DW_TAG_packed_type = 45; + + public const ushort DW_TAG_subprogram = 46; + + /// + /// DWARF3/2 spelling + /// + public const ushort DW_TAG_template_type_parameter = 47; + + /// + /// DWARF2 spelling + /// + public const ushort DW_TAG_template_type_param = 47; + + /// + /// DWARF3/2 spelling + /// + public const ushort DW_TAG_template_value_parameter = 48; + + /// + /// DWARF2 spelling + /// + public const ushort DW_TAG_template_value_param = 48; + + public const ushort DW_TAG_thrown_type = 49; + + public const ushort DW_TAG_try_block = 50; + + public const ushort DW_TAG_variant_part = 51; + + public const ushort DW_TAG_variable = 52; + + public const ushort DW_TAG_volatile_type = 53; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_dwarf_procedure = 54; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_restrict_type = 55; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_interface_type = 56; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_namespace = 57; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_imported_module = 58; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_unspecified_type = 59; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_partial_unit = 60; + + /// + /// DWARF3 + /// + public const ushort DW_TAG_imported_unit = 61; + + /// + /// Withdrawn from DWARF3 by DWARF3f. + /// + public const ushort DW_TAG_mutable_type = 62; + + /// + /// DWARF3f + /// + public const ushort DW_TAG_condition = 63; + + /// + /// DWARF3f + /// + public const ushort DW_TAG_shared_type = 64; + + /// + /// DWARF4 + /// + public const ushort DW_TAG_type_unit = 65; + + /// + /// DWARF4 + /// + public const ushort DW_TAG_rvalue_reference_type = 66; + + /// + /// DWARF4 + /// + public const ushort DW_TAG_template_alias = 67; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_coarray_type = 68; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_generic_subrange = 69; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_dynamic_type = 70; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_atomic_type = 71; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_call_site = 72; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_call_site_parameter = 73; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_skeleton_unit = 74; + + /// + /// DWARF5 + /// + public const ushort DW_TAG_immutable_type = 75; + + public const ushort DW_TAG_lo_user = 16512; + + public const ushort DW_TAG_MIPS_loop = 16513; + + /// + /// HP + /// + public const ushort DW_TAG_HP_array_descriptor = 16528; + + /// + /// GNU. Fortran. + /// + public const ushort DW_TAG_format_label = 16641; + + /// + /// GNU. For C++ + /// + public const ushort DW_TAG_function_template = 16642; + + /// + /// GNU. For C++ + /// + public const ushort DW_TAG_class_template = 16643; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_BINCL = 16644; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_EINCL = 16645; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_template_template_parameter = 16646; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_template_template_param = 16646; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_template_parameter_pack = 16647; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_formal_parameter_pack = 16648; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_call_site = 16649; + + /// + /// GNU + /// + public const ushort DW_TAG_GNU_call_site_parameter = 16650; + + /// + /// ALTIUM + /// + public const ushort DW_TAG_ALTIUM_circ_type = 20737; + + /// + /// ALTIUM + /// + public const ushort DW_TAG_ALTIUM_mwa_circ_type = 20738; + + /// + /// ALTIUM + /// + public const ushort DW_TAG_ALTIUM_rev_carry_type = 20739; + + /// + /// ALTIUM + /// + public const ushort DW_TAG_ALTIUM_rom = 20753; + + /// + /// UPC + /// + public const ushort DW_TAG_upc_shared_type = 34661; + + /// + /// UPC + /// + public const ushort DW_TAG_upc_strict_type = 34662; + + /// + /// UPC + /// + public const ushort DW_TAG_upc_relaxed_type = 34663; + + /// + /// PGI + /// + public const ushort DW_TAG_PGI_kanji_type = 40960; + + /// + /// PGI + /// + public const ushort DW_TAG_PGI_interface_block = 40992; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_function_template = 16897; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_class_template = 16898; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_struct_template = 16899; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_union_template = 16900; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_indirect_inheritance = 16901; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_codeflags = 16902; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_memop_info = 16903; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_omp_child_func = 16904; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_rtti_descriptor = 16905; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_dtor_info = 16906; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_dtor = 16907; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_f90_interface = 16908; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_fortran_vax_structure = 16909; + + /// + /// SUN + /// + public const ushort DW_TAG_SUN_hi = 17151; + + public const ushort DW_TAG_hi_user = 65535; + + public const ushort DW_FORM_addr = 1; + + public const ushort DW_FORM_block2 = 3; + + public const ushort DW_FORM_block4 = 4; + + public const ushort DW_FORM_data2 = 5; + + public const ushort DW_FORM_data4 = 6; + + public const ushort DW_FORM_data8 = 7; + + public const ushort DW_FORM_string = 8; + + public const ushort DW_FORM_block = 9; + + public const ushort DW_FORM_block1 = 10; + + public const ushort DW_FORM_data1 = 11; + + public const ushort DW_FORM_flag = 12; + + public const ushort DW_FORM_sdata = 13; + + public const ushort DW_FORM_strp = 14; + + public const ushort DW_FORM_udata = 15; + + public const ushort DW_FORM_ref_addr = 16; + + public const ushort DW_FORM_ref1 = 17; + + public const ushort DW_FORM_ref2 = 18; + + public const ushort DW_FORM_ref4 = 19; + + public const ushort DW_FORM_ref8 = 20; + + public const ushort DW_FORM_ref_udata = 21; + + public const ushort DW_FORM_indirect = 22; + + /// + /// DWARF4 + /// + public const ushort DW_FORM_sec_offset = 23; + + /// + /// DWARF4 + /// + public const ushort DW_FORM_exprloc = 24; + + /// + /// DWARF4 + /// + public const ushort DW_FORM_flag_present = 25; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strx = 26; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_addrx = 27; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_ref_sup4 = 28; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strp_sup = 29; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_data16 = 30; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_line_strp = 31; + + /// + /// DWARF4 + /// + public const ushort DW_FORM_ref_sig8 = 32; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_implicit_const = 33; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_loclistx = 34; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_rnglistx = 35; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_ref_sup8 = 36; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strx1 = 37; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strx2 = 38; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strx3 = 39; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_strx4 = 40; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_addrx1 = 41; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_addrx2 = 42; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_addrx3 = 43; + + /// + /// DWARF5 + /// + public const ushort DW_FORM_addrx4 = 44; + + /// + /// GNU extension in debug_info.dwo. + /// + public const ushort DW_FORM_GNU_addr_index = 7937; + + /// + /// GNU extension, somewhat like DW_FORM_strp + /// + public const ushort DW_FORM_GNU_str_index = 7938; + + /// + /// GNU extension. Offset in .debug_info. + /// + public const ushort DW_FORM_GNU_ref_alt = 7968; + + /// + /// GNU extension. Offset in .debug_str of another object file. + /// + public const ushort DW_FORM_GNU_strp_alt = 7969; + + public const ushort DW_AT_sibling = 1; + + public const ushort DW_AT_location = 2; + + public const ushort DW_AT_name = 3; + + public const ushort DW_AT_ordering = 9; + + public const ushort DW_AT_subscr_data = 10; + + public const ushort DW_AT_byte_size = 11; + + public const ushort DW_AT_bit_offset = 12; + + public const ushort DW_AT_bit_size = 13; + + public const ushort DW_AT_element_list = 15; + + public const ushort DW_AT_stmt_list = 16; + + public const ushort DW_AT_low_pc = 17; + + public const ushort DW_AT_high_pc = 18; + + public const ushort DW_AT_language = 19; + + public const ushort DW_AT_member = 20; + + public const ushort DW_AT_discr = 21; + + public const ushort DW_AT_discr_value = 22; + + public const ushort DW_AT_visibility = 23; + + public const ushort DW_AT_import = 24; + + public const ushort DW_AT_string_length = 25; + + public const ushort DW_AT_common_reference = 26; + + public const ushort DW_AT_comp_dir = 27; + + public const ushort DW_AT_const_value = 28; + + public const ushort DW_AT_containing_type = 29; + + public const ushort DW_AT_default_value = 30; + + public const ushort DW_AT_inline = 32; + + public const ushort DW_AT_is_optional = 33; + + public const ushort DW_AT_lower_bound = 34; + + public const ushort DW_AT_producer = 37; + + public const ushort DW_AT_prototyped = 39; + + public const ushort DW_AT_return_addr = 42; + + public const ushort DW_AT_start_scope = 44; + + /// + /// DWARF3 name + /// + public const ushort DW_AT_bit_stride = 46; + + /// + /// DWARF2 name + /// + public const ushort DW_AT_stride_size = 46; + + public const ushort DW_AT_upper_bound = 47; + + public const ushort DW_AT_abstract_origin = 49; + + public const ushort DW_AT_accessibility = 50; + + public const ushort DW_AT_address_class = 51; + + public const ushort DW_AT_artificial = 52; + + public const ushort DW_AT_base_types = 53; + + public const ushort DW_AT_calling_convention = 54; + + public const ushort DW_AT_count = 55; + + public const ushort DW_AT_data_member_location = 56; + + public const ushort DW_AT_decl_column = 57; + + public const ushort DW_AT_decl_file = 58; + + public const ushort DW_AT_decl_line = 59; + + public const ushort DW_AT_declaration = 60; + + /// + /// DWARF2 + /// + public const ushort DW_AT_discr_list = 61; + + public const ushort DW_AT_encoding = 62; + + public const ushort DW_AT_external = 63; + + public const ushort DW_AT_frame_base = 64; + + public const ushort DW_AT_friend = 65; + + public const ushort DW_AT_identifier_case = 66; + + /// + /// DWARF{234} not DWARF5 + /// + public const ushort DW_AT_macro_info = 67; + + public const ushort DW_AT_namelist_item = 68; + + public const ushort DW_AT_priority = 69; + + public const ushort DW_AT_segment = 70; + + public const ushort DW_AT_specification = 71; + + public const ushort DW_AT_static_link = 72; + + public const ushort DW_AT_type = 73; + + public const ushort DW_AT_use_location = 74; + + public const ushort DW_AT_variable_parameter = 75; + + public const ushort DW_AT_virtuality = 76; + + public const ushort DW_AT_vtable_elem_location = 77; + + /// + /// DWARF3 + /// + public const ushort DW_AT_allocated = 78; + + /// + /// DWARF3 + /// + public const ushort DW_AT_associated = 79; + + /// + /// DWARF3 + /// + public const ushort DW_AT_data_location = 80; + + /// + /// DWARF3f + /// + public const ushort DW_AT_byte_stride = 81; + + /// + /// DWARF3 (do not use) + /// + public const ushort DW_AT_stride = 81; + + /// + /// DWARF3 + /// + public const ushort DW_AT_entry_pc = 82; + + /// + /// DWARF3 + /// + public const ushort DW_AT_use_UTF8 = 83; + + /// + /// DWARF3 + /// + public const ushort DW_AT_extension = 84; + + /// + /// DWARF3 + /// + public const ushort DW_AT_ranges = 85; + + /// + /// DWARF3 + /// + public const ushort DW_AT_trampoline = 86; + + /// + /// DWARF3 + /// + public const ushort DW_AT_call_column = 87; + + /// + /// DWARF3 + /// + public const ushort DW_AT_call_file = 88; + + /// + /// DWARF3 + /// + public const ushort DW_AT_call_line = 89; + + /// + /// DWARF3 + /// + public const ushort DW_AT_description = 90; + + /// + /// DWARF3f + /// + public const ushort DW_AT_binary_scale = 91; + + /// + /// DWARF3f + /// + public const ushort DW_AT_decimal_scale = 92; + + /// + /// DWARF3f + /// + public const ushort DW_AT_small = 93; + + /// + /// DWARF3f + /// + public const ushort DW_AT_decimal_sign = 94; + + /// + /// DWARF3f + /// + public const ushort DW_AT_digit_count = 95; + + /// + /// DWARF3f + /// + public const ushort DW_AT_picture_string = 96; + + /// + /// DWARF3f + /// + public const ushort DW_AT_mutable = 97; + + /// + /// DWARF3f + /// + public const ushort DW_AT_threads_scaled = 98; + + /// + /// DWARF3f + /// + public const ushort DW_AT_explicit = 99; + + /// + /// DWARF3f + /// + public const ushort DW_AT_object_pointer = 100; + + /// + /// DWARF3f + /// + public const ushort DW_AT_endianity = 101; + + /// + /// DWARF3f + /// + public const ushort DW_AT_elemental = 102; + + /// + /// DWARF3f + /// + public const ushort DW_AT_pure = 103; + + /// + /// DWARF3f + /// + public const ushort DW_AT_recursive = 104; + + /// + /// DWARF4 + /// + public const ushort DW_AT_signature = 105; + + /// + /// DWARF4 + /// + public const ushort DW_AT_main_subprogram = 106; + + /// + /// DWARF4 + /// + public const ushort DW_AT_data_bit_offset = 107; + + /// + /// DWARF4 + /// + public const ushort DW_AT_const_expr = 108; + + /// + /// DWARF4 + /// + public const ushort DW_AT_enum_class = 109; + + /// + /// DWARF4 + /// + public const ushort DW_AT_linkage_name = 110; + + /// + /// DWARF5 + /// + public const ushort DW_AT_string_length_bit_size = 111; + + /// + /// DWARF5 + /// + public const ushort DW_AT_string_length_byte_size = 112; + + /// + /// DWARF5 + /// + public const ushort DW_AT_rank = 113; + + /// + /// DWARF5 + /// + public const ushort DW_AT_str_offsets_base = 114; + + /// + /// DWARF5 + /// + public const ushort DW_AT_addr_base = 115; + + /// + /// DWARF5 + /// + public const ushort DW_AT_rnglists_base = 116; + + /// + /// DWARF4! + /// + public const ushort DW_AT_dwo_id = 117; + + /// + /// DWARF5 + /// + public const ushort DW_AT_dwo_name = 118; + + /// + /// DWARF5 + /// + public const ushort DW_AT_reference = 119; + + /// + /// DWARF5 + /// + public const ushort DW_AT_rvalue_reference = 120; + + /// + /// DWARF5 + /// + public const ushort DW_AT_macros = 121; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_all_calls = 122; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_all_source_calls = 123; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_all_tail_calls = 124; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_return_pc = 125; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_value = 126; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_origin = 127; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_parameter = 128; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_pc = 129; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_tail_call = 130; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_target = 131; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_target_clobbered = 132; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_data_location = 133; + + /// + /// DWARF5 + /// + public const ushort DW_AT_call_data_value = 134; + + /// + /// DWARF5 + /// + public const ushort DW_AT_noreturn = 135; + + /// + /// DWARF5 + /// + public const ushort DW_AT_alignment = 136; + + /// + /// DWARF5 + /// + public const ushort DW_AT_export_symbols = 137; + + /// + /// DWARF5 + /// + public const ushort DW_AT_deleted = 138; + + /// + /// DWARF5 + /// + public const ushort DW_AT_defaulted = 139; + + /// + /// DWARF5 + /// + public const ushort DW_AT_loclists_base = 140; + + /// + /// HP + /// + public const ushort DW_AT_HP_block_index = 8192; + + public const ushort DW_AT_lo_user = 8192; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_fde = 8193; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_loop_begin = 8194; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_tail_loop_begin = 8195; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_epilog_begin = 8196; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_loop_unroll_factor = 8197; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_software_pipeline_depth = 8198; + + /// + /// MIPS/SGI, GNU, and others. + /// + public const ushort DW_AT_MIPS_linkage_name = 8199; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_stride = 8200; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_abstract_name = 8201; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_clone_origin = 8202; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_has_inlines = 8203; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_stride_byte = 8204; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_stride_elem = 8205; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_ptr_dopetype = 8206; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_allocatable_dopetype = 8207; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_assumed_shape_dopetype = 8208; + + /// + /// MIPS/SGI + /// + public const ushort DW_AT_MIPS_assumed_size = 8209; + + /// + /// conflict: MIPS + /// + public const ushort DW_AT_HP_unmodifiable = 8193; + + /// + /// conflict: MIPS + /// + public const ushort DW_AT_HP_actuals_stmt_list = 8208; + + /// + /// conflict: MIPS + /// + public const ushort DW_AT_HP_proc_per_section = 8209; + + /// + /// HP + /// + public const ushort DW_AT_HP_raw_data_ptr = 8210; + + /// + /// HP + /// + public const ushort DW_AT_HP_pass_by_reference = 8211; + + /// + /// HP + /// + public const ushort DW_AT_HP_opt_level = 8212; + + /// + /// HP + /// + public const ushort DW_AT_HP_prof_version_id = 8213; + + /// + /// HP + /// + public const ushort DW_AT_HP_opt_flags = 8214; + + /// + /// HP + /// + public const ushort DW_AT_HP_cold_region_low_pc = 8215; + + /// + /// HP + /// + public const ushort DW_AT_HP_cold_region_high_pc = 8216; + + /// + /// HP + /// + public const ushort DW_AT_HP_all_variables_modifiable = 8217; + + /// + /// HP + /// + public const ushort DW_AT_HP_linkage_name = 8218; + + /// + /// HP + /// + public const ushort DW_AT_HP_prof_flags = 8219; + + /// + /// COMPAQ/HP + /// + public const ushort DW_AT_CPQ_discontig_ranges = 8193; + + /// + /// COMPAQ/HP + /// + public const ushort DW_AT_CPQ_semantic_events = 8194; + + /// + /// COMPAQ/HP + /// + public const ushort DW_AT_CPQ_split_lifetimes_var = 8195; + + /// + /// COMPAQ/HP + /// + public const ushort DW_AT_CPQ_split_lifetimes_rtn = 8196; + + /// + /// COMPAQ/HP + /// + public const ushort DW_AT_CPQ_prologue_length = 8197; + + /// + /// Intel, 1 if byte swapped. + /// + public const ushort DW_AT_INTEL_other_endian = 8230; + + /// + /// GNU + /// + public const ushort DW_AT_sf_names = 8449; + + /// + /// GNU + /// + public const ushort DW_AT_src_info = 8450; + + /// + /// GNU + /// + public const ushort DW_AT_mac_info = 8451; + + /// + /// GNU + /// + public const ushort DW_AT_src_coords = 8452; + + /// + /// GNU + /// + public const ushort DW_AT_body_begin = 8453; + + /// + /// GNU + /// + public const ushort DW_AT_body_end = 8454; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_vector = 8455; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_guarded_by = 8456; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_pt_guarded_by = 8457; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_guarded = 8458; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_pt_guarded = 8459; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_locks_excluded = 8460; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_exclusive_locks_required = 8461; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_shared_locks_required = 8462; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_odr_signature = 8463; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_template_name = 8464; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_call_site_value = 8465; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_call_site_data_value = 8466; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_call_site_target = 8467; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_call_site_target_clobbered = 8468; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_tail_call = 8469; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_all_tail_call_sites = 8470; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_all_call_sites = 8471; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_all_source_call_sites = 8472; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_macros = 8473; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_dwo_name = 8496; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_dwo_id = 8497; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_ranges_base = 8498; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_addr_base = 8499; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_pubnames = 8500; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_pubtypes = 8501; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_discriminator = 8502; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_numerator = 8963; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_denominator = 8964; + + /// + /// GNU + /// + public const ushort DW_AT_GNU_bias = 8965; + + /// + /// ALTIUM + /// + public const ushort DW_AT_ALTIUM_loclist = 8960; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_template = 8705; + + /// + /// VMS + /// + public const ushort DW_AT_VMS_rtnbeg_pd_address = 8705; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_alignment = 8706; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_vtable = 8707; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_count_guarantee = 8708; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_command_line = 8709; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_vbase = 8710; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_compile_options = 8711; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_language = 8712; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_browser_file = 8713; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_vtable_abi = 8720; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_func_offsets = 8721; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_cf_kind = 8722; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_vtable_index = 8723; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_omp_tpriv_addr = 8724; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_omp_child_func = 8725; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_func_offset = 8726; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_memop_type_ref = 8727; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_profile_id = 8728; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_memop_signature = 8729; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_obj_dir = 8736; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_obj_file = 8737; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_original_name = 8738; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_hwcprof_signature = 8739; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_amd64_parmdump = 8740; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_part_link_name = 8741; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_link_name = 8742; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_pass_with_const = 8743; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_return_with_const = 8744; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_import_by_name = 8745; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_f90_pointer = 8746; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_pass_by_ref = 8747; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_f90_allocatable = 8748; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_f90_assumed_shape_array = 8749; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_c_vla = 8750; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_return_value_ptr = 8752; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_dtor_start = 8753; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_dtor_length = 8754; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_dtor_state_initial = 8755; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_dtor_state_final = 8756; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_dtor_state_deltas = 8757; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_import_by_lname = 8758; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_f90_use_only = 8759; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_namelist_spec = 8760; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_is_omp_child_func = 8761; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_fortran_main_alias = 8762; + + /// + /// SUN + /// + public const ushort DW_AT_SUN_fortran_based = 8763; + + /// + /// GNAT + /// + public const ushort DW_AT_use_GNAT_descriptive_type = 8961; + + /// + /// GNAT + /// + public const ushort DW_AT_GNAT_descriptive_type = 8962; + + /// + /// UPC + /// + public const ushort DW_AT_upc_threads_scaled = 12816; + + /// + /// PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. + /// + public const ushort DW_AT_PGI_lbase = 14848; + + /// + /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. + /// + public const ushort DW_AT_PGI_soffset = 14849; + + /// + /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. + /// + public const ushort DW_AT_PGI_lstride = 14850; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_optimized = 16353; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_flags = 16354; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_isa = 16355; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_block = 16356; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_major_runtime_vers = 16357; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_runtime_class = 16358; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_omit_frame_ptr = 16359; + + /// + /// Apple + /// + public const ushort DW_AT_APPLE_closure = 16356; + + public const ushort DW_AT_hi_user = 16383; + + public const byte DW_OP_addr = 3; + + public const byte DW_OP_deref = 6; + + public const byte DW_OP_const1u = 8; + + public const byte DW_OP_const1s = 9; + + public const byte DW_OP_const2u = 10; + + public const byte DW_OP_const2s = 11; + + public const byte DW_OP_const4u = 12; + + public const byte DW_OP_const4s = 13; + + public const byte DW_OP_const8u = 14; + + public const byte DW_OP_const8s = 15; + + public const byte DW_OP_constu = 16; + + public const byte DW_OP_consts = 17; + + public const byte DW_OP_dup = 18; + + public const byte DW_OP_drop = 19; + + public const byte DW_OP_over = 20; + + public const byte DW_OP_pick = 21; + + public const byte DW_OP_swap = 22; + + public const byte DW_OP_rot = 23; + + public const byte DW_OP_xderef = 24; + + public const byte DW_OP_abs = 25; + + public const byte DW_OP_and = 26; + + public const byte DW_OP_div = 27; + + public const byte DW_OP_minus = 28; + + public const byte DW_OP_mod = 29; + + public const byte DW_OP_mul = 30; + + public const byte DW_OP_neg = 31; + + public const byte DW_OP_not = 32; + + public const byte DW_OP_or = 33; + + public const byte DW_OP_plus = 34; + + public const byte DW_OP_plus_uconst = 35; + + public const byte DW_OP_shl = 36; + + public const byte DW_OP_shr = 37; + + public const byte DW_OP_shra = 38; + + public const byte DW_OP_xor = 39; + + public const byte DW_OP_bra = 40; + + public const byte DW_OP_eq = 41; + + public const byte DW_OP_ge = 42; + + public const byte DW_OP_gt = 43; + + public const byte DW_OP_le = 44; + + public const byte DW_OP_lt = 45; + + public const byte DW_OP_ne = 46; + + public const byte DW_OP_skip = 47; + + public const byte DW_OP_lit0 = 48; + + public const byte DW_OP_lit1 = 49; + + public const byte DW_OP_lit2 = 50; + + public const byte DW_OP_lit3 = 51; + + public const byte DW_OP_lit4 = 52; + + public const byte DW_OP_lit5 = 53; + + public const byte DW_OP_lit6 = 54; + + public const byte DW_OP_lit7 = 55; + + public const byte DW_OP_lit8 = 56; + + public const byte DW_OP_lit9 = 57; + + public const byte DW_OP_lit10 = 58; + + public const byte DW_OP_lit11 = 59; + + public const byte DW_OP_lit12 = 60; + + public const byte DW_OP_lit13 = 61; + + public const byte DW_OP_lit14 = 62; + + public const byte DW_OP_lit15 = 63; + + public const byte DW_OP_lit16 = 64; + + public const byte DW_OP_lit17 = 65; + + public const byte DW_OP_lit18 = 66; + + public const byte DW_OP_lit19 = 67; + + public const byte DW_OP_lit20 = 68; + + public const byte DW_OP_lit21 = 69; + + public const byte DW_OP_lit22 = 70; + + public const byte DW_OP_lit23 = 71; + + public const byte DW_OP_lit24 = 72; + + public const byte DW_OP_lit25 = 73; + + public const byte DW_OP_lit26 = 74; + + public const byte DW_OP_lit27 = 75; + + public const byte DW_OP_lit28 = 76; + + public const byte DW_OP_lit29 = 77; + + public const byte DW_OP_lit30 = 78; + + public const byte DW_OP_lit31 = 79; + + public const byte DW_OP_reg0 = 80; + + public const byte DW_OP_reg1 = 81; + + public const byte DW_OP_reg2 = 82; + + public const byte DW_OP_reg3 = 83; + + public const byte DW_OP_reg4 = 84; + + public const byte DW_OP_reg5 = 85; + + public const byte DW_OP_reg6 = 86; + + public const byte DW_OP_reg7 = 87; + + public const byte DW_OP_reg8 = 88; + + public const byte DW_OP_reg9 = 89; + + public const byte DW_OP_reg10 = 90; + + public const byte DW_OP_reg11 = 91; + + public const byte DW_OP_reg12 = 92; + + public const byte DW_OP_reg13 = 93; + + public const byte DW_OP_reg14 = 94; + + public const byte DW_OP_reg15 = 95; + + public const byte DW_OP_reg16 = 96; + + public const byte DW_OP_reg17 = 97; + + public const byte DW_OP_reg18 = 98; + + public const byte DW_OP_reg19 = 99; + + public const byte DW_OP_reg20 = 100; + + public const byte DW_OP_reg21 = 101; + + public const byte DW_OP_reg22 = 102; + + public const byte DW_OP_reg23 = 103; + + public const byte DW_OP_reg24 = 104; + + public const byte DW_OP_reg25 = 105; + + public const byte DW_OP_reg26 = 106; + + public const byte DW_OP_reg27 = 107; + + public const byte DW_OP_reg28 = 108; + + public const byte DW_OP_reg29 = 109; + + public const byte DW_OP_reg30 = 110; + + public const byte DW_OP_reg31 = 111; + + public const byte DW_OP_breg0 = 112; + + public const byte DW_OP_breg1 = 113; + + public const byte DW_OP_breg2 = 114; + + public const byte DW_OP_breg3 = 115; + + public const byte DW_OP_breg4 = 116; + + public const byte DW_OP_breg5 = 117; + + public const byte DW_OP_breg6 = 118; + + public const byte DW_OP_breg7 = 119; + + public const byte DW_OP_breg8 = 120; + + public const byte DW_OP_breg9 = 121; + + public const byte DW_OP_breg10 = 122; + + public const byte DW_OP_breg11 = 123; + + public const byte DW_OP_breg12 = 124; + + public const byte DW_OP_breg13 = 125; + + public const byte DW_OP_breg14 = 126; + + public const byte DW_OP_breg15 = 127; + + public const byte DW_OP_breg16 = 128; + + public const byte DW_OP_breg17 = 129; + + public const byte DW_OP_breg18 = 130; + + public const byte DW_OP_breg19 = 131; + + public const byte DW_OP_breg20 = 132; + + public const byte DW_OP_breg21 = 133; + + public const byte DW_OP_breg22 = 134; + + public const byte DW_OP_breg23 = 135; + + public const byte DW_OP_breg24 = 136; + + public const byte DW_OP_breg25 = 137; + + public const byte DW_OP_breg26 = 138; + + public const byte DW_OP_breg27 = 139; + + public const byte DW_OP_breg28 = 140; + + public const byte DW_OP_breg29 = 141; + + public const byte DW_OP_breg30 = 142; + + public const byte DW_OP_breg31 = 143; + + public const byte DW_OP_regx = 144; + + public const byte DW_OP_fbreg = 145; + + public const byte DW_OP_bregx = 146; + + public const byte DW_OP_piece = 147; + + public const byte DW_OP_deref_size = 148; + + public const byte DW_OP_xderef_size = 149; + + public const byte DW_OP_nop = 150; + + /// + /// DWARF3 + /// + public const byte DW_OP_push_object_address = 151; + + /// + /// DWARF3 + /// + public const byte DW_OP_call2 = 152; + + /// + /// DWARF3 + /// + public const byte DW_OP_call4 = 153; + + /// + /// DWARF3 + /// + public const byte DW_OP_call_ref = 154; + + /// + /// DWARF3f + /// + public const byte DW_OP_form_tls_address = 155; + + /// + /// DWARF3f + /// + public const byte DW_OP_call_frame_cfa = 156; + + /// + /// DWARF3f + /// + public const byte DW_OP_bit_piece = 157; + + /// + /// DWARF4 + /// + public const byte DW_OP_implicit_value = 158; + + /// + /// DWARF4 + /// + public const byte DW_OP_stack_value = 159; + + /// + /// DWARF5 + /// + public const byte DW_OP_implicit_pointer = 160; + + /// + /// DWARF5 + /// + public const byte DW_OP_addrx = 161; + + /// + /// DWARF5 + /// + public const byte DW_OP_constx = 162; + + /// + /// DWARF5 + /// + public const byte DW_OP_entry_value = 163; + + /// + /// DWARF5 + /// + public const byte DW_OP_const_type = 164; + + /// + /// DWARF5 + /// + public const byte DW_OP_regval_type = 165; + + /// + /// DWARF5 + /// + public const byte DW_OP_deref_type = 166; + + /// + /// DWARF5 + /// + public const byte DW_OP_xderef_type = 167; + + /// + /// DWARF5 + /// + public const byte DW_OP_convert = 168; + + /// + /// DWARF5 + /// + public const byte DW_OP_reinterpret = 169; + + /// + /// GNU + /// + public const byte DW_OP_GNU_push_tls_address = 224; + + public const byte DW_OP_lo_user = 224; + + /// + /// GNU + /// + public const byte DW_OP_GNU_uninit = 240; + + /// + /// GNU + /// + public const byte DW_OP_GNU_encoded_addr = 241; + + /// + /// GNU + /// + public const byte DW_OP_GNU_implicit_pointer = 242; + + /// + /// GNU + /// + public const byte DW_OP_GNU_entry_value = 243; + + /// + /// GNU + /// + public const byte DW_OP_GNU_const_type = 244; + + /// + /// GNU + /// + public const byte DW_OP_GNU_regval_type = 245; + + /// + /// GNU + /// + public const byte DW_OP_GNU_deref_type = 246; + + /// + /// GNU + /// + public const byte DW_OP_GNU_convert = 247; + + /// + /// GNU + /// + public const byte DW_OP_GNU_reinterpret = 249; + + /// + /// GNU + /// + public const byte DW_OP_GNU_parameter_ref = 250; + + /// + /// GNU DebugFission + /// + public const byte DW_OP_GNU_addr_index = 251; + + /// + /// GNU DebugFission + /// + public const byte DW_OP_GNU_const_index = 252; + + /// + /// HP conflict: GNU + /// + public const byte DW_OP_HP_unknown = 224; + + /// + /// HP + /// + public const byte DW_OP_HP_is_value = 225; + + /// + /// HP + /// + public const byte DW_OP_HP_fltconst4 = 226; + + /// + /// HP + /// + public const byte DW_OP_HP_fltconst8 = 227; + + /// + /// HP + /// + public const byte DW_OP_HP_mod_range = 228; + + /// + /// HP + /// + public const byte DW_OP_HP_unmod_range = 229; + + /// + /// HP + /// + public const byte DW_OP_HP_tls = 230; + + /// + /// Intel: made obsolete by DW_OP_bit_piece above. + /// + public const byte DW_OP_INTEL_bit_piece = 232; + + /// + /// Apple + /// + public const byte DW_OP_APPLE_uninit = 240; + + /// + /// PGI (STMicroelectronics) + /// + public const byte DW_OP_PGI_omp_thread_num = 248; + + public const byte DW_OP_hi_user = 255; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_compile_unit = 1; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_type_unit = 2; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_die_offset = 3; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_parent = 4; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_type_hash = 5; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_lo_user = 8192; + + /// + /// DWARF5 + /// + public const ushort DW_IDX_hi_user = 4095; + + /// + /// DWARF5 + /// + public const byte DW_UT_compile = 1; + + /// + /// DWARF5 + /// + public const byte DW_UT_type = 2; + + /// + /// DWARF5 + /// + public const byte DW_UT_partial = 3; + + /// + /// DWARF5 + /// + public const byte DW_UT_skeleton = 4; + + /// + /// DWARF5 + /// + public const byte DW_UT_split_compile = 5; + + /// + /// DWARF5 + /// + public const byte DW_UT_split_type = 6; + + /// + /// DWARF5 + /// + public const byte DW_UT_lo_user = 128; + + /// + /// DWARF5 + /// + public const byte DW_UT_hi_user = 255; + + public const byte DW_ACCESS_public = 1; + + public const byte DW_ACCESS_protected = 2; + + public const byte DW_ACCESS_private = 3; + + public const byte DW_VIS_local = 1; + + public const byte DW_VIS_exported = 2; + + public const byte DW_VIS_qualified = 3; + + public const byte DW_VIRTUALITY_none = 0; + + public const byte DW_VIRTUALITY_virtual = 1; + + public const byte DW_VIRTUALITY_pure_virtual = 2; + + public const ushort DW_LANG_C89 = 1; + + public const ushort DW_LANG_C = 2; + + public const ushort DW_LANG_Ada83 = 3; + + public const ushort DW_LANG_C_plus_plus = 4; + + public const ushort DW_LANG_Cobol74 = 5; + + public const ushort DW_LANG_Cobol85 = 6; + + public const ushort DW_LANG_Fortran77 = 7; + + public const ushort DW_LANG_Fortran90 = 8; + + public const ushort DW_LANG_Pascal83 = 9; + + public const ushort DW_LANG_Modula2 = 10; + + /// + /// DWARF3 + /// + public const ushort DW_LANG_Java = 11; + + /// + /// DWARF3 + /// + public const ushort DW_LANG_C99 = 12; + + /// + /// DWARF3 + /// + public const ushort DW_LANG_Ada95 = 13; + + /// + /// DWARF3 + /// + public const ushort DW_LANG_Fortran95 = 14; + + /// + /// DWARF3 + /// + public const ushort DW_LANG_PLI = 15; + + /// + /// DWARF3f + /// + public const ushort DW_LANG_ObjC = 16; + + /// + /// DWARF3f + /// + public const ushort DW_LANG_ObjC_plus_plus = 17; + + /// + /// DWARF3f + /// + public const ushort DW_LANG_UPC = 18; + + /// + /// DWARF3f + /// + public const ushort DW_LANG_D = 19; + + /// + /// DWARF4 + /// + public const ushort DW_LANG_Python = 20; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_OpenCL = 21; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Go = 22; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Modula3 = 23; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Haskel = 24; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_C_plus_plus_03 = 25; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_C_plus_plus_11 = 26; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_OCaml = 27; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Rust = 28; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_C11 = 29; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Swift = 30; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Julia = 31; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Dylan = 32; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_C_plus_plus_14 = 33; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Fortran03 = 34; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_Fortran08 = 35; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_RenderScript = 36; + + /// + /// DWARF5 + /// + public const ushort DW_LANG_BLISS = 37; + + public const ushort DW_LANG_lo_user = 32768; + + /// + /// MIPS + /// + public const ushort DW_LANG_Mips_Assembler = 32769; + + /// + /// UPC, use + /// DW_LANG_UPC instead. + /// + public const ushort DW_LANG_Upc = 34661; + + /// + /// ALTIUM + /// + public const ushort DW_LANG_ALTIUM_Assembler = 37121; + + /// + /// SUN + /// + public const ushort DW_LANG_SUN_Assembler = 36865; + + public const ushort DW_LANG_hi_user = 65535; + + public const byte DW_ID_case_sensitive = 0; + + public const byte DW_ID_up_case = 1; + + public const byte DW_ID_down_case = 2; + + public const byte DW_ID_case_insensitive = 3; + + public const byte DW_CC_normal = 1; + + public const byte DW_CC_program = 2; + + public const byte DW_CC_nocall = 3; + + /// + /// DWARF5 + /// + public const byte DW_CC_pass_by_reference = 4; + + /// + /// DWARF5 + /// + public const byte DW_CC_pass_by_value = 5; + + public const byte DW_CC_lo_user = 64; + + /// + /// GNU + /// + public const byte DW_CC_GNU_renesas_sh = 64; + + /// + /// GNU + /// + public const byte DW_CC_GNU_borland_fastcall_i386 = 65; + + /// + /// ALTIUM + /// + public const byte DW_CC_ALTIUM_interrupt = 101; + + /// + /// ALTIUM + /// + public const byte DW_CC_ALTIUM_near_system_stack = 102; + + /// + /// ALTIUM + /// + public const byte DW_CC_ALTIUM_near_user_stack = 103; + + /// + /// ALTIUM + /// + public const byte DW_CC_ALTIUM_huge_user_stack = 104; + + public const byte DW_CC_hi_user = 255; + + public const byte DW_INL_not_inlined = 0; + + public const byte DW_INL_inlined = 1; + + public const byte DW_INL_declared_not_inlined = 2; + + public const byte DW_INL_declared_inlined = 3; + + public const byte DW_ORD_row_major = 0; + + public const byte DW_ORD_col_major = 1; + + public const byte DW_DSC_label = 0; + + public const byte DW_DSC_range = 1; + + public const byte DW_LNS_copy = 1; + + public const byte DW_LNS_advance_pc = 2; + + public const byte DW_LNS_advance_line = 3; + + public const byte DW_LNS_set_file = 4; + + public const byte DW_LNS_set_column = 5; + + public const byte DW_LNS_negate_stmt = 6; + + public const byte DW_LNS_set_basic_block = 7; + + public const byte DW_LNS_const_add_pc = 8; + + public const byte DW_LNS_fixed_advance_pc = 9; + + /// + /// DWARF3 + /// + public const byte DW_LNS_set_prologue_end = 10; + + /// + /// DWARF3 + /// + public const byte DW_LNS_set_epilogue_begin = 11; + + /// + /// DWARF3 + /// + public const byte DW_LNS_set_isa = 12; + + /// + /// Actuals table only + /// + public const byte DW_LNS_set_address_from_logical = 13; + + /// + /// Logicals table only + /// + public const byte DW_LNS_set_subprogram = 13; + + /// + /// Logicals table only + /// + public const byte DW_LNS_inlined_call = 14; + + /// + /// Logicals table only + /// + public const byte DW_LNS_pop_context = 15; + + public const byte DW_LNE_end_sequence = 1; + + public const byte DW_LNE_set_address = 2; + + /// + /// DWARF4 and earlier only + /// + public const byte DW_LNE_define_file = 3; + + /// + /// DWARF4 + /// + public const byte DW_LNE_set_discriminator = 4; + + /// + /// 17 HP + /// + public const byte DW_LNE_HP_negate_is_UV_update = 17; + + /// + /// 18 HP + /// + public const byte DW_LNE_HP_push_context = 18; + + /// + /// 19 HP + /// + public const byte DW_LNE_HP_pop_context = 19; + + /// + /// 20 HP + /// + public const byte DW_LNE_HP_set_file_line_column = 20; + + /// + /// 21 HP + /// + public const byte DW_LNE_HP_set_routine_name = 21; + + /// + /// 22 HP + /// + public const byte DW_LNE_HP_set_sequence = 22; + + /// + /// 23 HP + /// + public const byte DW_LNE_HP_negate_post_semantics = 23; + + /// + /// 24 HP + /// + public const byte DW_LNE_HP_negate_function_exit = 24; + + /// + /// 25 HP + /// + public const byte DW_LNE_HP_negate_front_end_logical = 25; + + /// + /// 32 HP + /// + public const byte DW_LNE_HP_define_proc = 32; + + /// + /// HP + /// + public const byte DW_LNE_HP_source_file_correlation = 128; + + /// + /// DWARF3 + /// + public const byte DW_LNE_lo_user = 128; + + /// + /// DWARF3 + /// + public const byte DW_LNE_hi_user = 255; + + public const byte DW_ISA_UNKNOWN = 0; + + /// + /// ARM ISA + /// + public const byte DW_ISA_ARM_thumb = 1; + + /// + /// ARM ISA + /// + public const byte DW_ISA_ARM_arm = 2; + + public const byte DW_CHILDREN_no = 0; + + public const byte DW_CHILDREN_yes = 1; + } + + public readonly partial struct DwarfAttributeKindEx + { + public static readonly DwarfAttributeKindEx Sibling = new DwarfAttributeKindEx(DwarfNative.DW_AT_sibling); + + public static readonly DwarfAttributeKindEx Location = new DwarfAttributeKindEx(DwarfNative.DW_AT_location); + + public static readonly DwarfAttributeKindEx Name = new DwarfAttributeKindEx(DwarfNative.DW_AT_name); + + public static readonly DwarfAttributeKindEx Ordering = new DwarfAttributeKindEx(DwarfNative.DW_AT_ordering); + + public static readonly DwarfAttributeKindEx SubscrData = new DwarfAttributeKindEx(DwarfNative.DW_AT_subscr_data); + + public static readonly DwarfAttributeKindEx ByteSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_byte_size); + + public static readonly DwarfAttributeKindEx BitOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_offset); + + public static readonly DwarfAttributeKindEx BitSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_size); + + public static readonly DwarfAttributeKindEx ElementList = new DwarfAttributeKindEx(DwarfNative.DW_AT_element_list); + + public static readonly DwarfAttributeKindEx StmtList = new DwarfAttributeKindEx(DwarfNative.DW_AT_stmt_list); + + public static readonly DwarfAttributeKindEx LowPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_low_pc); + + public static readonly DwarfAttributeKindEx HighPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_high_pc); + + public static readonly DwarfAttributeKindEx Language = new DwarfAttributeKindEx(DwarfNative.DW_AT_language); + + public static readonly DwarfAttributeKindEx Member = new DwarfAttributeKindEx(DwarfNative.DW_AT_member); + + public static readonly DwarfAttributeKindEx Discr = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr); + + public static readonly DwarfAttributeKindEx DiscrValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr_value); + + public static readonly DwarfAttributeKindEx Visibility = new DwarfAttributeKindEx(DwarfNative.DW_AT_visibility); + + public static readonly DwarfAttributeKindEx Import = new DwarfAttributeKindEx(DwarfNative.DW_AT_import); + + public static readonly DwarfAttributeKindEx StringLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length); + + public static readonly DwarfAttributeKindEx CommonReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_common_reference); + + public static readonly DwarfAttributeKindEx CompDir = new DwarfAttributeKindEx(DwarfNative.DW_AT_comp_dir); + + public static readonly DwarfAttributeKindEx ConstValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_const_value); + + public static readonly DwarfAttributeKindEx ContainingType = new DwarfAttributeKindEx(DwarfNative.DW_AT_containing_type); + + public static readonly DwarfAttributeKindEx DefaultValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_default_value); + + public static readonly DwarfAttributeKindEx Inline = new DwarfAttributeKindEx(DwarfNative.DW_AT_inline); + + public static readonly DwarfAttributeKindEx IsOptional = new DwarfAttributeKindEx(DwarfNative.DW_AT_is_optional); + + public static readonly DwarfAttributeKindEx LowerBound = new DwarfAttributeKindEx(DwarfNative.DW_AT_lower_bound); + + public static readonly DwarfAttributeKindEx Producer = new DwarfAttributeKindEx(DwarfNative.DW_AT_producer); + + public static readonly DwarfAttributeKindEx Prototyped = new DwarfAttributeKindEx(DwarfNative.DW_AT_prototyped); + + public static readonly DwarfAttributeKindEx ReturnAddr = new DwarfAttributeKindEx(DwarfNative.DW_AT_return_addr); + + public static readonly DwarfAttributeKindEx StartScope = new DwarfAttributeKindEx(DwarfNative.DW_AT_start_scope); + + /// + /// DWARF3 name + /// + public static readonly DwarfAttributeKindEx BitStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_stride); + + /// + /// DWARF2 name + /// + public static readonly DwarfAttributeKindEx StrideSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_stride_size); + + public static readonly DwarfAttributeKindEx UpperBound = new DwarfAttributeKindEx(DwarfNative.DW_AT_upper_bound); + + public static readonly DwarfAttributeKindEx AbstractOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_abstract_origin); + + public static readonly DwarfAttributeKindEx Accessibility = new DwarfAttributeKindEx(DwarfNative.DW_AT_accessibility); + + public static readonly DwarfAttributeKindEx AddressClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_address_class); + + public static readonly DwarfAttributeKindEx Artificial = new DwarfAttributeKindEx(DwarfNative.DW_AT_artificial); + + public static readonly DwarfAttributeKindEx BaseTypes = new DwarfAttributeKindEx(DwarfNative.DW_AT_base_types); + + public static readonly DwarfAttributeKindEx CallingConvention = new DwarfAttributeKindEx(DwarfNative.DW_AT_calling_convention); + + public static readonly DwarfAttributeKindEx Count = new DwarfAttributeKindEx(DwarfNative.DW_AT_count); + + public static readonly DwarfAttributeKindEx DataMemberLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_member_location); + + public static readonly DwarfAttributeKindEx DeclColumn = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_column); + + public static readonly DwarfAttributeKindEx DeclFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_file); + + public static readonly DwarfAttributeKindEx DeclLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_line); + + public static readonly DwarfAttributeKindEx Declaration = new DwarfAttributeKindEx(DwarfNative.DW_AT_declaration); + + /// + /// DWARF2 + /// + public static readonly DwarfAttributeKindEx DiscrList = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr_list); + + public static readonly DwarfAttributeKindEx Encoding = new DwarfAttributeKindEx(DwarfNative.DW_AT_encoding); + + public static readonly DwarfAttributeKindEx External = new DwarfAttributeKindEx(DwarfNative.DW_AT_external); + + public static readonly DwarfAttributeKindEx FrameBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_frame_base); + + public static readonly DwarfAttributeKindEx Friend = new DwarfAttributeKindEx(DwarfNative.DW_AT_friend); + + public static readonly DwarfAttributeKindEx IdentifierCase = new DwarfAttributeKindEx(DwarfNative.DW_AT_identifier_case); + + /// + /// DWARF{234} not DWARF5 + /// + public static readonly DwarfAttributeKindEx MacroInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_macro_info); + + public static readonly DwarfAttributeKindEx NamelistItem = new DwarfAttributeKindEx(DwarfNative.DW_AT_namelist_item); + + public static readonly DwarfAttributeKindEx Priority = new DwarfAttributeKindEx(DwarfNative.DW_AT_priority); + + public static readonly DwarfAttributeKindEx Segment = new DwarfAttributeKindEx(DwarfNative.DW_AT_segment); + + public static readonly DwarfAttributeKindEx Specification = new DwarfAttributeKindEx(DwarfNative.DW_AT_specification); + + public static readonly DwarfAttributeKindEx StaticLink = new DwarfAttributeKindEx(DwarfNative.DW_AT_static_link); + + public static readonly DwarfAttributeKindEx Type = new DwarfAttributeKindEx(DwarfNative.DW_AT_type); + + public static readonly DwarfAttributeKindEx UseLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_location); + + public static readonly DwarfAttributeKindEx VariableParameter = new DwarfAttributeKindEx(DwarfNative.DW_AT_variable_parameter); + + public static readonly DwarfAttributeKindEx Virtuality = new DwarfAttributeKindEx(DwarfNative.DW_AT_virtuality); + + public static readonly DwarfAttributeKindEx VtableElemLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_vtable_elem_location); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Allocated = new DwarfAttributeKindEx(DwarfNative.DW_AT_allocated); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Associated = new DwarfAttributeKindEx(DwarfNative.DW_AT_associated); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx DataLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_location); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx ByteStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_byte_stride); + + /// + /// DWARF3 (do not use) + /// + public static readonly DwarfAttributeKindEx Stride = new DwarfAttributeKindEx(DwarfNative.DW_AT_stride); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx EntryPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_entry_pc); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx UseUTF8 = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_UTF8); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Extension = new DwarfAttributeKindEx(DwarfNative.DW_AT_extension); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Ranges = new DwarfAttributeKindEx(DwarfNative.DW_AT_ranges); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Trampoline = new DwarfAttributeKindEx(DwarfNative.DW_AT_trampoline); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx CallColumn = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_column); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx CallFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_file); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx CallLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_line); + + /// + /// DWARF3 + /// + public static readonly DwarfAttributeKindEx Description = new DwarfAttributeKindEx(DwarfNative.DW_AT_description); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx BinaryScale = new DwarfAttributeKindEx(DwarfNative.DW_AT_binary_scale); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx DecimalScale = new DwarfAttributeKindEx(DwarfNative.DW_AT_decimal_scale); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Small = new DwarfAttributeKindEx(DwarfNative.DW_AT_small); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx DecimalSign = new DwarfAttributeKindEx(DwarfNative.DW_AT_decimal_sign); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx DigitCount = new DwarfAttributeKindEx(DwarfNative.DW_AT_digit_count); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx PictureString = new DwarfAttributeKindEx(DwarfNative.DW_AT_picture_string); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Mutable = new DwarfAttributeKindEx(DwarfNative.DW_AT_mutable); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx ThreadsScaled = new DwarfAttributeKindEx(DwarfNative.DW_AT_threads_scaled); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Explicit = new DwarfAttributeKindEx(DwarfNative.DW_AT_explicit); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx ObjectPointer = new DwarfAttributeKindEx(DwarfNative.DW_AT_object_pointer); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Endianity = new DwarfAttributeKindEx(DwarfNative.DW_AT_endianity); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Elemental = new DwarfAttributeKindEx(DwarfNative.DW_AT_elemental); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Pure = new DwarfAttributeKindEx(DwarfNative.DW_AT_pure); + + /// + /// DWARF3f + /// + public static readonly DwarfAttributeKindEx Recursive = new DwarfAttributeKindEx(DwarfNative.DW_AT_recursive); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx Signature = new DwarfAttributeKindEx(DwarfNative.DW_AT_signature); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx MainSubprogram = new DwarfAttributeKindEx(DwarfNative.DW_AT_main_subprogram); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx DataBitOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_bit_offset); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx ConstExpr = new DwarfAttributeKindEx(DwarfNative.DW_AT_const_expr); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx EnumClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_enum_class); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeKindEx LinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_linkage_name); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx StringLengthBitSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length_bit_size); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx StringLengthByteSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length_byte_size); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Rank = new DwarfAttributeKindEx(DwarfNative.DW_AT_rank); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx StrOffsetsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_str_offsets_base); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx AddrBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_addr_base); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx RnglistsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_rnglists_base); + + /// + /// DWARF4! + /// + public static readonly DwarfAttributeKindEx DwoId = new DwarfAttributeKindEx(DwarfNative.DW_AT_dwo_id); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx DwoName = new DwarfAttributeKindEx(DwarfNative.DW_AT_dwo_name); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Reference = new DwarfAttributeKindEx(DwarfNative.DW_AT_reference); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx RvalueReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_rvalue_reference); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Macros = new DwarfAttributeKindEx(DwarfNative.DW_AT_macros); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallAllCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_calls); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallAllSourceCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_source_calls); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallAllTailCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_tail_calls); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallReturnPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_return_pc); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_value); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_origin); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallParameter = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_parameter); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_pc); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallTailCall = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_tail_call); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallTarget = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_target); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallTargetClobbered = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_target_clobbered); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallDataLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_data_location); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx CallDataValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_data_value); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Noreturn = new DwarfAttributeKindEx(DwarfNative.DW_AT_noreturn); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Alignment = new DwarfAttributeKindEx(DwarfNative.DW_AT_alignment); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx ExportSymbols = new DwarfAttributeKindEx(DwarfNative.DW_AT_export_symbols); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Deleted = new DwarfAttributeKindEx(DwarfNative.DW_AT_deleted); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx Defaulted = new DwarfAttributeKindEx(DwarfNative.DW_AT_defaulted); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeKindEx LoclistsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_loclists_base); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPBlockIndex = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_block_index); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSFde = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_fde); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSLoopBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_loop_begin); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSTailLoopBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_tail_loop_begin); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSEpilogBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_epilog_begin); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSLoopUnrollFactor = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_loop_unroll_factor); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSSoftwarePipelineDepth = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_software_pipeline_depth); + + /// + /// MIPS/SGI, GNU, and others. + /// + public static readonly DwarfAttributeKindEx MIPSLinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_linkage_name); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSAbstractName = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_abstract_name); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSCloneOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_clone_origin); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSHasInlines = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_has_inlines); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSStrideByte = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride_byte); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSStrideElem = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride_elem); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSPtrDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_ptr_dopetype); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSAllocatableDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_allocatable_dopetype); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSAssumedShapeDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_assumed_shape_dopetype); + + /// + /// MIPS/SGI + /// + public static readonly DwarfAttributeKindEx MIPSAssumedSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_assumed_size); + + /// + /// conflict: MIPS + /// + public static readonly DwarfAttributeKindEx HPUnmodifiable = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_unmodifiable); + + /// + /// conflict: MIPS + /// + public static readonly DwarfAttributeKindEx HPActualsStmtList = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_actuals_stmt_list); + + /// + /// conflict: MIPS + /// + public static readonly DwarfAttributeKindEx HPProcPerSection = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_proc_per_section); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPRawDataPtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_raw_data_ptr); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPPassByReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_pass_by_reference); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPOptLevel = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_opt_level); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPProfVersionId = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_prof_version_id); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPOptFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_opt_flags); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPColdRegionLowPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_cold_region_low_pc); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPColdRegionHighPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_cold_region_high_pc); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPAllVariablesModifiable = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_all_variables_modifiable); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPLinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_linkage_name); + + /// + /// HP + /// + public static readonly DwarfAttributeKindEx HPProfFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_prof_flags); + + /// + /// COMPAQ/HP + /// + public static readonly DwarfAttributeKindEx CPQDiscontigRanges = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_discontig_ranges); + + /// + /// COMPAQ/HP + /// + public static readonly DwarfAttributeKindEx CPQSemanticEvents = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_semantic_events); + + /// + /// COMPAQ/HP + /// + public static readonly DwarfAttributeKindEx CPQSplitLifetimesVar = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_split_lifetimes_var); + + /// + /// COMPAQ/HP + /// + public static readonly DwarfAttributeKindEx CPQSplitLifetimesRtn = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_split_lifetimes_rtn); + + /// + /// COMPAQ/HP + /// + public static readonly DwarfAttributeKindEx CPQPrologueLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_prologue_length); + + /// + /// Intel, 1 if byte swapped. + /// + public static readonly DwarfAttributeKindEx INTELOtherEndian = new DwarfAttributeKindEx(DwarfNative.DW_AT_INTEL_other_endian); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx SfNames = new DwarfAttributeKindEx(DwarfNative.DW_AT_sf_names); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx SrcInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_src_info); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx MacInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_mac_info); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx SrcCoords = new DwarfAttributeKindEx(DwarfNative.DW_AT_src_coords); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx BodyBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_body_begin); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx BodyEnd = new DwarfAttributeKindEx(DwarfNative.DW_AT_body_end); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUVector = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_vector); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUGuardedBy = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_guarded_by); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUPtGuardedBy = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pt_guarded_by); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUGuarded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_guarded); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUPtGuarded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pt_guarded); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNULocksExcluded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_locks_excluded); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUExclusiveLocksRequired = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_exclusive_locks_required); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUSharedLocksRequired = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_shared_locks_required); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUOdrSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_odr_signature); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUTemplateName = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_template_name); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUCallSiteValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_value); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUCallSiteDataValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_data_value); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUCallSiteTarget = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_target); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUCallSiteTargetClobbered = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_target_clobbered); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUTailCall = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_tail_call); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUAllTailCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_tail_call_sites); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUAllCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_call_sites); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUAllSourceCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_source_call_sites); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUMacros = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_macros); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUDwoName = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_dwo_name); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUDwoId = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_dwo_id); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNURangesBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_ranges_base); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUAddrBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_addr_base); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUPubnames = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pubnames); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUPubtypes = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pubtypes); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUDiscriminator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_discriminator); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUNumerator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_numerator); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUDenominator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_denominator); + + /// + /// GNU + /// + public static readonly DwarfAttributeKindEx GNUBias = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_bias); + + /// + /// ALTIUM + /// + public static readonly DwarfAttributeKindEx ALTIUMLoclist = new DwarfAttributeKindEx(DwarfNative.DW_AT_ALTIUM_loclist); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNTemplate = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_template); + + /// + /// VMS + /// + public static readonly DwarfAttributeKindEx VMSRtnbegPdAddress = new DwarfAttributeKindEx(DwarfNative.DW_AT_VMS_rtnbeg_pd_address); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNAlignment = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_alignment); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNVtable = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNCountGuarantee = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_count_guarantee); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNCommandLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_command_line); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNVbase = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vbase); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNCompileOptions = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_compile_options); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNLanguage = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_language); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNBrowserFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_browser_file); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNVtableAbi = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable_abi); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNFuncOffsets = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_func_offsets); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNCfKind = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_cf_kind); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNVtableIndex = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable_index); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNOmpTprivAddr = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_omp_tpriv_addr); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNOmpChildFunc = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_omp_child_func); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNFuncOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_func_offset); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNMemopTypeRef = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_memop_type_ref); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNProfileId = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_profile_id); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNMemopSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_memop_signature); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNObjDir = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_obj_dir); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNObjFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_obj_file); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNOriginalName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_original_name); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNHwcprofSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_hwcprof_signature); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNAmd64Parmdump = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_amd64_parmdump); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNPartLinkName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_part_link_name); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNLinkName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_link_name); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNPassWithConst = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_pass_with_const); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNReturnWithConst = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_return_with_const); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNImportByName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_import_by_name); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNF90Pointer = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_pointer); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNPassByRef = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_pass_by_ref); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNF90Allocatable = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_allocatable); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNF90AssumedShapeArray = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_assumed_shape_array); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNCVla = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_c_vla); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNReturnValuePtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_return_value_ptr); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNDtorStart = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_start); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNDtorLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_length); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNDtorStateInitial = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_initial); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNDtorStateFinal = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_final); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNDtorStateDeltas = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_deltas); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNImportByLname = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_import_by_lname); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNF90UseOnly = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_use_only); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNNamelistSpec = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_namelist_spec); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNIsOmpChildFunc = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_is_omp_child_func); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNFortranMainAlias = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_fortran_main_alias); + + /// + /// SUN + /// + public static readonly DwarfAttributeKindEx SUNFortranBased = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_fortran_based); + + /// + /// GNAT + /// + public static readonly DwarfAttributeKindEx UseGNATDescriptiveType = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_GNAT_descriptive_type); + + /// + /// GNAT + /// + public static readonly DwarfAttributeKindEx GNATDescriptiveType = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNAT_descriptive_type); + + /// + /// UPC + /// + public static readonly DwarfAttributeKindEx UpcThreadsScaled = new DwarfAttributeKindEx(DwarfNative.DW_AT_upc_threads_scaled); + + /// + /// PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. + /// + public static readonly DwarfAttributeKindEx PGILbase = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_lbase); + + /// + /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. + /// + public static readonly DwarfAttributeKindEx PGISoffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_soffset); + + /// + /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. + /// + public static readonly DwarfAttributeKindEx PGILstride = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_lstride); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEOptimized = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_optimized); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_flags); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEIsa = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_isa); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEBlock = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_block); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEMajorRuntimeVers = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_major_runtime_vers); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLERuntimeClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_runtime_class); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEOmitFramePtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_omit_frame_ptr); + + /// + /// Apple + /// + public static readonly DwarfAttributeKindEx APPLEClosure = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_closure); + + private string ToStringInternal() + { + switch ((ushort)Value) + { + case DwarfNative.DW_AT_sibling: return "DW_AT_sibling"; + case DwarfNative.DW_AT_location: return "DW_AT_location"; + case DwarfNative.DW_AT_name: return "DW_AT_name"; + case DwarfNative.DW_AT_ordering: return "DW_AT_ordering"; + case DwarfNative.DW_AT_subscr_data: return "DW_AT_subscr_data"; + case DwarfNative.DW_AT_byte_size: return "DW_AT_byte_size"; + case DwarfNative.DW_AT_bit_offset: return "DW_AT_bit_offset"; + case DwarfNative.DW_AT_bit_size: return "DW_AT_bit_size"; + case DwarfNative.DW_AT_element_list: return "DW_AT_element_list"; + case DwarfNative.DW_AT_stmt_list: return "DW_AT_stmt_list"; + case DwarfNative.DW_AT_low_pc: return "DW_AT_low_pc"; + case DwarfNative.DW_AT_high_pc: return "DW_AT_high_pc"; + case DwarfNative.DW_AT_language: return "DW_AT_language"; + case DwarfNative.DW_AT_member: return "DW_AT_member"; + case DwarfNative.DW_AT_discr: return "DW_AT_discr"; + case DwarfNative.DW_AT_discr_value: return "DW_AT_discr_value"; + case DwarfNative.DW_AT_visibility: return "DW_AT_visibility"; + case DwarfNative.DW_AT_import: return "DW_AT_import"; + case DwarfNative.DW_AT_string_length: return "DW_AT_string_length"; + case DwarfNative.DW_AT_common_reference: return "DW_AT_common_reference"; + case DwarfNative.DW_AT_comp_dir: return "DW_AT_comp_dir"; + case DwarfNative.DW_AT_const_value: return "DW_AT_const_value"; + case DwarfNative.DW_AT_containing_type: return "DW_AT_containing_type"; + case DwarfNative.DW_AT_default_value: return "DW_AT_default_value"; + case DwarfNative.DW_AT_inline: return "DW_AT_inline"; + case DwarfNative.DW_AT_is_optional: return "DW_AT_is_optional"; + case DwarfNative.DW_AT_lower_bound: return "DW_AT_lower_bound"; + case DwarfNative.DW_AT_producer: return "DW_AT_producer"; + case DwarfNative.DW_AT_prototyped: return "DW_AT_prototyped"; + case DwarfNative.DW_AT_return_addr: return "DW_AT_return_addr"; + case DwarfNative.DW_AT_start_scope: return "DW_AT_start_scope"; + case DwarfNative.DW_AT_bit_stride: return "DW_AT_bit_stride"; + case DwarfNative.DW_AT_upper_bound: return "DW_AT_upper_bound"; + case DwarfNative.DW_AT_abstract_origin: return "DW_AT_abstract_origin"; + case DwarfNative.DW_AT_accessibility: return "DW_AT_accessibility"; + case DwarfNative.DW_AT_address_class: return "DW_AT_address_class"; + case DwarfNative.DW_AT_artificial: return "DW_AT_artificial"; + case DwarfNative.DW_AT_base_types: return "DW_AT_base_types"; + case DwarfNative.DW_AT_calling_convention: return "DW_AT_calling_convention"; + case DwarfNative.DW_AT_count: return "DW_AT_count"; + case DwarfNative.DW_AT_data_member_location: return "DW_AT_data_member_location"; + case DwarfNative.DW_AT_decl_column: return "DW_AT_decl_column"; + case DwarfNative.DW_AT_decl_file: return "DW_AT_decl_file"; + case DwarfNative.DW_AT_decl_line: return "DW_AT_decl_line"; + case DwarfNative.DW_AT_declaration: return "DW_AT_declaration"; + case DwarfNative.DW_AT_discr_list: return "DW_AT_discr_list"; + case DwarfNative.DW_AT_encoding: return "DW_AT_encoding"; + case DwarfNative.DW_AT_external: return "DW_AT_external"; + case DwarfNative.DW_AT_frame_base: return "DW_AT_frame_base"; + case DwarfNative.DW_AT_friend: return "DW_AT_friend"; + case DwarfNative.DW_AT_identifier_case: return "DW_AT_identifier_case"; + case DwarfNative.DW_AT_macro_info: return "DW_AT_macro_info"; + case DwarfNative.DW_AT_namelist_item: return "DW_AT_namelist_item"; + case DwarfNative.DW_AT_priority: return "DW_AT_priority"; + case DwarfNative.DW_AT_segment: return "DW_AT_segment"; + case DwarfNative.DW_AT_specification: return "DW_AT_specification"; + case DwarfNative.DW_AT_static_link: return "DW_AT_static_link"; + case DwarfNative.DW_AT_type: return "DW_AT_type"; + case DwarfNative.DW_AT_use_location: return "DW_AT_use_location"; + case DwarfNative.DW_AT_variable_parameter: return "DW_AT_variable_parameter"; + case DwarfNative.DW_AT_virtuality: return "DW_AT_virtuality"; + case DwarfNative.DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location"; + case DwarfNative.DW_AT_allocated: return "DW_AT_allocated"; + case DwarfNative.DW_AT_associated: return "DW_AT_associated"; + case DwarfNative.DW_AT_data_location: return "DW_AT_data_location"; + case DwarfNative.DW_AT_byte_stride: return "DW_AT_byte_stride"; + case DwarfNative.DW_AT_entry_pc: return "DW_AT_entry_pc"; + case DwarfNative.DW_AT_use_UTF8: return "DW_AT_use_UTF8"; + case DwarfNative.DW_AT_extension: return "DW_AT_extension"; + case DwarfNative.DW_AT_ranges: return "DW_AT_ranges"; + case DwarfNative.DW_AT_trampoline: return "DW_AT_trampoline"; + case DwarfNative.DW_AT_call_column: return "DW_AT_call_column"; + case DwarfNative.DW_AT_call_file: return "DW_AT_call_file"; + case DwarfNative.DW_AT_call_line: return "DW_AT_call_line"; + case DwarfNative.DW_AT_description: return "DW_AT_description"; + case DwarfNative.DW_AT_binary_scale: return "DW_AT_binary_scale"; + case DwarfNative.DW_AT_decimal_scale: return "DW_AT_decimal_scale"; + case DwarfNative.DW_AT_small: return "DW_AT_small"; + case DwarfNative.DW_AT_decimal_sign: return "DW_AT_decimal_sign"; + case DwarfNative.DW_AT_digit_count: return "DW_AT_digit_count"; + case DwarfNative.DW_AT_picture_string: return "DW_AT_picture_string"; + case DwarfNative.DW_AT_mutable: return "DW_AT_mutable"; + case DwarfNative.DW_AT_threads_scaled: return "DW_AT_threads_scaled"; + case DwarfNative.DW_AT_explicit: return "DW_AT_explicit"; + case DwarfNative.DW_AT_object_pointer: return "DW_AT_object_pointer"; + case DwarfNative.DW_AT_endianity: return "DW_AT_endianity"; + case DwarfNative.DW_AT_elemental: return "DW_AT_elemental"; + case DwarfNative.DW_AT_pure: return "DW_AT_pure"; + case DwarfNative.DW_AT_recursive: return "DW_AT_recursive"; + case DwarfNative.DW_AT_signature: return "DW_AT_signature"; + case DwarfNative.DW_AT_main_subprogram: return "DW_AT_main_subprogram"; + case DwarfNative.DW_AT_data_bit_offset: return "DW_AT_data_bit_offset"; + case DwarfNative.DW_AT_const_expr: return "DW_AT_const_expr"; + case DwarfNative.DW_AT_enum_class: return "DW_AT_enum_class"; + case DwarfNative.DW_AT_linkage_name: return "DW_AT_linkage_name"; + case DwarfNative.DW_AT_string_length_bit_size: return "DW_AT_string_length_bit_size"; + case DwarfNative.DW_AT_string_length_byte_size: return "DW_AT_string_length_byte_size"; + case DwarfNative.DW_AT_rank: return "DW_AT_rank"; + case DwarfNative.DW_AT_str_offsets_base: return "DW_AT_str_offsets_base"; + case DwarfNative.DW_AT_addr_base: return "DW_AT_addr_base"; + case DwarfNative.DW_AT_rnglists_base: return "DW_AT_rnglists_base"; + case DwarfNative.DW_AT_dwo_id: return "DW_AT_dwo_id"; + case DwarfNative.DW_AT_dwo_name: return "DW_AT_dwo_name"; + case DwarfNative.DW_AT_reference: return "DW_AT_reference"; + case DwarfNative.DW_AT_rvalue_reference: return "DW_AT_rvalue_reference"; + case DwarfNative.DW_AT_macros: return "DW_AT_macros"; + case DwarfNative.DW_AT_call_all_calls: return "DW_AT_call_all_calls"; + case DwarfNative.DW_AT_call_all_source_calls: return "DW_AT_call_all_source_calls"; + case DwarfNative.DW_AT_call_all_tail_calls: return "DW_AT_call_all_tail_calls"; + case DwarfNative.DW_AT_call_return_pc: return "DW_AT_call_return_pc"; + case DwarfNative.DW_AT_call_value: return "DW_AT_call_value"; + case DwarfNative.DW_AT_call_origin: return "DW_AT_call_origin"; + case DwarfNative.DW_AT_call_parameter: return "DW_AT_call_parameter"; + case DwarfNative.DW_AT_call_pc: return "DW_AT_call_pc"; + case DwarfNative.DW_AT_call_tail_call: return "DW_AT_call_tail_call"; + case DwarfNative.DW_AT_call_target: return "DW_AT_call_target"; + case DwarfNative.DW_AT_call_target_clobbered: return "DW_AT_call_target_clobbered"; + case DwarfNative.DW_AT_call_data_location: return "DW_AT_call_data_location"; + case DwarfNative.DW_AT_call_data_value: return "DW_AT_call_data_value"; + case DwarfNative.DW_AT_noreturn: return "DW_AT_noreturn"; + case DwarfNative.DW_AT_alignment: return "DW_AT_alignment"; + case DwarfNative.DW_AT_export_symbols: return "DW_AT_export_symbols"; + case DwarfNative.DW_AT_deleted: return "DW_AT_deleted"; + case DwarfNative.DW_AT_defaulted: return "DW_AT_defaulted"; + case DwarfNative.DW_AT_loclists_base: return "DW_AT_loclists_base"; + case DwarfNative.DW_AT_HP_block_index: return "DW_AT_HP_block_index"; + case DwarfNative.DW_AT_MIPS_fde: return "DW_AT_MIPS_fde"; + case DwarfNative.DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin"; + case DwarfNative.DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin"; + case DwarfNative.DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin"; + case DwarfNative.DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor"; + case DwarfNative.DW_AT_MIPS_software_pipeline_depth: return "DW_AT_MIPS_software_pipeline_depth"; + case DwarfNative.DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name"; + case DwarfNative.DW_AT_MIPS_stride: return "DW_AT_MIPS_stride"; + case DwarfNative.DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name"; + case DwarfNative.DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin"; + case DwarfNative.DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines"; + case DwarfNative.DW_AT_MIPS_stride_byte: return "DW_AT_MIPS_stride_byte"; + case DwarfNative.DW_AT_MIPS_stride_elem: return "DW_AT_MIPS_stride_elem"; + case DwarfNative.DW_AT_MIPS_ptr_dopetype: return "DW_AT_MIPS_ptr_dopetype"; + case DwarfNative.DW_AT_MIPS_allocatable_dopetype: return "DW_AT_MIPS_allocatable_dopetype"; + case DwarfNative.DW_AT_MIPS_assumed_shape_dopetype: return "DW_AT_MIPS_assumed_shape_dopetype"; + case DwarfNative.DW_AT_MIPS_assumed_size: return "DW_AT_MIPS_assumed_size"; + case DwarfNative.DW_AT_HP_raw_data_ptr: return "DW_AT_HP_raw_data_ptr"; + case DwarfNative.DW_AT_HP_pass_by_reference: return "DW_AT_HP_pass_by_reference"; + case DwarfNative.DW_AT_HP_opt_level: return "DW_AT_HP_opt_level"; + case DwarfNative.DW_AT_HP_prof_version_id: return "DW_AT_HP_prof_version_id"; + case DwarfNative.DW_AT_HP_opt_flags: return "DW_AT_HP_opt_flags"; + case DwarfNative.DW_AT_HP_cold_region_low_pc: return "DW_AT_HP_cold_region_low_pc"; + case DwarfNative.DW_AT_HP_cold_region_high_pc: return "DW_AT_HP_cold_region_high_pc"; + case DwarfNative.DW_AT_HP_all_variables_modifiable: return "DW_AT_HP_all_variables_modifiable"; + case DwarfNative.DW_AT_HP_linkage_name: return "DW_AT_HP_linkage_name"; + case DwarfNative.DW_AT_HP_prof_flags: return "DW_AT_HP_prof_flags"; + case DwarfNative.DW_AT_INTEL_other_endian: return "DW_AT_INTEL_other_endian"; + case DwarfNative.DW_AT_sf_names: return "DW_AT_sf_names"; + case DwarfNative.DW_AT_src_info: return "DW_AT_src_info"; + case DwarfNative.DW_AT_mac_info: return "DW_AT_mac_info"; + case DwarfNative.DW_AT_src_coords: return "DW_AT_src_coords"; + case DwarfNative.DW_AT_body_begin: return "DW_AT_body_begin"; + case DwarfNative.DW_AT_body_end: return "DW_AT_body_end"; + case DwarfNative.DW_AT_GNU_vector: return "DW_AT_GNU_vector"; + case DwarfNative.DW_AT_GNU_guarded_by: return "DW_AT_GNU_guarded_by"; + case DwarfNative.DW_AT_GNU_pt_guarded_by: return "DW_AT_GNU_pt_guarded_by"; + case DwarfNative.DW_AT_GNU_guarded: return "DW_AT_GNU_guarded"; + case DwarfNative.DW_AT_GNU_pt_guarded: return "DW_AT_GNU_pt_guarded"; + case DwarfNative.DW_AT_GNU_locks_excluded: return "DW_AT_GNU_locks_excluded"; + case DwarfNative.DW_AT_GNU_exclusive_locks_required: return "DW_AT_GNU_exclusive_locks_required"; + case DwarfNative.DW_AT_GNU_shared_locks_required: return "DW_AT_GNU_shared_locks_required"; + case DwarfNative.DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature"; + case DwarfNative.DW_AT_GNU_template_name: return "DW_AT_GNU_template_name"; + case DwarfNative.DW_AT_GNU_call_site_value: return "DW_AT_GNU_call_site_value"; + case DwarfNative.DW_AT_GNU_call_site_data_value: return "DW_AT_GNU_call_site_data_value"; + case DwarfNative.DW_AT_GNU_call_site_target: return "DW_AT_GNU_call_site_target"; + case DwarfNative.DW_AT_GNU_call_site_target_clobbered: return "DW_AT_GNU_call_site_target_clobbered"; + case DwarfNative.DW_AT_GNU_tail_call: return "DW_AT_GNU_tail_call"; + case DwarfNative.DW_AT_GNU_all_tail_call_sites: return "DW_AT_GNU_all_tail_call_sites"; + case DwarfNative.DW_AT_GNU_all_call_sites: return "DW_AT_GNU_all_call_sites"; + case DwarfNative.DW_AT_GNU_all_source_call_sites: return "DW_AT_GNU_all_source_call_sites"; + case DwarfNative.DW_AT_GNU_macros: return "DW_AT_GNU_macros"; + case DwarfNative.DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name"; + case DwarfNative.DW_AT_GNU_dwo_id: return "DW_AT_GNU_dwo_id"; + case DwarfNative.DW_AT_GNU_ranges_base: return "DW_AT_GNU_ranges_base"; + case DwarfNative.DW_AT_GNU_addr_base: return "DW_AT_GNU_addr_base"; + case DwarfNative.DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames"; + case DwarfNative.DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes"; + case DwarfNative.DW_AT_GNU_discriminator: return "DW_AT_GNU_discriminator"; + case DwarfNative.DW_AT_GNU_numerator: return "DW_AT_GNU_numerator"; + case DwarfNative.DW_AT_GNU_denominator: return "DW_AT_GNU_denominator"; + case DwarfNative.DW_AT_GNU_bias: return "DW_AT_GNU_bias"; + case DwarfNative.DW_AT_ALTIUM_loclist: return "DW_AT_ALTIUM_loclist"; + case DwarfNative.DW_AT_SUN_template: return "DW_AT_SUN_template"; + case DwarfNative.DW_AT_SUN_alignment: return "DW_AT_SUN_alignment"; + case DwarfNative.DW_AT_SUN_vtable: return "DW_AT_SUN_vtable"; + case DwarfNative.DW_AT_SUN_count_guarantee: return "DW_AT_SUN_count_guarantee"; + case DwarfNative.DW_AT_SUN_command_line: return "DW_AT_SUN_command_line"; + case DwarfNative.DW_AT_SUN_vbase: return "DW_AT_SUN_vbase"; + case DwarfNative.DW_AT_SUN_compile_options: return "DW_AT_SUN_compile_options"; + case DwarfNative.DW_AT_SUN_language: return "DW_AT_SUN_language"; + case DwarfNative.DW_AT_SUN_browser_file: return "DW_AT_SUN_browser_file"; + case DwarfNative.DW_AT_SUN_vtable_abi: return "DW_AT_SUN_vtable_abi"; + case DwarfNative.DW_AT_SUN_func_offsets: return "DW_AT_SUN_func_offsets"; + case DwarfNative.DW_AT_SUN_cf_kind: return "DW_AT_SUN_cf_kind"; + case DwarfNative.DW_AT_SUN_vtable_index: return "DW_AT_SUN_vtable_index"; + case DwarfNative.DW_AT_SUN_omp_tpriv_addr: return "DW_AT_SUN_omp_tpriv_addr"; + case DwarfNative.DW_AT_SUN_omp_child_func: return "DW_AT_SUN_omp_child_func"; + case DwarfNative.DW_AT_SUN_func_offset: return "DW_AT_SUN_func_offset"; + case DwarfNative.DW_AT_SUN_memop_type_ref: return "DW_AT_SUN_memop_type_ref"; + case DwarfNative.DW_AT_SUN_profile_id: return "DW_AT_SUN_profile_id"; + case DwarfNative.DW_AT_SUN_memop_signature: return "DW_AT_SUN_memop_signature"; + case DwarfNative.DW_AT_SUN_obj_dir: return "DW_AT_SUN_obj_dir"; + case DwarfNative.DW_AT_SUN_obj_file: return "DW_AT_SUN_obj_file"; + case DwarfNative.DW_AT_SUN_original_name: return "DW_AT_SUN_original_name"; + case DwarfNative.DW_AT_SUN_hwcprof_signature: return "DW_AT_SUN_hwcprof_signature"; + case DwarfNative.DW_AT_SUN_amd64_parmdump: return "DW_AT_SUN_amd64_parmdump"; + case DwarfNative.DW_AT_SUN_part_link_name: return "DW_AT_SUN_part_link_name"; + case DwarfNative.DW_AT_SUN_link_name: return "DW_AT_SUN_link_name"; + case DwarfNative.DW_AT_SUN_pass_with_const: return "DW_AT_SUN_pass_with_const"; + case DwarfNative.DW_AT_SUN_return_with_const: return "DW_AT_SUN_return_with_const"; + case DwarfNative.DW_AT_SUN_import_by_name: return "DW_AT_SUN_import_by_name"; + case DwarfNative.DW_AT_SUN_f90_pointer: return "DW_AT_SUN_f90_pointer"; + case DwarfNative.DW_AT_SUN_pass_by_ref: return "DW_AT_SUN_pass_by_ref"; + case DwarfNative.DW_AT_SUN_f90_allocatable: return "DW_AT_SUN_f90_allocatable"; + case DwarfNative.DW_AT_SUN_f90_assumed_shape_array: return "DW_AT_SUN_f90_assumed_shape_array"; + case DwarfNative.DW_AT_SUN_c_vla: return "DW_AT_SUN_c_vla"; + case DwarfNative.DW_AT_SUN_return_value_ptr: return "DW_AT_SUN_return_value_ptr"; + case DwarfNative.DW_AT_SUN_dtor_start: return "DW_AT_SUN_dtor_start"; + case DwarfNative.DW_AT_SUN_dtor_length: return "DW_AT_SUN_dtor_length"; + case DwarfNative.DW_AT_SUN_dtor_state_initial: return "DW_AT_SUN_dtor_state_initial"; + case DwarfNative.DW_AT_SUN_dtor_state_final: return "DW_AT_SUN_dtor_state_final"; + case DwarfNative.DW_AT_SUN_dtor_state_deltas: return "DW_AT_SUN_dtor_state_deltas"; + case DwarfNative.DW_AT_SUN_import_by_lname: return "DW_AT_SUN_import_by_lname"; + case DwarfNative.DW_AT_SUN_f90_use_only: return "DW_AT_SUN_f90_use_only"; + case DwarfNative.DW_AT_SUN_namelist_spec: return "DW_AT_SUN_namelist_spec"; + case DwarfNative.DW_AT_SUN_is_omp_child_func: return "DW_AT_SUN_is_omp_child_func"; + case DwarfNative.DW_AT_SUN_fortran_main_alias: return "DW_AT_SUN_fortran_main_alias"; + case DwarfNative.DW_AT_SUN_fortran_based: return "DW_AT_SUN_fortran_based"; + case DwarfNative.DW_AT_use_GNAT_descriptive_type: return "DW_AT_use_GNAT_descriptive_type"; + case DwarfNative.DW_AT_GNAT_descriptive_type: return "DW_AT_GNAT_descriptive_type"; + case DwarfNative.DW_AT_upc_threads_scaled: return "DW_AT_upc_threads_scaled"; + case DwarfNative.DW_AT_PGI_lbase: return "DW_AT_PGI_lbase"; + case DwarfNative.DW_AT_PGI_soffset: return "DW_AT_PGI_soffset"; + case DwarfNative.DW_AT_PGI_lstride: return "DW_AT_PGI_lstride"; + case DwarfNative.DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized"; + case DwarfNative.DW_AT_APPLE_flags: return "DW_AT_APPLE_flags"; + case DwarfNative.DW_AT_APPLE_isa: return "DW_AT_APPLE_isa"; + case DwarfNative.DW_AT_APPLE_block: return "DW_AT_APPLE_block"; + case DwarfNative.DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers"; + case DwarfNative.DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class"; + case DwarfNative.DW_AT_APPLE_omit_frame_ptr: return "DW_AT_APPLE_omit_frame_ptr"; + default: return null; + } + } + } + + public enum DwarfAttributeKind : ushort + { + Sibling = DwarfNative.DW_AT_sibling, + + Location = DwarfNative.DW_AT_location, + + Name = DwarfNative.DW_AT_name, + + Ordering = DwarfNative.DW_AT_ordering, + + SubscrData = DwarfNative.DW_AT_subscr_data, + + ByteSize = DwarfNative.DW_AT_byte_size, + + BitOffset = DwarfNative.DW_AT_bit_offset, + + BitSize = DwarfNative.DW_AT_bit_size, + + ElementList = DwarfNative.DW_AT_element_list, + + StmtList = DwarfNative.DW_AT_stmt_list, + + LowPC = DwarfNative.DW_AT_low_pc, + + HighPC = DwarfNative.DW_AT_high_pc, + + Language = DwarfNative.DW_AT_language, + + Member = DwarfNative.DW_AT_member, + + Discr = DwarfNative.DW_AT_discr, + + DiscrValue = DwarfNative.DW_AT_discr_value, + + Visibility = DwarfNative.DW_AT_visibility, + + Import = DwarfNative.DW_AT_import, + + StringLength = DwarfNative.DW_AT_string_length, + + CommonReference = DwarfNative.DW_AT_common_reference, + + CompDir = DwarfNative.DW_AT_comp_dir, + + ConstValue = DwarfNative.DW_AT_const_value, + + ContainingType = DwarfNative.DW_AT_containing_type, + + DefaultValue = DwarfNative.DW_AT_default_value, + + Inline = DwarfNative.DW_AT_inline, + + IsOptional = DwarfNative.DW_AT_is_optional, + + LowerBound = DwarfNative.DW_AT_lower_bound, + + Producer = DwarfNative.DW_AT_producer, + + Prototyped = DwarfNative.DW_AT_prototyped, + + ReturnAddr = DwarfNative.DW_AT_return_addr, + + StartScope = DwarfNative.DW_AT_start_scope, + + BitStride = DwarfNative.DW_AT_bit_stride, + + StrideSize = DwarfNative.DW_AT_stride_size, + + UpperBound = DwarfNative.DW_AT_upper_bound, + + AbstractOrigin = DwarfNative.DW_AT_abstract_origin, + + Accessibility = DwarfNative.DW_AT_accessibility, + + AddressClass = DwarfNative.DW_AT_address_class, + + Artificial = DwarfNative.DW_AT_artificial, + + BaseTypes = DwarfNative.DW_AT_base_types, + + CallingConvention = DwarfNative.DW_AT_calling_convention, + + Count = DwarfNative.DW_AT_count, + + DataMemberLocation = DwarfNative.DW_AT_data_member_location, + + DeclColumn = DwarfNative.DW_AT_decl_column, + + DeclFile = DwarfNative.DW_AT_decl_file, + + DeclLine = DwarfNative.DW_AT_decl_line, + + Declaration = DwarfNative.DW_AT_declaration, + + DiscrList = DwarfNative.DW_AT_discr_list, + + Encoding = DwarfNative.DW_AT_encoding, + + External = DwarfNative.DW_AT_external, + + FrameBase = DwarfNative.DW_AT_frame_base, + + Friend = DwarfNative.DW_AT_friend, + + IdentifierCase = DwarfNative.DW_AT_identifier_case, + + MacroInfo = DwarfNative.DW_AT_macro_info, + + NamelistItem = DwarfNative.DW_AT_namelist_item, + + Priority = DwarfNative.DW_AT_priority, + + Segment = DwarfNative.DW_AT_segment, + + Specification = DwarfNative.DW_AT_specification, + + StaticLink = DwarfNative.DW_AT_static_link, + + Type = DwarfNative.DW_AT_type, + + UseLocation = DwarfNative.DW_AT_use_location, + + VariableParameter = DwarfNative.DW_AT_variable_parameter, + + Virtuality = DwarfNative.DW_AT_virtuality, + + VtableElemLocation = DwarfNative.DW_AT_vtable_elem_location, + + Allocated = DwarfNative.DW_AT_allocated, + + Associated = DwarfNative.DW_AT_associated, + + DataLocation = DwarfNative.DW_AT_data_location, + + ByteStride = DwarfNative.DW_AT_byte_stride, + + Stride = DwarfNative.DW_AT_stride, + + EntryPC = DwarfNative.DW_AT_entry_pc, + + UseUTF8 = DwarfNative.DW_AT_use_UTF8, + + Extension = DwarfNative.DW_AT_extension, + + Ranges = DwarfNative.DW_AT_ranges, + + Trampoline = DwarfNative.DW_AT_trampoline, + + CallColumn = DwarfNative.DW_AT_call_column, + + CallFile = DwarfNative.DW_AT_call_file, + + CallLine = DwarfNative.DW_AT_call_line, + + Description = DwarfNative.DW_AT_description, + + BinaryScale = DwarfNative.DW_AT_binary_scale, + + DecimalScale = DwarfNative.DW_AT_decimal_scale, + + Small = DwarfNative.DW_AT_small, + + DecimalSign = DwarfNative.DW_AT_decimal_sign, + + DigitCount = DwarfNative.DW_AT_digit_count, + + PictureString = DwarfNative.DW_AT_picture_string, + + Mutable = DwarfNative.DW_AT_mutable, + + ThreadsScaled = DwarfNative.DW_AT_threads_scaled, + + Explicit = DwarfNative.DW_AT_explicit, + + ObjectPointer = DwarfNative.DW_AT_object_pointer, + + Endianity = DwarfNative.DW_AT_endianity, + + Elemental = DwarfNative.DW_AT_elemental, + + Pure = DwarfNative.DW_AT_pure, + + Recursive = DwarfNative.DW_AT_recursive, + + Signature = DwarfNative.DW_AT_signature, + + MainSubprogram = DwarfNative.DW_AT_main_subprogram, + + DataBitOffset = DwarfNative.DW_AT_data_bit_offset, + + ConstExpr = DwarfNative.DW_AT_const_expr, + + EnumClass = DwarfNative.DW_AT_enum_class, + + LinkageName = DwarfNative.DW_AT_linkage_name, + + StringLengthBitSize = DwarfNative.DW_AT_string_length_bit_size, + + StringLengthByteSize = DwarfNative.DW_AT_string_length_byte_size, + + Rank = DwarfNative.DW_AT_rank, + + StrOffsetsBase = DwarfNative.DW_AT_str_offsets_base, + + AddrBase = DwarfNative.DW_AT_addr_base, + + RnglistsBase = DwarfNative.DW_AT_rnglists_base, + + DwoId = DwarfNative.DW_AT_dwo_id, + + DwoName = DwarfNative.DW_AT_dwo_name, + + Reference = DwarfNative.DW_AT_reference, + + RvalueReference = DwarfNative.DW_AT_rvalue_reference, + + Macros = DwarfNative.DW_AT_macros, + + CallAllCalls = DwarfNative.DW_AT_call_all_calls, + + CallAllSourceCalls = DwarfNative.DW_AT_call_all_source_calls, + + CallAllTailCalls = DwarfNative.DW_AT_call_all_tail_calls, + + CallReturnPC = DwarfNative.DW_AT_call_return_pc, + + CallValue = DwarfNative.DW_AT_call_value, + + CallOrigin = DwarfNative.DW_AT_call_origin, + + CallParameter = DwarfNative.DW_AT_call_parameter, + + CallPC = DwarfNative.DW_AT_call_pc, + + CallTailCall = DwarfNative.DW_AT_call_tail_call, + + CallTarget = DwarfNative.DW_AT_call_target, + + CallTargetClobbered = DwarfNative.DW_AT_call_target_clobbered, + + CallDataLocation = DwarfNative.DW_AT_call_data_location, + + CallDataValue = DwarfNative.DW_AT_call_data_value, + + Noreturn = DwarfNative.DW_AT_noreturn, + + Alignment = DwarfNative.DW_AT_alignment, + + ExportSymbols = DwarfNative.DW_AT_export_symbols, + + Deleted = DwarfNative.DW_AT_deleted, + + Defaulted = DwarfNative.DW_AT_defaulted, + + LoclistsBase = DwarfNative.DW_AT_loclists_base, + + HPBlockIndex = DwarfNative.DW_AT_HP_block_index, + + MIPSFde = DwarfNative.DW_AT_MIPS_fde, + + MIPSLoopBegin = DwarfNative.DW_AT_MIPS_loop_begin, + + MIPSTailLoopBegin = DwarfNative.DW_AT_MIPS_tail_loop_begin, + + MIPSEpilogBegin = DwarfNative.DW_AT_MIPS_epilog_begin, + + MIPSLoopUnrollFactor = DwarfNative.DW_AT_MIPS_loop_unroll_factor, + + MIPSSoftwarePipelineDepth = DwarfNative.DW_AT_MIPS_software_pipeline_depth, + + MIPSLinkageName = DwarfNative.DW_AT_MIPS_linkage_name, + + MIPSStride = DwarfNative.DW_AT_MIPS_stride, + + MIPSAbstractName = DwarfNative.DW_AT_MIPS_abstract_name, + + MIPSCloneOrigin = DwarfNative.DW_AT_MIPS_clone_origin, + + MIPSHasInlines = DwarfNative.DW_AT_MIPS_has_inlines, + + MIPSStrideByte = DwarfNative.DW_AT_MIPS_stride_byte, + + MIPSStrideElem = DwarfNative.DW_AT_MIPS_stride_elem, + + MIPSPtrDopetype = DwarfNative.DW_AT_MIPS_ptr_dopetype, + + MIPSAllocatableDopetype = DwarfNative.DW_AT_MIPS_allocatable_dopetype, + + MIPSAssumedShapeDopetype = DwarfNative.DW_AT_MIPS_assumed_shape_dopetype, + + MIPSAssumedSize = DwarfNative.DW_AT_MIPS_assumed_size, + + HPUnmodifiable = DwarfNative.DW_AT_HP_unmodifiable, + + HPActualsStmtList = DwarfNative.DW_AT_HP_actuals_stmt_list, + + HPProcPerSection = DwarfNative.DW_AT_HP_proc_per_section, + + HPRawDataPtr = DwarfNative.DW_AT_HP_raw_data_ptr, + + HPPassByReference = DwarfNative.DW_AT_HP_pass_by_reference, + + HPOptLevel = DwarfNative.DW_AT_HP_opt_level, + + HPProfVersionId = DwarfNative.DW_AT_HP_prof_version_id, + + HPOptFlags = DwarfNative.DW_AT_HP_opt_flags, + + HPColdRegionLowPC = DwarfNative.DW_AT_HP_cold_region_low_pc, + + HPColdRegionHighPC = DwarfNative.DW_AT_HP_cold_region_high_pc, + + HPAllVariablesModifiable = DwarfNative.DW_AT_HP_all_variables_modifiable, + + HPLinkageName = DwarfNative.DW_AT_HP_linkage_name, + + HPProfFlags = DwarfNative.DW_AT_HP_prof_flags, + + CPQDiscontigRanges = DwarfNative.DW_AT_CPQ_discontig_ranges, + + CPQSemanticEvents = DwarfNative.DW_AT_CPQ_semantic_events, + + CPQSplitLifetimesVar = DwarfNative.DW_AT_CPQ_split_lifetimes_var, + + CPQSplitLifetimesRtn = DwarfNative.DW_AT_CPQ_split_lifetimes_rtn, + + CPQPrologueLength = DwarfNative.DW_AT_CPQ_prologue_length, + + INTELOtherEndian = DwarfNative.DW_AT_INTEL_other_endian, + + SfNames = DwarfNative.DW_AT_sf_names, + + SrcInfo = DwarfNative.DW_AT_src_info, + + MacInfo = DwarfNative.DW_AT_mac_info, + + SrcCoords = DwarfNative.DW_AT_src_coords, + + BodyBegin = DwarfNative.DW_AT_body_begin, + + BodyEnd = DwarfNative.DW_AT_body_end, + + GNUVector = DwarfNative.DW_AT_GNU_vector, + + GNUGuardedBy = DwarfNative.DW_AT_GNU_guarded_by, + + GNUPtGuardedBy = DwarfNative.DW_AT_GNU_pt_guarded_by, + + GNUGuarded = DwarfNative.DW_AT_GNU_guarded, + + GNUPtGuarded = DwarfNative.DW_AT_GNU_pt_guarded, + + GNULocksExcluded = DwarfNative.DW_AT_GNU_locks_excluded, + + GNUExclusiveLocksRequired = DwarfNative.DW_AT_GNU_exclusive_locks_required, + + GNUSharedLocksRequired = DwarfNative.DW_AT_GNU_shared_locks_required, + + GNUOdrSignature = DwarfNative.DW_AT_GNU_odr_signature, + + GNUTemplateName = DwarfNative.DW_AT_GNU_template_name, + + GNUCallSiteValue = DwarfNative.DW_AT_GNU_call_site_value, + + GNUCallSiteDataValue = DwarfNative.DW_AT_GNU_call_site_data_value, + + GNUCallSiteTarget = DwarfNative.DW_AT_GNU_call_site_target, + + GNUCallSiteTargetClobbered = DwarfNative.DW_AT_GNU_call_site_target_clobbered, + + GNUTailCall = DwarfNative.DW_AT_GNU_tail_call, + + GNUAllTailCallSites = DwarfNative.DW_AT_GNU_all_tail_call_sites, + + GNUAllCallSites = DwarfNative.DW_AT_GNU_all_call_sites, + + GNUAllSourceCallSites = DwarfNative.DW_AT_GNU_all_source_call_sites, + + GNUMacros = DwarfNative.DW_AT_GNU_macros, + + GNUDwoName = DwarfNative.DW_AT_GNU_dwo_name, + + GNUDwoId = DwarfNative.DW_AT_GNU_dwo_id, + + GNURangesBase = DwarfNative.DW_AT_GNU_ranges_base, + + GNUAddrBase = DwarfNative.DW_AT_GNU_addr_base, + + GNUPubnames = DwarfNative.DW_AT_GNU_pubnames, + + GNUPubtypes = DwarfNative.DW_AT_GNU_pubtypes, + + GNUDiscriminator = DwarfNative.DW_AT_GNU_discriminator, + + GNUNumerator = DwarfNative.DW_AT_GNU_numerator, + + GNUDenominator = DwarfNative.DW_AT_GNU_denominator, + + GNUBias = DwarfNative.DW_AT_GNU_bias, + + ALTIUMLoclist = DwarfNative.DW_AT_ALTIUM_loclist, + + SUNTemplate = DwarfNative.DW_AT_SUN_template, + + VMSRtnbegPdAddress = DwarfNative.DW_AT_VMS_rtnbeg_pd_address, + + SUNAlignment = DwarfNative.DW_AT_SUN_alignment, + + SUNVtable = DwarfNative.DW_AT_SUN_vtable, + + SUNCountGuarantee = DwarfNative.DW_AT_SUN_count_guarantee, + + SUNCommandLine = DwarfNative.DW_AT_SUN_command_line, + + SUNVbase = DwarfNative.DW_AT_SUN_vbase, + + SUNCompileOptions = DwarfNative.DW_AT_SUN_compile_options, + + SUNLanguage = DwarfNative.DW_AT_SUN_language, + + SUNBrowserFile = DwarfNative.DW_AT_SUN_browser_file, + + SUNVtableAbi = DwarfNative.DW_AT_SUN_vtable_abi, + + SUNFuncOffsets = DwarfNative.DW_AT_SUN_func_offsets, + + SUNCfKind = DwarfNative.DW_AT_SUN_cf_kind, + + SUNVtableIndex = DwarfNative.DW_AT_SUN_vtable_index, + + SUNOmpTprivAddr = DwarfNative.DW_AT_SUN_omp_tpriv_addr, + + SUNOmpChildFunc = DwarfNative.DW_AT_SUN_omp_child_func, + + SUNFuncOffset = DwarfNative.DW_AT_SUN_func_offset, + + SUNMemopTypeRef = DwarfNative.DW_AT_SUN_memop_type_ref, + + SUNProfileId = DwarfNative.DW_AT_SUN_profile_id, + + SUNMemopSignature = DwarfNative.DW_AT_SUN_memop_signature, + + SUNObjDir = DwarfNative.DW_AT_SUN_obj_dir, + + SUNObjFile = DwarfNative.DW_AT_SUN_obj_file, + + SUNOriginalName = DwarfNative.DW_AT_SUN_original_name, + + SUNHwcprofSignature = DwarfNative.DW_AT_SUN_hwcprof_signature, + + SUNAmd64Parmdump = DwarfNative.DW_AT_SUN_amd64_parmdump, + + SUNPartLinkName = DwarfNative.DW_AT_SUN_part_link_name, + + SUNLinkName = DwarfNative.DW_AT_SUN_link_name, + + SUNPassWithConst = DwarfNative.DW_AT_SUN_pass_with_const, + + SUNReturnWithConst = DwarfNative.DW_AT_SUN_return_with_const, + + SUNImportByName = DwarfNative.DW_AT_SUN_import_by_name, + + SUNF90Pointer = DwarfNative.DW_AT_SUN_f90_pointer, + + SUNPassByRef = DwarfNative.DW_AT_SUN_pass_by_ref, + + SUNF90Allocatable = DwarfNative.DW_AT_SUN_f90_allocatable, + + SUNF90AssumedShapeArray = DwarfNative.DW_AT_SUN_f90_assumed_shape_array, + + SUNCVla = DwarfNative.DW_AT_SUN_c_vla, + + SUNReturnValuePtr = DwarfNative.DW_AT_SUN_return_value_ptr, + + SUNDtorStart = DwarfNative.DW_AT_SUN_dtor_start, + + SUNDtorLength = DwarfNative.DW_AT_SUN_dtor_length, + + SUNDtorStateInitial = DwarfNative.DW_AT_SUN_dtor_state_initial, + + SUNDtorStateFinal = DwarfNative.DW_AT_SUN_dtor_state_final, + + SUNDtorStateDeltas = DwarfNative.DW_AT_SUN_dtor_state_deltas, + + SUNImportByLname = DwarfNative.DW_AT_SUN_import_by_lname, + + SUNF90UseOnly = DwarfNative.DW_AT_SUN_f90_use_only, + + SUNNamelistSpec = DwarfNative.DW_AT_SUN_namelist_spec, + + SUNIsOmpChildFunc = DwarfNative.DW_AT_SUN_is_omp_child_func, + + SUNFortranMainAlias = DwarfNative.DW_AT_SUN_fortran_main_alias, + + SUNFortranBased = DwarfNative.DW_AT_SUN_fortran_based, + + UseGNATDescriptiveType = DwarfNative.DW_AT_use_GNAT_descriptive_type, + + GNATDescriptiveType = DwarfNative.DW_AT_GNAT_descriptive_type, + + UpcThreadsScaled = DwarfNative.DW_AT_upc_threads_scaled, + + PGILbase = DwarfNative.DW_AT_PGI_lbase, + + PGISoffset = DwarfNative.DW_AT_PGI_soffset, + + PGILstride = DwarfNative.DW_AT_PGI_lstride, + + APPLEOptimized = DwarfNative.DW_AT_APPLE_optimized, + + APPLEFlags = DwarfNative.DW_AT_APPLE_flags, + + APPLEIsa = DwarfNative.DW_AT_APPLE_isa, + + APPLEBlock = DwarfNative.DW_AT_APPLE_block, + + APPLEMajorRuntimeVers = DwarfNative.DW_AT_APPLE_major_runtime_vers, + + APPLERuntimeClass = DwarfNative.DW_AT_APPLE_runtime_class, + + APPLEOmitFramePtr = DwarfNative.DW_AT_APPLE_omit_frame_ptr, + + APPLEClosure = DwarfNative.DW_AT_APPLE_closure, + } + + public readonly partial struct DwarfAttributeFormEx + { + public static readonly DwarfAttributeFormEx Addr = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addr); + + public static readonly DwarfAttributeFormEx Block2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block2); + + public static readonly DwarfAttributeFormEx Block4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block4); + + public static readonly DwarfAttributeFormEx Data2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data2); + + public static readonly DwarfAttributeFormEx Data4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data4); + + public static readonly DwarfAttributeFormEx Data8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data8); + + public static readonly DwarfAttributeFormEx String = new DwarfAttributeFormEx(DwarfNative.DW_FORM_string); + + public static readonly DwarfAttributeFormEx Block = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block); + + public static readonly DwarfAttributeFormEx Block1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block1); + + public static readonly DwarfAttributeFormEx Data1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data1); + + public static readonly DwarfAttributeFormEx Flag = new DwarfAttributeFormEx(DwarfNative.DW_FORM_flag); + + public static readonly DwarfAttributeFormEx Sdata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_sdata); + + public static readonly DwarfAttributeFormEx Strp = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strp); + + public static readonly DwarfAttributeFormEx Udata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_udata); + + public static readonly DwarfAttributeFormEx RefAddr = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_addr); + + public static readonly DwarfAttributeFormEx Ref1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref1); + + public static readonly DwarfAttributeFormEx Ref2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref2); + + public static readonly DwarfAttributeFormEx Ref4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref4); + + public static readonly DwarfAttributeFormEx Ref8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref8); + + public static readonly DwarfAttributeFormEx RefUdata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_udata); + + public static readonly DwarfAttributeFormEx Indirect = new DwarfAttributeFormEx(DwarfNative.DW_FORM_indirect); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeFormEx SecOffset = new DwarfAttributeFormEx(DwarfNative.DW_FORM_sec_offset); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeFormEx Exprloc = new DwarfAttributeFormEx(DwarfNative.DW_FORM_exprloc); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeFormEx FlagPresent = new DwarfAttributeFormEx(DwarfNative.DW_FORM_flag_present); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Strx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Addrx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx RefSup4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sup4); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx StrpSup = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strp_sup); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Data16 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data16); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx LineStrp = new DwarfAttributeFormEx(DwarfNative.DW_FORM_line_strp); + + /// + /// DWARF4 + /// + public static readonly DwarfAttributeFormEx RefSig8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sig8); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx ImplicitConst = new DwarfAttributeFormEx(DwarfNative.DW_FORM_implicit_const); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Loclistx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_loclistx); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Rnglistx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_rnglistx); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx RefSup8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sup8); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Strx1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx1); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Strx2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx2); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Strx3 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx3); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Strx4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx4); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Addrx1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx1); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Addrx2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx2); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Addrx3 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx3); + + /// + /// DWARF5 + /// + public static readonly DwarfAttributeFormEx Addrx4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx4); + + /// + /// GNU extension in debug_info.dwo. + /// + public static readonly DwarfAttributeFormEx GNUAddrIndex = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_addr_index); + + /// + /// GNU extension, somewhat like DW_FORM_strp + /// + public static readonly DwarfAttributeFormEx GNUStrIndex = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_str_index); + + /// + /// GNU extension. Offset in .debug_info. + /// + public static readonly DwarfAttributeFormEx GNURefAlt = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_ref_alt); + + /// + /// GNU extension. Offset in .debug_str of another object file. + /// + public static readonly DwarfAttributeFormEx GNUStrpAlt = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_strp_alt); + + private string ToStringInternal() + { + switch ((ushort)Value) + { + case DwarfNative.DW_FORM_addr: return "DW_FORM_addr"; + case DwarfNative.DW_FORM_block2: return "DW_FORM_block2"; + case DwarfNative.DW_FORM_block4: return "DW_FORM_block4"; + case DwarfNative.DW_FORM_data2: return "DW_FORM_data2"; + case DwarfNative.DW_FORM_data4: return "DW_FORM_data4"; + case DwarfNative.DW_FORM_data8: return "DW_FORM_data8"; + case DwarfNative.DW_FORM_string: return "DW_FORM_string"; + case DwarfNative.DW_FORM_block: return "DW_FORM_block"; + case DwarfNative.DW_FORM_block1: return "DW_FORM_block1"; + case DwarfNative.DW_FORM_data1: return "DW_FORM_data1"; + case DwarfNative.DW_FORM_flag: return "DW_FORM_flag"; + case DwarfNative.DW_FORM_sdata: return "DW_FORM_sdata"; + case DwarfNative.DW_FORM_strp: return "DW_FORM_strp"; + case DwarfNative.DW_FORM_udata: return "DW_FORM_udata"; + case DwarfNative.DW_FORM_ref_addr: return "DW_FORM_ref_addr"; + case DwarfNative.DW_FORM_ref1: return "DW_FORM_ref1"; + case DwarfNative.DW_FORM_ref2: return "DW_FORM_ref2"; + case DwarfNative.DW_FORM_ref4: return "DW_FORM_ref4"; + case DwarfNative.DW_FORM_ref8: return "DW_FORM_ref8"; + case DwarfNative.DW_FORM_ref_udata: return "DW_FORM_ref_udata"; + case DwarfNative.DW_FORM_indirect: return "DW_FORM_indirect"; + case DwarfNative.DW_FORM_sec_offset: return "DW_FORM_sec_offset"; + case DwarfNative.DW_FORM_exprloc: return "DW_FORM_exprloc"; + case DwarfNative.DW_FORM_flag_present: return "DW_FORM_flag_present"; + case DwarfNative.DW_FORM_strx: return "DW_FORM_strx"; + case DwarfNative.DW_FORM_addrx: return "DW_FORM_addrx"; + case DwarfNative.DW_FORM_ref_sup4: return "DW_FORM_ref_sup4"; + case DwarfNative.DW_FORM_strp_sup: return "DW_FORM_strp_sup"; + case DwarfNative.DW_FORM_data16: return "DW_FORM_data16"; + case DwarfNative.DW_FORM_line_strp: return "DW_FORM_line_strp"; + case DwarfNative.DW_FORM_ref_sig8: return "DW_FORM_ref_sig8"; + case DwarfNative.DW_FORM_implicit_const: return "DW_FORM_implicit_const"; + case DwarfNative.DW_FORM_loclistx: return "DW_FORM_loclistx"; + case DwarfNative.DW_FORM_rnglistx: return "DW_FORM_rnglistx"; + case DwarfNative.DW_FORM_ref_sup8: return "DW_FORM_ref_sup8"; + case DwarfNative.DW_FORM_strx1: return "DW_FORM_strx1"; + case DwarfNative.DW_FORM_strx2: return "DW_FORM_strx2"; + case DwarfNative.DW_FORM_strx3: return "DW_FORM_strx3"; + case DwarfNative.DW_FORM_strx4: return "DW_FORM_strx4"; + case DwarfNative.DW_FORM_addrx1: return "DW_FORM_addrx1"; + case DwarfNative.DW_FORM_addrx2: return "DW_FORM_addrx2"; + case DwarfNative.DW_FORM_addrx3: return "DW_FORM_addrx3"; + case DwarfNative.DW_FORM_addrx4: return "DW_FORM_addrx4"; + case DwarfNative.DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index"; + case DwarfNative.DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index"; + case DwarfNative.DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt"; + case DwarfNative.DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt"; + default: return null; + } + } + } + + public enum DwarfAttributeForm : ushort + { + Addr = DwarfNative.DW_FORM_addr, + + Block2 = DwarfNative.DW_FORM_block2, + + Block4 = DwarfNative.DW_FORM_block4, + + Data2 = DwarfNative.DW_FORM_data2, + + Data4 = DwarfNative.DW_FORM_data4, + + Data8 = DwarfNative.DW_FORM_data8, + + String = DwarfNative.DW_FORM_string, + + Block = DwarfNative.DW_FORM_block, + + Block1 = DwarfNative.DW_FORM_block1, + + Data1 = DwarfNative.DW_FORM_data1, + + Flag = DwarfNative.DW_FORM_flag, + + Sdata = DwarfNative.DW_FORM_sdata, + + Strp = DwarfNative.DW_FORM_strp, + + Udata = DwarfNative.DW_FORM_udata, + + RefAddr = DwarfNative.DW_FORM_ref_addr, + + Ref1 = DwarfNative.DW_FORM_ref1, + + Ref2 = DwarfNative.DW_FORM_ref2, + + Ref4 = DwarfNative.DW_FORM_ref4, + + Ref8 = DwarfNative.DW_FORM_ref8, + + RefUdata = DwarfNative.DW_FORM_ref_udata, + + Indirect = DwarfNative.DW_FORM_indirect, + + SecOffset = DwarfNative.DW_FORM_sec_offset, + + Exprloc = DwarfNative.DW_FORM_exprloc, + + FlagPresent = DwarfNative.DW_FORM_flag_present, + + Strx = DwarfNative.DW_FORM_strx, + + Addrx = DwarfNative.DW_FORM_addrx, + + RefSup4 = DwarfNative.DW_FORM_ref_sup4, + + StrpSup = DwarfNative.DW_FORM_strp_sup, + + Data16 = DwarfNative.DW_FORM_data16, + + LineStrp = DwarfNative.DW_FORM_line_strp, + + RefSig8 = DwarfNative.DW_FORM_ref_sig8, + + ImplicitConst = DwarfNative.DW_FORM_implicit_const, + + Loclistx = DwarfNative.DW_FORM_loclistx, + + Rnglistx = DwarfNative.DW_FORM_rnglistx, + + RefSup8 = DwarfNative.DW_FORM_ref_sup8, + + Strx1 = DwarfNative.DW_FORM_strx1, + + Strx2 = DwarfNative.DW_FORM_strx2, + + Strx3 = DwarfNative.DW_FORM_strx3, + + Strx4 = DwarfNative.DW_FORM_strx4, + + Addrx1 = DwarfNative.DW_FORM_addrx1, + + Addrx2 = DwarfNative.DW_FORM_addrx2, + + Addrx3 = DwarfNative.DW_FORM_addrx3, + + Addrx4 = DwarfNative.DW_FORM_addrx4, + + GNUAddrIndex = DwarfNative.DW_FORM_GNU_addr_index, + + GNUStrIndex = DwarfNative.DW_FORM_GNU_str_index, + + GNURefAlt = DwarfNative.DW_FORM_GNU_ref_alt, + + GNUStrpAlt = DwarfNative.DW_FORM_GNU_strp_alt, + } + + public readonly partial struct DwarfTagEx + { + public static readonly DwarfTagEx ArrayType = new DwarfTagEx(DwarfNative.DW_TAG_array_type); + + public static readonly DwarfTagEx ClassType = new DwarfTagEx(DwarfNative.DW_TAG_class_type); + + public static readonly DwarfTagEx EntryPoint = new DwarfTagEx(DwarfNative.DW_TAG_entry_point); + + public static readonly DwarfTagEx EnumerationType = new DwarfTagEx(DwarfNative.DW_TAG_enumeration_type); + + public static readonly DwarfTagEx FormalParameter = new DwarfTagEx(DwarfNative.DW_TAG_formal_parameter); + + public static readonly DwarfTagEx ImportedDeclaration = new DwarfTagEx(DwarfNative.DW_TAG_imported_declaration); + + public static readonly DwarfTagEx Label = new DwarfTagEx(DwarfNative.DW_TAG_label); + + public static readonly DwarfTagEx LexicalBlock = new DwarfTagEx(DwarfNative.DW_TAG_lexical_block); + + public static readonly DwarfTagEx Member = new DwarfTagEx(DwarfNative.DW_TAG_member); + + public static readonly DwarfTagEx PointerType = new DwarfTagEx(DwarfNative.DW_TAG_pointer_type); + + public static readonly DwarfTagEx ReferenceType = new DwarfTagEx(DwarfNative.DW_TAG_reference_type); + + public static readonly DwarfTagEx CompileUnit = new DwarfTagEx(DwarfNative.DW_TAG_compile_unit); + + public static readonly DwarfTagEx StringType = new DwarfTagEx(DwarfNative.DW_TAG_string_type); + + public static readonly DwarfTagEx StructureType = new DwarfTagEx(DwarfNative.DW_TAG_structure_type); + + public static readonly DwarfTagEx SubroutineType = new DwarfTagEx(DwarfNative.DW_TAG_subroutine_type); + + public static readonly DwarfTagEx Typedef = new DwarfTagEx(DwarfNative.DW_TAG_typedef); + + public static readonly DwarfTagEx UnionType = new DwarfTagEx(DwarfNative.DW_TAG_union_type); + + public static readonly DwarfTagEx UnspecifiedParameters = new DwarfTagEx(DwarfNative.DW_TAG_unspecified_parameters); + + public static readonly DwarfTagEx Variant = new DwarfTagEx(DwarfNative.DW_TAG_variant); + + public static readonly DwarfTagEx CommonBlock = new DwarfTagEx(DwarfNative.DW_TAG_common_block); + + public static readonly DwarfTagEx CommonInclusion = new DwarfTagEx(DwarfNative.DW_TAG_common_inclusion); + + public static readonly DwarfTagEx Inheritance = new DwarfTagEx(DwarfNative.DW_TAG_inheritance); + + public static readonly DwarfTagEx InlinedSubroutine = new DwarfTagEx(DwarfNative.DW_TAG_inlined_subroutine); + + public static readonly DwarfTagEx Module = new DwarfTagEx(DwarfNative.DW_TAG_module); + + public static readonly DwarfTagEx PtrToMemberType = new DwarfTagEx(DwarfNative.DW_TAG_ptr_to_member_type); + + public static readonly DwarfTagEx SetType = new DwarfTagEx(DwarfNative.DW_TAG_set_type); + + public static readonly DwarfTagEx SubrangeType = new DwarfTagEx(DwarfNative.DW_TAG_subrange_type); + + public static readonly DwarfTagEx WithStmt = new DwarfTagEx(DwarfNative.DW_TAG_with_stmt); + + public static readonly DwarfTagEx AccessDeclaration = new DwarfTagEx(DwarfNative.DW_TAG_access_declaration); + + public static readonly DwarfTagEx BaseType = new DwarfTagEx(DwarfNative.DW_TAG_base_type); + + public static readonly DwarfTagEx CatchBlock = new DwarfTagEx(DwarfNative.DW_TAG_catch_block); + + public static readonly DwarfTagEx ConstType = new DwarfTagEx(DwarfNative.DW_TAG_const_type); + + public static readonly DwarfTagEx Constant = new DwarfTagEx(DwarfNative.DW_TAG_constant); + + public static readonly DwarfTagEx Enumerator = new DwarfTagEx(DwarfNative.DW_TAG_enumerator); + + public static readonly DwarfTagEx FileType = new DwarfTagEx(DwarfNative.DW_TAG_file_type); + + public static readonly DwarfTagEx Friend = new DwarfTagEx(DwarfNative.DW_TAG_friend); + + public static readonly DwarfTagEx Namelist = new DwarfTagEx(DwarfNative.DW_TAG_namelist); + + /// + /// DWARF3/2 spelling + /// + public static readonly DwarfTagEx NamelistItem = new DwarfTagEx(DwarfNative.DW_TAG_namelist_item); + + /// + /// SGI misspelling/typo + /// + public static readonly DwarfTagEx NamelistItems = new DwarfTagEx(DwarfNative.DW_TAG_namelist_items); + + public static readonly DwarfTagEx PackedType = new DwarfTagEx(DwarfNative.DW_TAG_packed_type); + + public static readonly DwarfTagEx Subprogram = new DwarfTagEx(DwarfNative.DW_TAG_subprogram); + + /// + /// DWARF3/2 spelling + /// + public static readonly DwarfTagEx TemplateTypeParameter = new DwarfTagEx(DwarfNative.DW_TAG_template_type_parameter); + + /// + /// DWARF2 spelling + /// + public static readonly DwarfTagEx TemplateTypeParam = new DwarfTagEx(DwarfNative.DW_TAG_template_type_param); + + /// + /// DWARF3/2 spelling + /// + public static readonly DwarfTagEx TemplateValueParameter = new DwarfTagEx(DwarfNative.DW_TAG_template_value_parameter); + + /// + /// DWARF2 spelling + /// + public static readonly DwarfTagEx TemplateValueParam = new DwarfTagEx(DwarfNative.DW_TAG_template_value_param); + + public static readonly DwarfTagEx ThrownType = new DwarfTagEx(DwarfNative.DW_TAG_thrown_type); + + public static readonly DwarfTagEx TryBlock = new DwarfTagEx(DwarfNative.DW_TAG_try_block); + + public static readonly DwarfTagEx VariantPart = new DwarfTagEx(DwarfNative.DW_TAG_variant_part); + + public static readonly DwarfTagEx Variable = new DwarfTagEx(DwarfNative.DW_TAG_variable); + + public static readonly DwarfTagEx VolatileType = new DwarfTagEx(DwarfNative.DW_TAG_volatile_type); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx DwarfProcedure = new DwarfTagEx(DwarfNative.DW_TAG_dwarf_procedure); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx RestrictType = new DwarfTagEx(DwarfNative.DW_TAG_restrict_type); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx InterfaceType = new DwarfTagEx(DwarfNative.DW_TAG_interface_type); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx Namespace = new DwarfTagEx(DwarfNative.DW_TAG_namespace); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx ImportedModule = new DwarfTagEx(DwarfNative.DW_TAG_imported_module); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx UnspecifiedType = new DwarfTagEx(DwarfNative.DW_TAG_unspecified_type); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx PartialUnit = new DwarfTagEx(DwarfNative.DW_TAG_partial_unit); + + /// + /// DWARF3 + /// + public static readonly DwarfTagEx ImportedUnit = new DwarfTagEx(DwarfNative.DW_TAG_imported_unit); + + /// + /// Withdrawn from DWARF3 by DWARF3f. + /// + public static readonly DwarfTagEx MutableType = new DwarfTagEx(DwarfNative.DW_TAG_mutable_type); + + /// + /// DWARF3f + /// + public static readonly DwarfTagEx Condition = new DwarfTagEx(DwarfNative.DW_TAG_condition); + + /// + /// DWARF3f + /// + public static readonly DwarfTagEx SharedType = new DwarfTagEx(DwarfNative.DW_TAG_shared_type); + + /// + /// DWARF4 + /// + public static readonly DwarfTagEx TypeUnit = new DwarfTagEx(DwarfNative.DW_TAG_type_unit); + + /// + /// DWARF4 + /// + public static readonly DwarfTagEx RvalueReferenceType = new DwarfTagEx(DwarfNative.DW_TAG_rvalue_reference_type); + + /// + /// DWARF4 + /// + public static readonly DwarfTagEx TemplateAlias = new DwarfTagEx(DwarfNative.DW_TAG_template_alias); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx CoarrayType = new DwarfTagEx(DwarfNative.DW_TAG_coarray_type); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx GenericSubrange = new DwarfTagEx(DwarfNative.DW_TAG_generic_subrange); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx DynamicType = new DwarfTagEx(DwarfNative.DW_TAG_dynamic_type); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx AtomicType = new DwarfTagEx(DwarfNative.DW_TAG_atomic_type); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx CallSite = new DwarfTagEx(DwarfNative.DW_TAG_call_site); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx CallSiteParameter = new DwarfTagEx(DwarfNative.DW_TAG_call_site_parameter); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx SkeletonUnit = new DwarfTagEx(DwarfNative.DW_TAG_skeleton_unit); + + /// + /// DWARF5 + /// + public static readonly DwarfTagEx ImmutableType = new DwarfTagEx(DwarfNative.DW_TAG_immutable_type); + + public static readonly DwarfTagEx MIPSLoop = new DwarfTagEx(DwarfNative.DW_TAG_MIPS_loop); + + /// + /// HP + /// + public static readonly DwarfTagEx HPArrayDescriptor = new DwarfTagEx(DwarfNative.DW_TAG_HP_array_descriptor); + + /// + /// GNU. Fortran. + /// + public static readonly DwarfTagEx FormatLabel = new DwarfTagEx(DwarfNative.DW_TAG_format_label); + + /// + /// GNU. For C++ + /// + public static readonly DwarfTagEx FunctionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_function_template); + + /// + /// GNU. For C++ + /// + public static readonly DwarfTagEx ClassTemplate = new DwarfTagEx(DwarfNative.DW_TAG_class_template); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUBINCL = new DwarfTagEx(DwarfNative.DW_TAG_GNU_BINCL); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUEINCL = new DwarfTagEx(DwarfNative.DW_TAG_GNU_EINCL); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUTemplateTemplateParameter = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_template_parameter); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUTemplateTemplateParam = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_template_param); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUTemplateParameterPack = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_parameter_pack); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUFormalParameterPack = new DwarfTagEx(DwarfNative.DW_TAG_GNU_formal_parameter_pack); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUCallSite = new DwarfTagEx(DwarfNative.DW_TAG_GNU_call_site); + + /// + /// GNU + /// + public static readonly DwarfTagEx GNUCallSiteParameter = new DwarfTagEx(DwarfNative.DW_TAG_GNU_call_site_parameter); + + /// + /// ALTIUM + /// + public static readonly DwarfTagEx ALTIUMCircType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_circ_type); + + /// + /// ALTIUM + /// + public static readonly DwarfTagEx ALTIUMMwaCircType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_mwa_circ_type); + + /// + /// ALTIUM + /// + public static readonly DwarfTagEx ALTIUMRevCarryType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_rev_carry_type); + + /// + /// ALTIUM + /// + public static readonly DwarfTagEx ALTIUMRom = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_rom); + + /// + /// UPC + /// + public static readonly DwarfTagEx UpcSharedType = new DwarfTagEx(DwarfNative.DW_TAG_upc_shared_type); + + /// + /// UPC + /// + public static readonly DwarfTagEx UpcStrictType = new DwarfTagEx(DwarfNative.DW_TAG_upc_strict_type); + + /// + /// UPC + /// + public static readonly DwarfTagEx UpcRelaxedType = new DwarfTagEx(DwarfNative.DW_TAG_upc_relaxed_type); + + /// + /// PGI + /// + public static readonly DwarfTagEx PGIKanjiType = new DwarfTagEx(DwarfNative.DW_TAG_PGI_kanji_type); + + /// + /// PGI + /// + public static readonly DwarfTagEx PGIInterfaceBlock = new DwarfTagEx(DwarfNative.DW_TAG_PGI_interface_block); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNFunctionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_function_template); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNClassTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_class_template); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNStructTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_struct_template); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNUnionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_union_template); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNIndirectInheritance = new DwarfTagEx(DwarfNative.DW_TAG_SUN_indirect_inheritance); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNCodeflags = new DwarfTagEx(DwarfNative.DW_TAG_SUN_codeflags); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNMemopInfo = new DwarfTagEx(DwarfNative.DW_TAG_SUN_memop_info); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNOmpChildFunc = new DwarfTagEx(DwarfNative.DW_TAG_SUN_omp_child_func); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNRttiDescriptor = new DwarfTagEx(DwarfNative.DW_TAG_SUN_rtti_descriptor); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNDtorInfo = new DwarfTagEx(DwarfNative.DW_TAG_SUN_dtor_info); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNDtor = new DwarfTagEx(DwarfNative.DW_TAG_SUN_dtor); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNF90Interface = new DwarfTagEx(DwarfNative.DW_TAG_SUN_f90_interface); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNFortranVaxStructure = new DwarfTagEx(DwarfNative.DW_TAG_SUN_fortran_vax_structure); + + /// + /// SUN + /// + public static readonly DwarfTagEx SUNHi = new DwarfTagEx(DwarfNative.DW_TAG_SUN_hi); + + private string ToStringInternal() + { + switch ((ushort)Value) + { + case DwarfNative.DW_TAG_array_type: return "DW_TAG_array_type"; + case DwarfNative.DW_TAG_class_type: return "DW_TAG_class_type"; + case DwarfNative.DW_TAG_entry_point: return "DW_TAG_entry_point"; + case DwarfNative.DW_TAG_enumeration_type: return "DW_TAG_enumeration_type"; + case DwarfNative.DW_TAG_formal_parameter: return "DW_TAG_formal_parameter"; + case DwarfNative.DW_TAG_imported_declaration: return "DW_TAG_imported_declaration"; + case DwarfNative.DW_TAG_label: return "DW_TAG_label"; + case DwarfNative.DW_TAG_lexical_block: return "DW_TAG_lexical_block"; + case DwarfNative.DW_TAG_member: return "DW_TAG_member"; + case DwarfNative.DW_TAG_pointer_type: return "DW_TAG_pointer_type"; + case DwarfNative.DW_TAG_reference_type: return "DW_TAG_reference_type"; + case DwarfNative.DW_TAG_compile_unit: return "DW_TAG_compile_unit"; + case DwarfNative.DW_TAG_string_type: return "DW_TAG_string_type"; + case DwarfNative.DW_TAG_structure_type: return "DW_TAG_structure_type"; + case DwarfNative.DW_TAG_subroutine_type: return "DW_TAG_subroutine_type"; + case DwarfNative.DW_TAG_typedef: return "DW_TAG_typedef"; + case DwarfNative.DW_TAG_union_type: return "DW_TAG_union_type"; + case DwarfNative.DW_TAG_unspecified_parameters: return "DW_TAG_unspecified_parameters"; + case DwarfNative.DW_TAG_variant: return "DW_TAG_variant"; + case DwarfNative.DW_TAG_common_block: return "DW_TAG_common_block"; + case DwarfNative.DW_TAG_common_inclusion: return "DW_TAG_common_inclusion"; + case DwarfNative.DW_TAG_inheritance: return "DW_TAG_inheritance"; + case DwarfNative.DW_TAG_inlined_subroutine: return "DW_TAG_inlined_subroutine"; + case DwarfNative.DW_TAG_module: return "DW_TAG_module"; + case DwarfNative.DW_TAG_ptr_to_member_type: return "DW_TAG_ptr_to_member_type"; + case DwarfNative.DW_TAG_set_type: return "DW_TAG_set_type"; + case DwarfNative.DW_TAG_subrange_type: return "DW_TAG_subrange_type"; + case DwarfNative.DW_TAG_with_stmt: return "DW_TAG_with_stmt"; + case DwarfNative.DW_TAG_access_declaration: return "DW_TAG_access_declaration"; + case DwarfNative.DW_TAG_base_type: return "DW_TAG_base_type"; + case DwarfNative.DW_TAG_catch_block: return "DW_TAG_catch_block"; + case DwarfNative.DW_TAG_const_type: return "DW_TAG_const_type"; + case DwarfNative.DW_TAG_constant: return "DW_TAG_constant"; + case DwarfNative.DW_TAG_enumerator: return "DW_TAG_enumerator"; + case DwarfNative.DW_TAG_file_type: return "DW_TAG_file_type"; + case DwarfNative.DW_TAG_friend: return "DW_TAG_friend"; + case DwarfNative.DW_TAG_namelist: return "DW_TAG_namelist"; + case DwarfNative.DW_TAG_namelist_item: return "DW_TAG_namelist_item"; + case DwarfNative.DW_TAG_packed_type: return "DW_TAG_packed_type"; + case DwarfNative.DW_TAG_subprogram: return "DW_TAG_subprogram"; + case DwarfNative.DW_TAG_template_type_parameter: return "DW_TAG_template_type_parameter"; + case DwarfNative.DW_TAG_template_value_parameter: return "DW_TAG_template_value_parameter"; + case DwarfNative.DW_TAG_thrown_type: return "DW_TAG_thrown_type"; + case DwarfNative.DW_TAG_try_block: return "DW_TAG_try_block"; + case DwarfNative.DW_TAG_variant_part: return "DW_TAG_variant_part"; + case DwarfNative.DW_TAG_variable: return "DW_TAG_variable"; + case DwarfNative.DW_TAG_volatile_type: return "DW_TAG_volatile_type"; + case DwarfNative.DW_TAG_dwarf_procedure: return "DW_TAG_dwarf_procedure"; + case DwarfNative.DW_TAG_restrict_type: return "DW_TAG_restrict_type"; + case DwarfNative.DW_TAG_interface_type: return "DW_TAG_interface_type"; + case DwarfNative.DW_TAG_namespace: return "DW_TAG_namespace"; + case DwarfNative.DW_TAG_imported_module: return "DW_TAG_imported_module"; + case DwarfNative.DW_TAG_unspecified_type: return "DW_TAG_unspecified_type"; + case DwarfNative.DW_TAG_partial_unit: return "DW_TAG_partial_unit"; + case DwarfNative.DW_TAG_imported_unit: return "DW_TAG_imported_unit"; + case DwarfNative.DW_TAG_mutable_type: return "DW_TAG_mutable_type"; + case DwarfNative.DW_TAG_condition: return "DW_TAG_condition"; + case DwarfNative.DW_TAG_shared_type: return "DW_TAG_shared_type"; + case DwarfNative.DW_TAG_type_unit: return "DW_TAG_type_unit"; + case DwarfNative.DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type"; + case DwarfNative.DW_TAG_template_alias: return "DW_TAG_template_alias"; + case DwarfNative.DW_TAG_coarray_type: return "DW_TAG_coarray_type"; + case DwarfNative.DW_TAG_generic_subrange: return "DW_TAG_generic_subrange"; + case DwarfNative.DW_TAG_dynamic_type: return "DW_TAG_dynamic_type"; + case DwarfNative.DW_TAG_atomic_type: return "DW_TAG_atomic_type"; + case DwarfNative.DW_TAG_call_site: return "DW_TAG_call_site"; + case DwarfNative.DW_TAG_call_site_parameter: return "DW_TAG_call_site_parameter"; + case DwarfNative.DW_TAG_skeleton_unit: return "DW_TAG_skeleton_unit"; + case DwarfNative.DW_TAG_immutable_type: return "DW_TAG_immutable_type"; + case DwarfNative.DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; + case DwarfNative.DW_TAG_HP_array_descriptor: return "DW_TAG_HP_array_descriptor"; + case DwarfNative.DW_TAG_format_label: return "DW_TAG_format_label"; + case DwarfNative.DW_TAG_function_template: return "DW_TAG_function_template"; + case DwarfNative.DW_TAG_class_template: return "DW_TAG_class_template"; + case DwarfNative.DW_TAG_GNU_BINCL: return "DW_TAG_GNU_BINCL"; + case DwarfNative.DW_TAG_GNU_EINCL: return "DW_TAG_GNU_EINCL"; + case DwarfNative.DW_TAG_GNU_template_template_parameter: return "DW_TAG_GNU_template_template_parameter"; + case DwarfNative.DW_TAG_GNU_template_parameter_pack: return "DW_TAG_GNU_template_parameter_pack"; + case DwarfNative.DW_TAG_GNU_formal_parameter_pack: return "DW_TAG_GNU_formal_parameter_pack"; + case DwarfNative.DW_TAG_GNU_call_site: return "DW_TAG_GNU_call_site"; + case DwarfNative.DW_TAG_GNU_call_site_parameter: return "DW_TAG_GNU_call_site_parameter"; + case DwarfNative.DW_TAG_ALTIUM_circ_type: return "DW_TAG_ALTIUM_circ_type"; + case DwarfNative.DW_TAG_ALTIUM_mwa_circ_type: return "DW_TAG_ALTIUM_mwa_circ_type"; + case DwarfNative.DW_TAG_ALTIUM_rev_carry_type: return "DW_TAG_ALTIUM_rev_carry_type"; + case DwarfNative.DW_TAG_ALTIUM_rom: return "DW_TAG_ALTIUM_rom"; + case DwarfNative.DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type"; + case DwarfNative.DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type"; + case DwarfNative.DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type"; + case DwarfNative.DW_TAG_PGI_kanji_type: return "DW_TAG_PGI_kanji_type"; + case DwarfNative.DW_TAG_PGI_interface_block: return "DW_TAG_PGI_interface_block"; + case DwarfNative.DW_TAG_SUN_function_template: return "DW_TAG_SUN_function_template"; + case DwarfNative.DW_TAG_SUN_class_template: return "DW_TAG_SUN_class_template"; + case DwarfNative.DW_TAG_SUN_struct_template: return "DW_TAG_SUN_struct_template"; + case DwarfNative.DW_TAG_SUN_union_template: return "DW_TAG_SUN_union_template"; + case DwarfNative.DW_TAG_SUN_indirect_inheritance: return "DW_TAG_SUN_indirect_inheritance"; + case DwarfNative.DW_TAG_SUN_codeflags: return "DW_TAG_SUN_codeflags"; + case DwarfNative.DW_TAG_SUN_memop_info: return "DW_TAG_SUN_memop_info"; + case DwarfNative.DW_TAG_SUN_omp_child_func: return "DW_TAG_SUN_omp_child_func"; + case DwarfNative.DW_TAG_SUN_rtti_descriptor: return "DW_TAG_SUN_rtti_descriptor"; + case DwarfNative.DW_TAG_SUN_dtor_info: return "DW_TAG_SUN_dtor_info"; + case DwarfNative.DW_TAG_SUN_dtor: return "DW_TAG_SUN_dtor"; + case DwarfNative.DW_TAG_SUN_f90_interface: return "DW_TAG_SUN_f90_interface"; + case DwarfNative.DW_TAG_SUN_fortran_vax_structure: return "DW_TAG_SUN_fortran_vax_structure"; + case DwarfNative.DW_TAG_SUN_hi: return "DW_TAG_SUN_hi"; + default: return null; + } + } + } + + public enum DwarfTag : ushort + { + ArrayType = DwarfNative.DW_TAG_array_type, + + ClassType = DwarfNative.DW_TAG_class_type, + + EntryPoint = DwarfNative.DW_TAG_entry_point, + + EnumerationType = DwarfNative.DW_TAG_enumeration_type, + + FormalParameter = DwarfNative.DW_TAG_formal_parameter, + + ImportedDeclaration = DwarfNative.DW_TAG_imported_declaration, + + Label = DwarfNative.DW_TAG_label, + + LexicalBlock = DwarfNative.DW_TAG_lexical_block, + + Member = DwarfNative.DW_TAG_member, + + PointerType = DwarfNative.DW_TAG_pointer_type, + + ReferenceType = DwarfNative.DW_TAG_reference_type, + + CompileUnit = DwarfNative.DW_TAG_compile_unit, + + StringType = DwarfNative.DW_TAG_string_type, + + StructureType = DwarfNative.DW_TAG_structure_type, + + SubroutineType = DwarfNative.DW_TAG_subroutine_type, + + Typedef = DwarfNative.DW_TAG_typedef, + + UnionType = DwarfNative.DW_TAG_union_type, + + UnspecifiedParameters = DwarfNative.DW_TAG_unspecified_parameters, + + Variant = DwarfNative.DW_TAG_variant, + + CommonBlock = DwarfNative.DW_TAG_common_block, + + CommonInclusion = DwarfNative.DW_TAG_common_inclusion, + + Inheritance = DwarfNative.DW_TAG_inheritance, + + InlinedSubroutine = DwarfNative.DW_TAG_inlined_subroutine, + + Module = DwarfNative.DW_TAG_module, + + PtrToMemberType = DwarfNative.DW_TAG_ptr_to_member_type, + + SetType = DwarfNative.DW_TAG_set_type, + + SubrangeType = DwarfNative.DW_TAG_subrange_type, + + WithStmt = DwarfNative.DW_TAG_with_stmt, + + AccessDeclaration = DwarfNative.DW_TAG_access_declaration, + + BaseType = DwarfNative.DW_TAG_base_type, + + CatchBlock = DwarfNative.DW_TAG_catch_block, + + ConstType = DwarfNative.DW_TAG_const_type, + + Constant = DwarfNative.DW_TAG_constant, + + Enumerator = DwarfNative.DW_TAG_enumerator, + + FileType = DwarfNative.DW_TAG_file_type, + + Friend = DwarfNative.DW_TAG_friend, + + Namelist = DwarfNative.DW_TAG_namelist, + + NamelistItem = DwarfNative.DW_TAG_namelist_item, + + NamelistItems = DwarfNative.DW_TAG_namelist_items, + + PackedType = DwarfNative.DW_TAG_packed_type, + + Subprogram = DwarfNative.DW_TAG_subprogram, + + TemplateTypeParameter = DwarfNative.DW_TAG_template_type_parameter, + + TemplateTypeParam = DwarfNative.DW_TAG_template_type_param, + + TemplateValueParameter = DwarfNative.DW_TAG_template_value_parameter, + + TemplateValueParam = DwarfNative.DW_TAG_template_value_param, + + ThrownType = DwarfNative.DW_TAG_thrown_type, + + TryBlock = DwarfNative.DW_TAG_try_block, + + VariantPart = DwarfNative.DW_TAG_variant_part, + + Variable = DwarfNative.DW_TAG_variable, + + VolatileType = DwarfNative.DW_TAG_volatile_type, + + DwarfProcedure = DwarfNative.DW_TAG_dwarf_procedure, + + RestrictType = DwarfNative.DW_TAG_restrict_type, + + InterfaceType = DwarfNative.DW_TAG_interface_type, + + Namespace = DwarfNative.DW_TAG_namespace, + + ImportedModule = DwarfNative.DW_TAG_imported_module, + + UnspecifiedType = DwarfNative.DW_TAG_unspecified_type, + + PartialUnit = DwarfNative.DW_TAG_partial_unit, + + ImportedUnit = DwarfNative.DW_TAG_imported_unit, + + MutableType = DwarfNative.DW_TAG_mutable_type, + + Condition = DwarfNative.DW_TAG_condition, + + SharedType = DwarfNative.DW_TAG_shared_type, + + TypeUnit = DwarfNative.DW_TAG_type_unit, + + RvalueReferenceType = DwarfNative.DW_TAG_rvalue_reference_type, + + TemplateAlias = DwarfNative.DW_TAG_template_alias, + + CoarrayType = DwarfNative.DW_TAG_coarray_type, + + GenericSubrange = DwarfNative.DW_TAG_generic_subrange, + + DynamicType = DwarfNative.DW_TAG_dynamic_type, + + AtomicType = DwarfNative.DW_TAG_atomic_type, + + CallSite = DwarfNative.DW_TAG_call_site, + + CallSiteParameter = DwarfNative.DW_TAG_call_site_parameter, + + SkeletonUnit = DwarfNative.DW_TAG_skeleton_unit, + + ImmutableType = DwarfNative.DW_TAG_immutable_type, + + MIPSLoop = DwarfNative.DW_TAG_MIPS_loop, + + HPArrayDescriptor = DwarfNative.DW_TAG_HP_array_descriptor, + + FormatLabel = DwarfNative.DW_TAG_format_label, + + FunctionTemplate = DwarfNative.DW_TAG_function_template, + + ClassTemplate = DwarfNative.DW_TAG_class_template, + + GNUBINCL = DwarfNative.DW_TAG_GNU_BINCL, + + GNUEINCL = DwarfNative.DW_TAG_GNU_EINCL, + + GNUTemplateTemplateParameter = DwarfNative.DW_TAG_GNU_template_template_parameter, + + GNUTemplateTemplateParam = DwarfNative.DW_TAG_GNU_template_template_param, + + GNUTemplateParameterPack = DwarfNative.DW_TAG_GNU_template_parameter_pack, + + GNUFormalParameterPack = DwarfNative.DW_TAG_GNU_formal_parameter_pack, + + GNUCallSite = DwarfNative.DW_TAG_GNU_call_site, + + GNUCallSiteParameter = DwarfNative.DW_TAG_GNU_call_site_parameter, + + ALTIUMCircType = DwarfNative.DW_TAG_ALTIUM_circ_type, + + ALTIUMMwaCircType = DwarfNative.DW_TAG_ALTIUM_mwa_circ_type, + + ALTIUMRevCarryType = DwarfNative.DW_TAG_ALTIUM_rev_carry_type, + + ALTIUMRom = DwarfNative.DW_TAG_ALTIUM_rom, + + UpcSharedType = DwarfNative.DW_TAG_upc_shared_type, + + UpcStrictType = DwarfNative.DW_TAG_upc_strict_type, + + UpcRelaxedType = DwarfNative.DW_TAG_upc_relaxed_type, + + PGIKanjiType = DwarfNative.DW_TAG_PGI_kanji_type, + + PGIInterfaceBlock = DwarfNative.DW_TAG_PGI_interface_block, + + SUNFunctionTemplate = DwarfNative.DW_TAG_SUN_function_template, + + SUNClassTemplate = DwarfNative.DW_TAG_SUN_class_template, + + SUNStructTemplate = DwarfNative.DW_TAG_SUN_struct_template, + + SUNUnionTemplate = DwarfNative.DW_TAG_SUN_union_template, + + SUNIndirectInheritance = DwarfNative.DW_TAG_SUN_indirect_inheritance, + + SUNCodeflags = DwarfNative.DW_TAG_SUN_codeflags, + + SUNMemopInfo = DwarfNative.DW_TAG_SUN_memop_info, + + SUNOmpChildFunc = DwarfNative.DW_TAG_SUN_omp_child_func, + + SUNRttiDescriptor = DwarfNative.DW_TAG_SUN_rtti_descriptor, + + SUNDtorInfo = DwarfNative.DW_TAG_SUN_dtor_info, + + SUNDtor = DwarfNative.DW_TAG_SUN_dtor, + + SUNF90Interface = DwarfNative.DW_TAG_SUN_f90_interface, + + SUNFortranVaxStructure = DwarfNative.DW_TAG_SUN_fortran_vax_structure, + + SUNHi = DwarfNative.DW_TAG_SUN_hi, + } + + public readonly partial struct DwarfOperationKindEx + { + public static readonly DwarfOperationKindEx Addr = new DwarfOperationKindEx(DwarfNative.DW_OP_addr); + + public static readonly DwarfOperationKindEx Deref = new DwarfOperationKindEx(DwarfNative.DW_OP_deref); + + public static readonly DwarfOperationKindEx Const1u = new DwarfOperationKindEx(DwarfNative.DW_OP_const1u); + + public static readonly DwarfOperationKindEx Const1s = new DwarfOperationKindEx(DwarfNative.DW_OP_const1s); + + public static readonly DwarfOperationKindEx Const2u = new DwarfOperationKindEx(DwarfNative.DW_OP_const2u); + + public static readonly DwarfOperationKindEx Const2s = new DwarfOperationKindEx(DwarfNative.DW_OP_const2s); + + public static readonly DwarfOperationKindEx Const4u = new DwarfOperationKindEx(DwarfNative.DW_OP_const4u); + + public static readonly DwarfOperationKindEx Const4s = new DwarfOperationKindEx(DwarfNative.DW_OP_const4s); + + public static readonly DwarfOperationKindEx Const8u = new DwarfOperationKindEx(DwarfNative.DW_OP_const8u); + + public static readonly DwarfOperationKindEx Const8s = new DwarfOperationKindEx(DwarfNative.DW_OP_const8s); + + public static readonly DwarfOperationKindEx Constu = new DwarfOperationKindEx(DwarfNative.DW_OP_constu); + + public static readonly DwarfOperationKindEx Consts = new DwarfOperationKindEx(DwarfNative.DW_OP_consts); + + public static readonly DwarfOperationKindEx Dup = new DwarfOperationKindEx(DwarfNative.DW_OP_dup); + + public static readonly DwarfOperationKindEx Drop = new DwarfOperationKindEx(DwarfNative.DW_OP_drop); + + public static readonly DwarfOperationKindEx Over = new DwarfOperationKindEx(DwarfNative.DW_OP_over); + + public static readonly DwarfOperationKindEx Pick = new DwarfOperationKindEx(DwarfNative.DW_OP_pick); + + public static readonly DwarfOperationKindEx Swap = new DwarfOperationKindEx(DwarfNative.DW_OP_swap); + + public static readonly DwarfOperationKindEx Rot = new DwarfOperationKindEx(DwarfNative.DW_OP_rot); + + public static readonly DwarfOperationKindEx Xderef = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef); + + public static readonly DwarfOperationKindEx Abs = new DwarfOperationKindEx(DwarfNative.DW_OP_abs); + + public static readonly DwarfOperationKindEx And = new DwarfOperationKindEx(DwarfNative.DW_OP_and); + + public static readonly DwarfOperationKindEx Div = new DwarfOperationKindEx(DwarfNative.DW_OP_div); + + public static readonly DwarfOperationKindEx Minus = new DwarfOperationKindEx(DwarfNative.DW_OP_minus); + + public static readonly DwarfOperationKindEx Mod = new DwarfOperationKindEx(DwarfNative.DW_OP_mod); + + public static readonly DwarfOperationKindEx Mul = new DwarfOperationKindEx(DwarfNative.DW_OP_mul); + + public static readonly DwarfOperationKindEx Neg = new DwarfOperationKindEx(DwarfNative.DW_OP_neg); + + public static readonly DwarfOperationKindEx Not = new DwarfOperationKindEx(DwarfNative.DW_OP_not); + + public static readonly DwarfOperationKindEx Or = new DwarfOperationKindEx(DwarfNative.DW_OP_or); + + public static readonly DwarfOperationKindEx Plus = new DwarfOperationKindEx(DwarfNative.DW_OP_plus); + + public static readonly DwarfOperationKindEx PlusUconst = new DwarfOperationKindEx(DwarfNative.DW_OP_plus_uconst); + + public static readonly DwarfOperationKindEx Shl = new DwarfOperationKindEx(DwarfNative.DW_OP_shl); + + public static readonly DwarfOperationKindEx Shr = new DwarfOperationKindEx(DwarfNative.DW_OP_shr); + + public static readonly DwarfOperationKindEx Shra = new DwarfOperationKindEx(DwarfNative.DW_OP_shra); + + public static readonly DwarfOperationKindEx Xor = new DwarfOperationKindEx(DwarfNative.DW_OP_xor); + + public static readonly DwarfOperationKindEx Bra = new DwarfOperationKindEx(DwarfNative.DW_OP_bra); + + public static readonly DwarfOperationKindEx Eq = new DwarfOperationKindEx(DwarfNative.DW_OP_eq); + + public static readonly DwarfOperationKindEx Ge = new DwarfOperationKindEx(DwarfNative.DW_OP_ge); + + public static readonly DwarfOperationKindEx Gt = new DwarfOperationKindEx(DwarfNative.DW_OP_gt); + + public static readonly DwarfOperationKindEx Le = new DwarfOperationKindEx(DwarfNative.DW_OP_le); + + public static readonly DwarfOperationKindEx Lt = new DwarfOperationKindEx(DwarfNative.DW_OP_lt); + + public static readonly DwarfOperationKindEx Ne = new DwarfOperationKindEx(DwarfNative.DW_OP_ne); + + public static readonly DwarfOperationKindEx Skip = new DwarfOperationKindEx(DwarfNative.DW_OP_skip); + + public static readonly DwarfOperationKindEx Lit0 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit0); + + public static readonly DwarfOperationKindEx Lit1 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit1); + + public static readonly DwarfOperationKindEx Lit2 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit2); + + public static readonly DwarfOperationKindEx Lit3 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit3); + + public static readonly DwarfOperationKindEx Lit4 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit4); + + public static readonly DwarfOperationKindEx Lit5 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit5); + + public static readonly DwarfOperationKindEx Lit6 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit6); + + public static readonly DwarfOperationKindEx Lit7 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit7); + + public static readonly DwarfOperationKindEx Lit8 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit8); + + public static readonly DwarfOperationKindEx Lit9 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit9); + + public static readonly DwarfOperationKindEx Lit10 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit10); + + public static readonly DwarfOperationKindEx Lit11 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit11); + + public static readonly DwarfOperationKindEx Lit12 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit12); + + public static readonly DwarfOperationKindEx Lit13 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit13); + + public static readonly DwarfOperationKindEx Lit14 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit14); + + public static readonly DwarfOperationKindEx Lit15 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit15); + + public static readonly DwarfOperationKindEx Lit16 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit16); + + public static readonly DwarfOperationKindEx Lit17 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit17); + + public static readonly DwarfOperationKindEx Lit18 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit18); + + public static readonly DwarfOperationKindEx Lit19 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit19); + + public static readonly DwarfOperationKindEx Lit20 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit20); + + public static readonly DwarfOperationKindEx Lit21 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit21); + + public static readonly DwarfOperationKindEx Lit22 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit22); + + public static readonly DwarfOperationKindEx Lit23 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit23); + + public static readonly DwarfOperationKindEx Lit24 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit24); + + public static readonly DwarfOperationKindEx Lit25 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit25); + + public static readonly DwarfOperationKindEx Lit26 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit26); + + public static readonly DwarfOperationKindEx Lit27 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit27); + + public static readonly DwarfOperationKindEx Lit28 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit28); + + public static readonly DwarfOperationKindEx Lit29 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit29); + + public static readonly DwarfOperationKindEx Lit30 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit30); + + public static readonly DwarfOperationKindEx Lit31 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit31); + + public static readonly DwarfOperationKindEx Reg0 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg0); + + public static readonly DwarfOperationKindEx Reg1 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg1); + + public static readonly DwarfOperationKindEx Reg2 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg2); + + public static readonly DwarfOperationKindEx Reg3 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg3); + + public static readonly DwarfOperationKindEx Reg4 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg4); + + public static readonly DwarfOperationKindEx Reg5 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg5); + + public static readonly DwarfOperationKindEx Reg6 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg6); + + public static readonly DwarfOperationKindEx Reg7 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg7); + + public static readonly DwarfOperationKindEx Reg8 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg8); + + public static readonly DwarfOperationKindEx Reg9 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg9); + + public static readonly DwarfOperationKindEx Reg10 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg10); + + public static readonly DwarfOperationKindEx Reg11 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg11); + + public static readonly DwarfOperationKindEx Reg12 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg12); + + public static readonly DwarfOperationKindEx Reg13 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg13); + + public static readonly DwarfOperationKindEx Reg14 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg14); + + public static readonly DwarfOperationKindEx Reg15 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg15); + + public static readonly DwarfOperationKindEx Reg16 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg16); + + public static readonly DwarfOperationKindEx Reg17 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg17); + + public static readonly DwarfOperationKindEx Reg18 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg18); + + public static readonly DwarfOperationKindEx Reg19 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg19); + + public static readonly DwarfOperationKindEx Reg20 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg20); + + public static readonly DwarfOperationKindEx Reg21 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg21); + + public static readonly DwarfOperationKindEx Reg22 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg22); + + public static readonly DwarfOperationKindEx Reg23 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg23); + + public static readonly DwarfOperationKindEx Reg24 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg24); + + public static readonly DwarfOperationKindEx Reg25 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg25); + + public static readonly DwarfOperationKindEx Reg26 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg26); + + public static readonly DwarfOperationKindEx Reg27 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg27); + + public static readonly DwarfOperationKindEx Reg28 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg28); + + public static readonly DwarfOperationKindEx Reg29 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg29); + + public static readonly DwarfOperationKindEx Reg30 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg30); + + public static readonly DwarfOperationKindEx Reg31 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg31); + + public static readonly DwarfOperationKindEx Breg0 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg0); + + public static readonly DwarfOperationKindEx Breg1 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg1); + + public static readonly DwarfOperationKindEx Breg2 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg2); + + public static readonly DwarfOperationKindEx Breg3 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg3); + + public static readonly DwarfOperationKindEx Breg4 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg4); + + public static readonly DwarfOperationKindEx Breg5 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg5); + + public static readonly DwarfOperationKindEx Breg6 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg6); + + public static readonly DwarfOperationKindEx Breg7 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg7); + + public static readonly DwarfOperationKindEx Breg8 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg8); + + public static readonly DwarfOperationKindEx Breg9 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg9); + + public static readonly DwarfOperationKindEx Breg10 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg10); + + public static readonly DwarfOperationKindEx Breg11 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg11); + + public static readonly DwarfOperationKindEx Breg12 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg12); + + public static readonly DwarfOperationKindEx Breg13 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg13); + + public static readonly DwarfOperationKindEx Breg14 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg14); + + public static readonly DwarfOperationKindEx Breg15 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg15); + + public static readonly DwarfOperationKindEx Breg16 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg16); + + public static readonly DwarfOperationKindEx Breg17 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg17); + + public static readonly DwarfOperationKindEx Breg18 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg18); + + public static readonly DwarfOperationKindEx Breg19 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg19); + + public static readonly DwarfOperationKindEx Breg20 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg20); + + public static readonly DwarfOperationKindEx Breg21 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg21); + + public static readonly DwarfOperationKindEx Breg22 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg22); + + public static readonly DwarfOperationKindEx Breg23 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg23); + + public static readonly DwarfOperationKindEx Breg24 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg24); + + public static readonly DwarfOperationKindEx Breg25 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg25); + + public static readonly DwarfOperationKindEx Breg26 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg26); + + public static readonly DwarfOperationKindEx Breg27 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg27); + + public static readonly DwarfOperationKindEx Breg28 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg28); + + public static readonly DwarfOperationKindEx Breg29 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg29); + + public static readonly DwarfOperationKindEx Breg30 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg30); + + public static readonly DwarfOperationKindEx Breg31 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg31); + + public static readonly DwarfOperationKindEx Regx = new DwarfOperationKindEx(DwarfNative.DW_OP_regx); + + public static readonly DwarfOperationKindEx Fbreg = new DwarfOperationKindEx(DwarfNative.DW_OP_fbreg); + + public static readonly DwarfOperationKindEx Bregx = new DwarfOperationKindEx(DwarfNative.DW_OP_bregx); + + public static readonly DwarfOperationKindEx Piece = new DwarfOperationKindEx(DwarfNative.DW_OP_piece); + + public static readonly DwarfOperationKindEx DerefSize = new DwarfOperationKindEx(DwarfNative.DW_OP_deref_size); + + public static readonly DwarfOperationKindEx XderefSize = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef_size); + + public static readonly DwarfOperationKindEx Nop = new DwarfOperationKindEx(DwarfNative.DW_OP_nop); + + /// + /// DWARF3 + /// + public static readonly DwarfOperationKindEx PushObjectAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_push_object_address); + + /// + /// DWARF3 + /// + public static readonly DwarfOperationKindEx Call2 = new DwarfOperationKindEx(DwarfNative.DW_OP_call2); + + /// + /// DWARF3 + /// + public static readonly DwarfOperationKindEx Call4 = new DwarfOperationKindEx(DwarfNative.DW_OP_call4); + + /// + /// DWARF3 + /// + public static readonly DwarfOperationKindEx CallRef = new DwarfOperationKindEx(DwarfNative.DW_OP_call_ref); + + /// + /// DWARF3f + /// + public static readonly DwarfOperationKindEx FormTlsAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_form_tls_address); + + /// + /// DWARF3f + /// + public static readonly DwarfOperationKindEx CallFrameCfa = new DwarfOperationKindEx(DwarfNative.DW_OP_call_frame_cfa); + + /// + /// DWARF3f + /// + public static readonly DwarfOperationKindEx BitPiece = new DwarfOperationKindEx(DwarfNative.DW_OP_bit_piece); + + /// + /// DWARF4 + /// + public static readonly DwarfOperationKindEx ImplicitValue = new DwarfOperationKindEx(DwarfNative.DW_OP_implicit_value); + + /// + /// DWARF4 + /// + public static readonly DwarfOperationKindEx StackValue = new DwarfOperationKindEx(DwarfNative.DW_OP_stack_value); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx ImplicitPointer = new DwarfOperationKindEx(DwarfNative.DW_OP_implicit_pointer); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx Addrx = new DwarfOperationKindEx(DwarfNative.DW_OP_addrx); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx Constx = new DwarfOperationKindEx(DwarfNative.DW_OP_constx); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx EntryValue = new DwarfOperationKindEx(DwarfNative.DW_OP_entry_value); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx ConstType = new DwarfOperationKindEx(DwarfNative.DW_OP_const_type); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx RegvalType = new DwarfOperationKindEx(DwarfNative.DW_OP_regval_type); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx DerefType = new DwarfOperationKindEx(DwarfNative.DW_OP_deref_type); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx XderefType = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef_type); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx Convert = new DwarfOperationKindEx(DwarfNative.DW_OP_convert); + + /// + /// DWARF5 + /// + public static readonly DwarfOperationKindEx Reinterpret = new DwarfOperationKindEx(DwarfNative.DW_OP_reinterpret); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUPushTlsAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_push_tls_address); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUUninit = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_uninit); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUEncodedAddr = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_encoded_addr); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUImplicitPointer = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_implicit_pointer); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUEntryValue = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_entry_value); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUConstType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_const_type); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNURegvalType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_regval_type); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUDerefType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_deref_type); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUConvert = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_convert); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUReinterpret = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_reinterpret); + + /// + /// GNU + /// + public static readonly DwarfOperationKindEx GNUParameterRef = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_parameter_ref); + + /// + /// GNU DebugFission + /// + public static readonly DwarfOperationKindEx GNUAddrIndex = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_addr_index); + + /// + /// GNU DebugFission + /// + public static readonly DwarfOperationKindEx GNUConstIndex = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_const_index); + + /// + /// HP conflict: GNU + /// + public static readonly DwarfOperationKindEx HPUnknown = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_unknown); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPIsValue = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_is_value); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPFltconst4 = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_fltconst4); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPFltconst8 = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_fltconst8); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPModRange = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_mod_range); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPUnmodRange = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_unmod_range); + + /// + /// HP + /// + public static readonly DwarfOperationKindEx HPTls = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_tls); + + /// + /// Intel: made obsolete by DW_OP_bit_piece above. + /// + public static readonly DwarfOperationKindEx INTELBitPiece = new DwarfOperationKindEx(DwarfNative.DW_OP_INTEL_bit_piece); + + /// + /// Apple + /// + public static readonly DwarfOperationKindEx APPLEUninit = new DwarfOperationKindEx(DwarfNative.DW_OP_APPLE_uninit); + + /// + /// PGI (STMicroelectronics) + /// + public static readonly DwarfOperationKindEx PGIOmpThreadNum = new DwarfOperationKindEx(DwarfNative.DW_OP_PGI_omp_thread_num); + + private string ToStringInternal() + { + switch ((byte)Value) + { + case DwarfNative.DW_OP_addr: return "DW_OP_addr"; + case DwarfNative.DW_OP_deref: return "DW_OP_deref"; + case DwarfNative.DW_OP_const1u: return "DW_OP_const1u"; + case DwarfNative.DW_OP_const1s: return "DW_OP_const1s"; + case DwarfNative.DW_OP_const2u: return "DW_OP_const2u"; + case DwarfNative.DW_OP_const2s: return "DW_OP_const2s"; + case DwarfNative.DW_OP_const4u: return "DW_OP_const4u"; + case DwarfNative.DW_OP_const4s: return "DW_OP_const4s"; + case DwarfNative.DW_OP_const8u: return "DW_OP_const8u"; + case DwarfNative.DW_OP_const8s: return "DW_OP_const8s"; + case DwarfNative.DW_OP_constu: return "DW_OP_constu"; + case DwarfNative.DW_OP_consts: return "DW_OP_consts"; + case DwarfNative.DW_OP_dup: return "DW_OP_dup"; + case DwarfNative.DW_OP_drop: return "DW_OP_drop"; + case DwarfNative.DW_OP_over: return "DW_OP_over"; + case DwarfNative.DW_OP_pick: return "DW_OP_pick"; + case DwarfNative.DW_OP_swap: return "DW_OP_swap"; + case DwarfNative.DW_OP_rot: return "DW_OP_rot"; + case DwarfNative.DW_OP_xderef: return "DW_OP_xderef"; + case DwarfNative.DW_OP_abs: return "DW_OP_abs"; + case DwarfNative.DW_OP_and: return "DW_OP_and"; + case DwarfNative.DW_OP_div: return "DW_OP_div"; + case DwarfNative.DW_OP_minus: return "DW_OP_minus"; + case DwarfNative.DW_OP_mod: return "DW_OP_mod"; + case DwarfNative.DW_OP_mul: return "DW_OP_mul"; + case DwarfNative.DW_OP_neg: return "DW_OP_neg"; + case DwarfNative.DW_OP_not: return "DW_OP_not"; + case DwarfNative.DW_OP_or: return "DW_OP_or"; + case DwarfNative.DW_OP_plus: return "DW_OP_plus"; + case DwarfNative.DW_OP_plus_uconst: return "DW_OP_plus_uconst"; + case DwarfNative.DW_OP_shl: return "DW_OP_shl"; + case DwarfNative.DW_OP_shr: return "DW_OP_shr"; + case DwarfNative.DW_OP_shra: return "DW_OP_shra"; + case DwarfNative.DW_OP_xor: return "DW_OP_xor"; + case DwarfNative.DW_OP_bra: return "DW_OP_bra"; + case DwarfNative.DW_OP_eq: return "DW_OP_eq"; + case DwarfNative.DW_OP_ge: return "DW_OP_ge"; + case DwarfNative.DW_OP_gt: return "DW_OP_gt"; + case DwarfNative.DW_OP_le: return "DW_OP_le"; + case DwarfNative.DW_OP_lt: return "DW_OP_lt"; + case DwarfNative.DW_OP_ne: return "DW_OP_ne"; + case DwarfNative.DW_OP_skip: return "DW_OP_skip"; + case DwarfNative.DW_OP_lit0: return "DW_OP_lit0"; + case DwarfNative.DW_OP_lit1: return "DW_OP_lit1"; + case DwarfNative.DW_OP_lit2: return "DW_OP_lit2"; + case DwarfNative.DW_OP_lit3: return "DW_OP_lit3"; + case DwarfNative.DW_OP_lit4: return "DW_OP_lit4"; + case DwarfNative.DW_OP_lit5: return "DW_OP_lit5"; + case DwarfNative.DW_OP_lit6: return "DW_OP_lit6"; + case DwarfNative.DW_OP_lit7: return "DW_OP_lit7"; + case DwarfNative.DW_OP_lit8: return "DW_OP_lit8"; + case DwarfNative.DW_OP_lit9: return "DW_OP_lit9"; + case DwarfNative.DW_OP_lit10: return "DW_OP_lit10"; + case DwarfNative.DW_OP_lit11: return "DW_OP_lit11"; + case DwarfNative.DW_OP_lit12: return "DW_OP_lit12"; + case DwarfNative.DW_OP_lit13: return "DW_OP_lit13"; + case DwarfNative.DW_OP_lit14: return "DW_OP_lit14"; + case DwarfNative.DW_OP_lit15: return "DW_OP_lit15"; + case DwarfNative.DW_OP_lit16: return "DW_OP_lit16"; + case DwarfNative.DW_OP_lit17: return "DW_OP_lit17"; + case DwarfNative.DW_OP_lit18: return "DW_OP_lit18"; + case DwarfNative.DW_OP_lit19: return "DW_OP_lit19"; + case DwarfNative.DW_OP_lit20: return "DW_OP_lit20"; + case DwarfNative.DW_OP_lit21: return "DW_OP_lit21"; + case DwarfNative.DW_OP_lit22: return "DW_OP_lit22"; + case DwarfNative.DW_OP_lit23: return "DW_OP_lit23"; + case DwarfNative.DW_OP_lit24: return "DW_OP_lit24"; + case DwarfNative.DW_OP_lit25: return "DW_OP_lit25"; + case DwarfNative.DW_OP_lit26: return "DW_OP_lit26"; + case DwarfNative.DW_OP_lit27: return "DW_OP_lit27"; + case DwarfNative.DW_OP_lit28: return "DW_OP_lit28"; + case DwarfNative.DW_OP_lit29: return "DW_OP_lit29"; + case DwarfNative.DW_OP_lit30: return "DW_OP_lit30"; + case DwarfNative.DW_OP_lit31: return "DW_OP_lit31"; + case DwarfNative.DW_OP_reg0: return "DW_OP_reg0"; + case DwarfNative.DW_OP_reg1: return "DW_OP_reg1"; + case DwarfNative.DW_OP_reg2: return "DW_OP_reg2"; + case DwarfNative.DW_OP_reg3: return "DW_OP_reg3"; + case DwarfNative.DW_OP_reg4: return "DW_OP_reg4"; + case DwarfNative.DW_OP_reg5: return "DW_OP_reg5"; + case DwarfNative.DW_OP_reg6: return "DW_OP_reg6"; + case DwarfNative.DW_OP_reg7: return "DW_OP_reg7"; + case DwarfNative.DW_OP_reg8: return "DW_OP_reg8"; + case DwarfNative.DW_OP_reg9: return "DW_OP_reg9"; + case DwarfNative.DW_OP_reg10: return "DW_OP_reg10"; + case DwarfNative.DW_OP_reg11: return "DW_OP_reg11"; + case DwarfNative.DW_OP_reg12: return "DW_OP_reg12"; + case DwarfNative.DW_OP_reg13: return "DW_OP_reg13"; + case DwarfNative.DW_OP_reg14: return "DW_OP_reg14"; + case DwarfNative.DW_OP_reg15: return "DW_OP_reg15"; + case DwarfNative.DW_OP_reg16: return "DW_OP_reg16"; + case DwarfNative.DW_OP_reg17: return "DW_OP_reg17"; + case DwarfNative.DW_OP_reg18: return "DW_OP_reg18"; + case DwarfNative.DW_OP_reg19: return "DW_OP_reg19"; + case DwarfNative.DW_OP_reg20: return "DW_OP_reg20"; + case DwarfNative.DW_OP_reg21: return "DW_OP_reg21"; + case DwarfNative.DW_OP_reg22: return "DW_OP_reg22"; + case DwarfNative.DW_OP_reg23: return "DW_OP_reg23"; + case DwarfNative.DW_OP_reg24: return "DW_OP_reg24"; + case DwarfNative.DW_OP_reg25: return "DW_OP_reg25"; + case DwarfNative.DW_OP_reg26: return "DW_OP_reg26"; + case DwarfNative.DW_OP_reg27: return "DW_OP_reg27"; + case DwarfNative.DW_OP_reg28: return "DW_OP_reg28"; + case DwarfNative.DW_OP_reg29: return "DW_OP_reg29"; + case DwarfNative.DW_OP_reg30: return "DW_OP_reg30"; + case DwarfNative.DW_OP_reg31: return "DW_OP_reg31"; + case DwarfNative.DW_OP_breg0: return "DW_OP_breg0"; + case DwarfNative.DW_OP_breg1: return "DW_OP_breg1"; + case DwarfNative.DW_OP_breg2: return "DW_OP_breg2"; + case DwarfNative.DW_OP_breg3: return "DW_OP_breg3"; + case DwarfNative.DW_OP_breg4: return "DW_OP_breg4"; + case DwarfNative.DW_OP_breg5: return "DW_OP_breg5"; + case DwarfNative.DW_OP_breg6: return "DW_OP_breg6"; + case DwarfNative.DW_OP_breg7: return "DW_OP_breg7"; + case DwarfNative.DW_OP_breg8: return "DW_OP_breg8"; + case DwarfNative.DW_OP_breg9: return "DW_OP_breg9"; + case DwarfNative.DW_OP_breg10: return "DW_OP_breg10"; + case DwarfNative.DW_OP_breg11: return "DW_OP_breg11"; + case DwarfNative.DW_OP_breg12: return "DW_OP_breg12"; + case DwarfNative.DW_OP_breg13: return "DW_OP_breg13"; + case DwarfNative.DW_OP_breg14: return "DW_OP_breg14"; + case DwarfNative.DW_OP_breg15: return "DW_OP_breg15"; + case DwarfNative.DW_OP_breg16: return "DW_OP_breg16"; + case DwarfNative.DW_OP_breg17: return "DW_OP_breg17"; + case DwarfNative.DW_OP_breg18: return "DW_OP_breg18"; + case DwarfNative.DW_OP_breg19: return "DW_OP_breg19"; + case DwarfNative.DW_OP_breg20: return "DW_OP_breg20"; + case DwarfNative.DW_OP_breg21: return "DW_OP_breg21"; + case DwarfNative.DW_OP_breg22: return "DW_OP_breg22"; + case DwarfNative.DW_OP_breg23: return "DW_OP_breg23"; + case DwarfNative.DW_OP_breg24: return "DW_OP_breg24"; + case DwarfNative.DW_OP_breg25: return "DW_OP_breg25"; + case DwarfNative.DW_OP_breg26: return "DW_OP_breg26"; + case DwarfNative.DW_OP_breg27: return "DW_OP_breg27"; + case DwarfNative.DW_OP_breg28: return "DW_OP_breg28"; + case DwarfNative.DW_OP_breg29: return "DW_OP_breg29"; + case DwarfNative.DW_OP_breg30: return "DW_OP_breg30"; + case DwarfNative.DW_OP_breg31: return "DW_OP_breg31"; + case DwarfNative.DW_OP_regx: return "DW_OP_regx"; + case DwarfNative.DW_OP_fbreg: return "DW_OP_fbreg"; + case DwarfNative.DW_OP_bregx: return "DW_OP_bregx"; + case DwarfNative.DW_OP_piece: return "DW_OP_piece"; + case DwarfNative.DW_OP_deref_size: return "DW_OP_deref_size"; + case DwarfNative.DW_OP_xderef_size: return "DW_OP_xderef_size"; + case DwarfNative.DW_OP_nop: return "DW_OP_nop"; + case DwarfNative.DW_OP_push_object_address: return "DW_OP_push_object_address"; + case DwarfNative.DW_OP_call2: return "DW_OP_call2"; + case DwarfNative.DW_OP_call4: return "DW_OP_call4"; + case DwarfNative.DW_OP_call_ref: return "DW_OP_call_ref"; + case DwarfNative.DW_OP_form_tls_address: return "DW_OP_form_tls_address"; + case DwarfNative.DW_OP_call_frame_cfa: return "DW_OP_call_frame_cfa"; + case DwarfNative.DW_OP_bit_piece: return "DW_OP_bit_piece"; + case DwarfNative.DW_OP_implicit_value: return "DW_OP_implicit_value"; + case DwarfNative.DW_OP_stack_value: return "DW_OP_stack_value"; + case DwarfNative.DW_OP_implicit_pointer: return "DW_OP_implicit_pointer"; + case DwarfNative.DW_OP_addrx: return "DW_OP_addrx"; + case DwarfNative.DW_OP_constx: return "DW_OP_constx"; + case DwarfNative.DW_OP_entry_value: return "DW_OP_entry_value"; + case DwarfNative.DW_OP_const_type: return "DW_OP_const_type"; + case DwarfNative.DW_OP_regval_type: return "DW_OP_regval_type"; + case DwarfNative.DW_OP_deref_type: return "DW_OP_deref_type"; + case DwarfNative.DW_OP_xderef_type: return "DW_OP_xderef_type"; + case DwarfNative.DW_OP_convert: return "DW_OP_convert"; + case DwarfNative.DW_OP_reinterpret: return "DW_OP_reinterpret"; + case DwarfNative.DW_OP_GNU_push_tls_address: return "DW_OP_GNU_push_tls_address"; + case DwarfNative.DW_OP_GNU_uninit: return "DW_OP_GNU_uninit"; + case DwarfNative.DW_OP_GNU_encoded_addr: return "DW_OP_GNU_encoded_addr"; + case DwarfNative.DW_OP_GNU_implicit_pointer: return "DW_OP_GNU_implicit_pointer"; + case DwarfNative.DW_OP_GNU_entry_value: return "DW_OP_GNU_entry_value"; + case DwarfNative.DW_OP_GNU_const_type: return "DW_OP_GNU_const_type"; + case DwarfNative.DW_OP_GNU_regval_type: return "DW_OP_GNU_regval_type"; + case DwarfNative.DW_OP_GNU_deref_type: return "DW_OP_GNU_deref_type"; + case DwarfNative.DW_OP_GNU_convert: return "DW_OP_GNU_convert"; + case DwarfNative.DW_OP_GNU_reinterpret: return "DW_OP_GNU_reinterpret"; + case DwarfNative.DW_OP_GNU_parameter_ref: return "DW_OP_GNU_parameter_ref"; + case DwarfNative.DW_OP_GNU_addr_index: return "DW_OP_GNU_addr_index"; + case DwarfNative.DW_OP_GNU_const_index: return "DW_OP_GNU_const_index"; + case DwarfNative.DW_OP_HP_is_value: return "DW_OP_HP_is_value"; + case DwarfNative.DW_OP_HP_fltconst4: return "DW_OP_HP_fltconst4"; + case DwarfNative.DW_OP_HP_fltconst8: return "DW_OP_HP_fltconst8"; + case DwarfNative.DW_OP_HP_mod_range: return "DW_OP_HP_mod_range"; + case DwarfNative.DW_OP_HP_unmod_range: return "DW_OP_HP_unmod_range"; + case DwarfNative.DW_OP_HP_tls: return "DW_OP_HP_tls"; + case DwarfNative.DW_OP_INTEL_bit_piece: return "DW_OP_INTEL_bit_piece"; + case DwarfNative.DW_OP_PGI_omp_thread_num: return "DW_OP_PGI_omp_thread_num"; + default: return null; + } + } + } + + public enum DwarfOperationKind : byte + { + Addr = DwarfNative.DW_OP_addr, + + Deref = DwarfNative.DW_OP_deref, + + Const1u = DwarfNative.DW_OP_const1u, + + Const1s = DwarfNative.DW_OP_const1s, + + Const2u = DwarfNative.DW_OP_const2u, + + Const2s = DwarfNative.DW_OP_const2s, + + Const4u = DwarfNative.DW_OP_const4u, + + Const4s = DwarfNative.DW_OP_const4s, + + Const8u = DwarfNative.DW_OP_const8u, + + Const8s = DwarfNative.DW_OP_const8s, + + Constu = DwarfNative.DW_OP_constu, + + Consts = DwarfNative.DW_OP_consts, + + Dup = DwarfNative.DW_OP_dup, + + Drop = DwarfNative.DW_OP_drop, + + Over = DwarfNative.DW_OP_over, + + Pick = DwarfNative.DW_OP_pick, + + Swap = DwarfNative.DW_OP_swap, + + Rot = DwarfNative.DW_OP_rot, + + Xderef = DwarfNative.DW_OP_xderef, + + Abs = DwarfNative.DW_OP_abs, + + And = DwarfNative.DW_OP_and, + + Div = DwarfNative.DW_OP_div, + + Minus = DwarfNative.DW_OP_minus, + + Mod = DwarfNative.DW_OP_mod, + + Mul = DwarfNative.DW_OP_mul, + + Neg = DwarfNative.DW_OP_neg, + + Not = DwarfNative.DW_OP_not, + + Or = DwarfNative.DW_OP_or, + + Plus = DwarfNative.DW_OP_plus, + + PlusUconst = DwarfNative.DW_OP_plus_uconst, + + Shl = DwarfNative.DW_OP_shl, + + Shr = DwarfNative.DW_OP_shr, + + Shra = DwarfNative.DW_OP_shra, + + Xor = DwarfNative.DW_OP_xor, + + Bra = DwarfNative.DW_OP_bra, + + Eq = DwarfNative.DW_OP_eq, + + Ge = DwarfNative.DW_OP_ge, + + Gt = DwarfNative.DW_OP_gt, + + Le = DwarfNative.DW_OP_le, + + Lt = DwarfNative.DW_OP_lt, + + Ne = DwarfNative.DW_OP_ne, + + Skip = DwarfNative.DW_OP_skip, + + Lit0 = DwarfNative.DW_OP_lit0, + + Lit1 = DwarfNative.DW_OP_lit1, + + Lit2 = DwarfNative.DW_OP_lit2, + + Lit3 = DwarfNative.DW_OP_lit3, + + Lit4 = DwarfNative.DW_OP_lit4, + + Lit5 = DwarfNative.DW_OP_lit5, + + Lit6 = DwarfNative.DW_OP_lit6, + + Lit7 = DwarfNative.DW_OP_lit7, + + Lit8 = DwarfNative.DW_OP_lit8, + + Lit9 = DwarfNative.DW_OP_lit9, + + Lit10 = DwarfNative.DW_OP_lit10, + + Lit11 = DwarfNative.DW_OP_lit11, + + Lit12 = DwarfNative.DW_OP_lit12, + + Lit13 = DwarfNative.DW_OP_lit13, + + Lit14 = DwarfNative.DW_OP_lit14, + + Lit15 = DwarfNative.DW_OP_lit15, + + Lit16 = DwarfNative.DW_OP_lit16, + + Lit17 = DwarfNative.DW_OP_lit17, + + Lit18 = DwarfNative.DW_OP_lit18, + + Lit19 = DwarfNative.DW_OP_lit19, + + Lit20 = DwarfNative.DW_OP_lit20, + + Lit21 = DwarfNative.DW_OP_lit21, + + Lit22 = DwarfNative.DW_OP_lit22, + + Lit23 = DwarfNative.DW_OP_lit23, + + Lit24 = DwarfNative.DW_OP_lit24, + + Lit25 = DwarfNative.DW_OP_lit25, + + Lit26 = DwarfNative.DW_OP_lit26, + + Lit27 = DwarfNative.DW_OP_lit27, + + Lit28 = DwarfNative.DW_OP_lit28, + + Lit29 = DwarfNative.DW_OP_lit29, + + Lit30 = DwarfNative.DW_OP_lit30, + + Lit31 = DwarfNative.DW_OP_lit31, + + Reg0 = DwarfNative.DW_OP_reg0, + + Reg1 = DwarfNative.DW_OP_reg1, + + Reg2 = DwarfNative.DW_OP_reg2, + + Reg3 = DwarfNative.DW_OP_reg3, + + Reg4 = DwarfNative.DW_OP_reg4, + + Reg5 = DwarfNative.DW_OP_reg5, + + Reg6 = DwarfNative.DW_OP_reg6, + + Reg7 = DwarfNative.DW_OP_reg7, + + Reg8 = DwarfNative.DW_OP_reg8, + + Reg9 = DwarfNative.DW_OP_reg9, + + Reg10 = DwarfNative.DW_OP_reg10, + + Reg11 = DwarfNative.DW_OP_reg11, + + Reg12 = DwarfNative.DW_OP_reg12, + + Reg13 = DwarfNative.DW_OP_reg13, + + Reg14 = DwarfNative.DW_OP_reg14, + + Reg15 = DwarfNative.DW_OP_reg15, + + Reg16 = DwarfNative.DW_OP_reg16, + + Reg17 = DwarfNative.DW_OP_reg17, + + Reg18 = DwarfNative.DW_OP_reg18, + + Reg19 = DwarfNative.DW_OP_reg19, + + Reg20 = DwarfNative.DW_OP_reg20, + + Reg21 = DwarfNative.DW_OP_reg21, + + Reg22 = DwarfNative.DW_OP_reg22, + + Reg23 = DwarfNative.DW_OP_reg23, + + Reg24 = DwarfNative.DW_OP_reg24, + + Reg25 = DwarfNative.DW_OP_reg25, + + Reg26 = DwarfNative.DW_OP_reg26, + + Reg27 = DwarfNative.DW_OP_reg27, + + Reg28 = DwarfNative.DW_OP_reg28, + + Reg29 = DwarfNative.DW_OP_reg29, + + Reg30 = DwarfNative.DW_OP_reg30, + + Reg31 = DwarfNative.DW_OP_reg31, + + Breg0 = DwarfNative.DW_OP_breg0, + + Breg1 = DwarfNative.DW_OP_breg1, + + Breg2 = DwarfNative.DW_OP_breg2, + + Breg3 = DwarfNative.DW_OP_breg3, + + Breg4 = DwarfNative.DW_OP_breg4, + + Breg5 = DwarfNative.DW_OP_breg5, + + Breg6 = DwarfNative.DW_OP_breg6, + + Breg7 = DwarfNative.DW_OP_breg7, + + Breg8 = DwarfNative.DW_OP_breg8, + + Breg9 = DwarfNative.DW_OP_breg9, + + Breg10 = DwarfNative.DW_OP_breg10, + + Breg11 = DwarfNative.DW_OP_breg11, + + Breg12 = DwarfNative.DW_OP_breg12, + + Breg13 = DwarfNative.DW_OP_breg13, + + Breg14 = DwarfNative.DW_OP_breg14, + + Breg15 = DwarfNative.DW_OP_breg15, + + Breg16 = DwarfNative.DW_OP_breg16, + + Breg17 = DwarfNative.DW_OP_breg17, + + Breg18 = DwarfNative.DW_OP_breg18, + + Breg19 = DwarfNative.DW_OP_breg19, + + Breg20 = DwarfNative.DW_OP_breg20, + + Breg21 = DwarfNative.DW_OP_breg21, + + Breg22 = DwarfNative.DW_OP_breg22, + + Breg23 = DwarfNative.DW_OP_breg23, + + Breg24 = DwarfNative.DW_OP_breg24, + + Breg25 = DwarfNative.DW_OP_breg25, + + Breg26 = DwarfNative.DW_OP_breg26, + + Breg27 = DwarfNative.DW_OP_breg27, + + Breg28 = DwarfNative.DW_OP_breg28, + + Breg29 = DwarfNative.DW_OP_breg29, + + Breg30 = DwarfNative.DW_OP_breg30, + + Breg31 = DwarfNative.DW_OP_breg31, + + Regx = DwarfNative.DW_OP_regx, + + Fbreg = DwarfNative.DW_OP_fbreg, + + Bregx = DwarfNative.DW_OP_bregx, + + Piece = DwarfNative.DW_OP_piece, + + DerefSize = DwarfNative.DW_OP_deref_size, + + XderefSize = DwarfNative.DW_OP_xderef_size, + + Nop = DwarfNative.DW_OP_nop, + + PushObjectAddress = DwarfNative.DW_OP_push_object_address, + + Call2 = DwarfNative.DW_OP_call2, + + Call4 = DwarfNative.DW_OP_call4, + + CallRef = DwarfNative.DW_OP_call_ref, + + FormTlsAddress = DwarfNative.DW_OP_form_tls_address, + + CallFrameCfa = DwarfNative.DW_OP_call_frame_cfa, + + BitPiece = DwarfNative.DW_OP_bit_piece, + + ImplicitValue = DwarfNative.DW_OP_implicit_value, + + StackValue = DwarfNative.DW_OP_stack_value, + + ImplicitPointer = DwarfNative.DW_OP_implicit_pointer, + + Addrx = DwarfNative.DW_OP_addrx, + + Constx = DwarfNative.DW_OP_constx, + + EntryValue = DwarfNative.DW_OP_entry_value, + + ConstType = DwarfNative.DW_OP_const_type, + + RegvalType = DwarfNative.DW_OP_regval_type, + + DerefType = DwarfNative.DW_OP_deref_type, + + XderefType = DwarfNative.DW_OP_xderef_type, + + Convert = DwarfNative.DW_OP_convert, + + Reinterpret = DwarfNative.DW_OP_reinterpret, + + GNUPushTlsAddress = DwarfNative.DW_OP_GNU_push_tls_address, + + GNUUninit = DwarfNative.DW_OP_GNU_uninit, + + GNUEncodedAddr = DwarfNative.DW_OP_GNU_encoded_addr, + + GNUImplicitPointer = DwarfNative.DW_OP_GNU_implicit_pointer, + + GNUEntryValue = DwarfNative.DW_OP_GNU_entry_value, + + GNUConstType = DwarfNative.DW_OP_GNU_const_type, + + GNURegvalType = DwarfNative.DW_OP_GNU_regval_type, + + GNUDerefType = DwarfNative.DW_OP_GNU_deref_type, + + GNUConvert = DwarfNative.DW_OP_GNU_convert, + + GNUReinterpret = DwarfNative.DW_OP_GNU_reinterpret, + + GNUParameterRef = DwarfNative.DW_OP_GNU_parameter_ref, + + GNUAddrIndex = DwarfNative.DW_OP_GNU_addr_index, + + GNUConstIndex = DwarfNative.DW_OP_GNU_const_index, + + HPUnknown = DwarfNative.DW_OP_HP_unknown, + + HPIsValue = DwarfNative.DW_OP_HP_is_value, + + HPFltconst4 = DwarfNative.DW_OP_HP_fltconst4, + + HPFltconst8 = DwarfNative.DW_OP_HP_fltconst8, + + HPModRange = DwarfNative.DW_OP_HP_mod_range, + + HPUnmodRange = DwarfNative.DW_OP_HP_unmod_range, + + HPTls = DwarfNative.DW_OP_HP_tls, + + INTELBitPiece = DwarfNative.DW_OP_INTEL_bit_piece, + + APPLEUninit = DwarfNative.DW_OP_APPLE_uninit, + + PGIOmpThreadNum = DwarfNative.DW_OP_PGI_omp_thread_num, + } + + public readonly partial struct DwarfLanguageKindEx + { + public static readonly DwarfLanguageKindEx C89 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C89); + + public static readonly DwarfLanguageKindEx C = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C); + + public static readonly DwarfLanguageKindEx Ada83 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Ada83); + + public static readonly DwarfLanguageKindEx CPlusPlus = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus); + + public static readonly DwarfLanguageKindEx Cobol74 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Cobol74); + + public static readonly DwarfLanguageKindEx Cobol85 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Cobol85); + + public static readonly DwarfLanguageKindEx Fortran77 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran77); + + public static readonly DwarfLanguageKindEx Fortran90 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran90); + + public static readonly DwarfLanguageKindEx Pascal83 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Pascal83); + + public static readonly DwarfLanguageKindEx Modula2 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Modula2); + + /// + /// DWARF3 + /// + public static readonly DwarfLanguageKindEx Java = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Java); + + /// + /// DWARF3 + /// + public static readonly DwarfLanguageKindEx C99 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C99); + + /// + /// DWARF3 + /// + public static readonly DwarfLanguageKindEx Ada95 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Ada95); + + /// + /// DWARF3 + /// + public static readonly DwarfLanguageKindEx Fortran95 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran95); + + /// + /// DWARF3 + /// + public static readonly DwarfLanguageKindEx PLI = new DwarfLanguageKindEx(DwarfNative.DW_LANG_PLI); + + /// + /// DWARF3f + /// + public static readonly DwarfLanguageKindEx ObjC = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ObjC); + + /// + /// DWARF3f + /// + public static readonly DwarfLanguageKindEx ObjCPlusPlus = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ObjC_plus_plus); + + /// + /// DWARF3f + /// + public static readonly DwarfLanguageKindEx UPC = new DwarfLanguageKindEx(DwarfNative.DW_LANG_UPC); + + /// + /// DWARF3f + /// + public static readonly DwarfLanguageKindEx D = new DwarfLanguageKindEx(DwarfNative.DW_LANG_D); + + /// + /// DWARF4 + /// + public static readonly DwarfLanguageKindEx Python = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Python); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx OpenCL = new DwarfLanguageKindEx(DwarfNative.DW_LANG_OpenCL); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Go = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Go); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Modula3 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Modula3); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Haskel = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Haskel); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx CPlusPlus03 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_03); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx CPlusPlus11 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_11); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx OCaml = new DwarfLanguageKindEx(DwarfNative.DW_LANG_OCaml); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Rust = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Rust); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx C11 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C11); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Swift = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Swift); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Julia = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Julia); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Dylan = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Dylan); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx CPlusPlus14 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_14); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Fortran03 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran03); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx Fortran08 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran08); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx RenderScript = new DwarfLanguageKindEx(DwarfNative.DW_LANG_RenderScript); + + /// + /// DWARF5 + /// + public static readonly DwarfLanguageKindEx BLISS = new DwarfLanguageKindEx(DwarfNative.DW_LANG_BLISS); + + /// + /// MIPS + /// + public static readonly DwarfLanguageKindEx MipsAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Mips_Assembler); + + /// + /// UPC, use + /// DW_LANG_UPC instead. + /// + public static readonly DwarfLanguageKindEx Upc = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Upc); + + /// + /// ALTIUM + /// + public static readonly DwarfLanguageKindEx ALTIUMAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ALTIUM_Assembler); + + /// + /// SUN + /// + public static readonly DwarfLanguageKindEx SUNAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_SUN_Assembler); + + private string ToStringInternal() + { + switch ((ushort)Value) + { + case DwarfNative.DW_LANG_C89: return "DW_LANG_C89"; + case DwarfNative.DW_LANG_C: return "DW_LANG_C"; + case DwarfNative.DW_LANG_Ada83: return "DW_LANG_Ada83"; + case DwarfNative.DW_LANG_C_plus_plus: return "DW_LANG_C_plus_plus"; + case DwarfNative.DW_LANG_Cobol74: return "DW_LANG_Cobol74"; + case DwarfNative.DW_LANG_Cobol85: return "DW_LANG_Cobol85"; + case DwarfNative.DW_LANG_Fortran77: return "DW_LANG_Fortran77"; + case DwarfNative.DW_LANG_Fortran90: return "DW_LANG_Fortran90"; + case DwarfNative.DW_LANG_Pascal83: return "DW_LANG_Pascal83"; + case DwarfNative.DW_LANG_Modula2: return "DW_LANG_Modula2"; + case DwarfNative.DW_LANG_Java: return "DW_LANG_Java"; + case DwarfNative.DW_LANG_C99: return "DW_LANG_C99"; + case DwarfNative.DW_LANG_Ada95: return "DW_LANG_Ada95"; + case DwarfNative.DW_LANG_Fortran95: return "DW_LANG_Fortran95"; + case DwarfNative.DW_LANG_PLI: return "DW_LANG_PLI"; + case DwarfNative.DW_LANG_ObjC: return "DW_LANG_ObjC"; + case DwarfNative.DW_LANG_ObjC_plus_plus: return "DW_LANG_ObjC_plus_plus"; + case DwarfNative.DW_LANG_UPC: return "DW_LANG_UPC"; + case DwarfNative.DW_LANG_D: return "DW_LANG_D"; + case DwarfNative.DW_LANG_Python: return "DW_LANG_Python"; + case DwarfNative.DW_LANG_OpenCL: return "DW_LANG_OpenCL"; + case DwarfNative.DW_LANG_Go: return "DW_LANG_Go"; + case DwarfNative.DW_LANG_Modula3: return "DW_LANG_Modula3"; + case DwarfNative.DW_LANG_Haskel: return "DW_LANG_Haskel"; + case DwarfNative.DW_LANG_C_plus_plus_03: return "DW_LANG_C_plus_plus_03"; + case DwarfNative.DW_LANG_C_plus_plus_11: return "DW_LANG_C_plus_plus_11"; + case DwarfNative.DW_LANG_OCaml: return "DW_LANG_OCaml"; + case DwarfNative.DW_LANG_Rust: return "DW_LANG_Rust"; + case DwarfNative.DW_LANG_C11: return "DW_LANG_C11"; + case DwarfNative.DW_LANG_Swift: return "DW_LANG_Swift"; + case DwarfNative.DW_LANG_Julia: return "DW_LANG_Julia"; + case DwarfNative.DW_LANG_Dylan: return "DW_LANG_Dylan"; + case DwarfNative.DW_LANG_C_plus_plus_14: return "DW_LANG_C_plus_plus_14"; + case DwarfNative.DW_LANG_Fortran03: return "DW_LANG_Fortran03"; + case DwarfNative.DW_LANG_Fortran08: return "DW_LANG_Fortran08"; + case DwarfNative.DW_LANG_RenderScript: return "DW_LANG_RenderScript"; + case DwarfNative.DW_LANG_BLISS: return "DW_LANG_BLISS"; + case DwarfNative.DW_LANG_Mips_Assembler: return "DW_LANG_Mips_Assembler"; + case DwarfNative.DW_LANG_Upc: return "DW_LANG_Upc"; + case DwarfNative.DW_LANG_ALTIUM_Assembler: return "DW_LANG_ALTIUM_Assembler"; + case DwarfNative.DW_LANG_SUN_Assembler: return "DW_LANG_SUN_Assembler"; + default: return null; + } + } + } + + public enum DwarfLanguageKind : ushort + { + C89 = DwarfNative.DW_LANG_C89, + + C = DwarfNative.DW_LANG_C, + + Ada83 = DwarfNative.DW_LANG_Ada83, + + CPlusPlus = DwarfNative.DW_LANG_C_plus_plus, + + Cobol74 = DwarfNative.DW_LANG_Cobol74, + + Cobol85 = DwarfNative.DW_LANG_Cobol85, + + Fortran77 = DwarfNative.DW_LANG_Fortran77, + + Fortran90 = DwarfNative.DW_LANG_Fortran90, + + Pascal83 = DwarfNative.DW_LANG_Pascal83, + + Modula2 = DwarfNative.DW_LANG_Modula2, + + Java = DwarfNative.DW_LANG_Java, + + C99 = DwarfNative.DW_LANG_C99, + + Ada95 = DwarfNative.DW_LANG_Ada95, + + Fortran95 = DwarfNative.DW_LANG_Fortran95, + + PLI = DwarfNative.DW_LANG_PLI, + + ObjC = DwarfNative.DW_LANG_ObjC, + + ObjCPlusPlus = DwarfNative.DW_LANG_ObjC_plus_plus, + + UPC = DwarfNative.DW_LANG_UPC, + + D = DwarfNative.DW_LANG_D, + + Python = DwarfNative.DW_LANG_Python, + + OpenCL = DwarfNative.DW_LANG_OpenCL, + + Go = DwarfNative.DW_LANG_Go, + + Modula3 = DwarfNative.DW_LANG_Modula3, + + Haskel = DwarfNative.DW_LANG_Haskel, + + CPlusPlus03 = DwarfNative.DW_LANG_C_plus_plus_03, + + CPlusPlus11 = DwarfNative.DW_LANG_C_plus_plus_11, + + OCaml = DwarfNative.DW_LANG_OCaml, + + Rust = DwarfNative.DW_LANG_Rust, + + C11 = DwarfNative.DW_LANG_C11, + + Swift = DwarfNative.DW_LANG_Swift, + + Julia = DwarfNative.DW_LANG_Julia, + + Dylan = DwarfNative.DW_LANG_Dylan, + + CPlusPlus14 = DwarfNative.DW_LANG_C_plus_plus_14, + + Fortran03 = DwarfNative.DW_LANG_Fortran03, + + Fortran08 = DwarfNative.DW_LANG_Fortran08, + + RenderScript = DwarfNative.DW_LANG_RenderScript, + + BLISS = DwarfNative.DW_LANG_BLISS, + + MipsAssembler = DwarfNative.DW_LANG_Mips_Assembler, + + Upc = DwarfNative.DW_LANG_Upc, + + ALTIUMAssembler = DwarfNative.DW_LANG_ALTIUM_Assembler, + + SUNAssembler = DwarfNative.DW_LANG_SUN_Assembler, + } + + public readonly partial struct DwarfCallingConventionEx + { + public static readonly DwarfCallingConventionEx Normal = new DwarfCallingConventionEx(DwarfNative.DW_CC_normal); + + public static readonly DwarfCallingConventionEx Program = new DwarfCallingConventionEx(DwarfNative.DW_CC_program); + + public static readonly DwarfCallingConventionEx Nocall = new DwarfCallingConventionEx(DwarfNative.DW_CC_nocall); + + /// + /// DWARF5 + /// + public static readonly DwarfCallingConventionEx PassByReference = new DwarfCallingConventionEx(DwarfNative.DW_CC_pass_by_reference); + + /// + /// DWARF5 + /// + public static readonly DwarfCallingConventionEx PassByValue = new DwarfCallingConventionEx(DwarfNative.DW_CC_pass_by_value); + + /// + /// GNU + /// + public static readonly DwarfCallingConventionEx GNURenesasSh = new DwarfCallingConventionEx(DwarfNative.DW_CC_GNU_renesas_sh); + + /// + /// GNU + /// + public static readonly DwarfCallingConventionEx GNUBorlandFastcallI386 = new DwarfCallingConventionEx(DwarfNative.DW_CC_GNU_borland_fastcall_i386); + + /// + /// ALTIUM + /// + public static readonly DwarfCallingConventionEx ALTIUMInterrupt = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_interrupt); + + /// + /// ALTIUM + /// + public static readonly DwarfCallingConventionEx ALTIUMNearSystemStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_near_system_stack); + + /// + /// ALTIUM + /// + public static readonly DwarfCallingConventionEx ALTIUMNearUserStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_near_user_stack); + + /// + /// ALTIUM + /// + public static readonly DwarfCallingConventionEx ALTIUMHugeUserStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_huge_user_stack); + + private string ToStringInternal() + { + switch ((byte)Value) + { + case DwarfNative.DW_CC_normal: return "DW_CC_normal"; + case DwarfNative.DW_CC_program: return "DW_CC_program"; + case DwarfNative.DW_CC_nocall: return "DW_CC_nocall"; + case DwarfNative.DW_CC_pass_by_reference: return "DW_CC_pass_by_reference"; + case DwarfNative.DW_CC_pass_by_value: return "DW_CC_pass_by_value"; + case DwarfNative.DW_CC_GNU_renesas_sh: return "DW_CC_GNU_renesas_sh"; + case DwarfNative.DW_CC_GNU_borland_fastcall_i386: return "DW_CC_GNU_borland_fastcall_i386"; + case DwarfNative.DW_CC_ALTIUM_interrupt: return "DW_CC_ALTIUM_interrupt"; + case DwarfNative.DW_CC_ALTIUM_near_system_stack: return "DW_CC_ALTIUM_near_system_stack"; + case DwarfNative.DW_CC_ALTIUM_near_user_stack: return "DW_CC_ALTIUM_near_user_stack"; + case DwarfNative.DW_CC_ALTIUM_huge_user_stack: return "DW_CC_ALTIUM_huge_user_stack"; + default: return null; + } + } + } + + public enum DwarfCallingConvention : byte + { + Normal = DwarfNative.DW_CC_normal, + + Program = DwarfNative.DW_CC_program, + + Nocall = DwarfNative.DW_CC_nocall, + + PassByReference = DwarfNative.DW_CC_pass_by_reference, + + PassByValue = DwarfNative.DW_CC_pass_by_value, + + GNURenesasSh = DwarfNative.DW_CC_GNU_renesas_sh, + + GNUBorlandFastcallI386 = DwarfNative.DW_CC_GNU_borland_fastcall_i386, + + ALTIUMInterrupt = DwarfNative.DW_CC_ALTIUM_interrupt, + + ALTIUMNearSystemStack = DwarfNative.DW_CC_ALTIUM_near_system_stack, + + ALTIUMNearUserStack = DwarfNative.DW_CC_ALTIUM_near_user_stack, + + ALTIUMHugeUserStack = DwarfNative.DW_CC_ALTIUM_huge_user_stack, + } + + public readonly partial struct DwarfUnitKindEx + { + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx Compile = new DwarfUnitKindEx(DwarfNative.DW_UT_compile); + + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx Type = new DwarfUnitKindEx(DwarfNative.DW_UT_type); + + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx Partial = new DwarfUnitKindEx(DwarfNative.DW_UT_partial); + + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx Skeleton = new DwarfUnitKindEx(DwarfNative.DW_UT_skeleton); + + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx SplitCompile = new DwarfUnitKindEx(DwarfNative.DW_UT_split_compile); + + /// + /// DWARF5 + /// + public static readonly DwarfUnitKindEx SplitType = new DwarfUnitKindEx(DwarfNative.DW_UT_split_type); + + private string ToStringInternal() + { + switch ((byte)Value) + { + case DwarfNative.DW_UT_compile: return "DW_UT_compile"; + case DwarfNative.DW_UT_type: return "DW_UT_type"; + case DwarfNative.DW_UT_partial: return "DW_UT_partial"; + case DwarfNative.DW_UT_skeleton: return "DW_UT_skeleton"; + case DwarfNative.DW_UT_split_compile: return "DW_UT_split_compile"; + case DwarfNative.DW_UT_split_type: return "DW_UT_split_type"; + default: return null; + } + } + } + + public enum DwarfUnitKind : byte + { + Compile = DwarfNative.DW_UT_compile, + + Type = DwarfNative.DW_UT_type, + + Partial = DwarfNative.DW_UT_partial, + + Skeleton = DwarfNative.DW_UT_skeleton, + + SplitCompile = DwarfNative.DW_UT_split_compile, + + SplitType = DwarfNative.DW_UT_split_type, + } + + public static partial class DwarfHelper + { + private static readonly DwarfAttributeEncoding[] AttributeToEncoding = new DwarfAttributeEncoding[] { + DwarfAttributeEncoding.None , // 0x00 (undefined) + DwarfAttributeEncoding.Reference , // 0x01 DW_AT_sibling + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationList , // 0x02 DW_AT_location + DwarfAttributeEncoding.String , // 0x03 DW_AT_name + DwarfAttributeEncoding.None , // 0x04 (undefined) + DwarfAttributeEncoding.None , // 0x05 (undefined) + DwarfAttributeEncoding.None , // 0x06 (undefined) + DwarfAttributeEncoding.None , // 0x07 (undefined) + DwarfAttributeEncoding.None , // 0x08 (undefined) + DwarfAttributeEncoding.Constant , // 0x09 DW_AT_ordering + DwarfAttributeEncoding.None , // 0x0a (undefined) + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x0b DW_AT_byte_size + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x0c DW_AT_bit_offset + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x0d DW_AT_bit_size + DwarfAttributeEncoding.None , // 0x0e (undefined) + DwarfAttributeEncoding.None , // 0x0f (undefined) + DwarfAttributeEncoding.LinePointer , // 0x10 DW_AT_stmt_list + DwarfAttributeEncoding.Address , // 0x11 DW_AT_low_pc + DwarfAttributeEncoding.Address | + DwarfAttributeEncoding.Constant , // 0x12 DW_AT_high_pc + DwarfAttributeEncoding.Constant , // 0x13 DW_AT_language + DwarfAttributeEncoding.None , // 0x14 (undefined) + DwarfAttributeEncoding.Reference , // 0x15 DW_AT_discr + DwarfAttributeEncoding.Constant , // 0x16 DW_AT_discr_value + DwarfAttributeEncoding.Constant , // 0x17 DW_AT_visibility + DwarfAttributeEncoding.Reference , // 0x18 DW_AT_import + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x19 DW_AT_string_length + DwarfAttributeEncoding.Reference , // 0x1a DW_AT_common_reference + DwarfAttributeEncoding.String , // 0x1b DW_AT_comp_dir + DwarfAttributeEncoding.Block | + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.String , // 0x1c DW_AT_const_value + DwarfAttributeEncoding.Reference , // 0x1d DW_AT_containing_type + DwarfAttributeEncoding.Reference , // 0x1e DW_AT_default_value + DwarfAttributeEncoding.None , // 0x1f (undefined) + DwarfAttributeEncoding.Constant , // 0x20 DW_AT_inline + DwarfAttributeEncoding.Flag , // 0x21 DW_AT_is_optional + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x22 DW_AT_lower_bound + DwarfAttributeEncoding.None , // 0x23 (undefined) + DwarfAttributeEncoding.None , // 0x24 (undefined) + DwarfAttributeEncoding.String , // 0x25 DW_AT_producer + DwarfAttributeEncoding.None , // 0x26 (undefined) + DwarfAttributeEncoding.Flag , // 0x27 DW_AT_prototyped + DwarfAttributeEncoding.None , // 0x28 (undefined) + DwarfAttributeEncoding.None , // 0x29 (undefined) + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x2a DW_AT_return_addr + DwarfAttributeEncoding.None , // 0x2b (undefined) + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.RangeListPointer , // 0x2c DW_AT_start_scope + DwarfAttributeEncoding.None , // 0x2d (undefined) + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x2e DW_AT_bit_stride + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x2f DW_AT_upper_bound + DwarfAttributeEncoding.None , // 0x30 (undefined) + DwarfAttributeEncoding.Reference , // 0x31 DW_AT_abstract_origin + DwarfAttributeEncoding.Constant , // 0x32 DW_AT_accessibility + DwarfAttributeEncoding.Constant , // 0x33 DW_AT_address_class + DwarfAttributeEncoding.Flag , // 0x34 DW_AT_artificial + DwarfAttributeEncoding.Reference , // 0x35 DW_AT_base_types + DwarfAttributeEncoding.Constant , // 0x36 DW_AT_calling_convention + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x37 DW_AT_count + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x38 DW_AT_data_member_location + DwarfAttributeEncoding.Constant , // 0x39 DW_AT_decl_column + DwarfAttributeEncoding.Constant , // 0x3a DW_AT_decl_file + DwarfAttributeEncoding.Constant , // 0x3b DW_AT_decl_line + DwarfAttributeEncoding.Flag , // 0x3c DW_AT_declaration + DwarfAttributeEncoding.Block , // 0x3d DW_AT_discr_list + DwarfAttributeEncoding.Constant , // 0x3e DW_AT_encoding + DwarfAttributeEncoding.Flag , // 0x3f DW_AT_external + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x40 DW_AT_frame_base + DwarfAttributeEncoding.Reference , // 0x41 DW_AT_friend + DwarfAttributeEncoding.Constant , // 0x42 DW_AT_identifier_case + DwarfAttributeEncoding.MacroPointer , // 0x43 DW_AT_macro_info + DwarfAttributeEncoding.Reference , // 0x44 DW_AT_namelist_item + DwarfAttributeEncoding.Reference , // 0x45 DW_AT_priority + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x46 DW_AT_segment + DwarfAttributeEncoding.Reference , // 0x47 DW_AT_specification + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x48 DW_AT_static_link + DwarfAttributeEncoding.Reference , // 0x49 DW_AT_type + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x4a DW_AT_use_location + DwarfAttributeEncoding.Flag , // 0x4b DW_AT_variable_parameter + DwarfAttributeEncoding.Constant , // 0x4c DW_AT_virtuality + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.LocationListPointer , // 0x4d DW_AT_vtable_elem_location + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x4e DW_AT_allocated + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x4f DW_AT_associated + DwarfAttributeEncoding.ExpressionLocation , // 0x50 DW_AT_data_location + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation | + DwarfAttributeEncoding.Reference , // 0x51 DW_AT_byte_stride + DwarfAttributeEncoding.Address , // 0x52 DW_AT_entry_pc + DwarfAttributeEncoding.Flag , // 0x53 DW_AT_use_UTF8 + DwarfAttributeEncoding.Reference , // 0x54 DW_AT_extension + DwarfAttributeEncoding.RangeListPointer , // 0x55 DW_AT_ranges + DwarfAttributeEncoding.Address | + DwarfAttributeEncoding.Flag | + DwarfAttributeEncoding.Reference | + DwarfAttributeEncoding.String , // 0x56 DW_AT_trampoline + DwarfAttributeEncoding.Constant , // 0x57 DW_AT_call_column + DwarfAttributeEncoding.Constant , // 0x58 DW_AT_call_file + DwarfAttributeEncoding.Constant , // 0x59 DW_AT_call_line + DwarfAttributeEncoding.String , // 0x5a DW_AT_description + DwarfAttributeEncoding.Constant , // 0x5b DW_AT_binary_scale + DwarfAttributeEncoding.Constant , // 0x5c DW_AT_decimal_scale + DwarfAttributeEncoding.Reference , // 0x5d DW_AT_small + DwarfAttributeEncoding.Constant , // 0x5e DW_AT_decimal_sign + DwarfAttributeEncoding.Constant , // 0x5f DW_AT_digit_count + DwarfAttributeEncoding.String , // 0x60 DW_AT_picture_string + DwarfAttributeEncoding.Flag , // 0x61 DW_AT_mutable + DwarfAttributeEncoding.Flag , // 0x62 DW_AT_threads_scaled + DwarfAttributeEncoding.Flag , // 0x63 DW_AT_explicit + DwarfAttributeEncoding.Reference , // 0x64 DW_AT_object_pointer + DwarfAttributeEncoding.Constant , // 0x65 DW_AT_endianity + DwarfAttributeEncoding.Flag , // 0x66 DW_AT_elemental + DwarfAttributeEncoding.Flag , // 0x67 DW_AT_pure + DwarfAttributeEncoding.Flag , // 0x68 DW_AT_recursive + DwarfAttributeEncoding.Reference , // 0x69 DW_AT_signature + DwarfAttributeEncoding.Flag , // 0x6a DW_AT_main_subprogram + DwarfAttributeEncoding.Constant , // 0x6b DW_AT_data_bit_offset + DwarfAttributeEncoding.Flag , // 0x6c DW_AT_const_expr + DwarfAttributeEncoding.Flag , // 0x6d DW_AT_enum_class + DwarfAttributeEncoding.String , // 0x6e DW_AT_linkage_name + DwarfAttributeEncoding.Constant , // 0x6f DW_AT_string_length_bit_size + DwarfAttributeEncoding.Constant , // 0x70 DW_AT_string_length_byte_size + DwarfAttributeEncoding.Constant | + DwarfAttributeEncoding.ExpressionLocation , // 0x71 DW_AT_rank + DwarfAttributeEncoding.StringOffsetPointer , // 0x72 DW_AT_str_offsets_base + DwarfAttributeEncoding.AddressPointer , // 0x73 DW_AT_addr_base + DwarfAttributeEncoding.RangeListsPointer , // 0x74 DW_AT_rnglists_base + DwarfAttributeEncoding.None , // 0x75 (undefined) + DwarfAttributeEncoding.String , // 0x76 DW_AT_dwo_name + DwarfAttributeEncoding.Flag , // 0x77 DW_AT_reference + DwarfAttributeEncoding.Flag , // 0x78 DW_AT_rvalue_reference + DwarfAttributeEncoding.MacroPointer , // 0x79 DW_AT_macros + DwarfAttributeEncoding.Flag , // 0x7a DW_AT_call_all_calls + DwarfAttributeEncoding.Flag , // 0x7b DW_AT_call_all_source_calls + DwarfAttributeEncoding.Flag , // 0x7c DW_AT_call_all_tail_calls + DwarfAttributeEncoding.Address , // 0x7d DW_AT_call_return_pc + DwarfAttributeEncoding.ExpressionLocation , // 0x7e DW_AT_call_value + DwarfAttributeEncoding.ExpressionLocation , // 0x7f DW_AT_call_origin + DwarfAttributeEncoding.Reference , // 0x80 DW_AT_call_parameter + DwarfAttributeEncoding.Address , // 0x81 DW_AT_call_pc + DwarfAttributeEncoding.Flag , // 0x82 DW_AT_call_tail_call + DwarfAttributeEncoding.ExpressionLocation , // 0x83 DW_AT_call_target + DwarfAttributeEncoding.ExpressionLocation , // 0x84 DW_AT_call_target_clobbered + DwarfAttributeEncoding.ExpressionLocation , // 0x85 DW_AT_call_data_location + DwarfAttributeEncoding.ExpressionLocation , // 0x86 DW_AT_call_data_value + DwarfAttributeEncoding.Flag , // 0x87 DW_AT_noreturn + DwarfAttributeEncoding.Constant , // 0x88 DW_AT_alignment + DwarfAttributeEncoding.Flag , // 0x89 DW_AT_export_symbols + DwarfAttributeEncoding.Flag , // 0x8a DW_AT_deleted + DwarfAttributeEncoding.Constant , // 0x8b DW_AT_defaulted + DwarfAttributeEncoding.LocationListsPointer , // 0x8c DW_AT_loclists_base + }; + } + + public partial class DwarfDIEAccessDeclaration : DwarfDIEDeclaration + { + public DwarfDIEAccessDeclaration() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_access_declaration; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + } + + public partial class DwarfDIEArrayType : DwarfDIEDeclaration + { + public DwarfDIEArrayType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_array_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? BitStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfArrayOrderingKind? Ordering + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ordering); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ordering, value); + } + } + + public DwarfConstant? Rank + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Rank); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Rank, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEAtomicType : DwarfDIEDeclaration + { + public DwarfDIEAtomicType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_atomic_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEBaseType : DwarfDIEDeclaration + { + public DwarfDIEBaseType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_base_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BinaryScale + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BinaryScale); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BinaryScale, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfConstant? DataBitOffset + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public DwarfConstant? DecimalScale + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DecimalScale); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DecimalScale, value); + } + } + + public DwarfConstant? DecimalSign + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DecimalSign); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DecimalSign, value); + } + } + + public DwarfConstant? DigitCount + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DigitCount); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DigitCount, value); + } + } + + public DwarfConstant? Encoding + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Encoding); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Encoding, value); + } + } + + public DwarfConstant? Endianity + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public string PictureString + { + get + { + return GetAttributeValue(DwarfAttributeKind.PictureString); + } + set + { + SetAttributeValue(DwarfAttributeKind.PictureString, value); + } + } + + public DwarfDIE Small + { + get + { + return GetAttributeValue(DwarfAttributeKind.Small); + } + set + { + SetAttributeValue(DwarfAttributeKind.Small, value); + } + } + } + + public partial class DwarfDIECallSite : DwarfDIE + { + public DwarfDIECallSite() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_call_site; + } + + public DwarfConstant? CallColumn + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallColumn); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallColumn, value); + } + } + + public DwarfConstant? CallFile + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallFile); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallFile, value); + } + } + + public DwarfConstant? CallLine + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallLine); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallLine, value); + } + } + + public DwarfExpression CallOrigin + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallOrigin); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallOrigin, value); + } + } + + public ulong? CallPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallPC, value); + } + } + + public ulong? CallReturnPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallReturnPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallReturnPC, value); + } + } + + public bool? CallTailCall + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallTailCall); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallTailCall, value); + } + } + + public DwarfExpression CallTarget + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallTarget); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallTarget, value); + } + } + + public DwarfExpression CallTargetClobbered + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallTargetClobbered); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallTargetClobbered, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIECallSiteParameter : DwarfDIE + { + public DwarfDIECallSiteParameter() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_call_site_parameter; + } + + public DwarfExpression CallDataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallDataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallDataLocation, value); + } + } + + public DwarfExpression CallDataValue + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallDataValue); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallDataValue, value); + } + } + + public DwarfDIE CallParameter + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallParameter); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallParameter, value); + } + } + + public DwarfExpression CallValue + { + get + { + return GetAttributeValue(DwarfAttributeKind.CallValue); + } + set + { + SetAttributeValue(DwarfAttributeKind.CallValue, value); + } + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIECatchBlock : DwarfDIEDeclaration + { + public DwarfDIECatchBlock() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_catch_block; + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + } + + public partial class DwarfDIEClassType : DwarfDIEDeclaration + { + public DwarfDIEClassType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_class_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfCallingConvention? CallingConvention + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public bool? ExportSymbols + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIECoarrayType : DwarfDIEDeclaration + { + public DwarfDIECoarrayType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_coarray_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIECommonBlock : DwarfDIEDeclaration + { + public DwarfDIECommonBlock() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_common_block; + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string LinkageName + { + get + { + return GetAttributeValue(DwarfAttributeKind.LinkageName); + } + set + { + SetAttributeValue(DwarfAttributeKind.LinkageName, value); + } + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIECommonInclusion : DwarfDIEDeclaration + { + public DwarfDIECommonInclusion() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_common_inclusion; + } + + public DwarfDIE CommonReference + { + get + { + return GetAttributeValue(DwarfAttributeKind.CommonReference); + } + set + { + SetAttributeValue(DwarfAttributeKind.CommonReference, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIECompileUnit : DwarfDIE + { + public DwarfDIECompileUnit() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_compile_unit; + } + + public ulong? AddrBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); + } + } + + public DwarfDIE BaseTypes + { + get + { + return GetAttributeValue(DwarfAttributeKind.BaseTypes); + } + set + { + SetAttributeValue(DwarfAttributeKind.BaseTypes, value); + } + } + + public string CompDir + { + get + { + return GetAttributeValue(DwarfAttributeKind.CompDir); + } + set + { + SetAttributeValue(DwarfAttributeKind.CompDir, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfIdentifierCaseKind? IdentifierCase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.IdentifierCase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.IdentifierCase, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public DwarfLanguageKind? Language + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Language); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Language, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Macros + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Macros); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Macros, value); + } + } + + public bool? MainSubprogram + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public string Producer + { + get + { + return GetAttributeValue(DwarfAttributeKind.Producer); + } + set + { + SetAttributeValue(DwarfAttributeKind.Producer, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public ulong? RnglistsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfLineProgramTable StmtList + { + get + { + return GetAttributeValue(DwarfAttributeKind.StmtList); + } + set + { + SetAttributeValue(DwarfAttributeKind.StmtList, value); + } + } + + public ulong? StrOffsetsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); + } + } + + public bool? UseUTF8 + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); + } + } + } + + public partial class DwarfDIECondition : DwarfDIEDeclaration + { + public DwarfDIECondition() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_condition; + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + } + + public partial class DwarfDIEConstType : DwarfDIEDeclaration + { + public DwarfDIEConstType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_const_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEConstant : DwarfDIEDeclaration + { + public DwarfDIEConstant() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_constant; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? ConstValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfConstant? Endianity + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); + } + } + + public bool? External + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.External); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.External, value); + } + } + + public string LinkageName + { + get + { + return GetAttributeValue(DwarfAttributeKind.LinkageName); + } + set + { + SetAttributeValue(DwarfAttributeKind.LinkageName, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEDwarfProcedure : DwarfDIE + { + public DwarfDIEDwarfProcedure() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_dwarf_procedure; + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + } + + public partial class DwarfDIEDynamicType : DwarfDIEDeclaration + { + public DwarfDIEDynamicType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_dynamic_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEEntryPoint : DwarfDIEDeclaration + { + public DwarfDIEEntryPoint() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_entry_point; + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfLocation? FrameBase + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.FrameBase); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.FrameBase, value); + } + } + + public string LinkageName + { + get + { + return GetAttributeValue(DwarfAttributeKind.LinkageName); + } + set + { + SetAttributeValue(DwarfAttributeKind.LinkageName, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfLocation? ReturnAddr + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfLocation? StaticLink + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.StaticLink); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.StaticLink, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEEnumerationType : DwarfDIEDeclaration + { + public DwarfDIEEnumerationType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_enumeration_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? BitStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfConstant? ByteStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public bool? EnumClass + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EnumClass); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EnumClass, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEEnumerator : DwarfDIEDeclaration + { + public DwarfDIEEnumerator() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_enumerator; + } + + public DwarfConstant? ConstValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + } + + public partial class DwarfDIEFileType : DwarfDIEDeclaration + { + public DwarfDIEFileType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_file_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEFormalParameter : DwarfDIEDeclaration + { + public DwarfDIEFormalParameter() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_formal_parameter; + } + + public bool? Artificial + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Artificial); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); + } + } + + public DwarfConstant? ConstValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); + } + } + + public DwarfDIE DefaultValue + { + get + { + return GetAttributeValue(DwarfAttributeKind.DefaultValue); + } + set + { + SetAttributeValue(DwarfAttributeKind.DefaultValue, value); + } + } + + public DwarfConstant? Endianity + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); + } + } + + public bool? IsOptional + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.IsOptional); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.IsOptional, value); + } + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public bool? VariableParameter + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.VariableParameter); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.VariableParameter, value); + } + } + } + + public partial class DwarfDIEFriend : DwarfDIEDeclaration + { + public DwarfDIEFriend() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_friend; + } + + public DwarfDIE Friend + { + get + { + return GetAttributeValue(DwarfAttributeKind.Friend); + } + set + { + SetAttributeValue(DwarfAttributeKind.Friend, value); + } + } + } + + public partial class DwarfDIEGenericSubrange : DwarfDIEDeclaration + { + public DwarfDIEGenericSubrange() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_generic_subrange; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? BitStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfConstant? ByteStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); + } + } + + public DwarfConstant? Count + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Count); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Count, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfConstant? LowerBound + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.LowerBound); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.LowerBound, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public bool? ThreadsScaled + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfConstant? UpperBound + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.UpperBound); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.UpperBound, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEImmutableType : DwarfDIEDeclaration + { + public DwarfDIEImmutableType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_immutable_type; + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEImportedDeclaration : DwarfDIEDeclaration + { + public DwarfDIEImportedDeclaration() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_declaration; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfDIE Import + { + get + { + return GetAttributeValue(DwarfAttributeKind.Import); + } + set + { + SetAttributeValue(DwarfAttributeKind.Import, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + } + + public partial class DwarfDIEImportedModule : DwarfDIEDeclaration + { + public DwarfDIEImportedModule() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_module; + } + + public DwarfDIE Import + { + get + { + return GetAttributeValue(DwarfAttributeKind.Import); + } + set + { + SetAttributeValue(DwarfAttributeKind.Import, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + } + + public partial class DwarfDIEImportedUnit : DwarfDIE + { + public DwarfDIEImportedUnit() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_unit; + } + + public DwarfDIE Import + { + get + { + return GetAttributeValue(DwarfAttributeKind.Import); + } + set + { + SetAttributeValue(DwarfAttributeKind.Import, value); + } + } + } + + public partial class DwarfDIEInheritance : DwarfDIEDeclaration + { + public DwarfDIEInheritance() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_inheritance; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfLocation? DataMemberLocation + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVirtuality? Virtuality + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Virtuality); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Virtuality, value); + } + } + } + + public partial class DwarfDIEInlinedSubroutine : DwarfDIE + { + public DwarfDIEInlinedSubroutine() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_inlined_subroutine; + } + + public DwarfConstant? CallColumn + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallColumn); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallColumn, value); + } + } + + public DwarfConstant? CallFile + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallFile); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallFile, value); + } + } + + public DwarfConstant? CallLine + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.CallLine); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.CallLine, value); + } + } + + public bool? ConstExpr + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ConstExpr); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ConstExpr, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? ReturnAddr + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public object Trampoline + { + get + { + return GetAttributeValue(DwarfAttributeKind.Trampoline); + } + set + { + SetAttributeValue(DwarfAttributeKind.Trampoline, value); + } + } + } + + public partial class DwarfDIEInterfaceType : DwarfDIEDeclaration + { + public DwarfDIEInterfaceType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_interface_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + } + + public partial class DwarfDIELabel : DwarfDIEDeclaration + { + public DwarfDIELabel() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_label; + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + } + + public partial class DwarfDIELexicalBlock : DwarfDIEDeclaration + { + public DwarfDIELexicalBlock() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_lexical_block; + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + } + + public partial class DwarfDIEMember : DwarfDIEDeclaration + { + public DwarfDIEMember() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_member; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public bool? Artificial + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Artificial); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfConstant? DataBitOffset + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset, value); + } + } + + public DwarfLocation? DataMemberLocation + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public bool? Mutable + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Mutable); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Mutable, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEModule : DwarfDIEDeclaration + { + public DwarfDIEModule() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_module; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Priority + { + get + { + return GetAttributeValue(DwarfAttributeKind.Priority); + } + set + { + SetAttributeValue(DwarfAttributeKind.Priority, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIENamelist : DwarfDIEDeclaration + { + public DwarfDIENamelist() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_namelist; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIENamelistItem : DwarfDIEDeclaration + { + public DwarfDIENamelistItem() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_namelist_item; + } + + public DwarfDIE NamelistItem + { + get + { + return GetAttributeValue(DwarfAttributeKind.NamelistItem); + } + set + { + SetAttributeValue(DwarfAttributeKind.NamelistItem, value); + } + } + } + + public partial class DwarfDIENamespace : DwarfDIEDeclaration + { + public DwarfDIENamespace() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_namespace; + } + + public bool? ExportSymbols + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); + } + } + + public DwarfDIE Extension + { + get + { + return GetAttributeValue(DwarfAttributeKind.Extension); + } + set + { + SetAttributeValue(DwarfAttributeKind.Extension, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + } + + public partial class DwarfDIEPackedType : DwarfDIEDeclaration + { + public DwarfDIEPackedType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_packed_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEPartialUnit : DwarfDIE + { + public DwarfDIEPartialUnit() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_partial_unit; + } + + public ulong? AddrBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); + } + } + + public DwarfDIE BaseTypes + { + get + { + return GetAttributeValue(DwarfAttributeKind.BaseTypes); + } + set + { + SetAttributeValue(DwarfAttributeKind.BaseTypes, value); + } + } + + public string CompDir + { + get + { + return GetAttributeValue(DwarfAttributeKind.CompDir); + } + set + { + SetAttributeValue(DwarfAttributeKind.CompDir, value); + } + } + + public string DwoName + { + get + { + return GetAttributeValue(DwarfAttributeKind.DwoName); + } + set + { + SetAttributeValue(DwarfAttributeKind.DwoName, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfIdentifierCaseKind? IdentifierCase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.IdentifierCase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.IdentifierCase, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public DwarfLanguageKind? Language + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Language); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Language, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Macros + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Macros); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Macros, value); + } + } + + public bool? MainSubprogram + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public string Producer + { + get + { + return GetAttributeValue(DwarfAttributeKind.Producer); + } + set + { + SetAttributeValue(DwarfAttributeKind.Producer, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public ulong? RnglistsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfLineProgramTable StmtList + { + get + { + return GetAttributeValue(DwarfAttributeKind.StmtList); + } + set + { + SetAttributeValue(DwarfAttributeKind.StmtList, value); + } + } + + public ulong? StrOffsetsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); + } + } + + public bool? UseUTF8 + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); + } + } + } + + public partial class DwarfDIEPointerType : DwarfDIEDeclaration + { + public DwarfDIEPointerType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_pointer_type; + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEPtrToMemberType : DwarfDIEDeclaration + { + public DwarfDIEPtrToMemberType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_ptr_to_member_type; + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfDIE ContainingType + { + get + { + return GetAttributeValue(DwarfAttributeKind.ContainingType); + } + set + { + SetAttributeValue(DwarfAttributeKind.ContainingType, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfLocation? UseLocation + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.UseLocation); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.UseLocation, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEReferenceType : DwarfDIEDeclaration + { + public DwarfDIEReferenceType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_reference_type; + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIERestrictType : DwarfDIEDeclaration + { + public DwarfDIERestrictType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_restrict_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIERvalueReferenceType : DwarfDIEDeclaration + { + public DwarfDIERvalueReferenceType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_rvalue_reference_type; + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIESetType : DwarfDIEDeclaration + { + public DwarfDIESetType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_set_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIESharedType : DwarfDIEDeclaration + { + public DwarfDIESharedType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_shared_type; + } + + public DwarfConstant? Count + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Count); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Count, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIESkeletonUnit : DwarfDIE + { + public DwarfDIESkeletonUnit() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_skeleton_unit; + } + + public ulong? AddrBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); + } + } + + public string CompDir + { + get + { + return GetAttributeValue(DwarfAttributeKind.CompDir); + } + set + { + SetAttributeValue(DwarfAttributeKind.CompDir, value); + } + } + + public string DwoName + { + get + { + return GetAttributeValue(DwarfAttributeKind.DwoName); + } + set + { + SetAttributeValue(DwarfAttributeKind.DwoName, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public ulong? RnglistsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); + } + } + + public DwarfLineProgramTable StmtList + { + get + { + return GetAttributeValue(DwarfAttributeKind.StmtList); + } + set + { + SetAttributeValue(DwarfAttributeKind.StmtList, value); + } + } + + public ulong? StrOffsetsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); + } + } + + public bool? UseUTF8 + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); + } + } + } + + public partial class DwarfDIEStringType : DwarfDIEDeclaration + { + public DwarfDIEStringType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_string_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfLocation? StringLength + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.StringLength); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.StringLength, value); + } + } + + public DwarfConstant? StringLengthBitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StringLengthBitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StringLengthBitSize, value); + } + } + + public DwarfConstant? StringLengthByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StringLengthByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StringLengthByteSize, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEStructureType : DwarfDIEDeclaration + { + public DwarfDIEStructureType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_structure_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfCallingConvention? CallingConvention + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public bool? ExportSymbols + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIESubprogram : DwarfDIEDeclaration + { + public DwarfDIESubprogram() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_subprogram; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public bool? Artificial + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Artificial); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); + } + } + + public DwarfCallingConvention? CallingConvention + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfConstant? Defaulted + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Defaulted); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Defaulted, value); + } + } + + public bool? Deleted + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Deleted); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Deleted, value); + } + } + + public bool? Elemental + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Elemental); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Elemental, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public bool? Explicit + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Explicit); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Explicit, value); + } + } + + public bool? External + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.External); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.External, value); + } + } + + public DwarfLocation? FrameBase + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.FrameBase); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.FrameBase, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public DwarfInlineKind? Inline + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Inline); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Inline, value); + } + } + + public string LinkageName + { + get + { + return GetAttributeValue(DwarfAttributeKind.LinkageName); + } + set + { + SetAttributeValue(DwarfAttributeKind.LinkageName, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public bool? MainSubprogram + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public bool? Noreturn + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Noreturn); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Noreturn, value); + } + } + + public DwarfDIE ObjectPointer + { + get + { + return GetAttributeValue(DwarfAttributeKind.ObjectPointer); + } + set + { + SetAttributeValue(DwarfAttributeKind.ObjectPointer, value); + } + } + + public bool? Prototyped + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Prototyped); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Prototyped, value); + } + } + + public bool? Pure + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Pure); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Pure, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public bool? Recursive + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Recursive); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Recursive, value); + } + } + + public bool? Reference + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Reference); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Reference, value); + } + } + + public DwarfLocation? ReturnAddr + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); + } + } + + public bool? RvalueReference + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.RvalueReference); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.RvalueReference, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfLocation? StaticLink + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.StaticLink); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.StaticLink, value); + } + } + + public object Trampoline + { + get + { + return GetAttributeValue(DwarfAttributeKind.Trampoline); + } + set + { + SetAttributeValue(DwarfAttributeKind.Trampoline, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + + public DwarfVirtuality? Virtuality + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Virtuality); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Virtuality, value); + } + } + + public DwarfLocation? VtableElemLocation + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.VtableElemLocation); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.VtableElemLocation, value); + } + } + } + + public partial class DwarfDIESubrangeType : DwarfDIEDeclaration + { + public DwarfDIESubrangeType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_subrange_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? BitStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfConstant? ByteStride + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); + } + } + + public DwarfConstant? Count + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Count); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Count, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfConstant? LowerBound + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.LowerBound); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.LowerBound, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public bool? ThreadsScaled + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfConstant? UpperBound + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.UpperBound); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.UpperBound, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIESubroutineType : DwarfDIEDeclaration + { + public DwarfDIESubroutineType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_subroutine_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public bool? Prototyped + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Prototyped); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Prototyped, value); + } + } + + public bool? Reference + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Reference); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Reference, value); + } + } + + public bool? RvalueReference + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.RvalueReference); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.RvalueReference, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIETemplateAlias : DwarfDIEDeclaration + { + public DwarfDIETemplateAlias() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_alias; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIETemplateTypeParameter : DwarfDIEDeclaration + { + public DwarfDIETemplateTypeParameter() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_type_parameter; + } + + public DwarfDIE DefaultValue + { + get + { + return GetAttributeValue(DwarfAttributeKind.DefaultValue); + } + set + { + SetAttributeValue(DwarfAttributeKind.DefaultValue, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIETemplateValueParameter : DwarfDIEDeclaration + { + public DwarfDIETemplateValueParameter() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_value_parameter; + } + + public DwarfConstant? ConstValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); + } + } + + public DwarfDIE DefaultValue + { + get + { + return GetAttributeValue(DwarfAttributeKind.DefaultValue); + } + set + { + SetAttributeValue(DwarfAttributeKind.DefaultValue, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEThrownType : DwarfDIEDeclaration + { + public DwarfDIEThrownType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_thrown_type; + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIETryBlock : DwarfDIEDeclaration + { + public DwarfDIETryBlock() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_try_block; + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + } + + public partial class DwarfDIETypedef : DwarfDIEDeclaration + { + public DwarfDIETypedef() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_typedef; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIETypeUnit : DwarfDIE + { + public DwarfDIETypeUnit() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_type_unit; + } + + public DwarfLanguageKind? Language + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Language); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Language, value); + } + } + + public DwarfLineProgramTable StmtList + { + get + { + return GetAttributeValue(DwarfAttributeKind.StmtList); + } + set + { + SetAttributeValue(DwarfAttributeKind.StmtList, value); + } + } + + public ulong? StrOffsetsBase + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); + } + } + + public bool? UseUTF8 + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); + } + } + } + + public partial class DwarfDIEUnionType : DwarfDIEDeclaration + { + public DwarfDIEUnionType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_union_type; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public DwarfConstant? Allocated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); + } + } + + public DwarfConstant? Associated + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Associated); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); + } + } + + public DwarfConstant? BitSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); + } + } + + public DwarfConstant? ByteSize + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); + } + } + + public DwarfCallingConvention? CallingConvention + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); + } + } + + public DwarfExpression DataLocation + { + get + { + return GetAttributeValue(DwarfAttributeKind.DataLocation); + } + set + { + SetAttributeValue(DwarfAttributeKind.DataLocation, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public bool? ExportSymbols + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Signature + { + get + { + return GetAttributeValue(DwarfAttributeKind.Signature); + } + set + { + SetAttributeValue(DwarfAttributeKind.Signature, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEUnspecifiedParameters : DwarfDIEDeclaration + { + public DwarfDIEUnspecifiedParameters() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_unspecified_parameters; + } + + public bool? Artificial + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Artificial); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); + } + } + } + + public partial class DwarfDIEUnspecifiedType : DwarfDIEDeclaration + { + public DwarfDIEUnspecifiedType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_unspecified_type; + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + } + + public partial class DwarfDIEVariable : DwarfDIEDeclaration + { + public DwarfDIEVariable() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_variable; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? Alignment + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); + } + } + + public bool? Artificial + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Artificial); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); + } + } + + public bool? ConstExpr + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.ConstExpr); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.ConstExpr, value); + } + } + + public DwarfConstant? ConstValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfConstant? Endianity + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); + } + } + + public bool? External + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.External); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.External, value); + } + } + + public string LinkageName + { + get + { + return GetAttributeValue(DwarfAttributeKind.LinkageName); + } + set + { + SetAttributeValue(DwarfAttributeKind.LinkageName, value); + } + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfDIE Specification + { + get + { + return GetAttributeValue(DwarfAttributeKind.Specification); + } + set + { + SetAttributeValue(DwarfAttributeKind.Specification, value); + } + } + + public DwarfConstant? StartScope + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + public partial class DwarfDIEVariant : DwarfDIEDeclaration + { + public DwarfDIEVariant() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_variant; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfDiscriminantListKind? DiscrList + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.DiscrList); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.DiscrList, value); + } + } + + public DwarfConstant? DiscrValue + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.DiscrValue); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.DiscrValue, value); + } + } + } + + public partial class DwarfDIEVariantPart : DwarfDIEDeclaration + { + public DwarfDIEVariantPart() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_variant_part; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public DwarfDIE Discr + { + get + { + return GetAttributeValue(DwarfAttributeKind.Discr); + } + set + { + SetAttributeValue(DwarfAttributeKind.Discr, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEVolatileType : DwarfDIEDeclaration + { + public DwarfDIEVolatileType() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_volatile_type; + } + + public string Name + { + get + { + return GetAttributeValue(DwarfAttributeKind.Name); + } + set + { + SetAttributeValue(DwarfAttributeKind.Name, value); + } + } + + public string Description + { + get + { + return GetAttributeValue(DwarfAttributeKind.Description); + } + set + { + SetAttributeValue(DwarfAttributeKind.Description, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + } + + public partial class DwarfDIEWithStmt : DwarfDIEDeclaration + { + public DwarfDIEWithStmt() + { + this.Tag = (DwarfTag)DwarfNative.DW_TAG_with_stmt; + } + + public DwarfAccessibility? Accessibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); + } + } + + public DwarfConstant? AddressClass + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); + } + } + + public bool? Declaration + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Declaration); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); + } + } + + public ulong? EntryPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); + } + } + + public DwarfConstant? HighPC + { + get + { + return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); + } + set + { + SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); + } + } + + public DwarfLocation? Location + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Location); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Location, value); + } + } + + public ulong? LowPC + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.LowPC); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); + } + } + + public ulong? Ranges + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Ranges); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); + } + } + + public DwarfLocation? Segment + { + get + { + return GetAttributeLocationOpt(DwarfAttributeKind.Segment); + } + set + { + SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); + } + } + + public DwarfDIE Type + { + get + { + return GetAttributeValue(DwarfAttributeKind.Type); + } + set + { + SetAttributeValue(DwarfAttributeKind.Type, value); + } + } + + public DwarfVisibility? Visibility + { + get + { + return GetAttributeValueOpt(DwarfAttributeKind.Visibility); + } + set + { + SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); + } + } + } + + internal static partial class DIEHelper + { + public static DwarfDIE ConvertTagToDwarfDIE(ushort tag) + { + switch (tag) + { + case DwarfNative.DW_TAG_access_declaration: + return new DwarfDIEAccessDeclaration(); + case DwarfNative.DW_TAG_array_type: + return new DwarfDIEArrayType(); + case DwarfNative.DW_TAG_atomic_type: + return new DwarfDIEAtomicType(); + case DwarfNative.DW_TAG_base_type: + return new DwarfDIEBaseType(); + case DwarfNative.DW_TAG_call_site: + return new DwarfDIECallSite(); + case DwarfNative.DW_TAG_call_site_parameter: + return new DwarfDIECallSiteParameter(); + case DwarfNative.DW_TAG_catch_block: + return new DwarfDIECatchBlock(); + case DwarfNative.DW_TAG_class_type: + return new DwarfDIEClassType(); + case DwarfNative.DW_TAG_coarray_type: + return new DwarfDIECoarrayType(); + case DwarfNative.DW_TAG_common_block: + return new DwarfDIECommonBlock(); + case DwarfNative.DW_TAG_common_inclusion: + return new DwarfDIECommonInclusion(); + case DwarfNative.DW_TAG_compile_unit: + return new DwarfDIECompileUnit(); + case DwarfNative.DW_TAG_condition: + return new DwarfDIECondition(); + case DwarfNative.DW_TAG_const_type: + return new DwarfDIEConstType(); + case DwarfNative.DW_TAG_constant: + return new DwarfDIEConstant(); + case DwarfNative.DW_TAG_dwarf_procedure: + return new DwarfDIEDwarfProcedure(); + case DwarfNative.DW_TAG_dynamic_type: + return new DwarfDIEDynamicType(); + case DwarfNative.DW_TAG_entry_point: + return new DwarfDIEEntryPoint(); + case DwarfNative.DW_TAG_enumeration_type: + return new DwarfDIEEnumerationType(); + case DwarfNative.DW_TAG_enumerator: + return new DwarfDIEEnumerator(); + case DwarfNative.DW_TAG_file_type: + return new DwarfDIEFileType(); + case DwarfNative.DW_TAG_formal_parameter: + return new DwarfDIEFormalParameter(); + case DwarfNative.DW_TAG_friend: + return new DwarfDIEFriend(); + case DwarfNative.DW_TAG_generic_subrange: + return new DwarfDIEGenericSubrange(); + case DwarfNative.DW_TAG_immutable_type: + return new DwarfDIEImmutableType(); + case DwarfNative.DW_TAG_imported_declaration: + return new DwarfDIEImportedDeclaration(); + case DwarfNative.DW_TAG_imported_module: + return new DwarfDIEImportedModule(); + case DwarfNative.DW_TAG_imported_unit: + return new DwarfDIEImportedUnit(); + case DwarfNative.DW_TAG_inheritance: + return new DwarfDIEInheritance(); + case DwarfNative.DW_TAG_inlined_subroutine: + return new DwarfDIEInlinedSubroutine(); + case DwarfNative.DW_TAG_interface_type: + return new DwarfDIEInterfaceType(); + case DwarfNative.DW_TAG_label: + return new DwarfDIELabel(); + case DwarfNative.DW_TAG_lexical_block: + return new DwarfDIELexicalBlock(); + case DwarfNative.DW_TAG_member: + return new DwarfDIEMember(); + case DwarfNative.DW_TAG_module: + return new DwarfDIEModule(); + case DwarfNative.DW_TAG_namelist: + return new DwarfDIENamelist(); + case DwarfNative.DW_TAG_namelist_item: + return new DwarfDIENamelistItem(); + case DwarfNative.DW_TAG_namespace: + return new DwarfDIENamespace(); + case DwarfNative.DW_TAG_packed_type: + return new DwarfDIEPackedType(); + case DwarfNative.DW_TAG_partial_unit: + return new DwarfDIEPartialUnit(); + case DwarfNative.DW_TAG_pointer_type: + return new DwarfDIEPointerType(); + case DwarfNative.DW_TAG_ptr_to_member_type: + return new DwarfDIEPtrToMemberType(); + case DwarfNative.DW_TAG_reference_type: + return new DwarfDIEReferenceType(); + case DwarfNative.DW_TAG_restrict_type: + return new DwarfDIERestrictType(); + case DwarfNative.DW_TAG_rvalue_reference_type: + return new DwarfDIERvalueReferenceType(); + case DwarfNative.DW_TAG_set_type: + return new DwarfDIESetType(); + case DwarfNative.DW_TAG_shared_type: + return new DwarfDIESharedType(); + case DwarfNative.DW_TAG_skeleton_unit: + return new DwarfDIESkeletonUnit(); + case DwarfNative.DW_TAG_string_type: + return new DwarfDIEStringType(); + case DwarfNative.DW_TAG_structure_type: + return new DwarfDIEStructureType(); + case DwarfNative.DW_TAG_subprogram: + return new DwarfDIESubprogram(); + case DwarfNative.DW_TAG_subrange_type: + return new DwarfDIESubrangeType(); + case DwarfNative.DW_TAG_subroutine_type: + return new DwarfDIESubroutineType(); + case DwarfNative.DW_TAG_template_alias: + return new DwarfDIETemplateAlias(); + case DwarfNative.DW_TAG_template_type_parameter: + return new DwarfDIETemplateTypeParameter(); + case DwarfNative.DW_TAG_template_value_parameter: + return new DwarfDIETemplateValueParameter(); + case DwarfNative.DW_TAG_thrown_type: + return new DwarfDIEThrownType(); + case DwarfNative.DW_TAG_try_block: + return new DwarfDIETryBlock(); + case DwarfNative.DW_TAG_typedef: + return new DwarfDIETypedef(); + case DwarfNative.DW_TAG_type_unit: + return new DwarfDIETypeUnit(); + case DwarfNative.DW_TAG_union_type: + return new DwarfDIEUnionType(); + case DwarfNative.DW_TAG_unspecified_parameters: + return new DwarfDIEUnspecifiedParameters(); + case DwarfNative.DW_TAG_unspecified_type: + return new DwarfDIEUnspecifiedType(); + case DwarfNative.DW_TAG_variable: + return new DwarfDIEVariable(); + case DwarfNative.DW_TAG_variant: + return new DwarfDIEVariant(); + case DwarfNative.DW_TAG_variant_part: + return new DwarfDIEVariantPart(); + case DwarfNative.DW_TAG_volatile_type: + return new DwarfDIEVolatileType(); + case DwarfNative.DW_TAG_with_stmt: + return new DwarfDIEWithStmt(); + } + return new DwarfDIE(); + } + } +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs new file mode 100644 index 00000000000000..983bda8854252d --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs @@ -0,0 +1,14546 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +using System; + +#pragma warning disable 1591 + +namespace LibObjectFile.Elf +{ + using System.Runtime.InteropServices; + + public static partial class ElfNative + { + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe partial struct Elf32_Ehdr + { + /// + /// Magic number and other info + /// + public fixed byte e_ident[16]; + + /// + /// Object file type + /// + public ElfNative.Elf32_Half e_type; + + /// + /// Architecture + /// + public ElfNative.Elf32_Half e_machine; + + /// + /// Object file version + /// + public ElfNative.Elf32_Word e_version; + + /// + /// Entry point virtual address + /// + public ElfNative.Elf32_Addr e_entry; + + /// + /// Program header table file offset + /// + public ElfNative.Elf32_Off e_phoff; + + /// + /// Section header table file offset + /// + public ElfNative.Elf32_Off e_shoff; + + /// + /// Processor-specific flags + /// + public ElfNative.Elf32_Word e_flags; + + /// + /// ELF header size in bytes + /// + public ElfNative.Elf32_Half e_ehsize; + + /// + /// Program header table entry size + /// + public ElfNative.Elf32_Half e_phentsize; + + /// + /// Program header table entry count + /// + public ElfNative.Elf32_Half e_phnum; + + /// + /// Section header table entry size + /// + public ElfNative.Elf32_Half e_shentsize; + + /// + /// Section header table entry count + /// + public ElfNative.Elf32_Half e_shnum; + + /// + /// Section header string table index + /// + public ElfNative.Elf32_Half e_shstrndx; + } + + /// + /// Type for a 16-bit quantity. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Half : IEquatable + { + public Elf32_Half(ushort value) => this.Value = value; + + public readonly ushort Value; + + public bool Equals(Elf32_Half other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Half other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ushort(Elf32_Half from) => from.Value; + + public static implicit operator Elf32_Half(ushort from) => new Elf32_Half(from); + + public static bool operator ==(Elf32_Half left, Elf32_Half right) => left.Equals(right); + + public static bool operator !=(Elf32_Half left, Elf32_Half right) => !left.Equals(right); + } + + /// + /// Types for signed and unsigned 32-bit quantities. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Word : IEquatable + { + public Elf32_Word(uint value) => this.Value = value; + + public readonly uint Value; + + public bool Equals(Elf32_Word other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Word other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator uint(Elf32_Word from) => from.Value; + + public static implicit operator Elf32_Word(uint from) => new Elf32_Word(from); + + public static bool operator ==(Elf32_Word left, Elf32_Word right) => left.Equals(right); + + public static bool operator !=(Elf32_Word left, Elf32_Word right) => !left.Equals(right); + } + + /// + /// Type of addresses. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Addr : IEquatable + { + public Elf32_Addr(uint value) => this.Value = value; + + public readonly uint Value; + + public bool Equals(Elf32_Addr other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Addr other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator uint(Elf32_Addr from) => from.Value; + + public static implicit operator Elf32_Addr(uint from) => new Elf32_Addr(from); + + public static bool operator ==(Elf32_Addr left, Elf32_Addr right) => left.Equals(right); + + public static bool operator !=(Elf32_Addr left, Elf32_Addr right) => !left.Equals(right); + } + + /// + /// Type of file offsets. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Off : IEquatable + { + public Elf32_Off(uint value) => this.Value = value; + + public readonly uint Value; + + public bool Equals(Elf32_Off other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Off other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator uint(Elf32_Off from) => from.Value; + + public static implicit operator Elf32_Off(uint from) => new Elf32_Off(from); + + public static bool operator ==(Elf32_Off left, Elf32_Off right) => left.Equals(right); + + public static bool operator !=(Elf32_Off left, Elf32_Off right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe partial struct Elf64_Ehdr + { + /// + /// Magic number and other info + /// + public fixed byte e_ident[16]; + + /// + /// Object file type + /// + public ElfNative.Elf64_Half e_type; + + /// + /// Architecture + /// + public ElfNative.Elf64_Half e_machine; + + /// + /// Object file version + /// + public ElfNative.Elf64_Word e_version; + + /// + /// Entry point virtual address + /// + public ElfNative.Elf64_Addr e_entry; + + /// + /// Program header table file offset + /// + public ElfNative.Elf64_Off e_phoff; + + /// + /// Section header table file offset + /// + public ElfNative.Elf64_Off e_shoff; + + /// + /// Processor-specific flags + /// + public ElfNative.Elf64_Word e_flags; + + /// + /// ELF header size in bytes + /// + public ElfNative.Elf64_Half e_ehsize; + + /// + /// Program header table entry size + /// + public ElfNative.Elf64_Half e_phentsize; + + /// + /// Program header table entry count + /// + public ElfNative.Elf64_Half e_phnum; + + /// + /// Section header table entry size + /// + public ElfNative.Elf64_Half e_shentsize; + + /// + /// Section header table entry count + /// + public ElfNative.Elf64_Half e_shnum; + + /// + /// Section header string table index + /// + public ElfNative.Elf64_Half e_shstrndx; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Half : IEquatable + { + public Elf64_Half(ushort value) => this.Value = value; + + public readonly ushort Value; + + public bool Equals(Elf64_Half other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Half other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ushort(Elf64_Half from) => from.Value; + + public static implicit operator Elf64_Half(ushort from) => new Elf64_Half(from); + + public static bool operator ==(Elf64_Half left, Elf64_Half right) => left.Equals(right); + + public static bool operator !=(Elf64_Half left, Elf64_Half right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Word : IEquatable + { + public Elf64_Word(uint value) => this.Value = value; + + public readonly uint Value; + + public bool Equals(Elf64_Word other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Word other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator uint(Elf64_Word from) => from.Value; + + public static implicit operator Elf64_Word(uint from) => new Elf64_Word(from); + + public static bool operator ==(Elf64_Word left, Elf64_Word right) => left.Equals(right); + + public static bool operator !=(Elf64_Word left, Elf64_Word right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Addr : IEquatable + { + public Elf64_Addr(ulong value) => this.Value = value; + + public readonly ulong Value; + + public bool Equals(Elf64_Addr other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Addr other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ulong(Elf64_Addr from) => from.Value; + + public static implicit operator Elf64_Addr(ulong from) => new Elf64_Addr(from); + + public static bool operator ==(Elf64_Addr left, Elf64_Addr right) => left.Equals(right); + + public static bool operator !=(Elf64_Addr left, Elf64_Addr right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Off : IEquatable + { + public Elf64_Off(ulong value) => this.Value = value; + + public readonly ulong Value; + + public bool Equals(Elf64_Off other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Off other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ulong(Elf64_Off from) => from.Value; + + public static implicit operator Elf64_Off(ulong from) => new Elf64_Off(from); + + public static bool operator ==(Elf64_Off left, Elf64_Off right) => left.Equals(right); + + public static bool operator !=(Elf64_Off left, Elf64_Off right) => !left.Equals(right); + } + + /// + /// Section header. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Shdr + { + /// + /// Section name (string tbl index) + /// + public ElfNative.Elf32_Word sh_name; + + /// + /// Section type + /// + public ElfNative.Elf32_Word sh_type; + + /// + /// Section flags + /// + public ElfNative.Elf32_Word sh_flags; + + /// + /// Section virtual addr at execution + /// + public ElfNative.Elf32_Addr sh_addr; + + /// + /// Section file offset + /// + public ElfNative.Elf32_Off sh_offset; + + /// + /// Section size in bytes + /// + public ElfNative.Elf32_Word sh_size; + + /// + /// Link to another section + /// + public ElfNative.Elf32_Word sh_link; + + /// + /// Additional section information + /// + public ElfNative.Elf32_Word sh_info; + + /// + /// Section alignment + /// + public ElfNative.Elf32_Word sh_addralign; + + /// + /// Entry size if section holds table + /// + public ElfNative.Elf32_Word sh_entsize; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Shdr + { + /// + /// Section name (string tbl index) + /// + public ElfNative.Elf64_Word sh_name; + + /// + /// Section type + /// + public ElfNative.Elf64_Word sh_type; + + /// + /// Section flags + /// + public ElfNative.Elf64_Xword sh_flags; + + /// + /// Section virtual addr at execution + /// + public ElfNative.Elf64_Addr sh_addr; + + /// + /// Section file offset + /// + public ElfNative.Elf64_Off sh_offset; + + /// + /// Section size in bytes + /// + public ElfNative.Elf64_Xword sh_size; + + /// + /// Link to another section + /// + public ElfNative.Elf64_Word sh_link; + + /// + /// Additional section information + /// + public ElfNative.Elf64_Word sh_info; + + /// + /// Section alignment + /// + public ElfNative.Elf64_Xword sh_addralign; + + /// + /// Entry size if section holds table + /// + public ElfNative.Elf64_Xword sh_entsize; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Xword : IEquatable + { + public Elf64_Xword(ulong value) => this.Value = value; + + public readonly ulong Value; + + public bool Equals(Elf64_Xword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Xword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ulong(Elf64_Xword from) => from.Value; + + public static implicit operator Elf64_Xword(ulong from) => new Elf64_Xword(from); + + public static bool operator ==(Elf64_Xword left, Elf64_Xword right) => left.Equals(right); + + public static bool operator !=(Elf64_Xword left, Elf64_Xword right) => !left.Equals(right); + } + + /// + /// Section compression header. Used when SHF_COMPRESSED is set. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Chdr + { + /// + /// Compression format. + /// + public ElfNative.Elf32_Word ch_type; + + /// + /// Uncompressed data size. + /// + public ElfNative.Elf32_Word ch_size; + + /// + /// Uncompressed data alignment. + /// + public ElfNative.Elf32_Word ch_addralign; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Chdr + { + /// + /// Compression format. + /// + public ElfNative.Elf64_Word ch_type; + + public ElfNative.Elf64_Word ch_reserved; + + /// + /// Uncompressed data size. + /// + public ElfNative.Elf64_Xword ch_size; + + /// + /// Uncompressed data alignment. + /// + public ElfNative.Elf64_Xword ch_addralign; + } + + /// + /// Symbol table entry. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Sym + { + /// + /// Symbol name (string tbl index) + /// + public ElfNative.Elf32_Word st_name; + + /// + /// Symbol value + /// + public ElfNative.Elf32_Addr st_value; + + /// + /// Symbol size + /// + public ElfNative.Elf32_Word st_size; + + /// + /// Symbol type and binding + /// + public byte st_info; + + /// + /// Symbol visibility + /// + public byte st_other; + + /// + /// Section index + /// + public ElfNative.Elf32_Section st_shndx; + } + + /// + /// Type for section indices, which are 16-bit quantities. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Section : IEquatable + { + public Elf32_Section(ushort value) => this.Value = value; + + public readonly ushort Value; + + public bool Equals(Elf32_Section other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Section other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ushort(Elf32_Section from) => from.Value; + + public static implicit operator Elf32_Section(ushort from) => new Elf32_Section(from); + + public static bool operator ==(Elf32_Section left, Elf32_Section right) => left.Equals(right); + + public static bool operator !=(Elf32_Section left, Elf32_Section right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Sym + { + /// + /// Symbol name (string tbl index) + /// + public ElfNative.Elf64_Word st_name; + + /// + /// Symbol type and binding + /// + public byte st_info; + + /// + /// Symbol visibility + /// + public byte st_other; + + /// + /// Section index + /// + public ElfNative.Elf64_Section st_shndx; + + /// + /// Symbol value + /// + public ElfNative.Elf64_Addr st_value; + + /// + /// Symbol size + /// + public ElfNative.Elf64_Xword st_size; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Section : IEquatable + { + public Elf64_Section(ushort value) => this.Value = value; + + public readonly ushort Value; + + public bool Equals(Elf64_Section other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Section other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ushort(Elf64_Section from) => from.Value; + + public static implicit operator Elf64_Section(ushort from) => new Elf64_Section(from); + + public static bool operator ==(Elf64_Section left, Elf64_Section right) => left.Equals(right); + + public static bool operator !=(Elf64_Section left, Elf64_Section right) => !left.Equals(right); + } + + /// + /// The syminfo section if available contains additional information about + /// every dynamic symbol. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Syminfo + { + /// + /// Direct bindings, symbol bound to + /// + public ElfNative.Elf32_Half si_boundto; + + /// + /// Per symbol flags + /// + public ElfNative.Elf32_Half si_flags; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Syminfo + { + /// + /// Direct bindings, symbol bound to + /// + public ElfNative.Elf64_Half si_boundto; + + /// + /// Per symbol flags + /// + public ElfNative.Elf64_Half si_flags; + } + + /// + /// Relocation table entry without addend (in section of type SHT_REL). + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Rel + { + /// + /// Address + /// + public ElfNative.Elf32_Addr r_offset; + + /// + /// Relocation type and symbol index + /// + public ElfNative.Elf32_Word r_info; + } + + /// + /// I have seen two different definitions of the Elf64_Rel and + /// Elf64_Rela structures, so we'll leave them out until Novell (or + /// whoever) gets their act together. + /// + /// + /// The following, at least, is used on Sparc v9, MIPS, and Alpha. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Rel + { + /// + /// Address + /// + public ElfNative.Elf64_Addr r_offset; + + /// + /// Relocation type and symbol index + /// + public ElfNative.Elf64_Xword r_info; + } + + /// + /// Relocation table entry with addend (in section of type SHT_RELA). + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Rela + { + /// + /// Address + /// + public ElfNative.Elf32_Addr r_offset; + + /// + /// Relocation type and symbol index + /// + public ElfNative.Elf32_Word r_info; + + /// + /// Addend + /// + public ElfNative.Elf32_Sword r_addend; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Sword : IEquatable + { + public Elf32_Sword(int value) => this.Value = value; + + public readonly int Value; + + public bool Equals(Elf32_Sword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Sword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator int(Elf32_Sword from) => from.Value; + + public static implicit operator Elf32_Sword(int from) => new Elf32_Sword(from); + + public static bool operator ==(Elf32_Sword left, Elf32_Sword right) => left.Equals(right); + + public static bool operator !=(Elf32_Sword left, Elf32_Sword right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Rela + { + /// + /// Address + /// + public ElfNative.Elf64_Addr r_offset; + + /// + /// Relocation type and symbol index + /// + public ElfNative.Elf64_Xword r_info; + + /// + /// Addend + /// + public ElfNative.Elf64_Sxword r_addend; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Sxword : IEquatable + { + public Elf64_Sxword(long value) => this.Value = value; + + public readonly long Value; + + public bool Equals(Elf64_Sxword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Sxword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator long(Elf64_Sxword from) => from.Value; + + public static implicit operator Elf64_Sxword(long from) => new Elf64_Sxword(from); + + public static bool operator ==(Elf64_Sxword left, Elf64_Sxword right) => left.Equals(right); + + public static bool operator !=(Elf64_Sxword left, Elf64_Sxword right) => !left.Equals(right); + } + + /// + /// Program segment header. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Phdr + { + /// + /// Segment type + /// + public ElfNative.Elf32_Word p_type; + + /// + /// Segment file offset + /// + public ElfNative.Elf32_Off p_offset; + + /// + /// Segment virtual address + /// + public ElfNative.Elf32_Addr p_vaddr; + + /// + /// Segment physical address + /// + public ElfNative.Elf32_Addr p_paddr; + + /// + /// Segment size in file + /// + public ElfNative.Elf32_Word p_filesz; + + /// + /// Segment size in memory + /// + public ElfNative.Elf32_Word p_memsz; + + /// + /// Segment flags + /// + public ElfNative.Elf32_Word p_flags; + + /// + /// Segment alignment + /// + public ElfNative.Elf32_Word p_align; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Phdr + { + /// + /// Segment type + /// + public ElfNative.Elf64_Word p_type; + + /// + /// Segment flags + /// + public ElfNative.Elf64_Word p_flags; + + /// + /// Segment file offset + /// + public ElfNative.Elf64_Off p_offset; + + /// + /// Segment virtual address + /// + public ElfNative.Elf64_Addr p_vaddr; + + /// + /// Segment physical address + /// + public ElfNative.Elf64_Addr p_paddr; + + /// + /// Segment size in file + /// + public ElfNative.Elf64_Xword p_filesz; + + /// + /// Segment size in memory + /// + public ElfNative.Elf64_Xword p_memsz; + + /// + /// Segment alignment + /// + public ElfNative.Elf64_Xword p_align; + } + + /// + /// Dynamic section entry. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Dyn + { + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] + public partial struct Elf32_Dyn_union_d_un + { + /// + /// Integer value + /// + [FieldOffset(0)] + public ElfNative.Elf32_Word d_val; + + /// + /// Address value + /// + [FieldOffset(0)] + public ElfNative.Elf32_Addr d_ptr; + } + + /// + /// Dynamic entry type + /// + public ElfNative.Elf32_Sword d_tag; + + public ElfNative.Elf32_Dyn.Elf32_Dyn_union_d_un d_un; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Dyn + { + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] + public partial struct Elf64_Dyn_union_d_un + { + /// + /// Integer value + /// + [FieldOffset(0)] + public ElfNative.Elf64_Xword d_val; + + /// + /// Address value + /// + [FieldOffset(0)] + public ElfNative.Elf64_Addr d_ptr; + } + + /// + /// Dynamic entry type + /// + public ElfNative.Elf64_Sxword d_tag; + + public ElfNative.Elf64_Dyn.Elf64_Dyn_union_d_un d_un; + } + + /// + /// Version definition sections. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Verdef + { + /// + /// Version revision + /// + public ElfNative.Elf32_Half vd_version; + + /// + /// Version information + /// + public ElfNative.Elf32_Half vd_flags; + + /// + /// Version Index + /// + public ElfNative.Elf32_Half vd_ndx; + + /// + /// Number of associated aux entries + /// + public ElfNative.Elf32_Half vd_cnt; + + /// + /// Version name hash value + /// + public ElfNative.Elf32_Word vd_hash; + + /// + /// Offset in bytes to verdaux array + /// + public ElfNative.Elf32_Word vd_aux; + + /// + /// Offset in bytes to next verdef + /// entry + /// + public ElfNative.Elf32_Word vd_next; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Verdef + { + /// + /// Version revision + /// + public ElfNative.Elf64_Half vd_version; + + /// + /// Version information + /// + public ElfNative.Elf64_Half vd_flags; + + /// + /// Version Index + /// + public ElfNative.Elf64_Half vd_ndx; + + /// + /// Number of associated aux entries + /// + public ElfNative.Elf64_Half vd_cnt; + + /// + /// Version name hash value + /// + public ElfNative.Elf64_Word vd_hash; + + /// + /// Offset in bytes to verdaux array + /// + public ElfNative.Elf64_Word vd_aux; + + /// + /// Offset in bytes to next verdef + /// entry + /// + public ElfNative.Elf64_Word vd_next; + } + + /// + /// Auxialiary version information. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Verdaux + { + /// + /// Version or dependency names + /// + public ElfNative.Elf32_Word vda_name; + + /// + /// Offset in bytes to next verdaux + /// entry + /// + public ElfNative.Elf32_Word vda_next; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Verdaux + { + /// + /// Version or dependency names + /// + public ElfNative.Elf64_Word vda_name; + + /// + /// Offset in bytes to next verdaux + /// entry + /// + public ElfNative.Elf64_Word vda_next; + } + + /// + /// Version dependency section. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Verneed + { + /// + /// Version of structure + /// + public ElfNative.Elf32_Half vn_version; + + /// + /// Number of associated aux entries + /// + public ElfNative.Elf32_Half vn_cnt; + + /// + /// Offset of filename for this + /// dependency + /// + public ElfNative.Elf32_Word vn_file; + + /// + /// Offset in bytes to vernaux array + /// + public ElfNative.Elf32_Word vn_aux; + + /// + /// Offset in bytes to next verneed + /// entry + /// + public ElfNative.Elf32_Word vn_next; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Verneed + { + /// + /// Version of structure + /// + public ElfNative.Elf64_Half vn_version; + + /// + /// Number of associated aux entries + /// + public ElfNative.Elf64_Half vn_cnt; + + /// + /// Offset of filename for this + /// dependency + /// + public ElfNative.Elf64_Word vn_file; + + /// + /// Offset in bytes to vernaux array + /// + public ElfNative.Elf64_Word vn_aux; + + /// + /// Offset in bytes to next verneed + /// entry + /// + public ElfNative.Elf64_Word vn_next; + } + + /// + /// Auxiliary needed version information. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Vernaux + { + /// + /// Hash value of dependency name + /// + public ElfNative.Elf32_Word vna_hash; + + /// + /// Dependency specific information + /// + public ElfNative.Elf32_Half vna_flags; + + /// + /// Unused + /// + public ElfNative.Elf32_Half vna_other; + + /// + /// Dependency name string offset + /// + public ElfNative.Elf32_Word vna_name; + + /// + /// Offset in bytes to next vernaux + /// entry + /// + public ElfNative.Elf32_Word vna_next; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Vernaux + { + /// + /// Hash value of dependency name + /// + public ElfNative.Elf64_Word vna_hash; + + /// + /// Dependency specific information + /// + public ElfNative.Elf64_Half vna_flags; + + /// + /// Unused + /// + public ElfNative.Elf64_Half vna_other; + + /// + /// Dependency name string offset + /// + public ElfNative.Elf64_Word vna_name; + + /// + /// Offset in bytes to next vernaux + /// entry + /// + public ElfNative.Elf64_Word vna_next; + } + + /// + /// This vector is normally only used by the program interpreter. The + /// usual definition in an ABI supplement uses the name auxv_t. The + /// vector is not usually defined in a standard + /// <elf + /// .h> file, but it + /// can't hurt. We rename it to avoid conflicts. The sizes of these + /// types are an arrangement between the exec server and the program + /// interpreter, so we don't fully specify them here. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_auxv_t + { + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] + public partial struct Elf32_auxv_t_union_a_un + { + /// + /// Integer value + /// + [FieldOffset(0)] + public uint a_val; + } + + /// + /// Entry type + /// + public uint a_type; + + public ElfNative.Elf32_auxv_t.Elf32_auxv_t_union_a_un a_un; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_auxv_t + { + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] + public partial struct Elf64_auxv_t_union_a_un + { + /// + /// Integer value + /// + [FieldOffset(0)] + public ulong a_val; + } + + /// + /// Entry type + /// + public ulong a_type; + + public ElfNative.Elf64_auxv_t.Elf64_auxv_t_union_a_un a_un; + } + + /// + /// Note section contents. Each entry in the note section begins with + /// a header of a fixed form. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Nhdr + { + /// + /// Length of the note's name. + /// + public ElfNative.Elf32_Word n_namesz; + + /// + /// Length of the note's descriptor. + /// + public ElfNative.Elf32_Word n_descsz; + + /// + /// Type of the note. + /// + public ElfNative.Elf32_Word n_type; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Nhdr + { + /// + /// Length of the note's name. + /// + public ElfNative.Elf64_Word n_namesz; + + /// + /// Length of the note's descriptor. + /// + public ElfNative.Elf64_Word n_descsz; + + /// + /// Type of the note. + /// + public ElfNative.Elf64_Word n_type; + } + + /// + /// Move records. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Move + { + /// + /// Symbol value. + /// + public ElfNative.Elf32_Xword m_value; + + /// + /// Size and index. + /// + public ElfNative.Elf32_Word m_info; + + /// + /// Symbol offset. + /// + public ElfNative.Elf32_Word m_poffset; + + /// + /// Repeat count. + /// + public ElfNative.Elf32_Half m_repeat; + + /// + /// Stride info. + /// + public ElfNative.Elf32_Half m_stride; + } + + /// + /// Types for signed and unsigned 64-bit quantities. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Xword : IEquatable + { + public Elf32_Xword(ulong value) => this.Value = value; + + public readonly ulong Value; + + public bool Equals(Elf32_Xword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Xword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ulong(Elf32_Xword from) => from.Value; + + public static implicit operator Elf32_Xword(ulong from) => new Elf32_Xword(from); + + public static bool operator ==(Elf32_Xword left, Elf32_Xword right) => left.Equals(right); + + public static bool operator !=(Elf32_Xword left, Elf32_Xword right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Move + { + /// + /// Symbol value. + /// + public ElfNative.Elf64_Xword m_value; + + /// + /// Size and index. + /// + public ElfNative.Elf64_Xword m_info; + + /// + /// Symbol offset. + /// + public ElfNative.Elf64_Xword m_poffset; + + /// + /// Repeat count. + /// + public ElfNative.Elf64_Half m_repeat; + + /// + /// Stride info. + /// + public ElfNative.Elf64_Half m_stride; + } + + /// + /// Entries found in sections of type SHT_MIPS_GPTAB. + /// + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] + public partial struct Elf32_gptab + { + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_gptab_gt_header + { + /// + /// -G value used for compilation. + /// + public ElfNative.Elf32_Word gt_current_g_value; + + /// + /// Not used. + /// + public ElfNative.Elf32_Word gt_unused; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_gptab_gt_entry + { + /// + /// If this value were used for -G. + /// + public ElfNative.Elf32_Word gt_g_value; + + /// + /// This many bytes would be used. + /// + public ElfNative.Elf32_Word gt_bytes; + } + + /// + /// First entry in section. + /// + [FieldOffset(0)] + public ElfNative.Elf32_gptab.Elf32_gptab_gt_header gt_header; + + /// + /// Subsequent entries in section. + /// + [FieldOffset(0)] + public ElfNative.Elf32_gptab.Elf32_gptab_gt_entry gt_entry; + } + + /// + /// Entry found in sections of type SHT_MIPS_REGINFO. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe partial struct Elf32_RegInfo + { + /// + /// General registers used. + /// + public ElfNative.Elf32_Word ri_gprmask; + + /// + /// Coprocessor registers used. + /// + public fixed uint ri_cprmask[4]; + + /// + /// $gp register value. + /// + public ElfNative.Elf32_Sword ri_gp_value; + } + + /// + /// Entries found in sections of type SHT_MIPS_OPTIONS. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf_Options + { + /// + /// Determines interpretation of the + /// variable part of descriptor. + /// + public byte kind; + + /// + /// Size of descriptor, including header. + /// + public byte size; + + /// + /// Section header index of section affected, + /// 0 for global options. + /// + public ElfNative.Elf32_Section section; + + /// + /// Kind-specific information. + /// + public ElfNative.Elf32_Word info; + } + + /// + /// Entry found in `.options' section. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf_Options_Hw + { + /// + /// Extra flags. + /// + public ElfNative.Elf32_Word hwp_flags1; + + /// + /// Extra flags. + /// + public ElfNative.Elf32_Word hwp_flags2; + } + + /// + /// Entries found in sections of type SHT_MIPS_LIBLIST. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf32_Lib + { + /// + /// Name (string table index) + /// + public ElfNative.Elf32_Word l_name; + + /// + /// Timestamp + /// + public ElfNative.Elf32_Word l_time_stamp; + + /// + /// Checksum + /// + public ElfNative.Elf32_Word l_checksum; + + /// + /// Interface version + /// + public ElfNative.Elf32_Word l_version; + + /// + /// Flags + /// + public ElfNative.Elf32_Word l_flags; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf64_Lib + { + /// + /// Name (string table index) + /// + public ElfNative.Elf64_Word l_name; + + /// + /// Timestamp + /// + public ElfNative.Elf64_Word l_time_stamp; + + /// + /// Checksum + /// + public ElfNative.Elf64_Word l_checksum; + + /// + /// Interface version + /// + public ElfNative.Elf64_Word l_version; + + /// + /// Flags + /// + public ElfNative.Elf64_Word l_flags; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public partial struct Elf_MIPS_ABIFlags_v0 + { + /// + /// Version of flags structure. + /// + public ElfNative.Elf32_Half version; + + /// + /// The level of the ISA: 1-5, 32, 64. + /// + public byte isa_level; + + /// + /// The revision of ISA: 0 for MIPS V and below, 1-n otherwise. + /// + public byte isa_rev; + + /// + /// The size of general purpose registers. + /// + public byte gpr_size; + + /// + /// The size of co-processor 1 registers. + /// + public byte cpr1_size; + + /// + /// The size of co-processor 2 registers. + /// + public byte cpr2_size; + + /// + /// The floating-point ABI. + /// + public byte fp_abi; + + /// + /// Processor-specific extension. + /// + public ElfNative.Elf32_Word isa_ext; + + /// + /// Mask of ASEs used. + /// + public ElfNative.Elf32_Word ases; + + /// + /// Mask of general flags. + /// + public ElfNative.Elf32_Word flags1; + + public ElfNative.Elf32_Word flags2; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Sword : IEquatable + { + public Elf64_Sword(int value) => this.Value = value; + + public readonly int Value; + + public bool Equals(Elf64_Sword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Sword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator int(Elf64_Sword from) => from.Value; + + public static implicit operator Elf64_Sword(int from) => new Elf64_Sword(from); + + public static bool operator ==(Elf64_Sword left, Elf64_Sword right) => left.Equals(right); + + public static bool operator !=(Elf64_Sword left, Elf64_Sword right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Sxword : IEquatable + { + public Elf32_Sxword(long value) => this.Value = value; + + public readonly long Value; + + public bool Equals(Elf32_Sxword other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Sxword other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator long(Elf32_Sxword from) => from.Value; + + public static implicit operator Elf32_Sxword(long from) => new Elf32_Sxword(from); + + public static bool operator ==(Elf32_Sxword left, Elf32_Sxword right) => left.Equals(right); + + public static bool operator !=(Elf32_Sxword left, Elf32_Sxword right) => !left.Equals(right); + } + + /// + /// Type for version symbol information. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Versym : IEquatable + { + public Elf32_Versym(ElfNative.Elf32_Half value) => this.Value = value; + + public readonly ElfNative.Elf32_Half Value; + + public bool Equals(Elf32_Versym other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Versym other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ElfNative.Elf32_Half(Elf32_Versym from) => from.Value; + + public static implicit operator Elf32_Versym(ElfNative.Elf32_Half from) => new Elf32_Versym(from); + + public static bool operator ==(Elf32_Versym left, Elf32_Versym right) => left.Equals(right); + + public static bool operator !=(Elf32_Versym left, Elf32_Versym right) => !left.Equals(right); + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf64_Versym : IEquatable + { + public Elf64_Versym(ElfNative.Elf64_Half value) => this.Value = value; + + public readonly ElfNative.Elf64_Half Value; + + public bool Equals(Elf64_Versym other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf64_Versym other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ElfNative.Elf64_Half(Elf64_Versym from) => from.Value; + + public static implicit operator Elf64_Versym(ElfNative.Elf64_Half from) => new Elf64_Versym(from); + + public static bool operator ==(Elf64_Versym left, Elf64_Versym right) => left.Equals(right); + + public static bool operator !=(Elf64_Versym left, Elf64_Versym right) => !left.Equals(right); + } + + /// + /// Entries found in sections of type SHT_MIPS_CONFLICT. + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public readonly partial struct Elf32_Conflict : IEquatable + { + public Elf32_Conflict(ElfNative.Elf32_Addr value) => this.Value = value; + + public readonly ElfNative.Elf32_Addr Value; + + public bool Equals(Elf32_Conflict other) => Value.Equals(other.Value); + + public override bool Equals(object obj) => obj is Elf32_Conflict other && Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public static implicit operator ElfNative.Elf32_Addr(Elf32_Conflict from) => from.Value; + + public static implicit operator Elf32_Conflict(ElfNative.Elf32_Addr from) => new Elf32_Conflict(from); + + public static bool operator ==(Elf32_Conflict left, Elf32_Conflict right) => left.Equals(right); + + public static bool operator !=(Elf32_Conflict left, Elf32_Conflict right) => !left.Equals(right); + } + + public const byte EI_NIDENT = 16; + + /// + /// File identification byte 0 index + /// + public const byte EI_MAG0 = 0; + + /// + /// Magic number byte 0 + /// + public const byte ELFMAG0 = 127; + + /// + /// File identification byte 1 index + /// + public const byte EI_MAG1 = 1; + + /// + /// Magic number byte 1 + /// + public const byte ELFMAG1 = 69; + + /// + /// File identification byte 2 index + /// + public const byte EI_MAG2 = 2; + + /// + /// Magic number byte 2 + /// + public const byte ELFMAG2 = 76; + + /// + /// File identification byte 3 index + /// + public const byte EI_MAG3 = 3; + + /// + /// Magic number byte 3 + /// + public const byte ELFMAG3 = 70; + + /// + /// File class byte index + /// + public const byte EI_CLASS = 4; + + /// + /// Invalid class + /// + public const byte ELFCLASSNONE = 0; + + /// + /// 32-bit objects + /// + public const byte ELFCLASS32 = 1; + + /// + /// 64-bit objects + /// + public const byte ELFCLASS64 = 2; + + public const byte ELFCLASSNUM = 3; + + /// + /// Data encoding byte index + /// + public const byte EI_DATA = 5; + + /// + /// Invalid data encoding + /// + public const byte ELFDATANONE = 0; + + /// + /// 2's complement, little endian + /// + public const byte ELFDATA2LSB = 1; + + /// + /// 2's complement, big endian + /// + public const byte ELFDATA2MSB = 2; + + public const byte ELFDATANUM = 3; + + /// + /// File version byte index + /// + public const byte EI_VERSION = 6; + + /// + /// OS ABI identification + /// + public const byte EI_OSABI = 7; + + /// + /// UNIX System V ABI + /// + public const byte ELFOSABI_NONE = 0; + + /// + /// UNIX System V ABI + /// + public const byte ELFOSABI_SYSV = 0; + + /// + /// HP-UX + /// + public const byte ELFOSABI_HPUX = 1; + + /// + /// NetBSD. + /// + public const byte ELFOSABI_NETBSD = 2; + + /// + /// Object uses GNU ELF extensions. + /// + public const byte ELFOSABI_GNU = 3; + + /// + /// Object uses GNU ELF extensions. + /// + public const byte ELFOSABI_LINUX = 3; + + /// + /// Sun Solaris. + /// + public const byte ELFOSABI_SOLARIS = 6; + + /// + /// IBM AIX. + /// + public const byte ELFOSABI_AIX = 7; + + /// + /// SGI Irix. + /// + public const byte ELFOSABI_IRIX = 8; + + /// + /// FreeBSD. + /// + public const byte ELFOSABI_FREEBSD = 9; + + /// + /// Compaq TRU64 UNIX. + /// + public const byte ELFOSABI_TRU64 = 10; + + /// + /// Novell Modesto. + /// + public const byte ELFOSABI_MODESTO = 11; + + /// + /// OpenBSD. + /// + public const byte ELFOSABI_OPENBSD = 12; + + /// + /// ARM EABI + /// + public const byte ELFOSABI_ARM_AEABI = 64; + + /// + /// ARM + /// + public const byte ELFOSABI_ARM = 97; + + /// + /// Standalone (embedded) application + /// + public const byte ELFOSABI_STANDALONE = 255; + + /// + /// ABI version + /// + public const byte EI_ABIVERSION = 8; + + /// + /// Byte index of padding bytes + /// + public const byte EI_PAD = 9; + + /// + /// No file type + /// + public const ushort ET_NONE = 0; + + /// + /// Relocatable file + /// + public const ushort ET_REL = 1; + + /// + /// Executable file + /// + public const ushort ET_EXEC = 2; + + /// + /// Shared object file + /// + public const ushort ET_DYN = 3; + + /// + /// Core file + /// + public const ushort ET_CORE = 4; + + /// + /// Number of defined types + /// + public const ushort ET_NUM = 5; + + /// + /// OS-specific range start + /// + public const ushort ET_LOOS = 65024; + + /// + /// OS-specific range end + /// + public const ushort ET_HIOS = 65279; + + /// + /// Processor-specific range start + /// + public const ushort ET_LOPROC = 65280; + + /// + /// Processor-specific range end + /// + public const ushort ET_HIPROC = 65535; + + /// + /// No machine + /// + public const ushort EM_NONE = 0; + + /// + /// AT + /// &T + /// WE 32100 + /// + public const ushort EM_M32 = 1; + + /// + /// SUN SPARC + /// + public const ushort EM_SPARC = 2; + + /// + /// Intel 80386 + /// + public const ushort EM_386 = 3; + + /// + /// Motorola m68k family + /// + public const ushort EM_68K = 4; + + /// + /// Motorola m88k family + /// + public const ushort EM_88K = 5; + + /// + /// Intel 80860 + /// + public const ushort EM_860 = 7; + + /// + /// MIPS R3000 big-endian + /// + public const ushort EM_MIPS = 8; + + /// + /// IBM System/370 + /// + public const ushort EM_S370 = 9; + + /// + /// MIPS R3000 little-endian + /// + public const ushort EM_MIPS_RS3_LE = 10; + + /// + /// HPPA + /// + public const ushort EM_PARISC = 15; + + /// + /// Fujitsu VPP500 + /// + public const ushort EM_VPP500 = 17; + + /// + /// Sun's "v8plus" + /// + public const ushort EM_SPARC32PLUS = 18; + + /// + /// Intel 80960 + /// + public const ushort EM_960 = 19; + + /// + /// PowerPC + /// + public const ushort EM_PPC = 20; + + /// + /// PowerPC 64-bit + /// + public const ushort EM_PPC64 = 21; + + /// + /// IBM S390 + /// + public const ushort EM_S390 = 22; + + /// + /// NEC V800 series + /// + public const ushort EM_V800 = 36; + + /// + /// Fujitsu FR20 + /// + public const ushort EM_FR20 = 37; + + /// + /// TRW RH-32 + /// + public const ushort EM_RH32 = 38; + + /// + /// Motorola RCE + /// + public const ushort EM_RCE = 39; + + /// + /// ARM + /// + public const ushort EM_ARM = 40; + + /// + /// Digital Alpha + /// + public const ushort EM_FAKE_ALPHA = 41; + + /// + /// Hitachi SH + /// + public const ushort EM_SH = 42; + + /// + /// SPARC v9 64-bit + /// + public const ushort EM_SPARCV9 = 43; + + /// + /// Siemens Tricore + /// + public const ushort EM_TRICORE = 44; + + /// + /// Argonaut RISC Core + /// + public const ushort EM_ARC = 45; + + /// + /// Hitachi H8/300 + /// + public const ushort EM_H8_300 = 46; + + /// + /// Hitachi H8/300H + /// + public const ushort EM_H8_300H = 47; + + /// + /// Hitachi H8S + /// + public const ushort EM_H8S = 48; + + /// + /// Hitachi H8/500 + /// + public const ushort EM_H8_500 = 49; + + /// + /// Intel Merced + /// + public const ushort EM_IA_64 = 50; + + /// + /// Stanford MIPS-X + /// + public const ushort EM_MIPS_X = 51; + + /// + /// Motorola Coldfire + /// + public const ushort EM_COLDFIRE = 52; + + /// + /// Motorola M68HC12 + /// + public const ushort EM_68HC12 = 53; + + /// + /// Fujitsu MMA Multimedia Accelerator + /// + public const ushort EM_MMA = 54; + + /// + /// Siemens PCP + /// + public const ushort EM_PCP = 55; + + /// + /// Sony nCPU embeeded RISC + /// + public const ushort EM_NCPU = 56; + + /// + /// Denso NDR1 microprocessor + /// + public const ushort EM_NDR1 = 57; + + /// + /// Motorola Start*Core processor + /// + public const ushort EM_STARCORE = 58; + + /// + /// Toyota ME16 processor + /// + public const ushort EM_ME16 = 59; + + /// + /// STMicroelectronic ST100 processor + /// + public const ushort EM_ST100 = 60; + + /// + /// Advanced Logic Corp. Tinyj emb.fam + /// + public const ushort EM_TINYJ = 61; + + /// + /// AMD x86-64 architecture + /// + public const ushort EM_X86_64 = 62; + + /// + /// Sony DSP Processor + /// + public const ushort EM_PDSP = 63; + + /// + /// Siemens FX66 microcontroller + /// + public const ushort EM_FX66 = 66; + + /// + /// STMicroelectronics ST9+ 8/16 mc + /// + public const ushort EM_ST9PLUS = 67; + + /// + /// STmicroelectronics ST7 8 bit mc + /// + public const ushort EM_ST7 = 68; + + /// + /// Motorola MC68HC16 microcontroller + /// + public const ushort EM_68HC16 = 69; + + /// + /// Motorola MC68HC11 microcontroller + /// + public const ushort EM_68HC11 = 70; + + /// + /// Motorola MC68HC08 microcontroller + /// + public const ushort EM_68HC08 = 71; + + /// + /// Motorola MC68HC05 microcontroller + /// + public const ushort EM_68HC05 = 72; + + /// + /// Silicon Graphics SVx + /// + public const ushort EM_SVX = 73; + + /// + /// STMicroelectronics ST19 8 bit mc + /// + public const ushort EM_ST19 = 74; + + /// + /// Digital VAX + /// + public const ushort EM_VAX = 75; + + /// + /// Axis Communications 32-bit embedded processor + /// + public const ushort EM_CRIS = 76; + + /// + /// Infineon Technologies 32-bit embedded processor + /// + public const ushort EM_JAVELIN = 77; + + /// + /// Element 14 64-bit DSP Processor + /// + public const ushort EM_FIREPATH = 78; + + /// + /// LSI Logic 16-bit DSP Processor + /// + public const ushort EM_ZSP = 79; + + /// + /// Donald Knuth's educational 64-bit processor + /// + public const ushort EM_MMIX = 80; + + /// + /// Harvard University machine-independent object files + /// + public const ushort EM_HUANY = 81; + + /// + /// SiTera Prism + /// + public const ushort EM_PRISM = 82; + + /// + /// Atmel AVR 8-bit microcontroller + /// + public const ushort EM_AVR = 83; + + /// + /// Fujitsu FR30 + /// + public const ushort EM_FR30 = 84; + + /// + /// Mitsubishi D10V + /// + public const ushort EM_D10V = 85; + + /// + /// Mitsubishi D30V + /// + public const ushort EM_D30V = 86; + + /// + /// NEC v850 + /// + public const ushort EM_V850 = 87; + + /// + /// Mitsubishi M32R + /// + public const ushort EM_M32R = 88; + + /// + /// Matsushita MN10300 + /// + public const ushort EM_MN10300 = 89; + + /// + /// Matsushita MN10200 + /// + public const ushort EM_MN10200 = 90; + + /// + /// picoJava + /// + public const ushort EM_PJ = 91; + + /// + /// OpenRISC 32-bit embedded processor + /// + public const ushort EM_OPENRISC = 92; + + /// + /// ARC Cores Tangent-A5 + /// + public const ushort EM_ARC_A5 = 93; + + /// + /// Tensilica Xtensa Architecture + /// + public const ushort EM_XTENSA = 94; + + /// + /// Altera Nios II + /// + public const ushort EM_ALTERA_NIOS2 = 113; + + /// + /// ARM AARCH64 + /// + public const ushort EM_AARCH64 = 183; + + /// + /// Tilera TILEPro + /// + public const ushort EM_TILEPRO = 188; + + /// + /// Xilinx MicroBlaze + /// + public const ushort EM_MICROBLAZE = 189; + + /// + /// Tilera TILE-Gx + /// + public const ushort EM_TILEGX = 191; + + public const ushort EM_NUM = 192; + + public const ushort EM_ALPHA = 36902; + + /// + /// Invalid ELF version + /// + public const byte EV_NONE = 0; + + /// + /// Current version + /// + public const byte EV_CURRENT = 1; + + public const byte EV_NUM = 2; + + /// + /// Undefined section + /// + public const uint SHN_UNDEF = 0; + + /// + /// Start of reserved indices *k/ + /// #define SHN_LOPROC 0xff00 /* Start of processor-specific + /// + public const uint SHN_LORESERVE = 65280; + + /// + /// Order section before all others (Solaris). + /// + public const uint SHN_BEFORE = 65280; + + /// + /// Order section after all others (Solaris). + /// + public const uint SHN_AFTER = 65281; + + /// + /// End of processor-specific + /// + public const uint SHN_HIPROC = 65311; + + /// + /// Start of OS-specific + /// + public const uint SHN_LOOS = 65312; + + /// + /// End of OS-specific + /// + public const uint SHN_HIOS = 65343; + + /// + /// Associated symbol is absolute + /// + public const uint SHN_ABS = 65521; + + /// + /// Associated symbol is common + /// + public const uint SHN_COMMON = 65522; + + /// + /// Index is in extra table. + /// + public const uint SHN_XINDEX = 65535; + + /// + /// End of reserved indices + /// + public const uint SHN_HIRESERVE = 65535; + + /// + /// Section header table entry unused + /// + public const uint SHT_NULL = 0; + + /// + /// Program data + /// + public const uint SHT_PROGBITS = 1; + + /// + /// Symbol table + /// + public const uint SHT_SYMTAB = 2; + + /// + /// String table + /// + public const uint SHT_STRTAB = 3; + + /// + /// Relocation entries with addends + /// + public const uint SHT_RELA = 4; + + /// + /// Symbol hash table + /// + public const uint SHT_HASH = 5; + + /// + /// Dynamic linking information + /// + public const uint SHT_DYNAMIC = 6; + + /// + /// Notes + /// + public const uint SHT_NOTE = 7; + + /// + /// Program space with no data (bss) + /// + public const uint SHT_NOBITS = 8; + + /// + /// Relocation entries, no addends + /// + public const uint SHT_REL = 9; + + /// + /// Reserved + /// + public const uint SHT_SHLIB = 10; + + /// + /// Dynamic linker symbol table + /// + public const uint SHT_DYNSYM = 11; + + /// + /// Array of constructors + /// + public const uint SHT_INIT_ARRAY = 14; + + /// + /// Array of destructors + /// + public const uint SHT_FINI_ARRAY = 15; + + /// + /// Array of pre-constructors + /// + public const uint SHT_PREINIT_ARRAY = 16; + + /// + /// Section group + /// + public const uint SHT_GROUP = 17; + + /// + /// Extended section indeces + /// + public const uint SHT_SYMTAB_SHNDX = 18; + + /// + /// Number of defined types. + /// + public const uint SHT_NUM = 19; + + /// + /// Start OS-specific. + /// + public const uint SHT_LOOS = 1610612736; + + /// + /// Object attributes. + /// + public const uint SHT_GNU_ATTRIBUTES = 1879048181; + + /// + /// GNU-style hash table. + /// + public const uint SHT_GNU_HASH = 1879048182; + + /// + /// Prelink library list + /// + public const uint SHT_GNU_LIBLIST = 1879048183; + + /// + /// Checksum for DSO content. + /// + public const uint SHT_CHECKSUM = 1879048184; + + /// + /// Sun-specific low bound. + /// + public const uint SHT_LOSUNW = 1879048186; + + public const uint SHT_SUNW_move = 1879048186; + + public const uint SHT_SUNW_COMDAT = 1879048187; + + public const uint SHT_SUNW_syminfo = 1879048188; + + /// + /// Version definition section. + /// + public const uint SHT_GNU_verdef = 1879048189; + + /// + /// Version needs section. + /// + public const uint SHT_GNU_verneed = 1879048190; + + /// + /// Version symbol table. + /// + public const uint SHT_GNU_versym = 1879048191; + + /// + /// Sun-specific high bound. + /// + public const uint SHT_HISUNW = 1879048191; + + /// + /// End OS-specific type + /// + public const uint SHT_HIOS = 1879048191; + + /// + /// Start of processor-specific + /// + public const uint SHT_LOPROC = 1879048192; + + /// + /// End of processor-specific + /// + public const uint SHT_HIPROC = 2147483647; + + /// + /// Start of application-specific + /// + public const uint SHT_LOUSER = 0x80000000; + + /// + /// End of application-specific + /// + public const uint SHT_HIUSER = 0x8fffffff; + + /// + /// Writable + /// + public const uint SHF_WRITE = 1; + + /// + /// Occupies memory during execution + /// + public const uint SHF_ALLOC = 2; + + /// + /// Executable + /// + public const uint SHF_EXECINSTR = 4; + + /// + /// Might be merged + /// + public const uint SHF_MERGE = 16; + + /// + /// Contains nul-terminated strings + /// + public const uint SHF_STRINGS = 32; + + /// + /// `sh_info' contains SHT index + /// + public const uint SHF_INFO_LINK = 64; + + /// + /// Preserve order after combining + /// + public const uint SHF_LINK_ORDER = 128; + + /// + /// Non-standard OS specific handling required + /// + public const uint SHF_OS_NONCONFORMING = 256; + + /// + /// Section is member of a group. + /// + public const uint SHF_GROUP = 512; + + /// + /// Section hold thread-local data. + /// + public const uint SHF_TLS = 1024; + + /// + /// Section with compressed data. + /// + public const uint SHF_COMPRESSED = 2048; + + /// + /// OS-specific. + /// + public const uint SHF_MASKOS = 267386880; + + /// + /// Processor-specific + /// + public const uint SHF_MASKPROC = 0xf0000000; + + /// + /// Special ordering requirement (Solaris). + /// + public const uint SHF_ORDERED = 1073741824; + + /// + /// Section is excluded unless referenced or allocated (Solaris). + /// + public const uint SHF_EXCLUDE = (1U << 31); + + /// + /// ZLIB/DEFLATE algorithm. + /// + public const int ELFCOMPRESS_ZLIB = 1; + + /// + /// Start of OS-specific. + /// + public const int ELFCOMPRESS_LOOS = 0x60000000; + + /// + /// End of OS-specific. + /// + public const int ELFCOMPRESS_HIOS = 0x6fffffff; + + /// + /// Start of processor-specific. + /// + public const int ELFCOMPRESS_LOPROC = 0x70000000; + + /// + /// End of processor-specific. + /// + public const int ELFCOMPRESS_HIPROC = 0x7fffffff; + + /// + /// Symbol bound to self + /// + public const ushort SYMINFO_BT_SELF = 65535; + + /// + /// Symbol bound to parent + /// + public const ushort SYMINFO_BT_PARENT = 65534; + + /// + /// Beginning of reserved entries + /// + public const ushort SYMINFO_BT_LOWRESERVE = 65280; + + /// + /// Direct bound symbol + /// + public const ushort SYMINFO_FLG_DIRECT = 1; + + /// + /// Pass-thru symbol for translator + /// + public const ushort SYMINFO_FLG_PASSTHRU = 2; + + /// + /// Symbol is a copy-reloc + /// + public const ushort SYMINFO_FLG_COPY = 4; + + /// + /// Symbol bound to object to be lazy loaded + /// + public const ushort SYMINFO_FLG_LAZYLOAD = 8; + + public const ushort SYMINFO_NONE = 0; + + public const ushort SYMINFO_CURRENT = 1; + + public const ushort SYMINFO_NUM = 2; + + /// + /// Local symbol + /// + public const byte STB_LOCAL = 0; + + /// + /// Global symbol + /// + public const byte STB_GLOBAL = 1; + + /// + /// Weak symbol + /// + public const byte STB_WEAK = 2; + + /// + /// Number of defined types. + /// + public const byte STB_NUM = 3; + + /// + /// Start of OS-specific + /// + public const byte STB_LOOS = 10; + + /// + /// Unique symbol. + /// + public const byte STB_GNU_UNIQUE = 10; + + /// + /// End of OS-specific + /// + public const byte STB_HIOS = 12; + + /// + /// Start of processor-specific + /// + public const byte STB_LOPROC = 13; + + /// + /// End of processor-specific + /// + public const byte STB_HIPROC = 15; + + /// + /// Symbol type is unspecified + /// + public const byte STT_NOTYPE = 0; + + /// + /// Symbol is a data object + /// + public const byte STT_OBJECT = 1; + + /// + /// Symbol is a code object + /// + public const byte STT_FUNC = 2; + + /// + /// Symbol associated with a section + /// + public const byte STT_SECTION = 3; + + /// + /// Symbol's name is file name + /// + public const byte STT_FILE = 4; + + /// + /// Symbol is a common data object + /// + public const byte STT_COMMON = 5; + + /// + /// Symbol is thread-local data object + /// + public const byte STT_TLS = 6; + + /// + /// Number of defined types. + /// + public const byte STT_NUM = 7; + + /// + /// Start of OS-specific + /// + public const byte STT_LOOS = 10; + + /// + /// Symbol is indirect code object + /// + public const byte STT_GNU_IFUNC = 10; + + /// + /// End of OS-specific + /// + public const byte STT_HIOS = 12; + + /// + /// Start of processor-specific + /// + public const byte STT_LOPROC = 13; + + /// + /// End of processor-specific + /// + public const byte STT_HIPROC = 15; + + /// + /// End of a chain. + /// + public const byte STN_UNDEF = 0; + + /// + /// Default symbol visibility rules + /// + public const byte STV_DEFAULT = 0; + + /// + /// Processor specific hidden class + /// + public const byte STV_INTERNAL = 1; + + /// + /// Sym unavailable in other modules + /// + public const byte STV_HIDDEN = 2; + + /// + /// Not preemptible, not exported + /// + public const byte STV_PROTECTED = 3; + + /// + /// Program header table entry unused + /// + public const uint PT_NULL = 0; + + /// + /// Loadable program segment + /// + public const uint PT_LOAD = 1; + + /// + /// Dynamic linking information + /// + public const uint PT_DYNAMIC = 2; + + /// + /// Program interpreter + /// + public const uint PT_INTERP = 3; + + /// + /// Auxiliary information + /// + public const uint PT_NOTE = 4; + + /// + /// Reserved + /// + public const uint PT_SHLIB = 5; + + /// + /// Entry for header table itself + /// + public const uint PT_PHDR = 6; + + /// + /// Thread-local storage segment + /// + public const uint PT_TLS = 7; + + /// + /// Number of defined types + /// + public const uint PT_NUM = 8; + + /// + /// Start of OS-specific + /// + public const uint PT_LOOS = 1610612736; + + /// + /// GCC .eh_frame_hdr segment + /// + public const uint PT_GNU_EH_FRAME = 1685382480; + + /// + /// Indicates stack executability + /// + public const uint PT_GNU_STACK = 1685382481; + + /// + /// Read-only after relocation + /// + public const uint PT_GNU_RELRO = 1685382482; + + public const uint PT_LOSUNW = 1879048186; + + /// + /// Sun Specific segment + /// + public const uint PT_SUNWBSS = 1879048186; + + /// + /// Stack segment + /// + public const uint PT_SUNWSTACK = 1879048187; + + public const uint PT_HISUNW = 1879048191; + + /// + /// End of OS-specific + /// + public const uint PT_HIOS = 1879048191; + + /// + /// Start of processor-specific + /// + public const uint PT_LOPROC = 1879048192; + + /// + /// End of processor-specific + /// + public const uint PT_HIPROC = 2147483647; + + /// + /// Segment is executable + /// + public const uint PF_X = 1; + + /// + /// Segment is writable + /// + public const uint PF_W = 2; + + /// + /// Segment is readable + /// + public const uint PF_R = 4; + + /// + /// OS-specific + /// + public const uint PF_MASKOS = 267386880; + + /// + /// Processor-specific + /// + public const uint PF_MASKPROC = 0xf0000000; + + /// + /// Contains copy of prstatus struct + /// + public const uint NT_PRSTATUS = 1; + + /// + /// Contains copy of fpregset struct + /// + public const uint NT_FPREGSET = 2; + + /// + /// Contains copy of prpsinfo struct + /// + public const uint NT_PRPSINFO = 3; + + /// + /// Contains copy of prxregset struct + /// + public const uint NT_PRXREG = 4; + + /// + /// Contains copy of task structure + /// + public const uint NT_TASKSTRUCT = 4; + + /// + /// String from sysinfo(SI_PLATFORM) + /// + public const uint NT_PLATFORM = 5; + + /// + /// Contains copy of auxv array + /// + public const uint NT_AUXV = 6; + + /// + /// Contains copy of gwindows struct + /// + public const uint NT_GWINDOWS = 7; + + /// + /// Contains copy of asrset struct + /// + public const uint NT_ASRS = 8; + + /// + /// Contains copy of pstatus struct + /// + public const uint NT_PSTATUS = 10; + + /// + /// Contains copy of psinfo struct + /// + public const uint NT_PSINFO = 13; + + /// + /// Contains copy of prcred struct + /// + public const uint NT_PRCRED = 14; + + /// + /// Contains copy of utsname struct + /// + public const uint NT_UTSNAME = 15; + + /// + /// Contains copy of lwpstatus struct + /// + public const uint NT_LWPSTATUS = 16; + + /// + /// Contains copy of lwpinfo struct + /// + public const uint NT_LWPSINFO = 17; + + /// + /// Contains copy of fprxregset struct + /// + public const uint NT_PRFPXREG = 20; + + /// + /// Contains copy of siginfo_t, size might increase + /// + public const uint NT_SIGINFO = 1397311305; + + /// + /// Contains information about mapped files + /// + public const uint NT_FILE = 1179208773; + + /// + /// Contains copy of user_fxsr_struct + /// + public const uint NT_PRXFPREG = 1189489535; + + /// + /// PowerPC Altivec/VMX registers + /// + public const uint NT_PPC_VMX = 256; + + /// + /// PowerPC SPE/EVR registers + /// + public const uint NT_PPC_SPE = 257; + + /// + /// PowerPC VSX registers + /// + public const uint NT_PPC_VSX = 258; + + /// + /// i386 TLS slots (struct user_desc) + /// + public const uint NT_386_TLS = 512; + + /// + /// x86 io permission bitmap (1=deny) + /// + public const uint NT_386_IOPERM = 513; + + /// + /// x86 extended state using xsave + /// + public const uint NT_X86_XSTATE = 514; + + /// + /// s390 upper register halves + /// + public const uint NT_S390_HIGH_GPRS = 768; + + /// + /// s390 timer register + /// + public const uint NT_S390_TIMER = 769; + + /// + /// s390 TOD clock comparator register + /// + public const uint NT_S390_TODCMP = 770; + + /// + /// s390 TOD programmable register + /// + public const uint NT_S390_TODPREG = 771; + + /// + /// s390 control registers + /// + public const uint NT_S390_CTRS = 772; + + /// + /// s390 prefix register + /// + public const uint NT_S390_PREFIX = 773; + + /// + /// s390 breaking event address + /// + public const uint NT_S390_LAST_BREAK = 774; + + /// + /// s390 system call restart data + /// + public const uint NT_S390_SYSTEM_CALL = 775; + + /// + /// s390 transaction diagnostic block + /// + public const uint NT_S390_TDB = 776; + + /// + /// ARM VFP/NEON registers + /// + public const uint NT_ARM_VFP = 1024; + + /// + /// ARM TLS register + /// + public const uint NT_ARM_TLS = 1025; + + /// + /// ARM hardware breakpoint registers + /// + public const uint NT_ARM_HW_BREAK = 1026; + + /// + /// ARM hardware watchpoint registers + /// + public const uint NT_ARM_HW_WATCH = 1027; + + /// + /// Contains a version string. + /// + public const uint NT_VERSION = 1; + + /// + /// Marks end of dynamic section + /// + public const int DT_NULL = 0; + + /// + /// Name of needed library + /// + public const int DT_NEEDED = 1; + + /// + /// Size in bytes of PLT relocs + /// + public const int DT_PLTRELSZ = 2; + + /// + /// Processor defined value + /// + public const int DT_PLTGOT = 3; + + /// + /// Address of symbol hash table + /// + public const int DT_HASH = 4; + + /// + /// Address of string table + /// + public const int DT_STRTAB = 5; + + /// + /// Address of symbol table + /// + public const int DT_SYMTAB = 6; + + /// + /// Address of Rela relocs + /// + public const int DT_RELA = 7; + + /// + /// Total size of Rela relocs + /// + public const int DT_RELASZ = 8; + + /// + /// Size of one Rela reloc + /// + public const int DT_RELAENT = 9; + + /// + /// Size of string table + /// + public const int DT_STRSZ = 10; + + /// + /// Size of one symbol table entry + /// + public const int DT_SYMENT = 11; + + /// + /// Address of init function + /// + public const int DT_INIT = 12; + + /// + /// Address of termination function + /// + public const int DT_FINI = 13; + + /// + /// Name of shared object + /// + public const int DT_SONAME = 14; + + /// + /// Library search path (deprecated) + /// + public const int DT_RPATH = 15; + + /// + /// Start symbol search here + /// + public const int DT_SYMBOLIC = 16; + + /// + /// Address of Rel relocs + /// + public const int DT_REL = 17; + + /// + /// Total size of Rel relocs + /// + public const int DT_RELSZ = 18; + + /// + /// Size of one Rel reloc + /// + public const int DT_RELENT = 19; + + /// + /// Type of reloc in PLT + /// + public const int DT_PLTREL = 20; + + /// + /// For debugging; unspecified + /// + public const int DT_DEBUG = 21; + + /// + /// Reloc might modify .text + /// + public const int DT_TEXTREL = 22; + + /// + /// Address of PLT relocs + /// + public const int DT_JMPREL = 23; + + /// + /// Process relocations of object + /// + public const int DT_BIND_NOW = 24; + + /// + /// Array with addresses of init fct + /// + public const int DT_INIT_ARRAY = 25; + + /// + /// Array with addresses of fini fct + /// + public const int DT_FINI_ARRAY = 26; + + /// + /// Size in bytes of DT_INIT_ARRAY + /// + public const int DT_INIT_ARRAYSZ = 27; + + /// + /// Size in bytes of DT_FINI_ARRAY + /// + public const int DT_FINI_ARRAYSZ = 28; + + /// + /// Library search path + /// + public const int DT_RUNPATH = 29; + + /// + /// Flags for the object being loaded + /// + public const int DT_FLAGS = 30; + + /// + /// Start of encoded range + /// + public const int DT_ENCODING = 32; + + /// + /// Array with addresses of preinit fct + /// + public const int DT_PREINIT_ARRAY = 32; + + /// + /// size in bytes of DT_PREINIT_ARRAY + /// + public const int DT_PREINIT_ARRAYSZ = 33; + + /// + /// Number used + /// + public const int DT_NUM = 34; + + /// + /// Start of OS-specific + /// + public const int DT_LOOS = 0x6000000d; + + /// + /// End of OS-specific + /// + public const int DT_HIOS = 0x6ffff000; + + /// + /// Start of processor-specific + /// + public const int DT_LOPROC = 0x70000000; + + /// + /// End of processor-specific + /// + public const int DT_HIPROC = 0x7fffffff; + + /// + /// Most used by any processor + /// + public const int DT_PROCNUM = 0x36; + + public const int DT_VALRNGLO = 0x6ffffd00; + + /// + /// Prelinking timestamp + /// + public const int DT_GNU_PRELINKED = 0x6ffffdf5; + + /// + /// Size of conflict section + /// + public const int DT_GNU_CONFLICTSZ = 0x6ffffdf6; + + /// + /// Size of library list + /// + public const int DT_GNU_LIBLISTSZ = 0x6ffffdf7; + + public const int DT_CHECKSUM = 0x6ffffdf8; + + public const int DT_PLTPADSZ = 0x6ffffdf9; + + public const int DT_MOVEENT = 0x6ffffdfa; + + public const int DT_MOVESZ = 0x6ffffdfb; + + /// + /// Feature selection (DTF_*). + /// + public const int DT_FEATURE_1 = 0x6ffffdfc; + + /// + /// Flags for DT_* entries, effecting the following DT_* entry. + /// + public const int DT_POSFLAG_1 = 0x6ffffdfd; + + /// + /// Size of syminfo table (in bytes) + /// + public const int DT_SYMINSZ = 0x6ffffdfe; + + /// + /// Entry size of syminfo + /// + public const int DT_SYMINENT = 0x6ffffdff; + + public const int DT_VALRNGHI = 0x6ffffdff; + + public const int DT_VALNUM = 12; + + public const int DT_ADDRRNGLO = 0x6ffffe00; + + /// + /// GNU-style hash table. + /// + public const int DT_GNU_HASH = 0x6ffffef5; + + public const int DT_TLSDESC_PLT = 0x6ffffef6; + + public const int DT_TLSDESC_GOT = 0x6ffffef7; + + /// + /// Start of conflict section + /// + public const int DT_GNU_CONFLICT = 0x6ffffef8; + + /// + /// Library list + /// + public const int DT_GNU_LIBLIST = 0x6ffffef9; + + /// + /// Configuration information. + /// + public const int DT_CONFIG = 0x6ffffefa; + + /// + /// Dependency auditing. + /// + public const int DT_DEPAUDIT = 0x6ffffefb; + + /// + /// Object auditing. + /// + public const int DT_AUDIT = 0x6ffffefc; + + /// + /// PLT padding. + /// + public const int DT_PLTPAD = 0x6ffffefd; + + /// + /// Move table. + /// + public const int DT_MOVETAB = 0x6ffffefe; + + /// + /// Syminfo table. + /// + public const int DT_SYMINFO = 0x6ffffeff; + + public const int DT_ADDRRNGHI = 0x6ffffeff; + + public const int DT_ADDRNUM = 11; + + public const int DT_VERSYM = 0x6ffffff0; + + public const int DT_RELACOUNT = 0x6ffffff9; + + public const int DT_RELCOUNT = 0x6ffffffa; + + /// + /// State flags, see DF_1_* below. + /// + public const int DT_FLAGS_1 = 0x6ffffffb; + + /// + /// Address of version definition table + /// + public const int DT_VERDEF = 0x6ffffffc; + + /// + /// Number of version definitions + /// + public const int DT_VERDEFNUM = 0x6ffffffd; + + /// + /// Address of table with needed versions + /// + public const int DT_VERNEED = 0x6ffffffe; + + /// + /// Number of needed versions + /// + public const int DT_VERNEEDNUM = 0x6fffffff; + + public const int DT_VERSIONTAGNUM = 16; + + /// + /// Shared object to load before self + /// + public const int DT_AUXILIARY = 0x7ffffffd; + + /// + /// Shared object to get values from + /// + public const int DT_FILTER = 0x7fffffff; + + public const int DT_EXTRANUM = 3; + + /// + /// Object may use DF_ORIGIN + /// + public const uint DF_ORIGIN = 1; + + /// + /// Symbol resolutions starts here + /// + public const uint DF_SYMBOLIC = 2; + + /// + /// Object contains text relocations + /// + public const uint DF_TEXTREL = 4; + + /// + /// No lazy binding for this object + /// + public const uint DF_BIND_NOW = 8; + + /// + /// Module uses the static TLS model + /// + public const uint DF_STATIC_TLS = 16; + + /// + /// Set RTLD_NOW for this object. + /// + public const uint DF_1_NOW = 1; + + /// + /// Set RTLD_GLOBAL for this object. + /// + public const uint DF_1_GLOBAL = 2; + + /// + /// Set RTLD_GROUP for this object. + /// + public const uint DF_1_GROUP = 4; + + /// + /// Set RTLD_NODELETE for this object. + /// + public const uint DF_1_NODELETE = 8; + + /// + /// Trigger filtee loading at runtime. + /// + public const uint DF_1_LOADFLTR = 16; + + /// + /// Set RTLD_INITFIRST for this object + /// + public const uint DF_1_INITFIRST = 32; + + /// + /// Set RTLD_NOOPEN for this object. + /// + public const uint DF_1_NOOPEN = 64; + + /// + /// $ORIGIN must be handled. + /// + public const uint DF_1_ORIGIN = 128; + + /// + /// Direct binding enabled. + /// + public const uint DF_1_DIRECT = 256; + + public const uint DF_1_TRANS = 512; + + /// + /// Object is used to interpose. + /// + public const uint DF_1_INTERPOSE = 1024; + + /// + /// Ignore default lib search path. + /// + public const uint DF_1_NODEFLIB = 2048; + + /// + /// Object can't be dldump'ed. + /// + public const uint DF_1_NODUMP = 4096; + + /// + /// Configuration alternative created. + /// + public const uint DF_1_CONFALT = 8192; + + /// + /// Filtee terminates filters search. + /// + public const uint DF_1_ENDFILTEE = 16384; + + /// + /// Disp reloc applied at build time. + /// + public const uint DF_1_DISPRELDNE = 32768; + + /// + /// Disp reloc applied at run-time. + /// + public const uint DF_1_DISPRELPND = 65536; + + /// + /// Object has no-direct binding. + /// + public const uint DF_1_NODIRECT = 131072; + + public const uint DF_1_IGNMULDEF = 262144; + + public const uint DF_1_NOKSYMS = 524288; + + public const uint DF_1_NOHDR = 1048576; + + /// + /// Object is modified after built. + /// + public const uint DF_1_EDITED = 2097152; + + public const uint DF_1_NORELOC = 4194304; + + /// + /// Object has individual interposers. + /// + public const uint DF_1_SYMINTPOSE = 8388608; + + /// + /// Global auditing required. + /// + public const uint DF_1_GLOBAUDIT = 16777216; + + /// + /// Singleton symbols are used. + /// + public const uint DF_1_SINGLETON = 33554432; + + public const uint DTF_1_PARINIT = 1; + + public const uint DTF_1_CONFEXP = 2; + + /// + /// Lazyload following object. + /// + public const uint DF_P1_LAZYLOAD = 1; + + /// + /// Symbols from next object are not generally available. + /// + public const uint DF_P1_GROUPPERM = 2; + + /// + /// No version + /// + public const ushort VER_DEF_NONE = 0; + + /// + /// Current version + /// + public const ushort VER_DEF_CURRENT = 1; + + /// + /// Given version number + /// + public const ushort VER_DEF_NUM = 2; + + /// + /// Version definition of file itself + /// + public const ushort VER_FLG_BASE = 1; + + /// + /// Weak version identifier + /// + public const ushort VER_FLG_WEAK = 2; + + /// + /// Symbol is local. + /// + public const ushort VER_NDX_LOCAL = 0; + + /// + /// Symbol is global. + /// + public const ushort VER_NDX_GLOBAL = 1; + + /// + /// Beginning of reserved entries. + /// + public const ushort VER_NDX_LORESERVE = 65280; + + /// + /// Symbol is to be eliminated. + /// + public const ushort VER_NDX_ELIMINATE = 65281; + + /// + /// No version + /// + public const ushort VER_NEED_NONE = 0; + + /// + /// Current version + /// + public const ushort VER_NEED_CURRENT = 1; + + /// + /// Given version number + /// + public const ushort VER_NEED_NUM = 2; + + public const uint NT_GNU_ABI_TAG = 1; + + public const uint ELF_NOTE_OS_LINUX = 0; + + public const uint ELF_NOTE_OS_GNU = 1; + + public const uint ELF_NOTE_OS_SOLARIS2 = 2; + + public const uint ELF_NOTE_OS_FREEBSD = 3; + + public const uint NT_GNU_HWCAP = 2; + + public const uint NT_GNU_BUILD_ID = 3; + + public const uint NT_GNU_GOLD_VERSION = 4; + + public const uint EF_CPU32 = 8454144; + + /// + /// No reloc + /// + public const uint R_68K_NONE = 0; + + /// + /// Direct 32 bit + /// + public const uint R_68K_32 = 1; + + /// + /// Direct 16 bit + /// + public const uint R_68K_16 = 2; + + /// + /// Direct 8 bit + /// + public const uint R_68K_8 = 3; + + /// + /// PC relative 32 bit + /// + public const uint R_68K_PC32 = 4; + + /// + /// PC relative 16 bit + /// + public const uint R_68K_PC16 = 5; + + /// + /// PC relative 8 bit + /// + public const uint R_68K_PC8 = 6; + + /// + /// 32 bit PC relative GOT entry + /// + public const uint R_68K_GOT32 = 7; + + /// + /// 16 bit PC relative GOT entry + /// + public const uint R_68K_GOT16 = 8; + + /// + /// 8 bit PC relative GOT entry + /// + public const uint R_68K_GOT8 = 9; + + /// + /// 32 bit GOT offset + /// + public const uint R_68K_GOT32O = 10; + + /// + /// 16 bit GOT offset + /// + public const uint R_68K_GOT16O = 11; + + /// + /// 8 bit GOT offset + /// + public const uint R_68K_GOT8O = 12; + + /// + /// 32 bit PC relative PLT address + /// + public const uint R_68K_PLT32 = 13; + + /// + /// 16 bit PC relative PLT address + /// + public const uint R_68K_PLT16 = 14; + + /// + /// 8 bit PC relative PLT address + /// + public const uint R_68K_PLT8 = 15; + + /// + /// 32 bit PLT offset + /// + public const uint R_68K_PLT32O = 16; + + /// + /// 16 bit PLT offset + /// + public const uint R_68K_PLT16O = 17; + + /// + /// 8 bit PLT offset + /// + public const uint R_68K_PLT8O = 18; + + /// + /// Copy symbol at runtime + /// + public const uint R_68K_COPY = 19; + + /// + /// Create GOT entry + /// + public const uint R_68K_GLOB_DAT = 20; + + /// + /// Create PLT entry + /// + public const uint R_68K_JMP_SLOT = 21; + + /// + /// Adjust by program base + /// + public const uint R_68K_RELATIVE = 22; + + /// + /// 32 bit GOT offset for GD + /// + public const uint R_68K_TLS_GD32 = 25; + + /// + /// 16 bit GOT offset for GD + /// + public const uint R_68K_TLS_GD16 = 26; + + /// + /// 8 bit GOT offset for GD + /// + public const uint R_68K_TLS_GD8 = 27; + + /// + /// 32 bit GOT offset for LDM + /// + public const uint R_68K_TLS_LDM32 = 28; + + /// + /// 16 bit GOT offset for LDM + /// + public const uint R_68K_TLS_LDM16 = 29; + + /// + /// 8 bit GOT offset for LDM + /// + public const uint R_68K_TLS_LDM8 = 30; + + /// + /// 32 bit module-relative offset + /// + public const uint R_68K_TLS_LDO32 = 31; + + /// + /// 16 bit module-relative offset + /// + public const uint R_68K_TLS_LDO16 = 32; + + /// + /// 8 bit module-relative offset + /// + public const uint R_68K_TLS_LDO8 = 33; + + /// + /// 32 bit GOT offset for IE + /// + public const uint R_68K_TLS_IE32 = 34; + + /// + /// 16 bit GOT offset for IE + /// + public const uint R_68K_TLS_IE16 = 35; + + /// + /// 8 bit GOT offset for IE + /// + public const uint R_68K_TLS_IE8 = 36; + + /// + /// 32 bit offset relative to static TLS block + /// + public const uint R_68K_TLS_LE32 = 37; + + /// + /// 16 bit offset relative to static TLS block + /// + public const uint R_68K_TLS_LE16 = 38; + + /// + /// 8 bit offset relative to static TLS block + /// + public const uint R_68K_TLS_LE8 = 39; + + /// + /// 32 bit module number + /// + public const uint R_68K_TLS_DTPMOD32 = 40; + + /// + /// 32 bit module-relative offset + /// + public const uint R_68K_TLS_DTPREL32 = 41; + + /// + /// 32 bit TP-relative offset + /// + public const uint R_68K_TLS_TPREL32 = 42; + + public const uint R_68K_NUM = 43; + + /// + /// No reloc + /// + public const uint R_386_NONE = 0; + + /// + /// Direct 32 bit + /// + public const uint R_386_32 = 1; + + /// + /// PC relative 32 bit + /// + public const uint R_386_PC32 = 2; + + /// + /// 32 bit GOT entry + /// + public const uint R_386_GOT32 = 3; + + /// + /// 32 bit PLT address + /// + public const uint R_386_PLT32 = 4; + + /// + /// Copy symbol at runtime + /// + public const uint R_386_COPY = 5; + + /// + /// Create GOT entry + /// + public const uint R_386_GLOB_DAT = 6; + + /// + /// Create PLT entry + /// + public const uint R_386_JMP_SLOT = 7; + + /// + /// Adjust by program base + /// + public const uint R_386_RELATIVE = 8; + + /// + /// 32 bit offset to GOT + /// + public const uint R_386_GOTOFF = 9; + + /// + /// 32 bit PC relative offset to GOT + /// + public const uint R_386_GOTPC = 10; + + public const uint R_386_32PLT = 11; + + /// + /// Offset in static TLS block + /// + public const uint R_386_TLS_TPOFF = 14; + + /// + /// Address of GOT entry for static TLS block offset + /// + public const uint R_386_TLS_IE = 15; + + /// + /// GOT entry for static TLS block offset + /// + public const uint R_386_TLS_GOTIE = 16; + + /// + /// Offset relative to static TLS block + /// + public const uint R_386_TLS_LE = 17; + + /// + /// Direct 32 bit for GNU version of general dynamic thread local data + /// + public const uint R_386_TLS_GD = 18; + + /// + /// Direct 32 bit for GNU version of local dynamic thread local data in LE code + /// + public const uint R_386_TLS_LDM = 19; + + public const uint R_386_16 = 20; + + public const uint R_386_PC16 = 21; + + public const uint R_386_8 = 22; + + public const uint R_386_PC8 = 23; + + /// + /// Direct 32 bit for general dynamic + /// thread local data + /// + public const uint R_386_TLS_GD_32 = 24; + + /// + /// Tag for pushl in GD TLS code + /// + public const uint R_386_TLS_GD_PUSH = 25; + + /// + /// Relocation for call to + /// __tls_get_addr() + /// + public const uint R_386_TLS_GD_CALL = 26; + + /// + /// Tag for popl in GD TLS code + /// + public const uint R_386_TLS_GD_POP = 27; + + /// + /// Direct 32 bit for local dynamic + /// thread local data in LE code + /// + public const uint R_386_TLS_LDM_32 = 28; + + /// + /// Tag for pushl in LDM TLS code + /// + public const uint R_386_TLS_LDM_PUSH = 29; + + /// + /// Relocation for call to + /// __tls_get_addr() in LDM code + /// + public const uint R_386_TLS_LDM_CALL = 30; + + /// + /// Tag for popl in LDM TLS code + /// + public const uint R_386_TLS_LDM_POP = 31; + + /// + /// Offset relative to TLS block + /// + public const uint R_386_TLS_LDO_32 = 32; + + /// + /// GOT entry for negated static TLS + /// block offset + /// + public const uint R_386_TLS_IE_32 = 33; + + /// + /// Negated offset relative to static + /// TLS block + /// + public const uint R_386_TLS_LE_32 = 34; + + /// + /// ID of module containing symbol + /// + public const uint R_386_TLS_DTPMOD32 = 35; + + /// + /// Offset in TLS block + /// + public const uint R_386_TLS_DTPOFF32 = 36; + + /// + /// Negated offset in static TLS block + /// + public const uint R_386_TLS_TPOFF32 = 37; + + /// + /// 32-bit symbol size + /// + public const uint R_386_SIZE32 = 38; + + /// + /// GOT offset for TLS descriptor. + /// + public const uint R_386_TLS_GOTDESC = 39; + + /// + /// Marker of call through TLS + /// descriptor for + /// relaxation. + /// + public const uint R_386_TLS_DESC_CALL = 40; + + /// + /// TLS descriptor containing + /// pointer to code and to + /// argument, returning the TLS + /// offset for the symbol. + /// + public const uint R_386_TLS_DESC = 41; + + /// + /// Adjust indirectly by program base + /// + public const uint R_386_IRELATIVE = 42; + + public const uint R_386_NUM = 43; + + /// + /// Global register reserved to app. + /// + public const byte STT_SPARC_REGISTER = 13; + + public const uint EF_SPARCV9_MM = 3; + + public const uint EF_SPARCV9_TSO = 0; + + public const uint EF_SPARCV9_PSO = 1; + + public const uint EF_SPARCV9_RMO = 2; + + /// + /// little endian data + /// + public const uint EF_SPARC_LEDATA = 8388608; + + public const uint EF_SPARC_EXT_MASK = 16776960; + + /// + /// generic V8+ features + /// + public const uint EF_SPARC_32PLUS = 256; + + /// + /// Sun UltraSPARC1 extensions + /// + public const uint EF_SPARC_SUN_US1 = 512; + + /// + /// HAL R1 extensions + /// + public const uint EF_SPARC_HAL_R1 = 1024; + + /// + /// Sun UltraSPARCIII extensions + /// + public const uint EF_SPARC_SUN_US3 = 2048; + + /// + /// No reloc + /// + public const uint R_SPARC_NONE = 0; + + /// + /// Direct 8 bit + /// + public const uint R_SPARC_8 = 1; + + /// + /// Direct 16 bit + /// + public const uint R_SPARC_16 = 2; + + /// + /// Direct 32 bit + /// + public const uint R_SPARC_32 = 3; + + /// + /// PC relative 8 bit + /// + public const uint R_SPARC_DISP8 = 4; + + /// + /// PC relative 16 bit + /// + public const uint R_SPARC_DISP16 = 5; + + /// + /// PC relative 32 bit + /// + public const uint R_SPARC_DISP32 = 6; + + /// + /// PC relative 30 bit shifted + /// + public const uint R_SPARC_WDISP30 = 7; + + /// + /// PC relative 22 bit shifted + /// + public const uint R_SPARC_WDISP22 = 8; + + /// + /// High 22 bit + /// + public const uint R_SPARC_HI22 = 9; + + /// + /// Direct 22 bit + /// + public const uint R_SPARC_22 = 10; + + /// + /// Direct 13 bit + /// + public const uint R_SPARC_13 = 11; + + /// + /// Truncated 10 bit + /// + public const uint R_SPARC_LO10 = 12; + + /// + /// Truncated 10 bit GOT entry + /// + public const uint R_SPARC_GOT10 = 13; + + /// + /// 13 bit GOT entry + /// + public const uint R_SPARC_GOT13 = 14; + + /// + /// 22 bit GOT entry shifted + /// + public const uint R_SPARC_GOT22 = 15; + + /// + /// PC relative 10 bit truncated + /// + public const uint R_SPARC_PC10 = 16; + + /// + /// PC relative 22 bit shifted + /// + public const uint R_SPARC_PC22 = 17; + + /// + /// 30 bit PC relative PLT address + /// + public const uint R_SPARC_WPLT30 = 18; + + /// + /// Copy symbol at runtime + /// + public const uint R_SPARC_COPY = 19; + + /// + /// Create GOT entry + /// + public const uint R_SPARC_GLOB_DAT = 20; + + /// + /// Create PLT entry + /// + public const uint R_SPARC_JMP_SLOT = 21; + + /// + /// Adjust by program base + /// + public const uint R_SPARC_RELATIVE = 22; + + /// + /// Direct 32 bit unaligned + /// + public const uint R_SPARC_UA32 = 23; + + /// + /// Direct 32 bit ref to PLT entry + /// + public const uint R_SPARC_PLT32 = 24; + + /// + /// High 22 bit PLT entry + /// + public const uint R_SPARC_HIPLT22 = 25; + + /// + /// Truncated 10 bit PLT entry + /// + public const uint R_SPARC_LOPLT10 = 26; + + /// + /// PC rel 32 bit ref to PLT entry + /// + public const uint R_SPARC_PCPLT32 = 27; + + /// + /// PC rel high 22 bit PLT entry + /// + public const uint R_SPARC_PCPLT22 = 28; + + /// + /// PC rel trunc 10 bit PLT entry + /// + public const uint R_SPARC_PCPLT10 = 29; + + /// + /// Direct 10 bit + /// + public const uint R_SPARC_10 = 30; + + /// + /// Direct 11 bit + /// + public const uint R_SPARC_11 = 31; + + /// + /// Direct 64 bit + /// + public const uint R_SPARC_64 = 32; + + /// + /// 10bit with secondary 13bit addend + /// + public const uint R_SPARC_OLO10 = 33; + + /// + /// Top 22 bits of direct 64 bit + /// + public const uint R_SPARC_HH22 = 34; + + /// + /// High middle 10 bits of ... + /// + public const uint R_SPARC_HM10 = 35; + + /// + /// Low middle 22 bits of ... + /// + public const uint R_SPARC_LM22 = 36; + + /// + /// Top 22 bits of pc rel 64 bit + /// + public const uint R_SPARC_PC_HH22 = 37; + + /// + /// High middle 10 bit of ... + /// + public const uint R_SPARC_PC_HM10 = 38; + + /// + /// Low miggle 22 bits of ... + /// + public const uint R_SPARC_PC_LM22 = 39; + + /// + /// PC relative 16 bit shifted + /// + public const uint R_SPARC_WDISP16 = 40; + + /// + /// PC relative 19 bit shifted + /// + public const uint R_SPARC_WDISP19 = 41; + + /// + /// was part of v9 ABI but was removed + /// + public const uint R_SPARC_GLOB_JMP = 42; + + /// + /// Direct 7 bit + /// + public const uint R_SPARC_7 = 43; + + /// + /// Direct 5 bit + /// + public const uint R_SPARC_5 = 44; + + /// + /// Direct 6 bit + /// + public const uint R_SPARC_6 = 45; + + /// + /// PC relative 64 bit + /// + public const uint R_SPARC_DISP64 = 46; + + /// + /// Direct 64 bit ref to PLT entry + /// + public const uint R_SPARC_PLT64 = 47; + + /// + /// High 22 bit complemented + /// + public const uint R_SPARC_HIX22 = 48; + + /// + /// Truncated 11 bit complemented + /// + public const uint R_SPARC_LOX10 = 49; + + /// + /// Direct high 12 of 44 bit + /// + public const uint R_SPARC_H44 = 50; + + /// + /// Direct mid 22 of 44 bit + /// + public const uint R_SPARC_M44 = 51; + + /// + /// Direct low 10 of 44 bit + /// + public const uint R_SPARC_L44 = 52; + + /// + /// Global register usage + /// + public const uint R_SPARC_REGISTER = 53; + + /// + /// Direct 64 bit unaligned + /// + public const uint R_SPARC_UA64 = 54; + + /// + /// Direct 16 bit unaligned + /// + public const uint R_SPARC_UA16 = 55; + + public const uint R_SPARC_TLS_GD_HI22 = 56; + + public const uint R_SPARC_TLS_GD_LO10 = 57; + + public const uint R_SPARC_TLS_GD_ADD = 58; + + public const uint R_SPARC_TLS_GD_CALL = 59; + + public const uint R_SPARC_TLS_LDM_HI22 = 60; + + public const uint R_SPARC_TLS_LDM_LO10 = 61; + + public const uint R_SPARC_TLS_LDM_ADD = 62; + + public const uint R_SPARC_TLS_LDM_CALL = 63; + + public const uint R_SPARC_TLS_LDO_HIX22 = 64; + + public const uint R_SPARC_TLS_LDO_LOX10 = 65; + + public const uint R_SPARC_TLS_LDO_ADD = 66; + + public const uint R_SPARC_TLS_IE_HI22 = 67; + + public const uint R_SPARC_TLS_IE_LO10 = 68; + + public const uint R_SPARC_TLS_IE_LD = 69; + + public const uint R_SPARC_TLS_IE_LDX = 70; + + public const uint R_SPARC_TLS_IE_ADD = 71; + + public const uint R_SPARC_TLS_LE_HIX22 = 72; + + public const uint R_SPARC_TLS_LE_LOX10 = 73; + + public const uint R_SPARC_TLS_DTPMOD32 = 74; + + public const uint R_SPARC_TLS_DTPMOD64 = 75; + + public const uint R_SPARC_TLS_DTPOFF32 = 76; + + public const uint R_SPARC_TLS_DTPOFF64 = 77; + + public const uint R_SPARC_TLS_TPOFF32 = 78; + + public const uint R_SPARC_TLS_TPOFF64 = 79; + + public const uint R_SPARC_GOTDATA_HIX22 = 80; + + public const uint R_SPARC_GOTDATA_LOX10 = 81; + + public const uint R_SPARC_GOTDATA_OP_HIX22 = 82; + + public const uint R_SPARC_GOTDATA_OP_LOX10 = 83; + + public const uint R_SPARC_GOTDATA_OP = 84; + + public const uint R_SPARC_H34 = 85; + + public const uint R_SPARC_SIZE32 = 86; + + public const uint R_SPARC_SIZE64 = 87; + + public const uint R_SPARC_WDISP10 = 88; + + public const uint R_SPARC_JMP_IREL = 248; + + public const uint R_SPARC_IRELATIVE = 249; + + public const uint R_SPARC_GNU_VTINHERIT = 250; + + public const uint R_SPARC_GNU_VTENTRY = 251; + + public const uint R_SPARC_REV32 = 252; + + public const uint R_SPARC_NUM = 253; + + public const int DT_SPARC_REGISTER = 0x70000001; + + public const int DT_SPARC_NUM = 2; + + /// + /// A .noreorder directive was used. + /// + public const uint EF_MIPS_NOREORDER = 1; + + /// + /// Contains PIC code. + /// + public const uint EF_MIPS_PIC = 2; + + /// + /// Uses PIC calling sequence. + /// + public const uint EF_MIPS_CPIC = 4; + + public const uint EF_MIPS_XGOT = 8; + + public const uint EF_MIPS_64BIT_WHIRL = 16; + + public const uint EF_MIPS_ABI2 = 32; + + public const uint EF_MIPS_ABI_ON32 = 64; + + /// + /// Uses FP64 (12 callee-saved). + /// + public const uint EF_MIPS_FP64 = 512; + + /// + /// Uses IEEE 754-2008 NaN encoding. + /// + public const uint EF_MIPS_NAN2008 = 1024; + + /// + /// MIPS architecture level. + /// + public const uint EF_MIPS_ARCH = 0xf0000000; + + /// + /// -mips1 code. + /// + public const uint EF_MIPS_ARCH_1 = 0; + + /// + /// -mips2 code. + /// + public const uint EF_MIPS_ARCH_2 = 268435456; + + /// + /// -mips3 code. + /// + public const uint EF_MIPS_ARCH_3 = 536870912; + + /// + /// -mips4 code. + /// + public const uint EF_MIPS_ARCH_4 = 805306368; + + /// + /// -mips5 code. + /// + public const uint EF_MIPS_ARCH_5 = 1073741824; + + /// + /// MIPS32 code. + /// + public const uint EF_MIPS_ARCH_32 = 1342177280; + + /// + /// MIPS64 code. + /// + public const uint EF_MIPS_ARCH_64 = 1610612736; + + /// + /// MIPS32r2 code. + /// + public const uint EF_MIPS_ARCH_32R2 = 1879048192; + + /// + /// MIPS64r2 code. + /// + public const uint EF_MIPS_ARCH_64R2 = 0x80000000; + + /// + /// Allocated common symbols. + /// + public const uint SHN_MIPS_ACOMMON = 65280; + + /// + /// Allocated test symbols. + /// + public const uint SHN_MIPS_TEXT = 65281; + + /// + /// Allocated data symbols. + /// + public const uint SHN_MIPS_DATA = 65282; + + /// + /// Small common symbols. + /// + public const uint SHN_MIPS_SCOMMON = 65283; + + /// + /// Small undefined symbols. + /// + public const uint SHN_MIPS_SUNDEFINED = 65284; + + /// + /// Shared objects used in link. + /// + public const uint SHT_MIPS_LIBLIST = 1879048192; + + public const uint SHT_MIPS_MSYM = 1879048193; + + /// + /// Conflicting symbols. + /// + public const uint SHT_MIPS_CONFLICT = 1879048194; + + /// + /// Global data area sizes. + /// + public const uint SHT_MIPS_GPTAB = 1879048195; + + /// + /// Reserved for SGI/MIPS compilers + /// + public const uint SHT_MIPS_UCODE = 1879048196; + + /// + /// MIPS ECOFF debugging info. + /// + public const uint SHT_MIPS_DEBUG = 1879048197; + + /// + /// Register usage information. + /// + public const uint SHT_MIPS_REGINFO = 1879048198; + + public const uint SHT_MIPS_PACKAGE = 1879048199; + + public const uint SHT_MIPS_PACKSYM = 1879048200; + + public const uint SHT_MIPS_RELD = 1879048201; + + public const uint SHT_MIPS_IFACE = 1879048203; + + public const uint SHT_MIPS_CONTENT = 1879048204; + + /// + /// Miscellaneous options. + /// + public const uint SHT_MIPS_OPTIONS = 1879048205; + + public const uint SHT_MIPS_SHDR = 1879048208; + + public const uint SHT_MIPS_FDESC = 1879048209; + + public const uint SHT_MIPS_EXTSYM = 1879048210; + + public const uint SHT_MIPS_DENSE = 1879048211; + + public const uint SHT_MIPS_PDESC = 1879048212; + + public const uint SHT_MIPS_LOCSYM = 1879048213; + + public const uint SHT_MIPS_AUXSYM = 1879048214; + + public const uint SHT_MIPS_OPTSYM = 1879048215; + + public const uint SHT_MIPS_LOCSTR = 1879048216; + + public const uint SHT_MIPS_LINE = 1879048217; + + public const uint SHT_MIPS_RFDESC = 1879048218; + + public const uint SHT_MIPS_DELTASYM = 1879048219; + + public const uint SHT_MIPS_DELTAINST = 1879048220; + + public const uint SHT_MIPS_DELTACLASS = 1879048221; + + /// + /// DWARF debugging information. + /// + public const uint SHT_MIPS_DWARF = 1879048222; + + public const uint SHT_MIPS_DELTADECL = 1879048223; + + public const uint SHT_MIPS_SYMBOL_LIB = 1879048224; + + /// + /// Event section. + /// + public const uint SHT_MIPS_EVENTS = 1879048225; + + public const uint SHT_MIPS_TRANSLATE = 1879048226; + + public const uint SHT_MIPS_PIXIE = 1879048227; + + public const uint SHT_MIPS_XLATE = 1879048228; + + public const uint SHT_MIPS_XLATE_DEBUG = 1879048229; + + public const uint SHT_MIPS_WHIRL = 1879048230; + + public const uint SHT_MIPS_EH_REGION = 1879048231; + + public const uint SHT_MIPS_XLATE_OLD = 1879048232; + + public const uint SHT_MIPS_PDR_EXCEPTION = 1879048233; + + /// + /// Must be in global data area. + /// + public const uint SHF_MIPS_GPREL = 268435456; + + public const uint SHF_MIPS_MERGE = 536870912; + + public const uint SHF_MIPS_ADDR = 1073741824; + + public const uint SHF_MIPS_STRINGS = 0x80000000; + + public const uint SHF_MIPS_NOSTRIP = 134217728; + + public const uint SHF_MIPS_LOCAL = 67108864; + + public const uint SHF_MIPS_NAMES = 33554432; + + public const uint SHF_MIPS_NODUPE = 16777216; + + public const byte STB_MIPS_SPLIT_COMMON = 13; + + /// + /// No reloc + /// + public const uint R_MIPS_NONE = 0; + + /// + /// Direct 16 bit + /// + public const uint R_MIPS_16 = 1; + + /// + /// Direct 32 bit + /// + public const uint R_MIPS_32 = 2; + + /// + /// PC relative 32 bit + /// + public const uint R_MIPS_REL32 = 3; + + /// + /// Direct 26 bit shifted + /// + public const uint R_MIPS_26 = 4; + + /// + /// High 16 bit + /// + public const uint R_MIPS_HI16 = 5; + + /// + /// Low 16 bit + /// + public const uint R_MIPS_LO16 = 6; + + /// + /// GP relative 16 bit + /// + public const uint R_MIPS_GPREL16 = 7; + + /// + /// 16 bit literal entry + /// + public const uint R_MIPS_LITERAL = 8; + + /// + /// 16 bit GOT entry + /// + public const uint R_MIPS_GOT16 = 9; + + /// + /// PC relative 16 bit + /// + public const uint R_MIPS_PC16 = 10; + + /// + /// 16 bit GOT entry for function + /// + public const uint R_MIPS_CALL16 = 11; + + /// + /// GP relative 32 bit + /// + public const uint R_MIPS_GPREL32 = 12; + + public const uint R_MIPS_SHIFT5 = 16; + + public const uint R_MIPS_SHIFT6 = 17; + + public const uint R_MIPS_64 = 18; + + public const uint R_MIPS_GOT_DISP = 19; + + public const uint R_MIPS_GOT_PAGE = 20; + + public const uint R_MIPS_GOT_OFST = 21; + + public const uint R_MIPS_GOT_HI16 = 22; + + public const uint R_MIPS_GOT_LO16 = 23; + + public const uint R_MIPS_SUB = 24; + + public const uint R_MIPS_INSERT_A = 25; + + public const uint R_MIPS_INSERT_B = 26; + + public const uint R_MIPS_DELETE = 27; + + public const uint R_MIPS_HIGHER = 28; + + public const uint R_MIPS_HIGHEST = 29; + + public const uint R_MIPS_CALL_HI16 = 30; + + public const uint R_MIPS_CALL_LO16 = 31; + + public const uint R_MIPS_SCN_DISP = 32; + + public const uint R_MIPS_REL16 = 33; + + public const uint R_MIPS_ADD_IMMEDIATE = 34; + + public const uint R_MIPS_PJUMP = 35; + + public const uint R_MIPS_RELGOT = 36; + + public const uint R_MIPS_JALR = 37; + + /// + /// Module number 32 bit + /// + public const uint R_MIPS_TLS_DTPMOD32 = 38; + + /// + /// Module-relative offset 32 bit + /// + public const uint R_MIPS_TLS_DTPREL32 = 39; + + /// + /// Module number 64 bit + /// + public const uint R_MIPS_TLS_DTPMOD64 = 40; + + /// + /// Module-relative offset 64 bit + /// + public const uint R_MIPS_TLS_DTPREL64 = 41; + + /// + /// 16 bit GOT offset for GD + /// + public const uint R_MIPS_TLS_GD = 42; + + /// + /// 16 bit GOT offset for LDM + /// + public const uint R_MIPS_TLS_LDM = 43; + + /// + /// Module-relative offset, high 16 bits + /// + public const uint R_MIPS_TLS_DTPREL_HI16 = 44; + + /// + /// Module-relative offset, low 16 bits + /// + public const uint R_MIPS_TLS_DTPREL_LO16 = 45; + + /// + /// 16 bit GOT offset for IE + /// + public const uint R_MIPS_TLS_GOTTPREL = 46; + + /// + /// TP-relative offset, 32 bit + /// + public const uint R_MIPS_TLS_TPREL32 = 47; + + /// + /// TP-relative offset, 64 bit + /// + public const uint R_MIPS_TLS_TPREL64 = 48; + + /// + /// TP-relative offset, high 16 bits + /// + public const uint R_MIPS_TLS_TPREL_HI16 = 49; + + /// + /// TP-relative offset, low 16 bits + /// + public const uint R_MIPS_TLS_TPREL_LO16 = 50; + + public const uint R_MIPS_GLOB_DAT = 51; + + public const uint R_MIPS_COPY = 126; + + public const uint R_MIPS_JUMP_SLOT = 127; + + public const uint R_MIPS_NUM = 128; + + /// + /// Register usage information. + /// + public const uint PT_MIPS_REGINFO = 1879048192; + + /// + /// Runtime procedure table. + /// + public const uint PT_MIPS_RTPROC = 1879048193; + + public const uint PT_MIPS_OPTIONS = 1879048194; + + /// + /// FP mode requirement. + /// + public const uint PT_MIPS_ABIFLAGS = 1879048195; + + public const uint PF_MIPS_LOCAL = 268435456; + + /// + /// Runtime linker interface version + /// + public const int DT_MIPS_RLD_VERSION = 0x70000001; + + /// + /// Timestamp + /// + public const int DT_MIPS_TIME_STAMP = 0x70000002; + + /// + /// Checksum + /// + public const int DT_MIPS_ICHECKSUM = 0x70000003; + + /// + /// Version string (string tbl index) + /// + public const int DT_MIPS_IVERSION = 0x70000004; + + /// + /// Flags + /// + public const int DT_MIPS_FLAGS = 0x70000005; + + /// + /// Base address + /// + public const int DT_MIPS_BASE_ADDRESS = 0x70000006; + + public const int DT_MIPS_MSYM = 0x70000007; + + /// + /// Address of CONFLICT section + /// + public const int DT_MIPS_CONFLICT = 0x70000008; + + /// + /// Address of LIBLIST section + /// + public const int DT_MIPS_LIBLIST = 0x70000009; + + /// + /// Number of local GOT entries + /// + public const int DT_MIPS_LOCAL_GOTNO = 0x7000000a; + + /// + /// Number of CONFLICT entries + /// + public const int DT_MIPS_CONFLICTNO = 0x7000000b; + + /// + /// Number of LIBLIST entries + /// + public const int DT_MIPS_LIBLISTNO = 0x70000010; + + /// + /// Number of DYNSYM entries + /// + public const int DT_MIPS_SYMTABNO = 0x70000011; + + /// + /// First external DYNSYM + /// + public const int DT_MIPS_UNREFEXTNO = 0x70000012; + + /// + /// First GOT entry in DYNSYM + /// + public const int DT_MIPS_GOTSYM = 0x70000013; + + /// + /// Number of GOT page table entries + /// + public const int DT_MIPS_HIPAGENO = 0x70000014; + + /// + /// Address of run time loader map. + /// + public const int DT_MIPS_RLD_MAP = 0x70000016; + + /// + /// Delta C++ class definition. + /// + public const int DT_MIPS_DELTA_CLASS = 0x70000017; + + /// + /// Number of entries in + /// DT_MIPS_DELTA_CLASS. + /// + public const int DT_MIPS_DELTA_CLASS_NO = 0x70000018; + + /// + /// Delta C++ class instances. + /// + public const int DT_MIPS_DELTA_INSTANCE = 0x70000019; + + /// + /// Number of entries in + /// DT_MIPS_DELTA_INSTANCE. + /// + public const int DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a; + + /// + /// Delta relocations. + /// + public const int DT_MIPS_DELTA_RELOC = 0x7000001b; + + /// + /// Number of entries in + /// DT_MIPS_DELTA_RELOC. + /// + public const int DT_MIPS_DELTA_RELOC_NO = 0x7000001c; + + /// + /// Delta symbols that Delta + /// relocations refer to. + /// + public const int DT_MIPS_DELTA_SYM = 0x7000001d; + + /// + /// Number of entries in + /// DT_MIPS_DELTA_SYM. + /// + public const int DT_MIPS_DELTA_SYM_NO = 0x7000001e; + + /// + /// Delta symbols that hold the + /// class declaration. + /// + public const int DT_MIPS_DELTA_CLASSSYM = 0x70000020; + + /// + /// Number of entries in + /// DT_MIPS_DELTA_CLASSSYM. + /// + public const int DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021; + + /// + /// Flags indicating for C++ flavor. + /// + public const int DT_MIPS_CXX_FLAGS = 0x70000022; + + public const int DT_MIPS_PIXIE_INIT = 0x70000023; + + public const int DT_MIPS_SYMBOL_LIB = 0x70000024; + + public const int DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025; + + public const int DT_MIPS_LOCAL_GOTIDX = 0x70000026; + + public const int DT_MIPS_HIDDEN_GOTIDX = 0x70000027; + + public const int DT_MIPS_PROTECTED_GOTIDX = 0x70000028; + + /// + /// Address of .options. + /// + public const int DT_MIPS_OPTIONS = 0x70000029; + + /// + /// Address of .interface. + /// + public const int DT_MIPS_INTERFACE = 0x7000002a; + + public const int DT_MIPS_DYNSTR_ALIGN = 0x7000002b; + + /// + /// Size of the .interface section. + /// + public const int DT_MIPS_INTERFACE_SIZE = 0x7000002c; + + /// + /// Address of rld_text_rsolve + /// function stored in GOT. + /// + public const int DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d; + + /// + /// Default suffix of dso to be added + /// by rld on dlopen() calls. + /// + public const int DT_MIPS_PERF_SUFFIX = 0x7000002e; + + /// + /// (O32)Size of compact rel section. + /// + public const int DT_MIPS_COMPACT_SIZE = 0x7000002f; + + /// + /// GP value for aux GOTs. + /// + public const int DT_MIPS_GP_VALUE = 0x70000030; + + /// + /// Address of aux .dynamic. + /// + public const int DT_MIPS_AUX_DYNAMIC = 0x70000031; + + public const int DT_MIPS_PLTGOT = 0x70000032; + + public const int DT_MIPS_RWPLT = 0x70000034; + + public const int DT_MIPS_RLD_MAP_REL = 0x70000035; + + public const int DT_MIPS_NUM = 0x36; + + /// + /// Trap nil pointer dereference. + /// + public const uint EF_PARISC_TRAPNIL = 65536; + + /// + /// Program uses arch. extensions. + /// + public const uint EF_PARISC_EXT = 131072; + + /// + /// Program expects little endian. + /// + public const uint EF_PARISC_LSB = 262144; + + /// + /// Program expects wide mode. + /// + public const uint EF_PARISC_WIDE = 524288; + + /// + /// No kernel assisted branch + /// prediction. + /// + public const uint EF_PARISC_NO_KABP = 1048576; + + /// + /// Allow lazy swapping. + /// + public const uint EF_PARISC_LAZYSWAP = 4194304; + + /// + /// Architecture version. + /// + public const uint EF_PARISC_ARCH = 65535; + + /// + /// Section for tenatively declared + /// symbols in ANSI C. + /// + public const uint SHN_PARISC_ANSI_COMMON = 65280; + + /// + /// Common blocks in huge model. + /// + public const uint SHN_PARISC_HUGE_COMMON = 65281; + + /// + /// Contains product specific ext. + /// + public const uint SHT_PARISC_EXT = 1879048192; + + /// + /// Unwind information. + /// + public const uint SHT_PARISC_UNWIND = 1879048193; + + /// + /// Debug info for optimized code. + /// + public const uint SHT_PARISC_DOC = 1879048194; + + /// + /// Section with short addressing. + /// + public const uint SHF_PARISC_SHORT = 536870912; + + /// + /// Section far from gp. + /// + public const uint SHF_PARISC_HUGE = 1073741824; + + /// + /// Static branch prediction code. + /// + public const uint SHF_PARISC_SBP = 0x80000000; + + /// + /// Millicode function entry point. + /// + public const byte STT_PARISC_MILLICODE = 13; + + public const byte STT_HP_OPAQUE = 11; + + public const byte STT_HP_STUB = 12; + + /// + /// No reloc. + /// + public const uint R_PARISC_NONE = 0; + + /// + /// Direct 32-bit reference. + /// + public const uint R_PARISC_DIR32 = 1; + + /// + /// Left 21 bits of eff. address. + /// + public const uint R_PARISC_DIR21L = 2; + + /// + /// Right 17 bits of eff. address. + /// + public const uint R_PARISC_DIR17R = 3; + + /// + /// 17 bits of eff. address. + /// + public const uint R_PARISC_DIR17F = 4; + + /// + /// Right 14 bits of eff. address. + /// + public const uint R_PARISC_DIR14R = 6; + + /// + /// 32-bit rel. address. + /// + public const uint R_PARISC_PCREL32 = 9; + + /// + /// Left 21 bits of rel. address. + /// + public const uint R_PARISC_PCREL21L = 10; + + /// + /// Right 17 bits of rel. address. + /// + public const uint R_PARISC_PCREL17R = 11; + + /// + /// 17 bits of rel. address. + /// + public const uint R_PARISC_PCREL17F = 12; + + /// + /// Right 14 bits of rel. address. + /// + public const uint R_PARISC_PCREL14R = 14; + + /// + /// Left 21 bits of rel. address. + /// + public const uint R_PARISC_DPREL21L = 18; + + /// + /// Right 14 bits of rel. address. + /// + public const uint R_PARISC_DPREL14R = 22; + + /// + /// GP-relative, left 21 bits. + /// + public const uint R_PARISC_GPREL21L = 26; + + /// + /// GP-relative, right 14 bits. + /// + public const uint R_PARISC_GPREL14R = 30; + + /// + /// LT-relative, left 21 bits. + /// + public const uint R_PARISC_LTOFF21L = 34; + + /// + /// LT-relative, right 14 bits. + /// + public const uint R_PARISC_LTOFF14R = 38; + + /// + /// 32 bits section rel. address. + /// + public const uint R_PARISC_SECREL32 = 41; + + /// + /// No relocation, set segment base. + /// + public const uint R_PARISC_SEGBASE = 48; + + /// + /// 32 bits segment rel. address. + /// + public const uint R_PARISC_SEGREL32 = 49; + + /// + /// PLT rel. address, left 21 bits. + /// + public const uint R_PARISC_PLTOFF21L = 50; + + /// + /// PLT rel. address, right 14 bits. + /// + public const uint R_PARISC_PLTOFF14R = 54; + + /// + /// 32 bits LT-rel. function pointer. + /// + public const uint R_PARISC_LTOFF_FPTR32 = 57; + + /// + /// LT-rel. fct ptr, left 21 bits. + /// + public const uint R_PARISC_LTOFF_FPTR21L = 58; + + /// + /// LT-rel. fct ptr, right 14 bits. + /// + public const uint R_PARISC_LTOFF_FPTR14R = 62; + + /// + /// 64 bits function address. + /// + public const uint R_PARISC_FPTR64 = 64; + + /// + /// 32 bits function address. + /// + public const uint R_PARISC_PLABEL32 = 65; + + /// + /// Left 21 bits of fdesc address. + /// + public const uint R_PARISC_PLABEL21L = 66; + + /// + /// Right 14 bits of fdesc address. + /// + public const uint R_PARISC_PLABEL14R = 70; + + /// + /// 64 bits PC-rel. address. + /// + public const uint R_PARISC_PCREL64 = 72; + + /// + /// 22 bits PC-rel. address. + /// + public const uint R_PARISC_PCREL22F = 74; + + /// + /// PC-rel. address, right 14 bits. + /// + public const uint R_PARISC_PCREL14WR = 75; + + /// + /// PC rel. address, right 14 bits. + /// + public const uint R_PARISC_PCREL14DR = 76; + + /// + /// 16 bits PC-rel. address. + /// + public const uint R_PARISC_PCREL16F = 77; + + /// + /// 16 bits PC-rel. address. + /// + public const uint R_PARISC_PCREL16WF = 78; + + /// + /// 16 bits PC-rel. address. + /// + public const uint R_PARISC_PCREL16DF = 79; + + /// + /// 64 bits of eff. address. + /// + public const uint R_PARISC_DIR64 = 80; + + /// + /// 14 bits of eff. address. + /// + public const uint R_PARISC_DIR14WR = 83; + + /// + /// 14 bits of eff. address. + /// + public const uint R_PARISC_DIR14DR = 84; + + /// + /// 16 bits of eff. address. + /// + public const uint R_PARISC_DIR16F = 85; + + /// + /// 16 bits of eff. address. + /// + public const uint R_PARISC_DIR16WF = 86; + + /// + /// 16 bits of eff. address. + /// + public const uint R_PARISC_DIR16DF = 87; + + /// + /// 64 bits of GP-rel. address. + /// + public const uint R_PARISC_GPREL64 = 88; + + /// + /// GP-rel. address, right 14 bits. + /// + public const uint R_PARISC_GPREL14WR = 91; + + /// + /// GP-rel. address, right 14 bits. + /// + public const uint R_PARISC_GPREL14DR = 92; + + /// + /// 16 bits GP-rel. address. + /// + public const uint R_PARISC_GPREL16F = 93; + + /// + /// 16 bits GP-rel. address. + /// + public const uint R_PARISC_GPREL16WF = 94; + + /// + /// 16 bits GP-rel. address. + /// + public const uint R_PARISC_GPREL16DF = 95; + + /// + /// 64 bits LT-rel. address. + /// + public const uint R_PARISC_LTOFF64 = 96; + + /// + /// LT-rel. address, right 14 bits. + /// + public const uint R_PARISC_LTOFF14WR = 99; + + /// + /// LT-rel. address, right 14 bits. + /// + public const uint R_PARISC_LTOFF14DR = 100; + + /// + /// 16 bits LT-rel. address. + /// + public const uint R_PARISC_LTOFF16F = 101; + + /// + /// 16 bits LT-rel. address. + /// + public const uint R_PARISC_LTOFF16WF = 102; + + /// + /// 16 bits LT-rel. address. + /// + public const uint R_PARISC_LTOFF16DF = 103; + + /// + /// 64 bits section rel. address. + /// + public const uint R_PARISC_SECREL64 = 104; + + /// + /// 64 bits segment rel. address. + /// + public const uint R_PARISC_SEGREL64 = 112; + + /// + /// PLT-rel. address, right 14 bits. + /// + public const uint R_PARISC_PLTOFF14WR = 115; + + /// + /// PLT-rel. address, right 14 bits. + /// + public const uint R_PARISC_PLTOFF14DR = 116; + + /// + /// 16 bits LT-rel. address. + /// + public const uint R_PARISC_PLTOFF16F = 117; + + /// + /// 16 bits PLT-rel. address. + /// + public const uint R_PARISC_PLTOFF16WF = 118; + + /// + /// 16 bits PLT-rel. address. + /// + public const uint R_PARISC_PLTOFF16DF = 119; + + /// + /// 64 bits LT-rel. function ptr. + /// + public const uint R_PARISC_LTOFF_FPTR64 = 120; + + /// + /// LT-rel. fct. ptr., right 14 bits. + /// + public const uint R_PARISC_LTOFF_FPTR14WR = 123; + + /// + /// LT-rel. fct. ptr., right 14 bits. + /// + public const uint R_PARISC_LTOFF_FPTR14DR = 124; + + /// + /// 16 bits LT-rel. function ptr. + /// + public const uint R_PARISC_LTOFF_FPTR16F = 125; + + /// + /// 16 bits LT-rel. function ptr. + /// + public const uint R_PARISC_LTOFF_FPTR16WF = 126; + + /// + /// 16 bits LT-rel. function ptr. + /// + public const uint R_PARISC_LTOFF_FPTR16DF = 127; + + public const uint R_PARISC_LORESERVE = 128; + + /// + /// Copy relocation. + /// + public const uint R_PARISC_COPY = 128; + + /// + /// Dynamic reloc, imported PLT + /// + public const uint R_PARISC_IPLT = 129; + + /// + /// Dynamic reloc, exported PLT + /// + public const uint R_PARISC_EPLT = 130; + + /// + /// 32 bits TP-rel. address. + /// + public const uint R_PARISC_TPREL32 = 153; + + /// + /// TP-rel. address, left 21 bits. + /// + public const uint R_PARISC_TPREL21L = 154; + + /// + /// TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_TPREL14R = 158; + + /// + /// LT-TP-rel. address, left 21 bits. + /// + public const uint R_PARISC_LTOFF_TP21L = 162; + + /// + /// LT-TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_LTOFF_TP14R = 166; + + /// + /// 14 bits LT-TP-rel. address. + /// + public const uint R_PARISC_LTOFF_TP14F = 167; + + /// + /// 64 bits TP-rel. address. + /// + public const uint R_PARISC_TPREL64 = 216; + + /// + /// TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_TPREL14WR = 219; + + /// + /// TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_TPREL14DR = 220; + + /// + /// 16 bits TP-rel. address. + /// + public const uint R_PARISC_TPREL16F = 221; + + /// + /// 16 bits TP-rel. address. + /// + public const uint R_PARISC_TPREL16WF = 222; + + /// + /// 16 bits TP-rel. address. + /// + public const uint R_PARISC_TPREL16DF = 223; + + /// + /// 64 bits LT-TP-rel. address. + /// + public const uint R_PARISC_LTOFF_TP64 = 224; + + /// + /// LT-TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_LTOFF_TP14WR = 227; + + /// + /// LT-TP-rel. address, right 14 bits. + /// + public const uint R_PARISC_LTOFF_TP14DR = 228; + + /// + /// 16 bits LT-TP-rel. address. + /// + public const uint R_PARISC_LTOFF_TP16F = 229; + + /// + /// 16 bits LT-TP-rel. address. + /// + public const uint R_PARISC_LTOFF_TP16WF = 230; + + /// + /// 16 bits LT-TP-rel. address. + /// + public const uint R_PARISC_LTOFF_TP16DF = 231; + + public const uint R_PARISC_GNU_VTENTRY = 232; + + public const uint R_PARISC_GNU_VTINHERIT = 233; + + /// + /// GD 21-bit left. + /// + public const uint R_PARISC_TLS_GD21L = 234; + + /// + /// GD 14-bit right. + /// + public const uint R_PARISC_TLS_GD14R = 235; + + /// + /// GD call to __t_g_a. + /// + public const uint R_PARISC_TLS_GDCALL = 236; + + /// + /// LD module 21-bit left. + /// + public const uint R_PARISC_TLS_LDM21L = 237; + + /// + /// LD module 14-bit right. + /// + public const uint R_PARISC_TLS_LDM14R = 238; + + /// + /// LD module call to __t_g_a. + /// + public const uint R_PARISC_TLS_LDMCALL = 239; + + /// + /// LD offset 21-bit left. + /// + public const uint R_PARISC_TLS_LDO21L = 240; + + /// + /// LD offset 14-bit right. + /// + public const uint R_PARISC_TLS_LDO14R = 241; + + /// + /// DTP module 32-bit. + /// + public const uint R_PARISC_TLS_DTPMOD32 = 242; + + /// + /// DTP module 64-bit. + /// + public const uint R_PARISC_TLS_DTPMOD64 = 243; + + /// + /// DTP offset 32-bit. + /// + public const uint R_PARISC_TLS_DTPOFF32 = 244; + + /// + /// DTP offset 32-bit. + /// + public const uint R_PARISC_TLS_DTPOFF64 = 245; + + public const uint R_PARISC_TLS_LE21L = 154; + + public const uint R_PARISC_TLS_LE14R = 158; + + public const uint R_PARISC_TLS_IE21L = 162; + + public const uint R_PARISC_TLS_IE14R = 166; + + public const uint R_PARISC_TLS_TPREL32 = 153; + + public const uint R_PARISC_TLS_TPREL64 = 216; + + public const uint R_PARISC_HIRESERVE = 255; + + public const uint PT_HP_TLS = 1610612736; + + public const uint PT_HP_CORE_NONE = 1610612737; + + public const uint PT_HP_CORE_VERSION = 1610612738; + + public const uint PT_HP_CORE_KERNEL = 1610612739; + + public const uint PT_HP_CORE_COMM = 1610612740; + + public const uint PT_HP_CORE_PROC = 1610612741; + + public const uint PT_HP_CORE_LOADABLE = 1610612742; + + public const uint PT_HP_CORE_STACK = 1610612743; + + public const uint PT_HP_CORE_SHM = 1610612744; + + public const uint PT_HP_CORE_MMF = 1610612745; + + public const uint PT_HP_PARALLEL = 1610612752; + + public const uint PT_HP_FASTBIND = 1610612753; + + public const uint PT_HP_OPT_ANNOT = 1610612754; + + public const uint PT_HP_HSL_ANNOT = 1610612755; + + public const uint PT_HP_STACK = 1610612756; + + public const uint PT_PARISC_ARCHEXT = 1879048192; + + public const uint PT_PARISC_UNWIND = 1879048193; + + public const uint PF_PARISC_SBP = 134217728; + + public const uint PF_HP_PAGE_SIZE = 1048576; + + public const uint PF_HP_FAR_SHARED = 2097152; + + public const uint PF_HP_NEAR_SHARED = 4194304; + + public const uint PF_HP_CODE = 16777216; + + public const uint PF_HP_MODIFY = 33554432; + + public const uint PF_HP_LAZYSWAP = 67108864; + + public const uint PF_HP_SBP = 134217728; + + /// + /// All addresses must be + /// < + /// 2GB. + /// + public const uint EF_ALPHA_32BIT = 1; + + /// + /// Relocations for relaxing exist. + /// + public const uint EF_ALPHA_CANRELAX = 2; + + public const uint SHT_ALPHA_DEBUG = 1879048193; + + public const uint SHT_ALPHA_REGINFO = 1879048194; + + public const uint SHF_ALPHA_GPREL = 268435456; + + /// + /// No reloc + /// + public const uint R_ALPHA_NONE = 0; + + /// + /// Direct 32 bit + /// + public const uint R_ALPHA_REFLONG = 1; + + /// + /// Direct 64 bit + /// + public const uint R_ALPHA_REFQUAD = 2; + + /// + /// GP relative 32 bit + /// + public const uint R_ALPHA_GPREL32 = 3; + + /// + /// GP relative 16 bit w/optimization + /// + public const uint R_ALPHA_LITERAL = 4; + + /// + /// Optimization hint for LITERAL + /// + public const uint R_ALPHA_LITUSE = 5; + + /// + /// Add displacement to GP + /// + public const uint R_ALPHA_GPDISP = 6; + + /// + /// PC+4 relative 23 bit shifted + /// + public const uint R_ALPHA_BRADDR = 7; + + /// + /// PC+4 relative 16 bit shifted + /// + public const uint R_ALPHA_HINT = 8; + + /// + /// PC relative 16 bit + /// + public const uint R_ALPHA_SREL16 = 9; + + /// + /// PC relative 32 bit + /// + public const uint R_ALPHA_SREL32 = 10; + + /// + /// PC relative 64 bit + /// + public const uint R_ALPHA_SREL64 = 11; + + /// + /// GP relative 32 bit, high 16 bits + /// + public const uint R_ALPHA_GPRELHIGH = 17; + + /// + /// GP relative 32 bit, low 16 bits + /// + public const uint R_ALPHA_GPRELLOW = 18; + + /// + /// GP relative 16 bit + /// + public const uint R_ALPHA_GPREL16 = 19; + + /// + /// Copy symbol at runtime + /// + public const uint R_ALPHA_COPY = 24; + + /// + /// Create GOT entry + /// + public const uint R_ALPHA_GLOB_DAT = 25; + + /// + /// Create PLT entry + /// + public const uint R_ALPHA_JMP_SLOT = 26; + + /// + /// Adjust by program base + /// + public const uint R_ALPHA_RELATIVE = 27; + + public const uint R_ALPHA_TLS_GD_HI = 28; + + public const uint R_ALPHA_TLSGD = 29; + + public const uint R_ALPHA_TLS_LDM = 30; + + public const uint R_ALPHA_DTPMOD64 = 31; + + public const uint R_ALPHA_GOTDTPREL = 32; + + public const uint R_ALPHA_DTPREL64 = 33; + + public const uint R_ALPHA_DTPRELHI = 34; + + public const uint R_ALPHA_DTPRELLO = 35; + + public const uint R_ALPHA_DTPREL16 = 36; + + public const uint R_ALPHA_GOTTPREL = 37; + + public const uint R_ALPHA_TPREL64 = 38; + + public const uint R_ALPHA_TPRELHI = 39; + + public const uint R_ALPHA_TPRELLO = 40; + + public const uint R_ALPHA_TPREL16 = 41; + + public const uint R_ALPHA_NUM = 46; + + public const int DT_ALPHA_PLTRO = ( 0); + + public const int DT_ALPHA_NUM = 1; + + /// + /// PowerPC embedded flag + /// + public const uint EF_PPC_EMB = 0x80000000; + + /// + /// PowerPC -mrelocatable flag + /// + public const uint EF_PPC_RELOCATABLE = 65536; + + /// + /// PowerPC -mrelocatable-lib + /// flag + /// + public const uint EF_PPC_RELOCATABLE_LIB = 32768; + + public const uint R_PPC_NONE = 0; + + /// + /// 32bit absolute address + /// + public const uint R_PPC_ADDR32 = 1; + + /// + /// 26bit address, 2 bits ignored. + /// + public const uint R_PPC_ADDR24 = 2; + + /// + /// 16bit absolute address + /// + public const uint R_PPC_ADDR16 = 3; + + /// + /// lower 16bit of absolute address + /// + public const uint R_PPC_ADDR16_LO = 4; + + /// + /// high 16bit of absolute address + /// + public const uint R_PPC_ADDR16_HI = 5; + + /// + /// adjusted high 16bit + /// + public const uint R_PPC_ADDR16_HA = 6; + + /// + /// 16bit address, 2 bits ignored + /// + public const uint R_PPC_ADDR14 = 7; + + public const uint R_PPC_ADDR14_BRTAKEN = 8; + + public const uint R_PPC_ADDR14_BRNTAKEN = 9; + + /// + /// PC relative 26 bit + /// + public const uint R_PPC_REL24 = 10; + + /// + /// PC relative 16 bit + /// + public const uint R_PPC_REL14 = 11; + + public const uint R_PPC_REL14_BRTAKEN = 12; + + public const uint R_PPC_REL14_BRNTAKEN = 13; + + public const uint R_PPC_GOT16 = 14; + + public const uint R_PPC_GOT16_LO = 15; + + public const uint R_PPC_GOT16_HI = 16; + + public const uint R_PPC_GOT16_HA = 17; + + public const uint R_PPC_PLTREL24 = 18; + + public const uint R_PPC_COPY = 19; + + public const uint R_PPC_GLOB_DAT = 20; + + public const uint R_PPC_JMP_SLOT = 21; + + public const uint R_PPC_RELATIVE = 22; + + public const uint R_PPC_LOCAL24PC = 23; + + public const uint R_PPC_UADDR32 = 24; + + public const uint R_PPC_UADDR16 = 25; + + public const uint R_PPC_REL32 = 26; + + public const uint R_PPC_PLT32 = 27; + + public const uint R_PPC_PLTREL32 = 28; + + public const uint R_PPC_PLT16_LO = 29; + + public const uint R_PPC_PLT16_HI = 30; + + public const uint R_PPC_PLT16_HA = 31; + + public const uint R_PPC_SDAREL16 = 32; + + public const uint R_PPC_SECTOFF = 33; + + public const uint R_PPC_SECTOFF_LO = 34; + + public const uint R_PPC_SECTOFF_HI = 35; + + public const uint R_PPC_SECTOFF_HA = 36; + + /// + /// none (sym+add)@tls + /// + public const uint R_PPC_TLS = 67; + + /// + /// word32 (sym+add)@dtpmod + /// + public const uint R_PPC_DTPMOD32 = 68; + + /// + /// half16* (sym+add)@tprel + /// + public const uint R_PPC_TPREL16 = 69; + + /// + /// half16 (sym+add)@tprel @l + /// + public const uint R_PPC_TPREL16_LO = 70; + + /// + /// half16 (sym+add)@tprel @h + /// + public const uint R_PPC_TPREL16_HI = 71; + + /// + /// half16 (sym+add)@tprel @ha + /// + public const uint R_PPC_TPREL16_HA = 72; + + /// + /// word32 (sym+add)@tprel + /// + public const uint R_PPC_TPREL32 = 73; + + /// + /// half16* (sym+add)@dtprel + /// + public const uint R_PPC_DTPREL16 = 74; + + /// + /// half16 (sym+add)@dtprel @l + /// + public const uint R_PPC_DTPREL16_LO = 75; + + /// + /// half16 (sym+add)@dtprel @h + /// + public const uint R_PPC_DTPREL16_HI = 76; + + /// + /// half16 (sym+add)@dtprel @ha + /// + public const uint R_PPC_DTPREL16_HA = 77; + + /// + /// word32 (sym+add)@dtprel + /// + public const uint R_PPC_DTPREL32 = 78; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @tlsgd + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSGD16 = 79; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@l + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSGD16_LO = 80; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@h + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSGD16_HI = 81; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@ha + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSGD16_HA = 82; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @tlsld + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSLD16 = 83; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@l + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSLD16_LO = 84; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@h + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSLD16_HI = 85; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@ha + /// + /// @enddot + /// + public const uint R_PPC_GOT_TLSLD16_HA = 86; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @tprel + /// + /// @enddot + /// + public const uint R_PPC_GOT_TPREL16 = 87; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tprel@l + /// + /// @enddot + /// + public const uint R_PPC_GOT_TPREL16_LO = 88; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tprel@h + /// + /// @enddot + /// + public const uint R_PPC_GOT_TPREL16_HI = 89; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tprel@ha + /// + /// @enddot + /// + public const uint R_PPC_GOT_TPREL16_HA = 90; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @dtprel + /// + /// @enddot + /// + public const uint R_PPC_GOT_DTPREL16 = 91; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @dtprel@l + /// + /// @enddot + /// + public const uint R_PPC_GOT_DTPREL16_LO = 92; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @dtprel@h + /// + /// @enddot + /// + public const uint R_PPC_GOT_DTPREL16_HI = 93; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @dtprel@ha + /// + /// @enddot + /// + public const uint R_PPC_GOT_DTPREL16_HA = 94; + + /// + /// none (sym+add)@tlsgd + /// + public const uint R_PPC_TLSGD = 95; + + /// + /// none (sym+add)@tlsld + /// + public const uint R_PPC_TLSLD = 96; + + public const uint R_PPC_EMB_NADDR32 = 101; + + public const uint R_PPC_EMB_NADDR16 = 102; + + public const uint R_PPC_EMB_NADDR16_LO = 103; + + public const uint R_PPC_EMB_NADDR16_HI = 104; + + public const uint R_PPC_EMB_NADDR16_HA = 105; + + public const uint R_PPC_EMB_SDAI16 = 106; + + public const uint R_PPC_EMB_SDA2I16 = 107; + + public const uint R_PPC_EMB_SDA2REL = 108; + + /// + /// 16 bit offset in SDA + /// + public const uint R_PPC_EMB_SDA21 = 109; + + public const uint R_PPC_EMB_MRKREF = 110; + + public const uint R_PPC_EMB_RELSEC16 = 111; + + public const uint R_PPC_EMB_RELST_LO = 112; + + public const uint R_PPC_EMB_RELST_HI = 113; + + public const uint R_PPC_EMB_RELST_HA = 114; + + public const uint R_PPC_EMB_BIT_FLD = 115; + + /// + /// 16 bit relative offset in SDA + /// + public const uint R_PPC_EMB_RELSDA = 116; + + /// + /// like EMB_SDA21, but lower 16 bit + /// + public const uint R_PPC_DIAB_SDA21_LO = 180; + + /// + /// like EMB_SDA21, but high 16 bit + /// + public const uint R_PPC_DIAB_SDA21_HI = 181; + + /// + /// like EMB_SDA21, adjusted high 16 + /// + public const uint R_PPC_DIAB_SDA21_HA = 182; + + /// + /// like EMB_RELSDA, but lower 16 bit + /// + public const uint R_PPC_DIAB_RELSDA_LO = 183; + + /// + /// like EMB_RELSDA, but high 16 bit + /// + public const uint R_PPC_DIAB_RELSDA_HI = 184; + + /// + /// like EMB_RELSDA, adjusted high 16 + /// + public const uint R_PPC_DIAB_RELSDA_HA = 185; + + public const uint R_PPC_IRELATIVE = 248; + + /// + /// half16 (sym+add-.) + /// + public const uint R_PPC_REL16 = 249; + + /// + /// half16 (sym+add-.)@l + /// + public const uint R_PPC_REL16_LO = 250; + + /// + /// half16 (sym+add-.)@h + /// + public const uint R_PPC_REL16_HI = 251; + + /// + /// half16 (sym+add-.)@ha + /// + public const uint R_PPC_REL16_HA = 252; + + public const uint R_PPC_TOC16 = 255; + + public const int DT_PPC_GOT = ( 0); + + public const int DT_PPC_OPT = ( 1); + + public const int DT_PPC_NUM = 2; + + public const uint R_PPC64_NONE = 0; + + /// + /// 32bit absolute address + /// + public const uint R_PPC64_ADDR32 = 1; + + /// + /// 26bit address, word aligned + /// + public const uint R_PPC64_ADDR24 = 2; + + /// + /// 16bit absolute address + /// + public const uint R_PPC64_ADDR16 = 3; + + /// + /// lower 16bits of address + /// + public const uint R_PPC64_ADDR16_LO = 4; + + /// + /// high 16bits of address. + /// + public const uint R_PPC64_ADDR16_HI = 5; + + /// + /// adjusted high 16bits. + /// + public const uint R_PPC64_ADDR16_HA = 6; + + /// + /// 16bit address, word aligned + /// + public const uint R_PPC64_ADDR14 = 7; + + public const uint R_PPC64_ADDR14_BRTAKEN = 8; + + public const uint R_PPC64_ADDR14_BRNTAKEN = 9; + + /// + /// PC-rel. 26 bit, word aligned + /// + public const uint R_PPC64_REL24 = 10; + + /// + /// PC relative 16 bit + /// + public const uint R_PPC64_REL14 = 11; + + public const uint R_PPC64_REL14_BRTAKEN = 12; + + public const uint R_PPC64_REL14_BRNTAKEN = 13; + + public const uint R_PPC64_GOT16 = 14; + + public const uint R_PPC64_GOT16_LO = 15; + + public const uint R_PPC64_GOT16_HI = 16; + + public const uint R_PPC64_GOT16_HA = 17; + + public const uint R_PPC64_COPY = 19; + + public const uint R_PPC64_GLOB_DAT = 20; + + public const uint R_PPC64_JMP_SLOT = 21; + + public const uint R_PPC64_RELATIVE = 22; + + public const uint R_PPC64_UADDR32 = 24; + + public const uint R_PPC64_UADDR16 = 25; + + public const uint R_PPC64_REL32 = 26; + + public const uint R_PPC64_PLT32 = 27; + + public const uint R_PPC64_PLTREL32 = 28; + + public const uint R_PPC64_PLT16_LO = 29; + + public const uint R_PPC64_PLT16_HI = 30; + + public const uint R_PPC64_PLT16_HA = 31; + + public const uint R_PPC64_SECTOFF = 33; + + public const uint R_PPC64_SECTOFF_LO = 34; + + public const uint R_PPC64_SECTOFF_HI = 35; + + public const uint R_PPC64_SECTOFF_HA = 36; + + /// + /// word30 (S + A - P) >> 2 + /// + public const uint R_PPC64_ADDR30 = 37; + + /// + /// doubleword64 S + A + /// + public const uint R_PPC64_ADDR64 = 38; + + /// + /// half16 #higher(S + A) + /// + public const uint R_PPC64_ADDR16_HIGHER = 39; + + /// + /// half16 #highera(S + A) + /// + public const uint R_PPC64_ADDR16_HIGHERA = 40; + + /// + /// half16 #highest(S + A) + /// + public const uint R_PPC64_ADDR16_HIGHEST = 41; + + /// + /// half16 #highesta(S + A) + /// + public const uint R_PPC64_ADDR16_HIGHESTA = 42; + + /// + /// doubleword64 S + A + /// + public const uint R_PPC64_UADDR64 = 43; + + /// + /// doubleword64 S + A - P + /// + public const uint R_PPC64_REL64 = 44; + + /// + /// doubleword64 L + A + /// + public const uint R_PPC64_PLT64 = 45; + + /// + /// doubleword64 L + A - P + /// + public const uint R_PPC64_PLTREL64 = 46; + + /// + /// half16* S + A - .TOC + /// + public const uint R_PPC64_TOC16 = 47; + + /// + /// half16 #lo(S + A - .TOC.) + /// + public const uint R_PPC64_TOC16_LO = 48; + + /// + /// half16 #hi(S + A - .TOC.) + /// + public const uint R_PPC64_TOC16_HI = 49; + + /// + /// half16 #ha(S + A - .TOC.) + /// + public const uint R_PPC64_TOC16_HA = 50; + + /// + /// doubleword64 .TOC + /// + public const uint R_PPC64_TOC = 51; + + /// + /// half16* M + A + /// + public const uint R_PPC64_PLTGOT16 = 52; + + /// + /// half16 #lo(M + A) + /// + public const uint R_PPC64_PLTGOT16_LO = 53; + + /// + /// half16 #hi(M + A) + /// + public const uint R_PPC64_PLTGOT16_HI = 54; + + /// + /// half16 #ha(M + A) + /// + public const uint R_PPC64_PLTGOT16_HA = 55; + + /// + /// half16ds* (S + A) >> 2 + /// + public const uint R_PPC64_ADDR16_DS = 56; + + /// + /// half16ds #lo(S + A) >> 2 + /// + public const uint R_PPC64_ADDR16_LO_DS = 57; + + /// + /// half16ds* (G + A) >> 2 + /// + public const uint R_PPC64_GOT16_DS = 58; + + /// + /// half16ds #lo(G + A) >> 2 + /// + public const uint R_PPC64_GOT16_LO_DS = 59; + + /// + /// half16ds #lo(L + A) >> 2 + /// + public const uint R_PPC64_PLT16_LO_DS = 60; + + /// + /// half16ds* (R + A) >> 2 + /// + public const uint R_PPC64_SECTOFF_DS = 61; + + /// + /// half16ds #lo(R + A) >> 2 + /// + public const uint R_PPC64_SECTOFF_LO_DS = 62; + + /// + /// half16ds* (S + A - .TOC.) >> 2 + /// + public const uint R_PPC64_TOC16_DS = 63; + + /// + /// half16ds #lo(S + A - .TOC.) >> 2 + /// + public const uint R_PPC64_TOC16_LO_DS = 64; + + /// + /// half16ds* (M + A) >> 2 + /// + public const uint R_PPC64_PLTGOT16_DS = 65; + + /// + /// half16ds #lo(M + A) >> 2 + /// + public const uint R_PPC64_PLTGOT16_LO_DS = 66; + + /// + /// none (sym+add)@tls + /// + public const uint R_PPC64_TLS = 67; + + /// + /// doubleword64 (sym+add)@dtpmod + /// + public const uint R_PPC64_DTPMOD64 = 68; + + /// + /// half16* (sym+add)@tprel + /// + public const uint R_PPC64_TPREL16 = 69; + + /// + /// half16 (sym+add)@tprel @l + /// + public const uint R_PPC64_TPREL16_LO = 70; + + /// + /// half16 (sym+add)@tprel @h + /// + public const uint R_PPC64_TPREL16_HI = 71; + + /// + /// half16 (sym+add)@tprel @ha + /// + public const uint R_PPC64_TPREL16_HA = 72; + + /// + /// doubleword64 (sym+add)@tprel + /// + public const uint R_PPC64_TPREL64 = 73; + + /// + /// half16* (sym+add)@dtprel + /// + public const uint R_PPC64_DTPREL16 = 74; + + /// + /// half16 (sym+add)@dtprel @l + /// + public const uint R_PPC64_DTPREL16_LO = 75; + + /// + /// half16 (sym+add)@dtprel @h + /// + public const uint R_PPC64_DTPREL16_HI = 76; + + /// + /// half16 (sym+add)@dtprel @ha + /// + public const uint R_PPC64_DTPREL16_HA = 77; + + /// + /// doubleword64 (sym+add)@dtprel + /// + public const uint R_PPC64_DTPREL64 = 78; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @tlsgd + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSGD16 = 79; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@l + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSGD16_LO = 80; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@h + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSGD16_HI = 81; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsgd@ha + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSGD16_HA = 82; + + /// + /// half16* (sym+add) + /// + /// + /// @dot @tlsld + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSLD16 = 83; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@l + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSLD16_LO = 84; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@h + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSLD16_HI = 85; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tlsld@ha + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TLSLD16_HA = 86; + + /// + /// half16ds* (sym+add) + /// + /// + /// @dot @tprel + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TPREL16_DS = 87; + + /// + /// half16ds (sym+add) + /// + /// + /// @dot @tprel@l + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TPREL16_LO_DS = 88; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tprel@h + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TPREL16_HI = 89; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @tprel@ha + /// + /// @enddot + /// + public const uint R_PPC64_GOT_TPREL16_HA = 90; + + /// + /// half16ds* (sym+add) + /// + /// + /// @dot @dtprel + /// + /// @enddot + /// + public const uint R_PPC64_GOT_DTPREL16_DS = 91; + + /// + /// half16ds (sym+add) + /// + /// + /// @dot @dtprel@l + /// + /// @enddot + /// + public const uint R_PPC64_GOT_DTPREL16_LO_DS = 92; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @dtprel@h + /// + /// @enddot + /// + public const uint R_PPC64_GOT_DTPREL16_HI = 93; + + /// + /// half16 (sym+add) + /// + /// + /// @dot @dtprel@ha + /// + /// @enddot + /// + public const uint R_PPC64_GOT_DTPREL16_HA = 94; + + /// + /// half16ds* (sym+add)@tprel + /// + public const uint R_PPC64_TPREL16_DS = 95; + + /// + /// half16ds (sym+add)@tprel @l + /// + public const uint R_PPC64_TPREL16_LO_DS = 96; + + /// + /// half16 (sym+add)@tprel @higher + /// + public const uint R_PPC64_TPREL16_HIGHER = 97; + + /// + /// half16 (sym+add)@tprel @highera + /// + public const uint R_PPC64_TPREL16_HIGHERA = 98; + + /// + /// half16 (sym+add)@tprel @highest + /// + public const uint R_PPC64_TPREL16_HIGHEST = 99; + + /// + /// half16 (sym+add)@tprel @highesta + /// + public const uint R_PPC64_TPREL16_HIGHESTA = 100; + + /// + /// half16ds* (sym+add)@dtprel + /// + public const uint R_PPC64_DTPREL16_DS = 101; + + /// + /// half16ds (sym+add)@dtprel @l + /// + public const uint R_PPC64_DTPREL16_LO_DS = 102; + + /// + /// half16 (sym+add)@dtprel @higher + /// + public const uint R_PPC64_DTPREL16_HIGHER = 103; + + /// + /// half16 (sym+add)@dtprel @highera + /// + public const uint R_PPC64_DTPREL16_HIGHERA = 104; + + /// + /// half16 (sym+add)@dtprel @highest + /// + public const uint R_PPC64_DTPREL16_HIGHEST = 105; + + /// + /// half16 (sym+add)@dtprel @highesta + /// + public const uint R_PPC64_DTPREL16_HIGHESTA = 106; + + /// + /// none (sym+add)@tlsgd + /// + public const uint R_PPC64_TLSGD = 107; + + /// + /// none (sym+add)@tlsld + /// + public const uint R_PPC64_TLSLD = 108; + + /// + /// none + /// + public const uint R_PPC64_TOCSAVE = 109; + + public const uint R_PPC64_ADDR16_HIGH = 110; + + public const uint R_PPC64_ADDR16_HIGHA = 111; + + public const uint R_PPC64_TPREL16_HIGH = 112; + + public const uint R_PPC64_TPREL16_HIGHA = 113; + + public const uint R_PPC64_DTPREL16_HIGH = 114; + + public const uint R_PPC64_DTPREL16_HIGHA = 115; + + public const uint R_PPC64_JMP_IREL = 247; + + public const uint R_PPC64_IRELATIVE = 248; + + /// + /// half16 (sym+add-.) + /// + public const uint R_PPC64_REL16 = 249; + + /// + /// half16 (sym+add-.)@l + /// + public const uint R_PPC64_REL16_LO = 250; + + /// + /// half16 (sym+add-.)@h + /// + public const uint R_PPC64_REL16_HI = 251; + + /// + /// half16 (sym+add-.)@ha + /// + public const uint R_PPC64_REL16_HA = 252; + + public const uint EF_PPC64_ABI = 3; + + public const int DT_PPC64_GLINK = ( 0); + + public const int DT_PPC64_OPD = ( 1); + + public const int DT_PPC64_OPDSZ = ( 2); + + public const int DT_PPC64_OPT = ( 3); + + public const int DT_PPC64_NUM = 4; + + public const uint EF_ARM_RELEXEC = 1; + + public const uint EF_ARM_HASENTRY = 2; + + public const uint EF_ARM_INTERWORK = 4; + + public const uint EF_ARM_APCS_26 = 8; + + public const uint EF_ARM_APCS_FLOAT = 16; + + public const uint EF_ARM_PIC = 32; + + /// + /// 8-bit structure alignment is in use + /// + public const uint EF_ARM_ALIGN8 = 64; + + public const uint EF_ARM_NEW_ABI = 128; + + public const uint EF_ARM_OLD_ABI = 256; + + public const uint EF_ARM_SOFT_FLOAT = 512; + + public const uint EF_ARM_VFP_FLOAT = 1024; + + public const uint EF_ARM_MAVERICK_FLOAT = 2048; + + /// + /// NB conflicts with EF_ARM_SOFT_FLOAT + /// + public const uint EF_ARM_ABI_FLOAT_SOFT = 512; + + /// + /// NB conflicts with EF_ARM_VFP_FLOAT + /// + public const uint EF_ARM_ABI_FLOAT_HARD = 1024; + + public const uint EF_ARM_SYMSARESORTED = 4; + + public const uint EF_ARM_DYNSYMSUSESEGIDX = 8; + + public const uint EF_ARM_MAPSYMSFIRST = 16; + + public const uint EF_ARM_EABIMASK = 0XFF000000; + + public const uint EF_ARM_BE8 = 8388608; + + public const uint EF_ARM_LE8 = 4194304; + + public const uint EF_ARM_EABI_UNKNOWN = 0; + + public const uint EF_ARM_EABI_VER1 = 16777216; + + public const uint EF_ARM_EABI_VER2 = 33554432; + + public const uint EF_ARM_EABI_VER3 = 50331648; + + public const uint EF_ARM_EABI_VER4 = 67108864; + + public const uint EF_ARM_EABI_VER5 = 83886080; + + /// + /// A Thumb function. + /// + public const byte STT_ARM_TFUNC = 13; + + /// + /// A Thumb label. + /// + public const byte STT_ARM_16BIT = 15; + + /// + /// Section contains an entry point + /// + public const uint SHF_ARM_ENTRYSECT = 268435456; + + /// + /// Section may be multiply defined + /// in the input to a link step. + /// + public const uint SHF_ARM_COMDEF = 0x80000000; + + /// + /// Segment contains the location + /// addressed by the static base. + /// + public const uint PF_ARM_SB = 268435456; + + /// + /// Position-independent segment. + /// + public const uint PF_ARM_PI = 536870912; + + /// + /// Absolute segment. + /// + public const uint PF_ARM_ABS = 1073741824; + + /// + /// ARM unwind segment. + /// + public const uint PT_ARM_EXIDX = 1879048193; + + /// + /// ARM unwind section. + /// + public const uint SHT_ARM_EXIDX = 1879048193; + + /// + /// Preemption details. + /// + public const uint SHT_ARM_PREEMPTMAP = 1879048194; + + /// + /// ARM attributes section. + /// + public const uint SHT_ARM_ATTRIBUTES = 1879048195; + + /// + /// No relocation. + /// + public const uint R_AARCH64_NONE = 0; + + /// + /// Direct 32 bit. + /// + public const uint R_AARCH64_P32_ABS32 = 1; + + /// + /// Copy symbol at runtime. + /// + public const uint R_AARCH64_P32_COPY = 180; + + /// + /// Create GOT entry. + /// + public const uint R_AARCH64_P32_GLOB_DAT = 181; + + /// + /// Create PLT entry. + /// + public const uint R_AARCH64_P32_JUMP_SLOT = 182; + + /// + /// Adjust by program base. + /// + public const uint R_AARCH64_P32_RELATIVE = 183; + + /// + /// Module number, 32 bit. + /// + public const uint R_AARCH64_P32_TLS_DTPMOD = 184; + + /// + /// Module-relative offset, 32 bit. + /// + public const uint R_AARCH64_P32_TLS_DTPREL = 185; + + /// + /// TP-relative offset, 32 bit. + /// + public const uint R_AARCH64_P32_TLS_TPREL = 186; + + /// + /// TLS Descriptor. + /// + public const uint R_AARCH64_P32_TLSDESC = 187; + + /// + /// STT_GNU_IFUNC relocation. + /// + public const uint R_AARCH64_P32_IRELATIVE = 188; + + /// + /// Direct 64 bit. + /// + public const uint R_AARCH64_ABS64 = 257; + + /// + /// Direct 32 bit. + /// + public const uint R_AARCH64_ABS32 = 258; + + /// + /// Direct 16-bit. + /// + public const uint R_AARCH64_ABS16 = 259; + + /// + /// PC-relative 64-bit. + /// + public const uint R_AARCH64_PREL64 = 260; + + /// + /// PC-relative 32-bit. + /// + public const uint R_AARCH64_PREL32 = 261; + + /// + /// PC-relative 16-bit. + /// + public const uint R_AARCH64_PREL16 = 262; + + /// + /// Dir. MOVZ imm. from bits 15:0. + /// + public const uint R_AARCH64_MOVW_UABS_G0 = 263; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_UABS_G0_NC = 264; + + /// + /// Dir. MOVZ imm. from bits 31:16. + /// + public const uint R_AARCH64_MOVW_UABS_G1 = 265; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_UABS_G1_NC = 266; + + /// + /// Dir. MOVZ imm. from bits 47:32. + /// + public const uint R_AARCH64_MOVW_UABS_G2 = 267; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_UABS_G2_NC = 268; + + /// + /// Dir. MOV{K,Z} imm. from 63:48. + /// + public const uint R_AARCH64_MOVW_UABS_G3 = 269; + + /// + /// Dir. MOV{N,Z} imm. from 15:0. + /// + public const uint R_AARCH64_MOVW_SABS_G0 = 270; + + /// + /// Dir. MOV{N,Z} imm. from 31:16. + /// + public const uint R_AARCH64_MOVW_SABS_G1 = 271; + + /// + /// Dir. MOV{N,Z} imm. from 47:32. + /// + public const uint R_AARCH64_MOVW_SABS_G2 = 272; + + /// + /// PC-rel. LD imm. from bits 20:2. + /// + public const uint R_AARCH64_LD_PREL_LO19 = 273; + + /// + /// PC-rel. ADR imm. from bits 20:0. + /// + public const uint R_AARCH64_ADR_PREL_LO21 = 274; + + /// + /// Page-rel. ADRP imm. from 32:12. + /// + public const uint R_AARCH64_ADR_PREL_PG_HI21 = 275; + + /// + /// Likewise; no overflow check. + /// + public const uint R_AARCH64_ADR_PREL_PG_HI21_NC = 276; + + /// + /// Dir. ADD imm. from bits 11:0. + /// + public const uint R_AARCH64_ADD_ABS_LO12_NC = 277; + + /// + /// Likewise for LD/ST; no check. + /// + public const uint R_AARCH64_LDST8_ABS_LO12_NC = 278; + + /// + /// PC-rel. TBZ/TBNZ imm. from 15:2. + /// + public const uint R_AARCH64_TSTBR14 = 279; + + /// + /// PC-rel. cond. br. imm. from 20:2. + /// + public const uint R_AARCH64_CONDBR19 = 280; + + /// + /// PC-rel. B imm. from bits 27:2. + /// + public const uint R_AARCH64_JUMP26 = 282; + + /// + /// Likewise for CALL. + /// + public const uint R_AARCH64_CALL26 = 283; + + /// + /// Dir. ADD imm. from bits 11:1. + /// + public const uint R_AARCH64_LDST16_ABS_LO12_NC = 284; + + /// + /// Likewise for bits 11:2. + /// + public const uint R_AARCH64_LDST32_ABS_LO12_NC = 285; + + /// + /// Likewise for bits 11:3. + /// + public const uint R_AARCH64_LDST64_ABS_LO12_NC = 286; + + /// + /// PC-rel. MOV{N,Z} imm. from 15:0. + /// + public const uint R_AARCH64_MOVW_PREL_G0 = 287; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_PREL_G0_NC = 288; + + /// + /// PC-rel. MOV{N,Z} imm. from 31:16. + /// + public const uint R_AARCH64_MOVW_PREL_G1 = 289; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_PREL_G1_NC = 290; + + /// + /// PC-rel. MOV{N,Z} imm. from 47:32. + /// + public const uint R_AARCH64_MOVW_PREL_G2 = 291; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_PREL_G2_NC = 292; + + /// + /// PC-rel. MOV{N,Z} imm. from 63:48. + /// + public const uint R_AARCH64_MOVW_PREL_G3 = 293; + + /// + /// Dir. ADD imm. from bits 11:4. + /// + public const uint R_AARCH64_LDST128_ABS_LO12_NC = 299; + + /// + /// GOT-rel. off. MOV{N,Z} imm. 15:0. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G0 = 300; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G0_NC = 301; + + /// + /// GOT-rel. o. MOV{N,Z} imm. 31:16. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G1 = 302; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G1_NC = 303; + + /// + /// GOT-rel. o. MOV{N,Z} imm. 47:32. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G2 = 304; + + /// + /// Likewise for MOVK; no check. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G2_NC = 305; + + /// + /// GOT-rel. o. MOV{N,Z} imm. 63:48. + /// + public const uint R_AARCH64_MOVW_GOTOFF_G3 = 306; + + /// + /// GOT-relative 64-bit. + /// + public const uint R_AARCH64_GOTREL64 = 307; + + /// + /// GOT-relative 32-bit. + /// + public const uint R_AARCH64_GOTREL32 = 308; + + /// + /// PC-rel. GOT off. load imm. 20:2. + /// + public const uint R_AARCH64_GOT_LD_PREL19 = 309; + + /// + /// GOT-rel. off. LD/ST imm. 14:3. + /// + public const uint R_AARCH64_LD64_GOTOFF_LO15 = 310; + + /// + /// P-page-rel. GOT off. ADRP 32:12. + /// + public const uint R_AARCH64_ADR_GOT_PAGE = 311; + + /// + /// Dir. GOT off. LD/ST imm. 11:3. + /// + public const uint R_AARCH64_LD64_GOT_LO12_NC = 312; + + /// + /// GOT-page-rel. GOT off. LD/ST 14:3 + /// + public const uint R_AARCH64_LD64_GOTPAGE_LO15 = 313; + + /// + /// PC-relative ADR imm. 20:0. + /// + public const uint R_AARCH64_TLSGD_ADR_PREL21 = 512; + + /// + /// page-rel. ADRP imm. 32:12. + /// + public const uint R_AARCH64_TLSGD_ADR_PAGE21 = 513; + + /// + /// direct ADD imm. from 11:0. + /// + public const uint R_AARCH64_TLSGD_ADD_LO12_NC = 514; + + /// + /// GOT-rel. MOV{N,Z} 31:16. + /// + public const uint R_AARCH64_TLSGD_MOVW_G1 = 515; + + /// + /// GOT-rel. MOVK imm. 15:0. + /// + public const uint R_AARCH64_TLSGD_MOVW_G0_NC = 516; + + /// + /// Like 512; local dynamic model. + /// + public const uint R_AARCH64_TLSLD_ADR_PREL21 = 517; + + /// + /// Like 513; local dynamic model. + /// + public const uint R_AARCH64_TLSLD_ADR_PAGE21 = 518; + + /// + /// Like 514; local dynamic model. + /// + public const uint R_AARCH64_TLSLD_ADD_LO12_NC = 519; + + /// + /// Like 515; local dynamic model. + /// + public const uint R_AARCH64_TLSLD_MOVW_G1 = 520; + + /// + /// Like 516; local dynamic model. + /// + public const uint R_AARCH64_TLSLD_MOVW_G0_NC = 521; + + /// + /// TLS PC-rel. load imm. 20:2. + /// + public const uint R_AARCH64_TLSLD_LD_PREL19 = 522; + + /// + /// TLS DTP-rel. MOV{N,Z} 47:32. + /// + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523; + + /// + /// TLS DTP-rel. MOV{N,Z} 31:16. + /// + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524; + + /// + /// Likewise; MOVK; no check. + /// + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525; + + /// + /// TLS DTP-rel. MOV{N,Z} 15:0. + /// + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526; + + /// + /// Likewise; MOVK; no check. + /// + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527; + + /// + /// DTP-rel. ADD imm. from 23:12. + /// + public const uint R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528; + + /// + /// DTP-rel. ADD imm. from 11:0. + /// + public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529; + + /// + /// Likewise; no ovfl. check. + /// + public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530; + + /// + /// DTP-rel. LD/ST imm. 11:0. + /// + public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532; + + /// + /// DTP-rel. LD/ST imm. 11:1. + /// + public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534; + + /// + /// DTP-rel. LD/ST imm. 11:2. + /// + public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536; + + /// + /// DTP-rel. LD/ST imm. 11:3. + /// + public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538; + + /// + /// GOT-rel. MOV{N,Z} 31:16. + /// + public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539; + + /// + /// GOT-rel. MOVK 15:0. + /// + public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540; + + /// + /// Page-rel. ADRP 32:12. + /// + public const uint R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541; + + /// + /// Direct LD off. 11:3. + /// + public const uint R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542; + + /// + /// PC-rel. load imm. 20:2. + /// + public const uint R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543; + + /// + /// TLS TP-rel. MOV{N,Z} 47:32. + /// + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544; + + /// + /// TLS TP-rel. MOV{N,Z} 31:16. + /// + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545; + + /// + /// Likewise; MOVK; no check. + /// + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546; + + /// + /// TLS TP-rel. MOV{N,Z} 15:0. + /// + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547; + + /// + /// Likewise; MOVK; no check. + /// + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548; + + /// + /// TP-rel. ADD imm. 23:12. + /// + public const uint R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549; + + /// + /// TP-rel. ADD imm. 11:0. + /// + public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550; + + /// + /// Likewise; no ovfl. check. + /// + public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551; + + /// + /// TP-rel. LD/ST off. 11:0. + /// + public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552; + + /// + /// Likewise; no ovfl. check. + /// + public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553; + + /// + /// TP-rel. LD/ST off. 11:1. + /// + public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555; + + /// + /// TP-rel. LD/ST off. 11:2. + /// + public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557; + + /// + /// TP-rel. LD/ST off. 11:3. + /// + public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559; + + /// + /// PC-rel. load immediate 20:2. + /// + public const uint R_AARCH64_TLSDESC_LD_PREL19 = 560; + + /// + /// PC-rel. ADR immediate 20:0. + /// + public const uint R_AARCH64_TLSDESC_ADR_PREL21 = 561; + + /// + /// Page-rel. ADRP imm. 32:12. + /// + public const uint R_AARCH64_TLSDESC_ADR_PAGE21 = 562; + + /// + /// Direct LD off. from 11:3. + /// + public const uint R_AARCH64_TLSDESC_LD64_LO12 = 563; + + /// + /// Direct ADD imm. from 11:0. + /// + public const uint R_AARCH64_TLSDESC_ADD_LO12 = 564; + + /// + /// GOT-rel. MOV{N,Z} imm. 31:16. + /// + public const uint R_AARCH64_TLSDESC_OFF_G1 = 565; + + /// + /// GOT-rel. MOVK imm. 15:0; no ck. + /// + public const uint R_AARCH64_TLSDESC_OFF_G0_NC = 566; + + /// + /// Relax LDR. + /// + public const uint R_AARCH64_TLSDESC_LDR = 567; + + /// + /// Relax ADD. + /// + public const uint R_AARCH64_TLSDESC_ADD = 568; + + /// + /// Relax BLR. + /// + public const uint R_AARCH64_TLSDESC_CALL = 569; + + /// + /// TP-rel. LD/ST off. 11:4. + /// + public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571; + + /// + /// DTP-rel. LD/ST imm. 11:4. + /// + public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572; + + /// + /// Likewise; no check. + /// + public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573; + + /// + /// Copy symbol at runtime. + /// + public const uint R_AARCH64_COPY = 1024; + + /// + /// Create GOT entry. + /// + public const uint R_AARCH64_GLOB_DAT = 1025; + + /// + /// Create PLT entry. + /// + public const uint R_AARCH64_JUMP_SLOT = 1026; + + /// + /// Adjust by program base. + /// + public const uint R_AARCH64_RELATIVE = 1027; + + /// + /// Module number, 64 bit. + /// + public const uint R_AARCH64_TLS_DTPMOD = 1028; + + /// + /// Module-relative offset, 64 bit. + /// + public const uint R_AARCH64_TLS_DTPREL = 1029; + + /// + /// TP-relative offset, 64 bit. + /// + public const uint R_AARCH64_TLS_TPREL = 1030; + + /// + /// TLS Descriptor. + /// + public const uint R_AARCH64_TLSDESC = 1031; + + /// + /// STT_GNU_IFUNC relocation. + /// + public const uint R_AARCH64_IRELATIVE = 1032; + + /// + /// No reloc + /// + public const uint R_ARM_NONE = 0; + + /// + /// Deprecated PC relative 26 bit branch. + /// + public const uint R_ARM_PC24 = 1; + + /// + /// Direct 32 bit + /// + public const uint R_ARM_ABS32 = 2; + + /// + /// PC relative 32 bit + /// + public const uint R_ARM_REL32 = 3; + + public const uint R_ARM_PC13 = 4; + + /// + /// Direct 16 bit + /// + public const uint R_ARM_ABS16 = 5; + + /// + /// Direct 12 bit + /// + public const uint R_ARM_ABS12 = 6; + + /// + /// Direct + /// & + /// 0x7C (LDR, STR). + /// + public const uint R_ARM_THM_ABS5 = 7; + + /// + /// Direct 8 bit + /// + public const uint R_ARM_ABS8 = 8; + + public const uint R_ARM_SBREL32 = 9; + + /// + /// PC relative 24 bit (Thumb32 BL). + /// + public const uint R_ARM_THM_PC22 = 10; + + /// + /// PC relative + /// & + /// 0x3FC (Thumb16 LDR, ADD, ADR). + /// + public const uint R_ARM_THM_PC8 = 11; + + public const uint R_ARM_AMP_VCALL9 = 12; + + /// + /// Obsolete static relocation. + /// + public const uint R_ARM_SWI24 = 13; + + /// + /// Dynamic relocation. + /// + public const uint R_ARM_TLS_DESC = 13; + + /// + /// Reserved. + /// + public const uint R_ARM_THM_SWI8 = 14; + + /// + /// Reserved. + /// + public const uint R_ARM_XPC25 = 15; + + /// + /// Reserved. + /// + public const uint R_ARM_THM_XPC22 = 16; + + /// + /// ID of module containing symbol + /// + public const uint R_ARM_TLS_DTPMOD32 = 17; + + /// + /// Offset in TLS block + /// + public const uint R_ARM_TLS_DTPOFF32 = 18; + + /// + /// Offset in static TLS block + /// + public const uint R_ARM_TLS_TPOFF32 = 19; + + /// + /// Copy symbol at runtime + /// + public const uint R_ARM_COPY = 20; + + /// + /// Create GOT entry + /// + public const uint R_ARM_GLOB_DAT = 21; + + /// + /// Create PLT entry + /// + public const uint R_ARM_JUMP_SLOT = 22; + + /// + /// Adjust by program base + /// + public const uint R_ARM_RELATIVE = 23; + + /// + /// 32 bit offset to GOT + /// + public const uint R_ARM_GOTOFF = 24; + + /// + /// 32 bit PC relative offset to GOT + /// + public const uint R_ARM_GOTPC = 25; + + /// + /// 32 bit GOT entry + /// + public const uint R_ARM_GOT32 = 26; + + /// + /// Deprecated, 32 bit PLT address. + /// + public const uint R_ARM_PLT32 = 27; + + /// + /// PC relative 24 bit (BL, BLX). + /// + public const uint R_ARM_CALL = 28; + + /// + /// PC relative 24 bit (B, BL + /// <cond + /// >). + /// + public const uint R_ARM_JUMP24 = 29; + + /// + /// PC relative 24 bit (Thumb32 B.W). + /// + public const uint R_ARM_THM_JUMP24 = 30; + + /// + /// Adjust by program base. + /// + public const uint R_ARM_BASE_ABS = 31; + + /// + /// Obsolete. + /// + public const uint R_ARM_ALU_PCREL_7_0 = 32; + + /// + /// Obsolete. + /// + public const uint R_ARM_ALU_PCREL_15_8 = 33; + + /// + /// Obsolete. + /// + public const uint R_ARM_ALU_PCREL_23_15 = 34; + + /// + /// Deprecated, prog. base relative. + /// + public const uint R_ARM_LDR_SBREL_11_0 = 35; + + /// + /// Deprecated, prog. base relative. + /// + public const uint R_ARM_ALU_SBREL_19_12 = 36; + + /// + /// Deprecated, prog. base relative. + /// + public const uint R_ARM_ALU_SBREL_27_20 = 37; + + public const uint R_ARM_TARGET1 = 38; + + /// + /// Program base relative. + /// + public const uint R_ARM_SBREL31 = 39; + + public const uint R_ARM_V4BX = 40; + + public const uint R_ARM_TARGET2 = 41; + + /// + /// 32 bit PC relative. + /// + public const uint R_ARM_PREL31 = 42; + + /// + /// Direct 16-bit (MOVW). + /// + public const uint R_ARM_MOVW_ABS_NC = 43; + + /// + /// Direct high 16-bit (MOVT). + /// + public const uint R_ARM_MOVT_ABS = 44; + + /// + /// PC relative 16-bit (MOVW). + /// + public const uint R_ARM_MOVW_PREL_NC = 45; + + /// + /// PC relative (MOVT). + /// + public const uint R_ARM_MOVT_PREL = 46; + + /// + /// Direct 16 bit (Thumb32 MOVW). + /// + public const uint R_ARM_THM_MOVW_ABS_NC = 47; + + /// + /// Direct high 16 bit (Thumb32 MOVT). + /// + public const uint R_ARM_THM_MOVT_ABS = 48; + + /// + /// PC relative 16 bit (Thumb32 MOVW). + /// + public const uint R_ARM_THM_MOVW_PREL_NC = 49; + + /// + /// PC relative high 16 bit (Thumb32 MOVT). + /// + public const uint R_ARM_THM_MOVT_PREL = 50; + + /// + /// PC relative 20 bit (Thumb32 B + /// <cond + /// >.W). + /// + public const uint R_ARM_THM_JUMP19 = 51; + + /// + /// PC relative X + /// & + /// 0x7E (Thumb16 CBZ, CBNZ). + /// + public const uint R_ARM_THM_JUMP6 = 52; + + /// + /// PC relative 12 bit (Thumb32 ADR.W). + /// + public const uint R_ARM_THM_ALU_PREL_11_0 = 53; + + /// + /// PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). + /// + public const uint R_ARM_THM_PC12 = 54; + + /// + /// Direct 32-bit. + /// + public const uint R_ARM_ABS32_NOI = 55; + + /// + /// PC relative 32-bit. + /// + public const uint R_ARM_REL32_NOI = 56; + + /// + /// PC relative (ADD, SUB). + /// + public const uint R_ARM_ALU_PC_G0_NC = 57; + + /// + /// PC relative (ADD, SUB). + /// + public const uint R_ARM_ALU_PC_G0 = 58; + + /// + /// PC relative (ADD, SUB). + /// + public const uint R_ARM_ALU_PC_G1_NC = 59; + + /// + /// PC relative (ADD, SUB). + /// + public const uint R_ARM_ALU_PC_G1 = 60; + + /// + /// PC relative (ADD, SUB). + /// + public const uint R_ARM_ALU_PC_G2 = 61; + + /// + /// PC relative (LDR,STR,LDRB,STRB). + /// + public const uint R_ARM_LDR_PC_G1 = 62; + + /// + /// PC relative (LDR,STR,LDRB,STRB). + /// + public const uint R_ARM_LDR_PC_G2 = 63; + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public const uint R_ARM_LDRS_PC_G0 = 64; + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public const uint R_ARM_LDRS_PC_G1 = 65; + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public const uint R_ARM_LDRS_PC_G2 = 66; + + /// + /// PC relative (LDC, STC). + /// + public const uint R_ARM_LDC_PC_G0 = 67; + + /// + /// PC relative (LDC, STC). + /// + public const uint R_ARM_LDC_PC_G1 = 68; + + /// + /// PC relative (LDC, STC). + /// + public const uint R_ARM_LDC_PC_G2 = 69; + + /// + /// Program base relative (ADD,SUB). + /// + public const uint R_ARM_ALU_SB_G0_NC = 70; + + /// + /// Program base relative (ADD,SUB). + /// + public const uint R_ARM_ALU_SB_G0 = 71; + + /// + /// Program base relative (ADD,SUB). + /// + public const uint R_ARM_ALU_SB_G1_NC = 72; + + /// + /// Program base relative (ADD,SUB). + /// + public const uint R_ARM_ALU_SB_G1 = 73; + + /// + /// Program base relative (ADD,SUB). + /// + public const uint R_ARM_ALU_SB_G2 = 74; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDR_SB_G0 = 75; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDR_SB_G1 = 76; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDR_SB_G2 = 77; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDRS_SB_G0 = 78; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDRS_SB_G1 = 79; + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public const uint R_ARM_LDRS_SB_G2 = 80; + + /// + /// Program base relative (LDC,STC). + /// + public const uint R_ARM_LDC_SB_G0 = 81; + + /// + /// Program base relative (LDC,STC). + /// + public const uint R_ARM_LDC_SB_G1 = 82; + + /// + /// Program base relative (LDC,STC). + /// + public const uint R_ARM_LDC_SB_G2 = 83; + + /// + /// Program base relative 16 bit (MOVW). + /// + public const uint R_ARM_MOVW_BREL_NC = 84; + + /// + /// Program base relative high 16 bit (MOVT). + /// + public const uint R_ARM_MOVT_BREL = 85; + + /// + /// Program base relative 16 bit (MOVW). + /// + public const uint R_ARM_MOVW_BREL = 86; + + /// + /// Program base relative 16 bit (Thumb32 MOVW). + /// + public const uint R_ARM_THM_MOVW_BREL_NC = 87; + + /// + /// Program base relative high 16 bit (Thumb32 MOVT). + /// + public const uint R_ARM_THM_MOVT_BREL = 88; + + /// + /// Program base relative 16 bit (Thumb32 MOVW). + /// + public const uint R_ARM_THM_MOVW_BREL = 89; + + public const uint R_ARM_TLS_GOTDESC = 90; + + public const uint R_ARM_TLS_CALL = 91; + + /// + /// TLS relaxation. + /// + public const uint R_ARM_TLS_DESCSEQ = 92; + + public const uint R_ARM_THM_TLS_CALL = 93; + + public const uint R_ARM_PLT32_ABS = 94; + + /// + /// GOT entry. + /// + public const uint R_ARM_GOT_ABS = 95; + + /// + /// PC relative GOT entry. + /// + public const uint R_ARM_GOT_PREL = 96; + + /// + /// GOT entry relative to GOT origin (LDR). + /// + public const uint R_ARM_GOT_BREL12 = 97; + + /// + /// 12 bit, GOT entry relative to GOT origin (LDR, STR). + /// + public const uint R_ARM_GOTOFF12 = 98; + + public const uint R_ARM_GOTRELAX = 99; + + public const uint R_ARM_GNU_VTENTRY = 100; + + public const uint R_ARM_GNU_VTINHERIT = 101; + + /// + /// PC relative + /// & + /// 0xFFE (Thumb16 B). + /// + public const uint R_ARM_THM_PC11 = 102; + + /// + /// PC relative + /// & + /// 0x1FE (Thumb16 B/B + /// <cond + /// >). + /// + public const uint R_ARM_THM_PC9 = 103; + + /// + /// PC-rel 32 bit for global dynamic thread local data + /// + public const uint R_ARM_TLS_GD32 = 104; + + /// + /// PC-rel 32 bit for local dynamic thread local data + /// + public const uint R_ARM_TLS_LDM32 = 105; + + /// + /// 32 bit offset relative to TLS block + /// + public const uint R_ARM_TLS_LDO32 = 106; + + /// + /// PC-rel 32 bit for GOT entry of static TLS block offset + /// + public const uint R_ARM_TLS_IE32 = 107; + + /// + /// 32 bit offset relative to static TLS block + /// + public const uint R_ARM_TLS_LE32 = 108; + + /// + /// 12 bit relative to TLS block (LDR, STR). + /// + public const uint R_ARM_TLS_LDO12 = 109; + + /// + /// 12 bit relative to static TLS block (LDR, STR). + /// + public const uint R_ARM_TLS_LE12 = 110; + + /// + /// 12 bit GOT entry relative to GOT origin (LDR). + /// + public const uint R_ARM_TLS_IE12GP = 111; + + /// + /// Obsolete. + /// + public const uint R_ARM_ME_TOO = 128; + + public const uint R_ARM_THM_TLS_DESCSEQ = 129; + + public const uint R_ARM_THM_TLS_DESCSEQ16 = 129; + + public const uint R_ARM_THM_TLS_DESCSEQ32 = 130; + + /// + /// GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). + /// + public const uint R_ARM_THM_GOT_BREL12 = 131; + + public const uint R_ARM_IRELATIVE = 160; + + public const uint R_ARM_RXPC25 = 249; + + public const uint R_ARM_RSBREL32 = 250; + + public const uint R_ARM_THM_RPC22 = 251; + + public const uint R_ARM_RREL32 = 252; + + public const uint R_ARM_RABS22 = 253; + + public const uint R_ARM_RPC24 = 254; + + public const uint R_ARM_RBASE = 255; + + public const uint R_ARM_NUM = 256; + + /// + /// os-specific flags + /// + public const uint EF_IA_64_MASKOS = 15; + + /// + /// 64-bit ABI + /// + public const uint EF_IA_64_ABI64 = 16; + + /// + /// arch. version mask + /// + public const uint EF_IA_64_ARCH = 0xff000000; + + /// + /// arch extension bits + /// + public const uint PT_IA_64_ARCHEXT = 1879048192; + + /// + /// ia64 unwind bits + /// + public const uint PT_IA_64_UNWIND = 1879048193; + + public const uint PT_IA_64_HP_OPT_ANOT = 1610612754; + + public const uint PT_IA_64_HP_HSL_ANOT = 1610612755; + + public const uint PT_IA_64_HP_STACK = 1610612756; + + /// + /// spec insns w/o recovery + /// + public const uint PF_IA_64_NORECOV = 0x80000000; + + /// + /// extension bits + /// + public const uint SHT_IA_64_EXT = 1879048192; + + /// + /// unwind bits + /// + public const uint SHT_IA_64_UNWIND = 1879048193; + + /// + /// section near gp + /// + public const uint SHF_IA_64_SHORT = 268435456; + + /// + /// spec insns w/o recovery + /// + public const uint SHF_IA_64_NORECOV = 536870912; + + public const int DT_IA_64_PLT_RESERVE = ( 0); + + public const int DT_IA_64_NUM = 1; + + /// + /// none + /// + public const uint R_IA64_NONE = 0; + + /// + /// symbol + addend, add imm14 + /// + public const uint R_IA64_IMM14 = 33; + + /// + /// symbol + addend, add imm22 + /// + public const uint R_IA64_IMM22 = 34; + + /// + /// symbol + addend, mov imm64 + /// + public const uint R_IA64_IMM64 = 35; + + /// + /// symbol + addend, data4 MSB + /// + public const uint R_IA64_DIR32MSB = 36; + + /// + /// symbol + addend, data4 LSB + /// + public const uint R_IA64_DIR32LSB = 37; + + /// + /// symbol + addend, data8 MSB + /// + public const uint R_IA64_DIR64MSB = 38; + + /// + /// symbol + addend, data8 LSB + /// + public const uint R_IA64_DIR64LSB = 39; + + /// + /// @gprel (sym + add), add imm22 + /// + public const uint R_IA64_GPREL22 = 42; + + /// + /// @gprel (sym + add), mov imm64 + /// + public const uint R_IA64_GPREL64I = 43; + + /// + /// @gprel (sym + add), data4 MSB + /// + public const uint R_IA64_GPREL32MSB = 44; + + /// + /// @gprel (sym + add), data4 LSB + /// + public const uint R_IA64_GPREL32LSB = 45; + + /// + /// @gprel (sym + add), data8 MSB + /// + public const uint R_IA64_GPREL64MSB = 46; + + /// + /// @gprel (sym + add), data8 LSB + /// + public const uint R_IA64_GPREL64LSB = 47; + + /// + /// @ltoff (sym + add), add imm22 + /// + public const uint R_IA64_LTOFF22 = 50; + + /// + /// @ltoff (sym + add), mov imm64 + /// + public const uint R_IA64_LTOFF64I = 51; + + /// + /// @pltoff (sym + add), add imm22 + /// + public const uint R_IA64_PLTOFF22 = 58; + + /// + /// @pltoff (sym + add), mov imm64 + /// + public const uint R_IA64_PLTOFF64I = 59; + + /// + /// @pltoff (sym + add), data8 MSB + /// + public const uint R_IA64_PLTOFF64MSB = 62; + + /// + /// @pltoff (sym + add), data8 LSB + /// + public const uint R_IA64_PLTOFF64LSB = 63; + + /// + /// @fptr (sym + add), mov imm64 + /// + public const uint R_IA64_FPTR64I = 67; + + /// + /// @fptr (sym + add), data4 MSB + /// + public const uint R_IA64_FPTR32MSB = 68; + + /// + /// @fptr (sym + add), data4 LSB + /// + public const uint R_IA64_FPTR32LSB = 69; + + /// + /// @fptr (sym + add), data8 MSB + /// + public const uint R_IA64_FPTR64MSB = 70; + + /// + /// @fptr (sym + add), data8 LSB + /// + public const uint R_IA64_FPTR64LSB = 71; + + /// + /// @pcrel (sym + add), brl + /// + public const uint R_IA64_PCREL60B = 72; + + /// + /// @pcrel (sym + add), ptb, call + /// + public const uint R_IA64_PCREL21B = 73; + + /// + /// @pcrel (sym + add), chk.s + /// + public const uint R_IA64_PCREL21M = 74; + + /// + /// @pcrel (sym + add), fchkf + /// + public const uint R_IA64_PCREL21F = 75; + + /// + /// @pcrel (sym + add), data4 MSB + /// + public const uint R_IA64_PCREL32MSB = 76; + + /// + /// @pcrel (sym + add), data4 LSB + /// + public const uint R_IA64_PCREL32LSB = 77; + + /// + /// @pcrel (sym + add), data8 MSB + /// + public const uint R_IA64_PCREL64MSB = 78; + + /// + /// @pcrel (sym + add), data8 LSB + /// + public const uint R_IA64_PCREL64LSB = 79; + + /// + /// @ltoff (@fptr (s+a)), imm22 + /// + public const uint R_IA64_LTOFF_FPTR22 = 82; + + /// + /// @ltoff (@fptr (s+a)), imm64 + /// + public const uint R_IA64_LTOFF_FPTR64I = 83; + + /// + /// @ltoff (@fptr (s+a)), data4 MSB + /// + public const uint R_IA64_LTOFF_FPTR32MSB = 84; + + /// + /// @ltoff (@fptr (s+a)), data4 LSB + /// + public const uint R_IA64_LTOFF_FPTR32LSB = 85; + + /// + /// @ltoff (@fptr (s+a)), data8 MSB + /// + public const uint R_IA64_LTOFF_FPTR64MSB = 86; + + /// + /// @ltoff (@fptr (s+a)), data8 LSB + /// + public const uint R_IA64_LTOFF_FPTR64LSB = 87; + + /// + /// @segrel (sym + add), data4 MSB + /// + public const uint R_IA64_SEGREL32MSB = 92; + + /// + /// @segrel (sym + add), data4 LSB + /// + public const uint R_IA64_SEGREL32LSB = 93; + + /// + /// @segrel (sym + add), data8 MSB + /// + public const uint R_IA64_SEGREL64MSB = 94; + + /// + /// @segrel (sym + add), data8 LSB + /// + public const uint R_IA64_SEGREL64LSB = 95; + + /// + /// @secrel (sym + add), data4 MSB + /// + public const uint R_IA64_SECREL32MSB = 100; + + /// + /// @secrel (sym + add), data4 LSB + /// + public const uint R_IA64_SECREL32LSB = 101; + + /// + /// @secrel (sym + add), data8 MSB + /// + public const uint R_IA64_SECREL64MSB = 102; + + /// + /// @secrel (sym + add), data8 LSB + /// + public const uint R_IA64_SECREL64LSB = 103; + + /// + /// data 4 + REL + /// + public const uint R_IA64_REL32MSB = 108; + + /// + /// data 4 + REL + /// + public const uint R_IA64_REL32LSB = 109; + + /// + /// data 8 + REL + /// + public const uint R_IA64_REL64MSB = 110; + + /// + /// data 8 + REL + /// + public const uint R_IA64_REL64LSB = 111; + + /// + /// symbol + addend, data4 MSB + /// + public const uint R_IA64_LTV32MSB = 116; + + /// + /// symbol + addend, data4 LSB + /// + public const uint R_IA64_LTV32LSB = 117; + + /// + /// symbol + addend, data8 MSB + /// + public const uint R_IA64_LTV64MSB = 118; + + /// + /// symbol + addend, data8 LSB + /// + public const uint R_IA64_LTV64LSB = 119; + + /// + /// @pcrel (sym + add), 21bit inst + /// + public const uint R_IA64_PCREL21BI = 121; + + /// + /// @pcrel (sym + add), 22bit inst + /// + public const uint R_IA64_PCREL22 = 122; + + /// + /// @pcrel (sym + add), 64bit inst + /// + public const uint R_IA64_PCREL64I = 123; + + /// + /// dynamic reloc, imported PLT, MSB + /// + public const uint R_IA64_IPLTMSB = 128; + + /// + /// dynamic reloc, imported PLT, LSB + /// + public const uint R_IA64_IPLTLSB = 129; + + /// + /// copy relocation + /// + public const uint R_IA64_COPY = 132; + + /// + /// Addend and symbol difference + /// + public const uint R_IA64_SUB = 133; + + /// + /// LTOFF22, relaxable. + /// + public const uint R_IA64_LTOFF22X = 134; + + /// + /// Use of LTOFF22X. + /// + public const uint R_IA64_LDXMOV = 135; + + /// + /// @tprel (sym + add), imm14 + /// + public const uint R_IA64_TPREL14 = 145; + + /// + /// @tprel (sym + add), imm22 + /// + public const uint R_IA64_TPREL22 = 146; + + /// + /// @tprel (sym + add), imm64 + /// + public const uint R_IA64_TPREL64I = 147; + + /// + /// @tprel (sym + add), data8 MSB + /// + public const uint R_IA64_TPREL64MSB = 150; + + /// + /// @tprel (sym + add), data8 LSB + /// + public const uint R_IA64_TPREL64LSB = 151; + + /// + /// @ltoff (@tprel (s+a)), imm2 + /// + public const uint R_IA64_LTOFF_TPREL22 = 154; + + /// + /// @dtpmod (sym + add), data8 MSB + /// + public const uint R_IA64_DTPMOD64MSB = 166; + + /// + /// @dtpmod (sym + add), data8 LSB + /// + public const uint R_IA64_DTPMOD64LSB = 167; + + /// + /// @ltoff (@dtpmod (sym + add)), imm22 + /// + public const uint R_IA64_LTOFF_DTPMOD22 = 170; + + /// + /// @dtprel (sym + add), imm14 + /// + public const uint R_IA64_DTPREL14 = 177; + + /// + /// @dtprel (sym + add), imm22 + /// + public const uint R_IA64_DTPREL22 = 178; + + /// + /// @dtprel (sym + add), imm64 + /// + public const uint R_IA64_DTPREL64I = 179; + + /// + /// @dtprel (sym + add), data4 MSB + /// + public const uint R_IA64_DTPREL32MSB = 180; + + /// + /// @dtprel (sym + add), data4 LSB + /// + public const uint R_IA64_DTPREL32LSB = 181; + + /// + /// @dtprel (sym + add), data8 MSB + /// + public const uint R_IA64_DTPREL64MSB = 182; + + /// + /// @dtprel (sym + add), data8 LSB + /// + public const uint R_IA64_DTPREL64LSB = 183; + + /// + /// @ltoff (@dtprel (s+a)), imm22 + /// + public const uint R_IA64_LTOFF_DTPREL22 = 186; + + public const uint EF_SH_MACH_MASK = 31; + + public const uint EF_SH_UNKNOWN = 0; + + public const uint EF_SH1 = 1; + + public const uint EF_SH2 = 2; + + public const uint EF_SH3 = 3; + + public const uint EF_SH_DSP = 4; + + public const uint EF_SH3_DSP = 5; + + public const uint EF_SH4AL_DSP = 6; + + public const uint EF_SH3E = 8; + + public const uint EF_SH4 = 9; + + public const uint EF_SH2E = 11; + + public const uint EF_SH4A = 12; + + public const uint EF_SH2A = 13; + + public const uint EF_SH4_NOFPU = 16; + + public const uint EF_SH4A_NOFPU = 17; + + public const uint EF_SH4_NOMMU_NOFPU = 18; + + public const uint EF_SH2A_NOFPU = 19; + + public const uint EF_SH3_NOMMU = 20; + + public const uint EF_SH2A_SH4_NOFPU = 21; + + public const uint EF_SH2A_SH3_NOFPU = 22; + + public const uint EF_SH2A_SH4 = 23; + + public const uint EF_SH2A_SH3E = 24; + + public const uint R_SH_NONE = 0; + + public const uint R_SH_DIR32 = 1; + + public const uint R_SH_REL32 = 2; + + public const uint R_SH_DIR8WPN = 3; + + public const uint R_SH_IND12W = 4; + + public const uint R_SH_DIR8WPL = 5; + + public const uint R_SH_DIR8WPZ = 6; + + public const uint R_SH_DIR8BP = 7; + + public const uint R_SH_DIR8W = 8; + + public const uint R_SH_DIR8L = 9; + + public const uint R_SH_SWITCH16 = 25; + + public const uint R_SH_SWITCH32 = 26; + + public const uint R_SH_USES = 27; + + public const uint R_SH_COUNT = 28; + + public const uint R_SH_ALIGN = 29; + + public const uint R_SH_CODE = 30; + + public const uint R_SH_DATA = 31; + + public const uint R_SH_LABEL = 32; + + public const uint R_SH_SWITCH8 = 33; + + public const uint R_SH_GNU_VTINHERIT = 34; + + public const uint R_SH_GNU_VTENTRY = 35; + + public const uint R_SH_TLS_GD_32 = 144; + + public const uint R_SH_TLS_LD_32 = 145; + + public const uint R_SH_TLS_LDO_32 = 146; + + public const uint R_SH_TLS_IE_32 = 147; + + public const uint R_SH_TLS_LE_32 = 148; + + public const uint R_SH_TLS_DTPMOD32 = 149; + + public const uint R_SH_TLS_DTPOFF32 = 150; + + public const uint R_SH_TLS_TPOFF32 = 151; + + public const uint R_SH_GOT32 = 160; + + public const uint R_SH_PLT32 = 161; + + public const uint R_SH_COPY = 162; + + public const uint R_SH_GLOB_DAT = 163; + + public const uint R_SH_JMP_SLOT = 164; + + public const uint R_SH_RELATIVE = 165; + + public const uint R_SH_GOTOFF = 166; + + public const uint R_SH_GOTPC = 167; + + public const uint R_SH_NUM = 256; + + /// + /// High GPRs kernel facility needed. + /// + public const uint EF_S390_HIGH_GPRS = 1; + + /// + /// No reloc. + /// + public const uint R_390_NONE = 0; + + /// + /// Direct 8 bit. + /// + public const uint R_390_8 = 1; + + /// + /// Direct 12 bit. + /// + public const uint R_390_12 = 2; + + /// + /// Direct 16 bit. + /// + public const uint R_390_16 = 3; + + /// + /// Direct 32 bit. + /// + public const uint R_390_32 = 4; + + /// + /// PC relative 32 bit. + /// + public const uint R_390_PC32 = 5; + + /// + /// 12 bit GOT offset. + /// + public const uint R_390_GOT12 = 6; + + /// + /// 32 bit GOT offset. + /// + public const uint R_390_GOT32 = 7; + + /// + /// 32 bit PC relative PLT address. + /// + public const uint R_390_PLT32 = 8; + + /// + /// Copy symbol at runtime. + /// + public const uint R_390_COPY = 9; + + /// + /// Create GOT entry. + /// + public const uint R_390_GLOB_DAT = 10; + + /// + /// Create PLT entry. + /// + public const uint R_390_JMP_SLOT = 11; + + /// + /// Adjust by program base. + /// + public const uint R_390_RELATIVE = 12; + + /// + /// 32 bit offset to GOT. + /// + public const uint R_390_GOTOFF32 = 13; + + /// + /// 32 bit PC relative offset to GOT. + /// + public const uint R_390_GOTPC = 14; + + /// + /// 16 bit GOT offset. + /// + public const uint R_390_GOT16 = 15; + + /// + /// PC relative 16 bit. + /// + public const uint R_390_PC16 = 16; + + /// + /// PC relative 16 bit shifted by 1. + /// + public const uint R_390_PC16DBL = 17; + + /// + /// 16 bit PC rel. PLT shifted by 1. + /// + public const uint R_390_PLT16DBL = 18; + + /// + /// PC relative 32 bit shifted by 1. + /// + public const uint R_390_PC32DBL = 19; + + /// + /// 32 bit PC rel. PLT shifted by 1. + /// + public const uint R_390_PLT32DBL = 20; + + /// + /// 32 bit PC rel. GOT shifted by 1. + /// + public const uint R_390_GOTPCDBL = 21; + + /// + /// Direct 64 bit. + /// + public const uint R_390_64 = 22; + + /// + /// PC relative 64 bit. + /// + public const uint R_390_PC64 = 23; + + /// + /// 64 bit GOT offset. + /// + public const uint R_390_GOT64 = 24; + + /// + /// 64 bit PC relative PLT address. + /// + public const uint R_390_PLT64 = 25; + + /// + /// 32 bit PC rel. to GOT entry >> 1. + /// + public const uint R_390_GOTENT = 26; + + /// + /// 16 bit offset to GOT. + /// + public const uint R_390_GOTOFF16 = 27; + + /// + /// 64 bit offset to GOT. + /// + public const uint R_390_GOTOFF64 = 28; + + /// + /// 12 bit offset to jump slot. + /// + public const uint R_390_GOTPLT12 = 29; + + /// + /// 16 bit offset to jump slot. + /// + public const uint R_390_GOTPLT16 = 30; + + /// + /// 32 bit offset to jump slot. + /// + public const uint R_390_GOTPLT32 = 31; + + /// + /// 64 bit offset to jump slot. + /// + public const uint R_390_GOTPLT64 = 32; + + /// + /// 32 bit rel. offset to jump slot. + /// + public const uint R_390_GOTPLTENT = 33; + + /// + /// 16 bit offset from GOT to PLT. + /// + public const uint R_390_PLTOFF16 = 34; + + /// + /// 32 bit offset from GOT to PLT. + /// + public const uint R_390_PLTOFF32 = 35; + + /// + /// 16 bit offset from GOT to PLT. + /// + public const uint R_390_PLTOFF64 = 36; + + /// + /// Tag for load insn in TLS code. + /// + public const uint R_390_TLS_LOAD = 37; + + /// + /// Tag for function call in general dynamic TLS code. + /// + public const uint R_390_TLS_GDCALL = 38; + + /// + /// Tag for function call in local dynamic TLS code. + /// + public const uint R_390_TLS_LDCALL = 39; + + /// + /// Direct 32 bit for general dynamic thread local data. + /// + public const uint R_390_TLS_GD32 = 40; + + /// + /// Direct 64 bit for general dynamic thread local data. + /// + public const uint R_390_TLS_GD64 = 41; + + /// + /// 12 bit GOT offset for static TLS block offset. + /// + public const uint R_390_TLS_GOTIE12 = 42; + + /// + /// 32 bit GOT offset for static TLS block offset. + /// + public const uint R_390_TLS_GOTIE32 = 43; + + /// + /// 64 bit GOT offset for static TLS block offset. + /// + public const uint R_390_TLS_GOTIE64 = 44; + + /// + /// Direct 32 bit for local dynamic thread local data in LE code. + /// + public const uint R_390_TLS_LDM32 = 45; + + /// + /// Direct 64 bit for local dynamic thread local data in LE code. + /// + public const uint R_390_TLS_LDM64 = 46; + + /// + /// 32 bit address of GOT entry for negated static TLS block offset. + /// + public const uint R_390_TLS_IE32 = 47; + + /// + /// 64 bit address of GOT entry for negated static TLS block offset. + /// + public const uint R_390_TLS_IE64 = 48; + + /// + /// 32 bit rel. offset to GOT entry for negated static TLS block offset. + /// + public const uint R_390_TLS_IEENT = 49; + + /// + /// 32 bit negated offset relative to static TLS block. + /// + public const uint R_390_TLS_LE32 = 50; + + /// + /// 64 bit negated offset relative to static TLS block. + /// + public const uint R_390_TLS_LE64 = 51; + + /// + /// 32 bit offset relative to TLS block. + /// + public const uint R_390_TLS_LDO32 = 52; + + /// + /// 64 bit offset relative to TLS block. + /// + public const uint R_390_TLS_LDO64 = 53; + + /// + /// ID of module containing symbol. + /// + public const uint R_390_TLS_DTPMOD = 54; + + /// + /// Offset in TLS block. + /// + public const uint R_390_TLS_DTPOFF = 55; + + /// + /// Negated offset in static TLS block. + /// + public const uint R_390_TLS_TPOFF = 56; + + /// + /// Direct 20 bit. + /// + public const uint R_390_20 = 57; + + /// + /// 20 bit GOT offset. + /// + public const uint R_390_GOT20 = 58; + + /// + /// 20 bit offset to jump slot. + /// + public const uint R_390_GOTPLT20 = 59; + + /// + /// 20 bit GOT offset for static TLS block offset. + /// + public const uint R_390_TLS_GOTIE20 = 60; + + /// + /// STT_GNU_IFUNC relocation. + /// + public const uint R_390_IRELATIVE = 61; + + public const uint R_390_NUM = 62; + + public const uint R_CRIS_NONE = 0; + + public const uint R_CRIS_8 = 1; + + public const uint R_CRIS_16 = 2; + + public const uint R_CRIS_32 = 3; + + public const uint R_CRIS_8_PCREL = 4; + + public const uint R_CRIS_16_PCREL = 5; + + public const uint R_CRIS_32_PCREL = 6; + + public const uint R_CRIS_GNU_VTINHERIT = 7; + + public const uint R_CRIS_GNU_VTENTRY = 8; + + public const uint R_CRIS_COPY = 9; + + public const uint R_CRIS_GLOB_DAT = 10; + + public const uint R_CRIS_JUMP_SLOT = 11; + + public const uint R_CRIS_RELATIVE = 12; + + public const uint R_CRIS_16_GOT = 13; + + public const uint R_CRIS_32_GOT = 14; + + public const uint R_CRIS_16_GOTPLT = 15; + + public const uint R_CRIS_32_GOTPLT = 16; + + public const uint R_CRIS_32_GOTREL = 17; + + public const uint R_CRIS_32_PLT_GOTREL = 18; + + public const uint R_CRIS_32_PLT_PCREL = 19; + + public const uint R_CRIS_NUM = 20; + + /// + /// No reloc + /// + public const uint R_X86_64_NONE = 0; + + /// + /// Direct 64 bit + /// + public const uint R_X86_64_64 = 1; + + /// + /// PC relative 32 bit signed + /// + public const uint R_X86_64_PC32 = 2; + + /// + /// 32 bit GOT entry + /// + public const uint R_X86_64_GOT32 = 3; + + /// + /// 32 bit PLT address + /// + public const uint R_X86_64_PLT32 = 4; + + /// + /// Copy symbol at runtime + /// + public const uint R_X86_64_COPY = 5; + + /// + /// Create GOT entry + /// + public const uint R_X86_64_GLOB_DAT = 6; + + /// + /// Create PLT entry + /// + public const uint R_X86_64_JUMP_SLOT = 7; + + /// + /// Adjust by program base + /// + public const uint R_X86_64_RELATIVE = 8; + + /// + /// 32 bit signed PC relative offset to GOT + /// + public const uint R_X86_64_GOTPCREL = 9; + + /// + /// Direct 32 bit zero extended + /// + public const uint R_X86_64_32 = 10; + + /// + /// Direct 32 bit sign extended + /// + public const uint R_X86_64_32S = 11; + + /// + /// Direct 16 bit zero extended + /// + public const uint R_X86_64_16 = 12; + + /// + /// 16 bit sign extended pc relative + /// + public const uint R_X86_64_PC16 = 13; + + /// + /// Direct 8 bit sign extended + /// + public const uint R_X86_64_8 = 14; + + /// + /// 8 bit sign extended pc relative + /// + public const uint R_X86_64_PC8 = 15; + + /// + /// ID of module containing symbol + /// + public const uint R_X86_64_DTPMOD64 = 16; + + /// + /// Offset in module's TLS block + /// + public const uint R_X86_64_DTPOFF64 = 17; + + /// + /// Offset in initial TLS block + /// + public const uint R_X86_64_TPOFF64 = 18; + + /// + /// 32 bit signed PC relative offset to two GOT entries for GD symbol + /// + public const uint R_X86_64_TLSGD = 19; + + /// + /// 32 bit signed PC relative offset to two GOT entries for LD symbol + /// + public const uint R_X86_64_TLSLD = 20; + + /// + /// Offset in TLS block + /// + public const uint R_X86_64_DTPOFF32 = 21; + + /// + /// 32 bit signed PC relative offset to GOT entry for IE symbol + /// + public const uint R_X86_64_GOTTPOFF = 22; + + /// + /// Offset in initial TLS block + /// + public const uint R_X86_64_TPOFF32 = 23; + + /// + /// PC relative 64 bit + /// + public const uint R_X86_64_PC64 = 24; + + /// + /// 64 bit offset to GOT + /// + public const uint R_X86_64_GOTOFF64 = 25; + + /// + /// 32 bit signed pc relative offset to GOT + /// + public const uint R_X86_64_GOTPC32 = 26; + + /// + /// 64-bit GOT entry offset + /// + public const uint R_X86_64_GOT64 = 27; + + /// + /// 64-bit PC relative offset to GOT entry + /// + public const uint R_X86_64_GOTPCREL64 = 28; + + /// + /// 64-bit PC relative offset to GOT + /// + public const uint R_X86_64_GOTPC64 = 29; + + /// + /// like GOT64, says PLT entry needed + /// + public const uint R_X86_64_GOTPLT64 = 30; + + /// + /// 64-bit GOT relative offset to PLT entry + /// + public const uint R_X86_64_PLTOFF64 = 31; + + /// + /// Size of symbol plus 32-bit addend + /// + public const uint R_X86_64_SIZE32 = 32; + + /// + /// Size of symbol plus 64-bit addend + /// + public const uint R_X86_64_SIZE64 = 33; + + /// + /// GOT offset for TLS descriptor. + /// + public const uint R_X86_64_GOTPC32_TLSDESC = 34; + + /// + /// Marker for call through TLS descriptor. + /// + public const uint R_X86_64_TLSDESC_CALL = 35; + + /// + /// TLS descriptor. + /// + public const uint R_X86_64_TLSDESC = 36; + + /// + /// Adjust indirectly by program base + /// + public const uint R_X86_64_IRELATIVE = 37; + + /// + /// 64-bit adjust by program base + /// + public const uint R_X86_64_RELATIVE64 = 38; + + public const uint R_X86_64_NUM = 39; + + /// + /// No reloc. + /// + public const uint R_MN10300_NONE = 0; + + /// + /// Direct 32 bit. + /// + public const uint R_MN10300_32 = 1; + + /// + /// Direct 16 bit. + /// + public const uint R_MN10300_16 = 2; + + /// + /// Direct 8 bit. + /// + public const uint R_MN10300_8 = 3; + + /// + /// PC-relative 32-bit. + /// + public const uint R_MN10300_PCREL32 = 4; + + /// + /// PC-relative 16-bit signed. + /// + public const uint R_MN10300_PCREL16 = 5; + + /// + /// PC-relative 8-bit signed. + /// + public const uint R_MN10300_PCREL8 = 6; + + /// + /// Ancient C++ vtable garbage... + /// + public const uint R_MN10300_GNU_VTINHERIT = 7; + + /// + /// ... collection annotation. + /// + public const uint R_MN10300_GNU_VTENTRY = 8; + + /// + /// Direct 24 bit. + /// + public const uint R_MN10300_24 = 9; + + /// + /// 32-bit PCrel offset to GOT. + /// + public const uint R_MN10300_GOTPC32 = 10; + + /// + /// 16-bit PCrel offset to GOT. + /// + public const uint R_MN10300_GOTPC16 = 11; + + /// + /// 32-bit offset from GOT. + /// + public const uint R_MN10300_GOTOFF32 = 12; + + /// + /// 24-bit offset from GOT. + /// + public const uint R_MN10300_GOTOFF24 = 13; + + /// + /// 16-bit offset from GOT. + /// + public const uint R_MN10300_GOTOFF16 = 14; + + /// + /// 32-bit PCrel to PLT entry. + /// + public const uint R_MN10300_PLT32 = 15; + + /// + /// 16-bit PCrel to PLT entry. + /// + public const uint R_MN10300_PLT16 = 16; + + /// + /// 32-bit offset to GOT entry. + /// + public const uint R_MN10300_GOT32 = 17; + + /// + /// 24-bit offset to GOT entry. + /// + public const uint R_MN10300_GOT24 = 18; + + /// + /// 16-bit offset to GOT entry. + /// + public const uint R_MN10300_GOT16 = 19; + + /// + /// Copy symbol at runtime. + /// + public const uint R_MN10300_COPY = 20; + + /// + /// Create GOT entry. + /// + public const uint R_MN10300_GLOB_DAT = 21; + + /// + /// Create PLT entry. + /// + public const uint R_MN10300_JMP_SLOT = 22; + + /// + /// Adjust by program base. + /// + public const uint R_MN10300_RELATIVE = 23; + + /// + /// 32-bit offset for global dynamic. + /// + public const uint R_MN10300_TLS_GD = 24; + + /// + /// 32-bit offset for local dynamic. + /// + public const uint R_MN10300_TLS_LD = 25; + + /// + /// Module-relative offset. + /// + public const uint R_MN10300_TLS_LDO = 26; + + /// + /// GOT offset for static TLS block offset. + /// + public const uint R_MN10300_TLS_GOTIE = 27; + + /// + /// GOT address for static TLS block offset. + /// + public const uint R_MN10300_TLS_IE = 28; + + /// + /// Offset relative to static TLS block. + /// + public const uint R_MN10300_TLS_LE = 29; + + /// + /// ID of module containing symbol. + /// + public const uint R_MN10300_TLS_DTPMOD = 30; + + /// + /// Offset in module TLS block. + /// + public const uint R_MN10300_TLS_DTPOFF = 31; + + /// + /// Offset in static TLS block. + /// + public const uint R_MN10300_TLS_TPOFF = 32; + + /// + /// Adjustment for next reloc as needed by linker relaxation. + /// + public const uint R_MN10300_SYM_DIFF = 33; + + /// + /// Alignment requirement for linker relaxation. + /// + public const uint R_MN10300_ALIGN = 34; + + public const uint R_MN10300_NUM = 35; + + /// + /// No reloc. + /// + public const uint R_M32R_NONE = 0; + + /// + /// Direct 16 bit. + /// + public const uint R_M32R_16 = 1; + + /// + /// Direct 32 bit. + /// + public const uint R_M32R_32 = 2; + + /// + /// Direct 24 bit. + /// + public const uint R_M32R_24 = 3; + + /// + /// PC relative 10 bit shifted. + /// + public const uint R_M32R_10_PCREL = 4; + + /// + /// PC relative 18 bit shifted. + /// + public const uint R_M32R_18_PCREL = 5; + + /// + /// PC relative 26 bit shifted. + /// + public const uint R_M32R_26_PCREL = 6; + + /// + /// High 16 bit with unsigned low. + /// + public const uint R_M32R_HI16_ULO = 7; + + /// + /// High 16 bit with signed low. + /// + public const uint R_M32R_HI16_SLO = 8; + + /// + /// Low 16 bit. + /// + public const uint R_M32R_LO16 = 9; + + /// + /// 16 bit offset in SDA. + /// + public const uint R_M32R_SDA16 = 10; + + public const uint R_M32R_GNU_VTINHERIT = 11; + + public const uint R_M32R_GNU_VTENTRY = 12; + + /// + /// Direct 16 bit. + /// + public const uint R_M32R_16_RELA = 33; + + /// + /// Direct 32 bit. + /// + public const uint R_M32R_32_RELA = 34; + + /// + /// Direct 24 bit. + /// + public const uint R_M32R_24_RELA = 35; + + /// + /// PC relative 10 bit shifted. + /// + public const uint R_M32R_10_PCREL_RELA = 36; + + /// + /// PC relative 18 bit shifted. + /// + public const uint R_M32R_18_PCREL_RELA = 37; + + /// + /// PC relative 26 bit shifted. + /// + public const uint R_M32R_26_PCREL_RELA = 38; + + /// + /// High 16 bit with unsigned low + /// + public const uint R_M32R_HI16_ULO_RELA = 39; + + /// + /// High 16 bit with signed low + /// + public const uint R_M32R_HI16_SLO_RELA = 40; + + /// + /// Low 16 bit + /// + public const uint R_M32R_LO16_RELA = 41; + + /// + /// 16 bit offset in SDA + /// + public const uint R_M32R_SDA16_RELA = 42; + + public const uint R_M32R_RELA_GNU_VTINHERIT = 43; + + public const uint R_M32R_RELA_GNU_VTENTRY = 44; + + /// + /// PC relative 32 bit. + /// + public const uint R_M32R_REL32 = 45; + + /// + /// 24 bit GOT entry + /// + public const uint R_M32R_GOT24 = 48; + + /// + /// 26 bit PC relative to PLT shifted + /// + public const uint R_M32R_26_PLTREL = 49; + + /// + /// Copy symbol at runtime + /// + public const uint R_M32R_COPY = 50; + + /// + /// Create GOT entry + /// + public const uint R_M32R_GLOB_DAT = 51; + + /// + /// Create PLT entry + /// + public const uint R_M32R_JMP_SLOT = 52; + + /// + /// Adjust by program base + /// + public const uint R_M32R_RELATIVE = 53; + + /// + /// 24 bit offset to GOT + /// + public const uint R_M32R_GOTOFF = 54; + + /// + /// 24 bit PC relative offset to GOT + /// + public const uint R_M32R_GOTPC24 = 55; + + /// + /// High 16 bit GOT entry with unsigned low + /// + public const uint R_M32R_GOT16_HI_ULO = 56; + + /// + /// High 16 bit GOT entry with signed low + /// + public const uint R_M32R_GOT16_HI_SLO = 57; + + /// + /// Low 16 bit GOT entry + /// + public const uint R_M32R_GOT16_LO = 58; + + /// + /// High 16 bit PC relative offset to GOT with unsigned low + /// + public const uint R_M32R_GOTPC_HI_ULO = 59; + + /// + /// High 16 bit PC relative offset to GOT with signed low + /// + public const uint R_M32R_GOTPC_HI_SLO = 60; + + /// + /// Low 16 bit PC relative offset to GOT + /// + public const uint R_M32R_GOTPC_LO = 61; + + /// + /// High 16 bit offset to GOT with unsigned low + /// + public const uint R_M32R_GOTOFF_HI_ULO = 62; + + /// + /// High 16 bit offset to GOT with signed low + /// + public const uint R_M32R_GOTOFF_HI_SLO = 63; + + /// + /// Low 16 bit offset to GOT + /// + public const uint R_M32R_GOTOFF_LO = 64; + + /// + /// Keep this the last entry. + /// + public const uint R_M32R_NUM = 256; + + /// + /// No reloc. + /// + public const uint R_MICROBLAZE_NONE = 0; + + /// + /// Direct 32 bit. + /// + public const uint R_MICROBLAZE_32 = 1; + + /// + /// PC relative 32 bit. + /// + public const uint R_MICROBLAZE_32_PCREL = 2; + + /// + /// PC relative 64 bit. + /// + public const uint R_MICROBLAZE_64_PCREL = 3; + + /// + /// Low 16 bits of PCREL32. + /// + public const uint R_MICROBLAZE_32_PCREL_LO = 4; + + /// + /// Direct 64 bit. + /// + public const uint R_MICROBLAZE_64 = 5; + + /// + /// Low 16 bit. + /// + public const uint R_MICROBLAZE_32_LO = 6; + + /// + /// Read-only small data area. + /// + public const uint R_MICROBLAZE_SRO32 = 7; + + /// + /// Read-write small data area. + /// + public const uint R_MICROBLAZE_SRW32 = 8; + + /// + /// No reloc. + /// + public const uint R_MICROBLAZE_64_NONE = 9; + + /// + /// Symbol Op Symbol relocation. + /// + public const uint R_MICROBLAZE_32_SYM_OP_SYM = 10; + + /// + /// GNU C++ vtable hierarchy. + /// + public const uint R_MICROBLAZE_GNU_VTINHERIT = 11; + + /// + /// GNU C++ vtable member usage. + /// + public const uint R_MICROBLAZE_GNU_VTENTRY = 12; + + /// + /// PC-relative GOT offset. + /// + public const uint R_MICROBLAZE_GOTPC_64 = 13; + + /// + /// GOT entry offset. + /// + public const uint R_MICROBLAZE_GOT_64 = 14; + + /// + /// PLT offset (PC-relative). + /// + public const uint R_MICROBLAZE_PLT_64 = 15; + + /// + /// Adjust by program base. + /// + public const uint R_MICROBLAZE_REL = 16; + + /// + /// Create PLT entry. + /// + public const uint R_MICROBLAZE_JUMP_SLOT = 17; + + /// + /// Create GOT entry. + /// + public const uint R_MICROBLAZE_GLOB_DAT = 18; + + /// + /// 64 bit offset to GOT. + /// + public const uint R_MICROBLAZE_GOTOFF_64 = 19; + + /// + /// 32 bit offset to GOT. + /// + public const uint R_MICROBLAZE_GOTOFF_32 = 20; + + /// + /// Runtime copy. + /// + public const uint R_MICROBLAZE_COPY = 21; + + /// + /// TLS Reloc. + /// + public const uint R_MICROBLAZE_TLS = 22; + + /// + /// TLS General Dynamic. + /// + public const uint R_MICROBLAZE_TLSGD = 23; + + /// + /// TLS Local Dynamic. + /// + public const uint R_MICROBLAZE_TLSLD = 24; + + /// + /// TLS Module ID. + /// + public const uint R_MICROBLAZE_TLSDTPMOD32 = 25; + + /// + /// TLS Offset Within TLS Block. + /// + public const uint R_MICROBLAZE_TLSDTPREL32 = 26; + + /// + /// TLS Offset Within TLS Block. + /// + public const uint R_MICROBLAZE_TLSDTPREL64 = 27; + + /// + /// TLS Offset From Thread Pointer. + /// + public const uint R_MICROBLAZE_TLSGOTTPREL32 = 28; + + /// + /// TLS Offset From Thread Pointer. + /// + public const uint R_MICROBLAZE_TLSTPREL32 = 29; + + /// + /// Address of _gp. + /// + public const int DT_NIOS2_GP = 0x70000002; + + /// + /// No reloc. + /// + public const uint R_NIOS2_NONE = 0; + + /// + /// Direct signed 16 bit. + /// + public const uint R_NIOS2_S16 = 1; + + /// + /// Direct unsigned 16 bit. + /// + public const uint R_NIOS2_U16 = 2; + + /// + /// PC relative 16 bit. + /// + public const uint R_NIOS2_PCREL16 = 3; + + /// + /// Direct call. + /// + public const uint R_NIOS2_CALL26 = 4; + + /// + /// 5 bit constant expression. + /// + public const uint R_NIOS2_IMM5 = 5; + + /// + /// 5 bit expression, shift 22. + /// + public const uint R_NIOS2_CACHE_OPX = 6; + + /// + /// 6 bit constant expression. + /// + public const uint R_NIOS2_IMM6 = 7; + + /// + /// 8 bit constant expression. + /// + public const uint R_NIOS2_IMM8 = 8; + + /// + /// High 16 bit. + /// + public const uint R_NIOS2_HI16 = 9; + + /// + /// Low 16 bit. + /// + public const uint R_NIOS2_LO16 = 10; + + /// + /// High 16 bit, adjusted. + /// + public const uint R_NIOS2_HIADJ16 = 11; + + /// + /// 32 bit symbol value + addend. + /// + public const uint R_NIOS2_BFD_RELOC_32 = 12; + + /// + /// 16 bit symbol value + addend. + /// + public const uint R_NIOS2_BFD_RELOC_16 = 13; + + /// + /// 8 bit symbol value + addend. + /// + public const uint R_NIOS2_BFD_RELOC_8 = 14; + + /// + /// 16 bit GP pointer offset. + /// + public const uint R_NIOS2_GPREL = 15; + + /// + /// GNU C++ vtable hierarchy. + /// + public const uint R_NIOS2_GNU_VTINHERIT = 16; + + /// + /// GNU C++ vtable member usage. + /// + public const uint R_NIOS2_GNU_VTENTRY = 17; + + /// + /// Unconditional branch. + /// + public const uint R_NIOS2_UJMP = 18; + + /// + /// Conditional branch. + /// + public const uint R_NIOS2_CJMP = 19; + + /// + /// Indirect call through register. + /// + public const uint R_NIOS2_CALLR = 20; + + /// + /// Alignment requirement for linker relaxation. + /// + public const uint R_NIOS2_ALIGN = 21; + + /// + /// 16 bit GOT entry. + /// + public const uint R_NIOS2_GOT16 = 22; + + /// + /// 16 bit GOT entry for function. + /// + public const uint R_NIOS2_CALL16 = 23; + + /// + /// %lo of offset to GOT pointer. + /// + public const uint R_NIOS2_GOTOFF_LO = 24; + + /// + /// %hiadj of offset to GOT pointer. + /// + public const uint R_NIOS2_GOTOFF_HA = 25; + + /// + /// %lo of PC relative offset. + /// + public const uint R_NIOS2_PCREL_LO = 26; + + /// + /// %hiadj of PC relative offset. + /// + public const uint R_NIOS2_PCREL_HA = 27; + + /// + /// 16 bit GOT offset for TLS GD. + /// + public const uint R_NIOS2_TLS_GD16 = 28; + + /// + /// 16 bit GOT offset for TLS LDM. + /// + public const uint R_NIOS2_TLS_LDM16 = 29; + + /// + /// 16 bit module relative offset. + /// + public const uint R_NIOS2_TLS_LDO16 = 30; + + /// + /// 16 bit GOT offset for TLS IE. + /// + public const uint R_NIOS2_TLS_IE16 = 31; + + /// + /// 16 bit LE TP-relative offset. + /// + public const uint R_NIOS2_TLS_LE16 = 32; + + /// + /// Module number. + /// + public const uint R_NIOS2_TLS_DTPMOD = 33; + + /// + /// Module-relative offset. + /// + public const uint R_NIOS2_TLS_DTPREL = 34; + + /// + /// TP-relative offset. + /// + public const uint R_NIOS2_TLS_TPREL = 35; + + /// + /// Copy symbol at runtime. + /// + public const uint R_NIOS2_COPY = 36; + + /// + /// Create GOT entry. + /// + public const uint R_NIOS2_GLOB_DAT = 37; + + /// + /// Create PLT entry. + /// + public const uint R_NIOS2_JUMP_SLOT = 38; + + /// + /// Adjust by program base. + /// + public const uint R_NIOS2_RELATIVE = 39; + + /// + /// 16 bit offset to GOT pointer. + /// + public const uint R_NIOS2_GOTOFF = 40; + + /// + /// Direct call in .noat section. + /// + public const uint R_NIOS2_CALL26_NOAT = 41; + + /// + /// %lo() of GOT entry. + /// + public const uint R_NIOS2_GOT_LO = 42; + + /// + /// %hiadj() of GOT entry. + /// + public const uint R_NIOS2_GOT_HA = 43; + + /// + /// %lo() of function GOT entry. + /// + public const uint R_NIOS2_CALL_LO = 44; + + /// + /// %hiadj() of function GOT entry. + /// + public const uint R_NIOS2_CALL_HA = 45; + + /// + /// No reloc + /// + public const uint R_TILEPRO_NONE = 0; + + /// + /// Direct 32 bit + /// + public const uint R_TILEPRO_32 = 1; + + /// + /// Direct 16 bit + /// + public const uint R_TILEPRO_16 = 2; + + /// + /// Direct 8 bit + /// + public const uint R_TILEPRO_8 = 3; + + /// + /// PC relative 32 bit + /// + public const uint R_TILEPRO_32_PCREL = 4; + + /// + /// PC relative 16 bit + /// + public const uint R_TILEPRO_16_PCREL = 5; + + /// + /// PC relative 8 bit + /// + public const uint R_TILEPRO_8_PCREL = 6; + + /// + /// Low 16 bit + /// + public const uint R_TILEPRO_LO16 = 7; + + /// + /// High 16 bit + /// + public const uint R_TILEPRO_HI16 = 8; + + /// + /// High 16 bit, adjusted + /// + public const uint R_TILEPRO_HA16 = 9; + + /// + /// Copy relocation + /// + public const uint R_TILEPRO_COPY = 10; + + /// + /// Create GOT entry + /// + public const uint R_TILEPRO_GLOB_DAT = 11; + + /// + /// Create PLT entry + /// + public const uint R_TILEPRO_JMP_SLOT = 12; + + /// + /// Adjust by program base + /// + public const uint R_TILEPRO_RELATIVE = 13; + + /// + /// X1 pipe branch offset + /// + public const uint R_TILEPRO_BROFF_X1 = 14; + + /// + /// X1 pipe jump offset + /// + public const uint R_TILEPRO_JOFFLONG_X1 = 15; + + /// + /// X1 pipe jump offset to PLT + /// + public const uint R_TILEPRO_JOFFLONG_X1_PLT = 16; + + /// + /// X0 pipe 8-bit + /// + public const uint R_TILEPRO_IMM8_X0 = 17; + + /// + /// Y0 pipe 8-bit + /// + public const uint R_TILEPRO_IMM8_Y0 = 18; + + /// + /// X1 pipe 8-bit + /// + public const uint R_TILEPRO_IMM8_X1 = 19; + + /// + /// Y1 pipe 8-bit + /// + public const uint R_TILEPRO_IMM8_Y1 = 20; + + /// + /// X1 pipe mtspr + /// + public const uint R_TILEPRO_MT_IMM15_X1 = 21; + + /// + /// X1 pipe mfspr + /// + public const uint R_TILEPRO_MF_IMM15_X1 = 22; + + /// + /// X0 pipe 16-bit + /// + public const uint R_TILEPRO_IMM16_X0 = 23; + + /// + /// X1 pipe 16-bit + /// + public const uint R_TILEPRO_IMM16_X1 = 24; + + /// + /// X0 pipe low 16-bit + /// + public const uint R_TILEPRO_IMM16_X0_LO = 25; + + /// + /// X1 pipe low 16-bit + /// + public const uint R_TILEPRO_IMM16_X1_LO = 26; + + /// + /// X0 pipe high 16-bit + /// + public const uint R_TILEPRO_IMM16_X0_HI = 27; + + /// + /// X1 pipe high 16-bit + /// + public const uint R_TILEPRO_IMM16_X1_HI = 28; + + /// + /// X0 pipe high 16-bit, adjusted + /// + public const uint R_TILEPRO_IMM16_X0_HA = 29; + + /// + /// X1 pipe high 16-bit, adjusted + /// + public const uint R_TILEPRO_IMM16_X1_HA = 30; + + /// + /// X0 pipe PC relative 16 bit + /// + public const uint R_TILEPRO_IMM16_X0_PCREL = 31; + + /// + /// X1 pipe PC relative 16 bit + /// + public const uint R_TILEPRO_IMM16_X1_PCREL = 32; + + /// + /// X0 pipe PC relative low 16 bit + /// + public const uint R_TILEPRO_IMM16_X0_LO_PCREL = 33; + + /// + /// X1 pipe PC relative low 16 bit + /// + public const uint R_TILEPRO_IMM16_X1_LO_PCREL = 34; + + /// + /// X0 pipe PC relative high 16 bit + /// + public const uint R_TILEPRO_IMM16_X0_HI_PCREL = 35; + + /// + /// X1 pipe PC relative high 16 bit + /// + public const uint R_TILEPRO_IMM16_X1_HI_PCREL = 36; + + /// + /// X0 pipe PC relative ha() 16 bit + /// + public const uint R_TILEPRO_IMM16_X0_HA_PCREL = 37; + + /// + /// X1 pipe PC relative ha() 16 bit + /// + public const uint R_TILEPRO_IMM16_X1_HA_PCREL = 38; + + /// + /// X0 pipe 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X0_GOT = 39; + + /// + /// X1 pipe 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X1_GOT = 40; + + /// + /// X0 pipe low 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X0_GOT_LO = 41; + + /// + /// X1 pipe low 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X1_GOT_LO = 42; + + /// + /// X0 pipe high 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X0_GOT_HI = 43; + + /// + /// X1 pipe high 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X1_GOT_HI = 44; + + /// + /// X0 pipe ha() 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X0_GOT_HA = 45; + + /// + /// X1 pipe ha() 16-bit GOT offset + /// + public const uint R_TILEPRO_IMM16_X1_GOT_HA = 46; + + /// + /// X0 pipe mm "start" + /// + public const uint R_TILEPRO_MMSTART_X0 = 47; + + /// + /// X0 pipe mm "end" + /// + public const uint R_TILEPRO_MMEND_X0 = 48; + + /// + /// X1 pipe mm "start" + /// + public const uint R_TILEPRO_MMSTART_X1 = 49; + + /// + /// X1 pipe mm "end" + /// + public const uint R_TILEPRO_MMEND_X1 = 50; + + /// + /// X0 pipe shift amount + /// + public const uint R_TILEPRO_SHAMT_X0 = 51; + + /// + /// X1 pipe shift amount + /// + public const uint R_TILEPRO_SHAMT_X1 = 52; + + /// + /// Y0 pipe shift amount + /// + public const uint R_TILEPRO_SHAMT_Y0 = 53; + + /// + /// Y1 pipe shift amount + /// + public const uint R_TILEPRO_SHAMT_Y1 = 54; + + /// + /// X1 pipe destination 8-bit + /// + public const uint R_TILEPRO_DEST_IMM8_X1 = 55; + + /// + /// "jal" for TLS GD + /// + public const uint R_TILEPRO_TLS_GD_CALL = 60; + + /// + /// X0 pipe "addi" for TLS GD + /// + public const uint R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61; + + /// + /// X1 pipe "addi" for TLS GD + /// + public const uint R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62; + + /// + /// Y0 pipe "addi" for TLS GD + /// + public const uint R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63; + + /// + /// Y1 pipe "addi" for TLS GD + /// + public const uint R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64; + + /// + /// "lw_tls" for TLS IE + /// + public const uint R_TILEPRO_TLS_IE_LOAD = 65; + + /// + /// X0 pipe 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_GD = 66; + + /// + /// X1 pipe 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_GD = 67; + + /// + /// X0 pipe low 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_GD_LO = 68; + + /// + /// X1 pipe low 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_GD_LO = 69; + + /// + /// X0 pipe high 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_GD_HI = 70; + + /// + /// X1 pipe high 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_GD_HI = 71; + + /// + /// X0 pipe ha() 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_GD_HA = 72; + + /// + /// X1 pipe ha() 16-bit TLS GD offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_GD_HA = 73; + + /// + /// X0 pipe 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_IE = 74; + + /// + /// X1 pipe 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_IE = 75; + + /// + /// X0 pipe low 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_IE_LO = 76; + + /// + /// X1 pipe low 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_IE_LO = 77; + + /// + /// X0 pipe high 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_IE_HI = 78; + + /// + /// X1 pipe high 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_IE_HI = 79; + + /// + /// X0 pipe ha() 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_IE_HA = 80; + + /// + /// X1 pipe ha() 16-bit TLS IE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_IE_HA = 81; + + /// + /// ID of module containing symbol + /// + public const uint R_TILEPRO_TLS_DTPMOD32 = 82; + + /// + /// Offset in TLS block + /// + public const uint R_TILEPRO_TLS_DTPOFF32 = 83; + + /// + /// Offset in static TLS block + /// + public const uint R_TILEPRO_TLS_TPOFF32 = 84; + + /// + /// X0 pipe 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_LE = 85; + + /// + /// X1 pipe 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_LE = 86; + + /// + /// X0 pipe low 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_LE_LO = 87; + + /// + /// X1 pipe low 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_LE_LO = 88; + + /// + /// X0 pipe high 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_LE_HI = 89; + + /// + /// X1 pipe high 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_LE_HI = 90; + + /// + /// X0 pipe ha() 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X0_TLS_LE_HA = 91; + + /// + /// X1 pipe ha() 16-bit TLS LE offset + /// + public const uint R_TILEPRO_IMM16_X1_TLS_LE_HA = 92; + + /// + /// GNU C++ vtable hierarchy + /// + public const uint R_TILEPRO_GNU_VTINHERIT = 128; + + /// + /// GNU C++ vtable member usage + /// + public const uint R_TILEPRO_GNU_VTENTRY = 129; + + public const uint R_TILEPRO_NUM = 130; + + /// + /// No reloc + /// + public const uint R_TILEGX_NONE = 0; + + /// + /// Direct 64 bit + /// + public const uint R_TILEGX_64 = 1; + + /// + /// Direct 32 bit + /// + public const uint R_TILEGX_32 = 2; + + /// + /// Direct 16 bit + /// + public const uint R_TILEGX_16 = 3; + + /// + /// Direct 8 bit + /// + public const uint R_TILEGX_8 = 4; + + /// + /// PC relative 64 bit + /// + public const uint R_TILEGX_64_PCREL = 5; + + /// + /// PC relative 32 bit + /// + public const uint R_TILEGX_32_PCREL = 6; + + /// + /// PC relative 16 bit + /// + public const uint R_TILEGX_16_PCREL = 7; + + /// + /// PC relative 8 bit + /// + public const uint R_TILEGX_8_PCREL = 8; + + /// + /// hword 0 16-bit + /// + public const uint R_TILEGX_HW0 = 9; + + /// + /// hword 1 16-bit + /// + public const uint R_TILEGX_HW1 = 10; + + /// + /// hword 2 16-bit + /// + public const uint R_TILEGX_HW2 = 11; + + /// + /// hword 3 16-bit + /// + public const uint R_TILEGX_HW3 = 12; + + /// + /// last hword 0 16-bit + /// + public const uint R_TILEGX_HW0_LAST = 13; + + /// + /// last hword 1 16-bit + /// + public const uint R_TILEGX_HW1_LAST = 14; + + /// + /// last hword 2 16-bit + /// + public const uint R_TILEGX_HW2_LAST = 15; + + /// + /// Copy relocation + /// + public const uint R_TILEGX_COPY = 16; + + /// + /// Create GOT entry + /// + public const uint R_TILEGX_GLOB_DAT = 17; + + /// + /// Create PLT entry + /// + public const uint R_TILEGX_JMP_SLOT = 18; + + /// + /// Adjust by program base + /// + public const uint R_TILEGX_RELATIVE = 19; + + /// + /// X1 pipe branch offset + /// + public const uint R_TILEGX_BROFF_X1 = 20; + + /// + /// X1 pipe jump offset + /// + public const uint R_TILEGX_JUMPOFF_X1 = 21; + + /// + /// X1 pipe jump offset to PLT + /// + public const uint R_TILEGX_JUMPOFF_X1_PLT = 22; + + /// + /// X0 pipe 8-bit + /// + public const uint R_TILEGX_IMM8_X0 = 23; + + /// + /// Y0 pipe 8-bit + /// + public const uint R_TILEGX_IMM8_Y0 = 24; + + /// + /// X1 pipe 8-bit + /// + public const uint R_TILEGX_IMM8_X1 = 25; + + /// + /// Y1 pipe 8-bit + /// + public const uint R_TILEGX_IMM8_Y1 = 26; + + /// + /// X1 pipe destination 8-bit + /// + public const uint R_TILEGX_DEST_IMM8_X1 = 27; + + /// + /// X1 pipe mtspr + /// + public const uint R_TILEGX_MT_IMM14_X1 = 28; + + /// + /// X1 pipe mfspr + /// + public const uint R_TILEGX_MF_IMM14_X1 = 29; + + /// + /// X0 pipe mm "start" + /// + public const uint R_TILEGX_MMSTART_X0 = 30; + + /// + /// X0 pipe mm "end" + /// + public const uint R_TILEGX_MMEND_X0 = 31; + + /// + /// X0 pipe shift amount + /// + public const uint R_TILEGX_SHAMT_X0 = 32; + + /// + /// X1 pipe shift amount + /// + public const uint R_TILEGX_SHAMT_X1 = 33; + + /// + /// Y0 pipe shift amount + /// + public const uint R_TILEGX_SHAMT_Y0 = 34; + + /// + /// Y1 pipe shift amount + /// + public const uint R_TILEGX_SHAMT_Y1 = 35; + + /// + /// X0 pipe hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0 = 36; + + /// + /// X1 pipe hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0 = 37; + + /// + /// X0 pipe hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1 = 38; + + /// + /// X1 pipe hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1 = 39; + + /// + /// X0 pipe hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2 = 40; + + /// + /// X1 pipe hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2 = 41; + + /// + /// X0 pipe hword 3 + /// + public const uint R_TILEGX_IMM16_X0_HW3 = 42; + + /// + /// X1 pipe hword 3 + /// + public const uint R_TILEGX_IMM16_X1_HW3 = 43; + + /// + /// X0 pipe last hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST = 44; + + /// + /// X1 pipe last hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST = 45; + + /// + /// X0 pipe last hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST = 46; + + /// + /// X1 pipe last hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST = 47; + + /// + /// X0 pipe last hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2_LAST = 48; + + /// + /// X1 pipe last hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2_LAST = 49; + + /// + /// X0 pipe PC relative hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0_PCREL = 50; + + /// + /// X1 pipe PC relative hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0_PCREL = 51; + + /// + /// X0 pipe PC relative hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1_PCREL = 52; + + /// + /// X1 pipe PC relative hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1_PCREL = 53; + + /// + /// X0 pipe PC relative hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2_PCREL = 54; + + /// + /// X1 pipe PC relative hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2_PCREL = 55; + + /// + /// X0 pipe PC relative hword 3 + /// + public const uint R_TILEGX_IMM16_X0_HW3_PCREL = 56; + + /// + /// X1 pipe PC relative hword 3 + /// + public const uint R_TILEGX_IMM16_X1_HW3_PCREL = 57; + + /// + /// X0 pipe PC-rel last hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58; + + /// + /// X1 pipe PC-rel last hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59; + + /// + /// X0 pipe PC-rel last hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60; + + /// + /// X1 pipe PC-rel last hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61; + + /// + /// X0 pipe PC-rel last hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62; + + /// + /// X1 pipe PC-rel last hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63; + + /// + /// X0 pipe hword 0 GOT offset + /// + public const uint R_TILEGX_IMM16_X0_HW0_GOT = 64; + + /// + /// X1 pipe hword 0 GOT offset + /// + public const uint R_TILEGX_IMM16_X1_HW0_GOT = 65; + + /// + /// X0 pipe PC-rel PLT hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66; + + /// + /// X1 pipe PC-rel PLT hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67; + + /// + /// X0 pipe PC-rel PLT hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68; + + /// + /// X1 pipe PC-rel PLT hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69; + + /// + /// X0 pipe PC-rel PLT hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70; + + /// + /// X1 pipe PC-rel PLT hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71; + + /// + /// X0 pipe last hword 0 GOT offset + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72; + + /// + /// X1 pipe last hword 0 GOT offset + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73; + + /// + /// X0 pipe last hword 1 GOT offset + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74; + + /// + /// X1 pipe last hword 1 GOT offset + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75; + + /// + /// X0 pipe PC-rel PLT hword 3 + /// + public const uint R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76; + + /// + /// X1 pipe PC-rel PLT hword 3 + /// + public const uint R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77; + + /// + /// X0 pipe hword 0 TLS GD offset + /// + public const uint R_TILEGX_IMM16_X0_HW0_TLS_GD = 78; + + /// + /// X1 pipe hword 0 TLS GD offset + /// + public const uint R_TILEGX_IMM16_X1_HW0_TLS_GD = 79; + + /// + /// X0 pipe hword 0 TLS LE offset + /// + public const uint R_TILEGX_IMM16_X0_HW0_TLS_LE = 80; + + /// + /// X1 pipe hword 0 TLS LE offset + /// + public const uint R_TILEGX_IMM16_X1_HW0_TLS_LE = 81; + + /// + /// X0 pipe last hword 0 LE off + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82; + + /// + /// X1 pipe last hword 0 LE off + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83; + + /// + /// X0 pipe last hword 1 LE off + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84; + + /// + /// X1 pipe last hword 1 LE off + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85; + + /// + /// X0 pipe last hword 0 GD off + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86; + + /// + /// X1 pipe last hword 0 GD off + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87; + + /// + /// X0 pipe last hword 1 GD off + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88; + + /// + /// X1 pipe last hword 1 GD off + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89; + + /// + /// X0 pipe hword 0 TLS IE offset + /// + public const uint R_TILEGX_IMM16_X0_HW0_TLS_IE = 92; + + /// + /// X1 pipe hword 0 TLS IE offset + /// + public const uint R_TILEGX_IMM16_X1_HW0_TLS_IE = 93; + + /// + /// X0 pipe PC-rel PLT last hword 0 + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94; + + /// + /// X1 pipe PC-rel PLT last hword 0 + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95; + + /// + /// X0 pipe PC-rel PLT last hword 1 + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96; + + /// + /// X1 pipe PC-rel PLT last hword 1 + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97; + + /// + /// X0 pipe PC-rel PLT last hword 2 + /// + public const uint R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98; + + /// + /// X1 pipe PC-rel PLT last hword 2 + /// + public const uint R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99; + + /// + /// X0 pipe last hword 0 IE off + /// + public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100; + + /// + /// X1 pipe last hword 0 IE off + /// + public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101; + + /// + /// X0 pipe last hword 1 IE off + /// + public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102; + + /// + /// X1 pipe last hword 1 IE off + /// + public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103; + + /// + /// 64-bit ID of symbol's module + /// + public const uint R_TILEGX_TLS_DTPMOD64 = 106; + + /// + /// 64-bit offset in TLS block + /// + public const uint R_TILEGX_TLS_DTPOFF64 = 107; + + /// + /// 64-bit offset in static TLS block + /// + public const uint R_TILEGX_TLS_TPOFF64 = 108; + + /// + /// 32-bit ID of symbol's module + /// + public const uint R_TILEGX_TLS_DTPMOD32 = 109; + + /// + /// 32-bit offset in TLS block + /// + public const uint R_TILEGX_TLS_DTPOFF32 = 110; + + /// + /// 32-bit offset in static TLS block + /// + public const uint R_TILEGX_TLS_TPOFF32 = 111; + + /// + /// "jal" for TLS GD + /// + public const uint R_TILEGX_TLS_GD_CALL = 112; + + /// + /// X0 pipe "addi" for TLS GD + /// + public const uint R_TILEGX_IMM8_X0_TLS_GD_ADD = 113; + + /// + /// X1 pipe "addi" for TLS GD + /// + public const uint R_TILEGX_IMM8_X1_TLS_GD_ADD = 114; + + /// + /// Y0 pipe "addi" for TLS GD + /// + public const uint R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115; + + /// + /// Y1 pipe "addi" for TLS GD + /// + public const uint R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116; + + /// + /// "ld_tls" for TLS IE + /// + public const uint R_TILEGX_TLS_IE_LOAD = 117; + + /// + /// X0 pipe "addi" for TLS GD/IE + /// + public const uint R_TILEGX_IMM8_X0_TLS_ADD = 118; + + /// + /// X1 pipe "addi" for TLS GD/IE + /// + public const uint R_TILEGX_IMM8_X1_TLS_ADD = 119; + + /// + /// Y0 pipe "addi" for TLS GD/IE + /// + public const uint R_TILEGX_IMM8_Y0_TLS_ADD = 120; + + /// + /// Y1 pipe "addi" for TLS GD/IE + /// + public const uint R_TILEGX_IMM8_Y1_TLS_ADD = 121; + + /// + /// GNU C++ vtable hierarchy + /// + public const uint R_TILEGX_GNU_VTINHERIT = 128; + + /// + /// GNU C++ vtable member usage + /// + public const uint R_TILEGX_GNU_VTENTRY = 129; + + public const uint R_TILEGX_NUM = 130; + } + + public readonly partial struct ElfArchEx + { + /// + /// No machine + /// + public static readonly ElfArchEx NONE = new ElfArchEx(ElfNative.EM_NONE); + + /// + /// AT + /// &T + /// WE 32100 + /// + public static readonly ElfArchEx M32 = new ElfArchEx(ElfNative.EM_M32); + + /// + /// SUN SPARC + /// + public static readonly ElfArchEx SPARC = new ElfArchEx(ElfNative.EM_SPARC); + + /// + /// Intel 80386 + /// + public static readonly ElfArchEx I386 = new ElfArchEx(ElfNative.EM_386); + + /// + /// Motorola m68k family + /// + public static readonly ElfArchEx M68K = new ElfArchEx(ElfNative.EM_68K); + + /// + /// Motorola m88k family + /// + public static readonly ElfArchEx M88K = new ElfArchEx(ElfNative.EM_88K); + + /// + /// Intel 80860 + /// + public static readonly ElfArchEx I860 = new ElfArchEx(ElfNative.EM_860); + + /// + /// MIPS R3000 big-endian + /// + public static readonly ElfArchEx MIPS = new ElfArchEx(ElfNative.EM_MIPS); + + /// + /// IBM System/370 + /// + public static readonly ElfArchEx S370 = new ElfArchEx(ElfNative.EM_S370); + + /// + /// MIPS R3000 little-endian + /// + public static readonly ElfArchEx MIPS_RS3_LE = new ElfArchEx(ElfNative.EM_MIPS_RS3_LE); + + /// + /// HPPA + /// + public static readonly ElfArchEx PARISC = new ElfArchEx(ElfNative.EM_PARISC); + + /// + /// Fujitsu VPP500 + /// + public static readonly ElfArchEx VPP500 = new ElfArchEx(ElfNative.EM_VPP500); + + /// + /// Sun's "v8plus" + /// + public static readonly ElfArchEx SPARC32PLUS = new ElfArchEx(ElfNative.EM_SPARC32PLUS); + + /// + /// Intel 80960 + /// + public static readonly ElfArchEx I960 = new ElfArchEx(ElfNative.EM_960); + + /// + /// PowerPC + /// + public static readonly ElfArchEx PPC = new ElfArchEx(ElfNative.EM_PPC); + + /// + /// PowerPC 64-bit + /// + public static readonly ElfArchEx PPC64 = new ElfArchEx(ElfNative.EM_PPC64); + + /// + /// IBM S390 + /// + public static readonly ElfArchEx S390 = new ElfArchEx(ElfNative.EM_S390); + + /// + /// NEC V800 series + /// + public static readonly ElfArchEx V800 = new ElfArchEx(ElfNative.EM_V800); + + /// + /// Fujitsu FR20 + /// + public static readonly ElfArchEx FR20 = new ElfArchEx(ElfNative.EM_FR20); + + /// + /// TRW RH-32 + /// + public static readonly ElfArchEx RH32 = new ElfArchEx(ElfNative.EM_RH32); + + /// + /// Motorola RCE + /// + public static readonly ElfArchEx RCE = new ElfArchEx(ElfNative.EM_RCE); + + /// + /// ARM + /// + public static readonly ElfArchEx ARM = new ElfArchEx(ElfNative.EM_ARM); + + /// + /// Digital Alpha + /// + public static readonly ElfArchEx FAKE_ALPHA = new ElfArchEx(ElfNative.EM_FAKE_ALPHA); + + /// + /// Hitachi SH + /// + public static readonly ElfArchEx SH = new ElfArchEx(ElfNative.EM_SH); + + /// + /// SPARC v9 64-bit + /// + public static readonly ElfArchEx SPARCV9 = new ElfArchEx(ElfNative.EM_SPARCV9); + + /// + /// Siemens Tricore + /// + public static readonly ElfArchEx TRICORE = new ElfArchEx(ElfNative.EM_TRICORE); + + /// + /// Argonaut RISC Core + /// + public static readonly ElfArchEx ARC = new ElfArchEx(ElfNative.EM_ARC); + + /// + /// Hitachi H8/300 + /// + public static readonly ElfArchEx H8_300 = new ElfArchEx(ElfNative.EM_H8_300); + + /// + /// Hitachi H8/300H + /// + public static readonly ElfArchEx H8_300H = new ElfArchEx(ElfNative.EM_H8_300H); + + /// + /// Hitachi H8S + /// + public static readonly ElfArchEx H8S = new ElfArchEx(ElfNative.EM_H8S); + + /// + /// Hitachi H8/500 + /// + public static readonly ElfArchEx H8_500 = new ElfArchEx(ElfNative.EM_H8_500); + + /// + /// Intel Merced + /// + public static readonly ElfArchEx IA_64 = new ElfArchEx(ElfNative.EM_IA_64); + + /// + /// Stanford MIPS-X + /// + public static readonly ElfArchEx MIPS_X = new ElfArchEx(ElfNative.EM_MIPS_X); + + /// + /// Motorola Coldfire + /// + public static readonly ElfArchEx COLDFIRE = new ElfArchEx(ElfNative.EM_COLDFIRE); + + /// + /// Motorola M68HC12 + /// + public static readonly ElfArchEx M68HC12 = new ElfArchEx(ElfNative.EM_68HC12); + + /// + /// Fujitsu MMA Multimedia Accelerator + /// + public static readonly ElfArchEx MMA = new ElfArchEx(ElfNative.EM_MMA); + + /// + /// Siemens PCP + /// + public static readonly ElfArchEx PCP = new ElfArchEx(ElfNative.EM_PCP); + + /// + /// Sony nCPU embeeded RISC + /// + public static readonly ElfArchEx NCPU = new ElfArchEx(ElfNative.EM_NCPU); + + /// + /// Denso NDR1 microprocessor + /// + public static readonly ElfArchEx NDR1 = new ElfArchEx(ElfNative.EM_NDR1); + + /// + /// Motorola Start*Core processor + /// + public static readonly ElfArchEx STARCORE = new ElfArchEx(ElfNative.EM_STARCORE); + + /// + /// Toyota ME16 processor + /// + public static readonly ElfArchEx ME16 = new ElfArchEx(ElfNative.EM_ME16); + + /// + /// STMicroelectronic ST100 processor + /// + public static readonly ElfArchEx ST100 = new ElfArchEx(ElfNative.EM_ST100); + + /// + /// Advanced Logic Corp. Tinyj emb.fam + /// + public static readonly ElfArchEx TINYJ = new ElfArchEx(ElfNative.EM_TINYJ); + + /// + /// AMD x86-64 architecture + /// + public static readonly ElfArchEx X86_64 = new ElfArchEx(ElfNative.EM_X86_64); + + /// + /// Sony DSP Processor + /// + public static readonly ElfArchEx PDSP = new ElfArchEx(ElfNative.EM_PDSP); + + /// + /// Siemens FX66 microcontroller + /// + public static readonly ElfArchEx FX66 = new ElfArchEx(ElfNative.EM_FX66); + + /// + /// STMicroelectronics ST9+ 8/16 mc + /// + public static readonly ElfArchEx ST9PLUS = new ElfArchEx(ElfNative.EM_ST9PLUS); + + /// + /// STmicroelectronics ST7 8 bit mc + /// + public static readonly ElfArchEx ST7 = new ElfArchEx(ElfNative.EM_ST7); + + /// + /// Motorola MC68HC16 microcontroller + /// + public static readonly ElfArchEx M68HC16 = new ElfArchEx(ElfNative.EM_68HC16); + + /// + /// Motorola MC68HC11 microcontroller + /// + public static readonly ElfArchEx M68HC11 = new ElfArchEx(ElfNative.EM_68HC11); + + /// + /// Motorola MC68HC08 microcontroller + /// + public static readonly ElfArchEx M68HC08 = new ElfArchEx(ElfNative.EM_68HC08); + + /// + /// Motorola MC68HC05 microcontroller + /// + public static readonly ElfArchEx M68HC05 = new ElfArchEx(ElfNative.EM_68HC05); + + /// + /// Silicon Graphics SVx + /// + public static readonly ElfArchEx SVX = new ElfArchEx(ElfNative.EM_SVX); + + /// + /// STMicroelectronics ST19 8 bit mc + /// + public static readonly ElfArchEx ST19 = new ElfArchEx(ElfNative.EM_ST19); + + /// + /// Digital VAX + /// + public static readonly ElfArchEx VAX = new ElfArchEx(ElfNative.EM_VAX); + + /// + /// Axis Communications 32-bit embedded processor + /// + public static readonly ElfArchEx CRIS = new ElfArchEx(ElfNative.EM_CRIS); + + /// + /// Infineon Technologies 32-bit embedded processor + /// + public static readonly ElfArchEx JAVELIN = new ElfArchEx(ElfNative.EM_JAVELIN); + + /// + /// Element 14 64-bit DSP Processor + /// + public static readonly ElfArchEx FIREPATH = new ElfArchEx(ElfNative.EM_FIREPATH); + + /// + /// LSI Logic 16-bit DSP Processor + /// + public static readonly ElfArchEx ZSP = new ElfArchEx(ElfNative.EM_ZSP); + + /// + /// Donald Knuth's educational 64-bit processor + /// + public static readonly ElfArchEx MMIX = new ElfArchEx(ElfNative.EM_MMIX); + + /// + /// Harvard University machine-independent object files + /// + public static readonly ElfArchEx HUANY = new ElfArchEx(ElfNative.EM_HUANY); + + /// + /// SiTera Prism + /// + public static readonly ElfArchEx PRISM = new ElfArchEx(ElfNative.EM_PRISM); + + /// + /// Atmel AVR 8-bit microcontroller + /// + public static readonly ElfArchEx AVR = new ElfArchEx(ElfNative.EM_AVR); + + /// + /// Fujitsu FR30 + /// + public static readonly ElfArchEx FR30 = new ElfArchEx(ElfNative.EM_FR30); + + /// + /// Mitsubishi D10V + /// + public static readonly ElfArchEx D10V = new ElfArchEx(ElfNative.EM_D10V); + + /// + /// Mitsubishi D30V + /// + public static readonly ElfArchEx D30V = new ElfArchEx(ElfNative.EM_D30V); + + /// + /// NEC v850 + /// + public static readonly ElfArchEx V850 = new ElfArchEx(ElfNative.EM_V850); + + /// + /// Mitsubishi M32R + /// + public static readonly ElfArchEx M32R = new ElfArchEx(ElfNative.EM_M32R); + + /// + /// Matsushita MN10300 + /// + public static readonly ElfArchEx MN10300 = new ElfArchEx(ElfNative.EM_MN10300); + + /// + /// Matsushita MN10200 + /// + public static readonly ElfArchEx MN10200 = new ElfArchEx(ElfNative.EM_MN10200); + + /// + /// picoJava + /// + public static readonly ElfArchEx PJ = new ElfArchEx(ElfNative.EM_PJ); + + /// + /// OpenRISC 32-bit embedded processor + /// + public static readonly ElfArchEx OPENRISC = new ElfArchEx(ElfNative.EM_OPENRISC); + + /// + /// ARC Cores Tangent-A5 + /// + public static readonly ElfArchEx ARC_A5 = new ElfArchEx(ElfNative.EM_ARC_A5); + + /// + /// Tensilica Xtensa Architecture + /// + public static readonly ElfArchEx XTENSA = new ElfArchEx(ElfNative.EM_XTENSA); + + /// + /// Altera Nios II + /// + public static readonly ElfArchEx ALTERA_NIOS2 = new ElfArchEx(ElfNative.EM_ALTERA_NIOS2); + + /// + /// ARM AARCH64 + /// + public static readonly ElfArchEx AARCH64 = new ElfArchEx(ElfNative.EM_AARCH64); + + /// + /// Tilera TILEPro + /// + public static readonly ElfArchEx TILEPRO = new ElfArchEx(ElfNative.EM_TILEPRO); + + /// + /// Xilinx MicroBlaze + /// + public static readonly ElfArchEx MICROBLAZE = new ElfArchEx(ElfNative.EM_MICROBLAZE); + + /// + /// Tilera TILE-Gx + /// + public static readonly ElfArchEx TILEGX = new ElfArchEx(ElfNative.EM_TILEGX); + + public static readonly ElfArchEx ALPHA = new ElfArchEx(ElfNative.EM_ALPHA); + + private string ToStringInternal() + { + switch ((ushort)Value) + { + case ElfNative.EM_NONE: return "EM_NONE"; + case ElfNative.EM_M32: return "EM_M32"; + case ElfNative.EM_SPARC: return "EM_SPARC"; + case ElfNative.EM_386: return "EM_386"; + case ElfNative.EM_68K: return "EM_68K"; + case ElfNative.EM_88K: return "EM_88K"; + case ElfNative.EM_860: return "EM_860"; + case ElfNative.EM_MIPS: return "EM_MIPS"; + case ElfNative.EM_S370: return "EM_S370"; + case ElfNative.EM_MIPS_RS3_LE: return "EM_MIPS_RS3_LE"; + case ElfNative.EM_PARISC: return "EM_PARISC"; + case ElfNative.EM_VPP500: return "EM_VPP500"; + case ElfNative.EM_SPARC32PLUS: return "EM_SPARC32PLUS"; + case ElfNative.EM_960: return "EM_960"; + case ElfNative.EM_PPC: return "EM_PPC"; + case ElfNative.EM_PPC64: return "EM_PPC64"; + case ElfNative.EM_S390: return "EM_S390"; + case ElfNative.EM_V800: return "EM_V800"; + case ElfNative.EM_FR20: return "EM_FR20"; + case ElfNative.EM_RH32: return "EM_RH32"; + case ElfNative.EM_RCE: return "EM_RCE"; + case ElfNative.EM_ARM: return "EM_ARM"; + case ElfNative.EM_FAKE_ALPHA: return "EM_FAKE_ALPHA"; + case ElfNative.EM_SH: return "EM_SH"; + case ElfNative.EM_SPARCV9: return "EM_SPARCV9"; + case ElfNative.EM_TRICORE: return "EM_TRICORE"; + case ElfNative.EM_ARC: return "EM_ARC"; + case ElfNative.EM_H8_300: return "EM_H8_300"; + case ElfNative.EM_H8_300H: return "EM_H8_300H"; + case ElfNative.EM_H8S: return "EM_H8S"; + case ElfNative.EM_H8_500: return "EM_H8_500"; + case ElfNative.EM_IA_64: return "EM_IA_64"; + case ElfNative.EM_MIPS_X: return "EM_MIPS_X"; + case ElfNative.EM_COLDFIRE: return "EM_COLDFIRE"; + case ElfNative.EM_68HC12: return "EM_68HC12"; + case ElfNative.EM_MMA: return "EM_MMA"; + case ElfNative.EM_PCP: return "EM_PCP"; + case ElfNative.EM_NCPU: return "EM_NCPU"; + case ElfNative.EM_NDR1: return "EM_NDR1"; + case ElfNative.EM_STARCORE: return "EM_STARCORE"; + case ElfNative.EM_ME16: return "EM_ME16"; + case ElfNative.EM_ST100: return "EM_ST100"; + case ElfNative.EM_TINYJ: return "EM_TINYJ"; + case ElfNative.EM_X86_64: return "EM_X86_64"; + case ElfNative.EM_PDSP: return "EM_PDSP"; + case ElfNative.EM_FX66: return "EM_FX66"; + case ElfNative.EM_ST9PLUS: return "EM_ST9PLUS"; + case ElfNative.EM_ST7: return "EM_ST7"; + case ElfNative.EM_68HC16: return "EM_68HC16"; + case ElfNative.EM_68HC11: return "EM_68HC11"; + case ElfNative.EM_68HC08: return "EM_68HC08"; + case ElfNative.EM_68HC05: return "EM_68HC05"; + case ElfNative.EM_SVX: return "EM_SVX"; + case ElfNative.EM_ST19: return "EM_ST19"; + case ElfNative.EM_VAX: return "EM_VAX"; + case ElfNative.EM_CRIS: return "EM_CRIS"; + case ElfNative.EM_JAVELIN: return "EM_JAVELIN"; + case ElfNative.EM_FIREPATH: return "EM_FIREPATH"; + case ElfNative.EM_ZSP: return "EM_ZSP"; + case ElfNative.EM_MMIX: return "EM_MMIX"; + case ElfNative.EM_HUANY: return "EM_HUANY"; + case ElfNative.EM_PRISM: return "EM_PRISM"; + case ElfNative.EM_AVR: return "EM_AVR"; + case ElfNative.EM_FR30: return "EM_FR30"; + case ElfNative.EM_D10V: return "EM_D10V"; + case ElfNative.EM_D30V: return "EM_D30V"; + case ElfNative.EM_V850: return "EM_V850"; + case ElfNative.EM_M32R: return "EM_M32R"; + case ElfNative.EM_MN10300: return "EM_MN10300"; + case ElfNative.EM_MN10200: return "EM_MN10200"; + case ElfNative.EM_PJ: return "EM_PJ"; + case ElfNative.EM_OPENRISC: return "EM_OPENRISC"; + case ElfNative.EM_ARC_A5: return "EM_ARC_A5"; + case ElfNative.EM_XTENSA: return "EM_XTENSA"; + case ElfNative.EM_ALTERA_NIOS2: return "EM_ALTERA_NIOS2"; + case ElfNative.EM_AARCH64: return "EM_AARCH64"; + case ElfNative.EM_TILEPRO: return "EM_TILEPRO"; + case ElfNative.EM_MICROBLAZE: return "EM_MICROBLAZE"; + case ElfNative.EM_TILEGX: return "EM_TILEGX"; + case ElfNative.EM_ALPHA: return "EM_ALPHA"; + default: return null; + } + } + } + + public enum ElfArch : ushort + { + NONE = ElfNative.EM_NONE, + + M32 = ElfNative.EM_M32, + + SPARC = ElfNative.EM_SPARC, + + I386 = ElfNative.EM_386, + + M68K = ElfNative.EM_68K, + + M88K = ElfNative.EM_88K, + + I860 = ElfNative.EM_860, + + MIPS = ElfNative.EM_MIPS, + + S370 = ElfNative.EM_S370, + + MIPS_RS3_LE = ElfNative.EM_MIPS_RS3_LE, + + PARISC = ElfNative.EM_PARISC, + + VPP500 = ElfNative.EM_VPP500, + + SPARC32PLUS = ElfNative.EM_SPARC32PLUS, + + I960 = ElfNative.EM_960, + + PPC = ElfNative.EM_PPC, + + PPC64 = ElfNative.EM_PPC64, + + S390 = ElfNative.EM_S390, + + V800 = ElfNative.EM_V800, + + FR20 = ElfNative.EM_FR20, + + RH32 = ElfNative.EM_RH32, + + RCE = ElfNative.EM_RCE, + + ARM = ElfNative.EM_ARM, + + FAKE_ALPHA = ElfNative.EM_FAKE_ALPHA, + + SH = ElfNative.EM_SH, + + SPARCV9 = ElfNative.EM_SPARCV9, + + TRICORE = ElfNative.EM_TRICORE, + + ARC = ElfNative.EM_ARC, + + H8_300 = ElfNative.EM_H8_300, + + H8_300H = ElfNative.EM_H8_300H, + + H8S = ElfNative.EM_H8S, + + H8_500 = ElfNative.EM_H8_500, + + IA_64 = ElfNative.EM_IA_64, + + MIPS_X = ElfNative.EM_MIPS_X, + + COLDFIRE = ElfNative.EM_COLDFIRE, + + M68HC12 = ElfNative.EM_68HC12, + + MMA = ElfNative.EM_MMA, + + PCP = ElfNative.EM_PCP, + + NCPU = ElfNative.EM_NCPU, + + NDR1 = ElfNative.EM_NDR1, + + STARCORE = ElfNative.EM_STARCORE, + + ME16 = ElfNative.EM_ME16, + + ST100 = ElfNative.EM_ST100, + + TINYJ = ElfNative.EM_TINYJ, + + X86_64 = ElfNative.EM_X86_64, + + PDSP = ElfNative.EM_PDSP, + + FX66 = ElfNative.EM_FX66, + + ST9PLUS = ElfNative.EM_ST9PLUS, + + ST7 = ElfNative.EM_ST7, + + M68HC16 = ElfNative.EM_68HC16, + + M68HC11 = ElfNative.EM_68HC11, + + M68HC08 = ElfNative.EM_68HC08, + + M68HC05 = ElfNative.EM_68HC05, + + SVX = ElfNative.EM_SVX, + + ST19 = ElfNative.EM_ST19, + + VAX = ElfNative.EM_VAX, + + CRIS = ElfNative.EM_CRIS, + + JAVELIN = ElfNative.EM_JAVELIN, + + FIREPATH = ElfNative.EM_FIREPATH, + + ZSP = ElfNative.EM_ZSP, + + MMIX = ElfNative.EM_MMIX, + + HUANY = ElfNative.EM_HUANY, + + PRISM = ElfNative.EM_PRISM, + + AVR = ElfNative.EM_AVR, + + FR30 = ElfNative.EM_FR30, + + D10V = ElfNative.EM_D10V, + + D30V = ElfNative.EM_D30V, + + V850 = ElfNative.EM_V850, + + M32R = ElfNative.EM_M32R, + + MN10300 = ElfNative.EM_MN10300, + + MN10200 = ElfNative.EM_MN10200, + + PJ = ElfNative.EM_PJ, + + OPENRISC = ElfNative.EM_OPENRISC, + + ARC_A5 = ElfNative.EM_ARC_A5, + + XTENSA = ElfNative.EM_XTENSA, + + ALTERA_NIOS2 = ElfNative.EM_ALTERA_NIOS2, + + AARCH64 = ElfNative.EM_AARCH64, + + TILEPRO = ElfNative.EM_TILEPRO, + + MICROBLAZE = ElfNative.EM_MICROBLAZE, + + TILEGX = ElfNative.EM_TILEGX, + + ALPHA = ElfNative.EM_ALPHA, + } + + public readonly partial struct ElfOSABIEx + { + /// + /// UNIX System V ABI + /// + public static readonly ElfOSABIEx NONE = new ElfOSABIEx(ElfNative.ELFOSABI_NONE); + + /// + /// UNIX System V ABI + /// + public static readonly ElfOSABIEx SYSV = new ElfOSABIEx(ElfNative.ELFOSABI_SYSV); + + /// + /// HP-UX + /// + public static readonly ElfOSABIEx HPUX = new ElfOSABIEx(ElfNative.ELFOSABI_HPUX); + + /// + /// NetBSD. + /// + public static readonly ElfOSABIEx NETBSD = new ElfOSABIEx(ElfNative.ELFOSABI_NETBSD); + + /// + /// Object uses GNU ELF extensions. + /// + public static readonly ElfOSABIEx GNU = new ElfOSABIEx(ElfNative.ELFOSABI_GNU); + + /// + /// Object uses GNU ELF extensions. + /// + public static readonly ElfOSABIEx LINUX = new ElfOSABIEx(ElfNative.ELFOSABI_LINUX); + + /// + /// Sun Solaris. + /// + public static readonly ElfOSABIEx SOLARIS = new ElfOSABIEx(ElfNative.ELFOSABI_SOLARIS); + + /// + /// IBM AIX. + /// + public static readonly ElfOSABIEx AIX = new ElfOSABIEx(ElfNative.ELFOSABI_AIX); + + /// + /// SGI Irix. + /// + public static readonly ElfOSABIEx IRIX = new ElfOSABIEx(ElfNative.ELFOSABI_IRIX); + + /// + /// FreeBSD. + /// + public static readonly ElfOSABIEx FREEBSD = new ElfOSABIEx(ElfNative.ELFOSABI_FREEBSD); + + /// + /// Compaq TRU64 UNIX. + /// + public static readonly ElfOSABIEx TRU64 = new ElfOSABIEx(ElfNative.ELFOSABI_TRU64); + + /// + /// Novell Modesto. + /// + public static readonly ElfOSABIEx MODESTO = new ElfOSABIEx(ElfNative.ELFOSABI_MODESTO); + + /// + /// OpenBSD. + /// + public static readonly ElfOSABIEx OPENBSD = new ElfOSABIEx(ElfNative.ELFOSABI_OPENBSD); + + /// + /// ARM EABI + /// + public static readonly ElfOSABIEx ARM_AEABI = new ElfOSABIEx(ElfNative.ELFOSABI_ARM_AEABI); + + /// + /// ARM + /// + public static readonly ElfOSABIEx ARM = new ElfOSABIEx(ElfNative.ELFOSABI_ARM); + + /// + /// Standalone (embedded) application + /// + public static readonly ElfOSABIEx STANDALONE = new ElfOSABIEx(ElfNative.ELFOSABI_STANDALONE); + + private string ToStringInternal() + { + switch ((byte)Value) + { + case ElfNative.ELFOSABI_NONE: return "ELFOSABI_NONE"; + case ElfNative.ELFOSABI_HPUX: return "ELFOSABI_HPUX"; + case ElfNative.ELFOSABI_NETBSD: return "ELFOSABI_NETBSD"; + case ElfNative.ELFOSABI_GNU: return "ELFOSABI_GNU"; + case ElfNative.ELFOSABI_SOLARIS: return "ELFOSABI_SOLARIS"; + case ElfNative.ELFOSABI_AIX: return "ELFOSABI_AIX"; + case ElfNative.ELFOSABI_IRIX: return "ELFOSABI_IRIX"; + case ElfNative.ELFOSABI_FREEBSD: return "ELFOSABI_FREEBSD"; + case ElfNative.ELFOSABI_TRU64: return "ELFOSABI_TRU64"; + case ElfNative.ELFOSABI_MODESTO: return "ELFOSABI_MODESTO"; + case ElfNative.ELFOSABI_OPENBSD: return "ELFOSABI_OPENBSD"; + case ElfNative.ELFOSABI_ARM_AEABI: return "ELFOSABI_ARM_AEABI"; + case ElfNative.ELFOSABI_ARM: return "ELFOSABI_ARM"; + case ElfNative.ELFOSABI_STANDALONE: return "ELFOSABI_STANDALONE"; + default: return null; + } + } + } + + public enum ElfOSABI : byte + { + NONE = ElfNative.ELFOSABI_NONE, + + SYSV = ElfNative.ELFOSABI_SYSV, + + HPUX = ElfNative.ELFOSABI_HPUX, + + NETBSD = ElfNative.ELFOSABI_NETBSD, + + GNU = ElfNative.ELFOSABI_GNU, + + LINUX = ElfNative.ELFOSABI_LINUX, + + SOLARIS = ElfNative.ELFOSABI_SOLARIS, + + AIX = ElfNative.ELFOSABI_AIX, + + IRIX = ElfNative.ELFOSABI_IRIX, + + FREEBSD = ElfNative.ELFOSABI_FREEBSD, + + TRU64 = ElfNative.ELFOSABI_TRU64, + + MODESTO = ElfNative.ELFOSABI_MODESTO, + + OPENBSD = ElfNative.ELFOSABI_OPENBSD, + + ARM_AEABI = ElfNative.ELFOSABI_ARM_AEABI, + + ARM = ElfNative.ELFOSABI_ARM, + + STANDALONE = ElfNative.ELFOSABI_STANDALONE, + } + + public readonly partial struct ElfRelocationType + { + /// + /// No reloc + /// + public static readonly ElfRelocationType R_386_NONE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_NONE); + + /// + /// Direct 32 bit + /// + public static readonly ElfRelocationType R_386_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_32); + + /// + /// PC relative 32 bit + /// + public static readonly ElfRelocationType R_386_PC32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC32); + + /// + /// 32 bit GOT entry + /// + public static readonly ElfRelocationType R_386_GOT32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOT32); + + /// + /// 32 bit PLT address + /// + public static readonly ElfRelocationType R_386_PLT32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PLT32); + + /// + /// Copy symbol at runtime + /// + public static readonly ElfRelocationType R_386_COPY = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_COPY); + + /// + /// Create GOT entry + /// + public static readonly ElfRelocationType R_386_GLOB_DAT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GLOB_DAT); + + /// + /// Create PLT entry + /// + public static readonly ElfRelocationType R_386_JMP_SLOT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_JMP_SLOT); + + /// + /// Adjust by program base + /// + public static readonly ElfRelocationType R_386_RELATIVE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_RELATIVE); + + /// + /// 32 bit offset to GOT + /// + public static readonly ElfRelocationType R_386_GOTOFF = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOTOFF); + + /// + /// 32 bit PC relative offset to GOT + /// + public static readonly ElfRelocationType R_386_GOTPC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOTPC); + + public static readonly ElfRelocationType R_386_32PLT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_32PLT); + + /// + /// Offset in static TLS block + /// + public static readonly ElfRelocationType R_386_TLS_TPOFF = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_TPOFF); + + /// + /// Address of GOT entry for static TLS block offset + /// + public static readonly ElfRelocationType R_386_TLS_IE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_IE); + + /// + /// GOT entry for static TLS block offset + /// + public static readonly ElfRelocationType R_386_TLS_GOTIE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GOTIE); + + /// + /// Offset relative to static TLS block + /// + public static readonly ElfRelocationType R_386_TLS_LE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LE); + + /// + /// Direct 32 bit for GNU version of general dynamic thread local data + /// + public static readonly ElfRelocationType R_386_TLS_GD = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD); + + /// + /// Direct 32 bit for GNU version of local dynamic thread local data in LE code + /// + public static readonly ElfRelocationType R_386_TLS_LDM = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM); + + public static readonly ElfRelocationType R_386_16 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_16); + + public static readonly ElfRelocationType R_386_PC16 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC16); + + public static readonly ElfRelocationType R_386_8 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_8); + + public static readonly ElfRelocationType R_386_PC8 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC8); + + /// + /// Direct 32 bit for general dynamic + /// thread local data + /// + public static readonly ElfRelocationType R_386_TLS_GD_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_32); + + /// + /// Tag for pushl in GD TLS code + /// + public static readonly ElfRelocationType R_386_TLS_GD_PUSH = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_PUSH); + + /// + /// Relocation for call to + /// __tls_get_addr() + /// + public static readonly ElfRelocationType R_386_TLS_GD_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_CALL); + + /// + /// Tag for popl in GD TLS code + /// + public static readonly ElfRelocationType R_386_TLS_GD_POP = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_POP); + + /// + /// Direct 32 bit for local dynamic + /// thread local data in LE code + /// + public static readonly ElfRelocationType R_386_TLS_LDM_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_32); + + /// + /// Tag for pushl in LDM TLS code + /// + public static readonly ElfRelocationType R_386_TLS_LDM_PUSH = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_PUSH); + + /// + /// Relocation for call to + /// __tls_get_addr() in LDM code + /// + public static readonly ElfRelocationType R_386_TLS_LDM_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_CALL); + + /// + /// Tag for popl in LDM TLS code + /// + public static readonly ElfRelocationType R_386_TLS_LDM_POP = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_POP); + + /// + /// Offset relative to TLS block + /// + public static readonly ElfRelocationType R_386_TLS_LDO_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDO_32); + + /// + /// GOT entry for negated static TLS + /// block offset + /// + public static readonly ElfRelocationType R_386_TLS_IE_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_IE_32); + + /// + /// Negated offset relative to static + /// TLS block + /// + public static readonly ElfRelocationType R_386_TLS_LE_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LE_32); + + /// + /// ID of module containing symbol + /// + public static readonly ElfRelocationType R_386_TLS_DTPMOD32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DTPMOD32); + + /// + /// Offset in TLS block + /// + public static readonly ElfRelocationType R_386_TLS_DTPOFF32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DTPOFF32); + + /// + /// Negated offset in static TLS block + /// + public static readonly ElfRelocationType R_386_TLS_TPOFF32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_TPOFF32); + + /// + /// 32-bit symbol size + /// + public static readonly ElfRelocationType R_386_SIZE32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_SIZE32); + + /// + /// GOT offset for TLS descriptor. + /// + public static readonly ElfRelocationType R_386_TLS_GOTDESC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GOTDESC); + + /// + /// Marker of call through TLS + /// descriptor for + /// relaxation. + /// + public static readonly ElfRelocationType R_386_TLS_DESC_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DESC_CALL); + + /// + /// TLS descriptor containing + /// pointer to code and to + /// argument, returning the TLS + /// offset for the symbol. + /// + public static readonly ElfRelocationType R_386_TLS_DESC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DESC); + + /// + /// Adjust indirectly by program base + /// + public static readonly ElfRelocationType R_386_IRELATIVE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_IRELATIVE); + + /// + /// No relocation. + /// + public static readonly ElfRelocationType R_AARCH64_NONE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_NONE); + + /// + /// Direct 32 bit. + /// + public static readonly ElfRelocationType R_AARCH64_P32_ABS32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_ABS32); + + /// + /// Copy symbol at runtime. + /// + public static readonly ElfRelocationType R_AARCH64_P32_COPY = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_COPY); + + /// + /// Create GOT entry. + /// + public static readonly ElfRelocationType R_AARCH64_P32_GLOB_DAT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_GLOB_DAT); + + /// + /// Create PLT entry. + /// + public static readonly ElfRelocationType R_AARCH64_P32_JUMP_SLOT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_JUMP_SLOT); + + /// + /// Adjust by program base. + /// + public static readonly ElfRelocationType R_AARCH64_P32_RELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_RELATIVE); + + /// + /// Module number, 32 bit. + /// + public static readonly ElfRelocationType R_AARCH64_P32_TLS_DTPMOD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_DTPMOD); + + /// + /// Module-relative offset, 32 bit. + /// + public static readonly ElfRelocationType R_AARCH64_P32_TLS_DTPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_DTPREL); + + /// + /// TP-relative offset, 32 bit. + /// + public static readonly ElfRelocationType R_AARCH64_P32_TLS_TPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_TPREL); + + /// + /// TLS Descriptor. + /// + public static readonly ElfRelocationType R_AARCH64_P32_TLSDESC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLSDESC); + + /// + /// STT_GNU_IFUNC relocation. + /// + public static readonly ElfRelocationType R_AARCH64_P32_IRELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_IRELATIVE); + + /// + /// Direct 64 bit. + /// + public static readonly ElfRelocationType R_AARCH64_ABS64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS64); + + /// + /// Direct 32 bit. + /// + public static readonly ElfRelocationType R_AARCH64_ABS32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS32); + + /// + /// Direct 16-bit. + /// + public static readonly ElfRelocationType R_AARCH64_ABS16 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS16); + + /// + /// PC-relative 64-bit. + /// + public static readonly ElfRelocationType R_AARCH64_PREL64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL64); + + /// + /// PC-relative 32-bit. + /// + public static readonly ElfRelocationType R_AARCH64_PREL32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL32); + + /// + /// PC-relative 16-bit. + /// + public static readonly ElfRelocationType R_AARCH64_PREL16 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL16); + + /// + /// Dir. MOVZ imm. from bits 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G0); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G0_NC); + + /// + /// Dir. MOVZ imm. from bits 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G1); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G1_NC); + + /// + /// Dir. MOVZ imm. from bits 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G2); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G2_NC); + + /// + /// Dir. MOV{K,Z} imm. from 63:48. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G3); + + /// + /// Dir. MOV{N,Z} imm. from 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G0); + + /// + /// Dir. MOV{N,Z} imm. from 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G1); + + /// + /// Dir. MOV{N,Z} imm. from 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G2); + + /// + /// PC-rel. LD imm. from bits 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_LD_PREL_LO19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD_PREL_LO19); + + /// + /// PC-rel. ADR imm. from bits 20:0. + /// + public static readonly ElfRelocationType R_AARCH64_ADR_PREL_LO21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_LO21); + + /// + /// Page-rel. ADRP imm. from 32:12. + /// + public static readonly ElfRelocationType R_AARCH64_ADR_PREL_PG_HI21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_PG_HI21); + + /// + /// Likewise; no overflow check. + /// + public static readonly ElfRelocationType R_AARCH64_ADR_PREL_PG_HI21_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_PG_HI21_NC); + + /// + /// Dir. ADD imm. from bits 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_ADD_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADD_ABS_LO12_NC); + + /// + /// Likewise for LD/ST; no check. + /// + public static readonly ElfRelocationType R_AARCH64_LDST8_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST8_ABS_LO12_NC); + + /// + /// PC-rel. TBZ/TBNZ imm. from 15:2. + /// + public static readonly ElfRelocationType R_AARCH64_TSTBR14 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TSTBR14); + + /// + /// PC-rel. cond. br. imm. from 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_CONDBR19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_CONDBR19); + + /// + /// PC-rel. B imm. from bits 27:2. + /// + public static readonly ElfRelocationType R_AARCH64_JUMP26 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_JUMP26); + + /// + /// Likewise for CALL. + /// + public static readonly ElfRelocationType R_AARCH64_CALL26 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_CALL26); + + /// + /// Dir. ADD imm. from bits 11:1. + /// + public static readonly ElfRelocationType R_AARCH64_LDST16_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST16_ABS_LO12_NC); + + /// + /// Likewise for bits 11:2. + /// + public static readonly ElfRelocationType R_AARCH64_LDST32_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST32_ABS_LO12_NC); + + /// + /// Likewise for bits 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_LDST64_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST64_ABS_LO12_NC); + + /// + /// PC-rel. MOV{N,Z} imm. from 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G0); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G0_NC); + + /// + /// PC-rel. MOV{N,Z} imm. from 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G1); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G1_NC); + + /// + /// PC-rel. MOV{N,Z} imm. from 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G2); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G2_NC); + + /// + /// PC-rel. MOV{N,Z} imm. from 63:48. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G3); + + /// + /// Dir. ADD imm. from bits 11:4. + /// + public static readonly ElfRelocationType R_AARCH64_LDST128_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST128_ABS_LO12_NC); + + /// + /// GOT-rel. off. MOV{N,Z} imm. 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G0); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G0_NC); + + /// + /// GOT-rel. o. MOV{N,Z} imm. 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G1); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G1_NC); + + /// + /// GOT-rel. o. MOV{N,Z} imm. 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G2); + + /// + /// Likewise for MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G2_NC); + + /// + /// GOT-rel. o. MOV{N,Z} imm. 63:48. + /// + public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G3); + + /// + /// GOT-relative 64-bit. + /// + public static readonly ElfRelocationType R_AARCH64_GOTREL64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOTREL64); + + /// + /// GOT-relative 32-bit. + /// + public static readonly ElfRelocationType R_AARCH64_GOTREL32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOTREL32); + + /// + /// PC-rel. GOT off. load imm. 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_GOT_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOT_LD_PREL19); + + /// + /// GOT-rel. off. LD/ST imm. 14:3. + /// + public static readonly ElfRelocationType R_AARCH64_LD64_GOTOFF_LO15 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOTOFF_LO15); + + /// + /// P-page-rel. GOT off. ADRP 32:12. + /// + public static readonly ElfRelocationType R_AARCH64_ADR_GOT_PAGE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_GOT_PAGE); + + /// + /// Dir. GOT off. LD/ST imm. 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_LD64_GOT_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOT_LO12_NC); + + /// + /// GOT-page-rel. GOT off. LD/ST 14:3 + /// + public static readonly ElfRelocationType R_AARCH64_LD64_GOTPAGE_LO15 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOTPAGE_LO15); + + /// + /// PC-relative ADR imm. 20:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSGD_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADR_PREL21); + + /// + /// page-rel. ADRP imm. 32:12. + /// + public static readonly ElfRelocationType R_AARCH64_TLSGD_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADR_PAGE21); + + /// + /// direct ADD imm. from 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSGD_ADD_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADD_LO12_NC); + + /// + /// GOT-rel. MOV{N,Z} 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_TLSGD_MOVW_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_MOVW_G1); + + /// + /// GOT-rel. MOVK imm. 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSGD_MOVW_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_MOVW_G0_NC); + + /// + /// Like 512; local dynamic model. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADR_PREL21); + + /// + /// Like 513; local dynamic model. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADR_PAGE21); + + /// + /// Like 514; local dynamic model. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_LO12_NC); + + /// + /// Like 515; local dynamic model. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_G1); + + /// + /// Like 516; local dynamic model. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_G0_NC); + + /// + /// TLS PC-rel. load imm. 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LD_PREL19); + + /// + /// TLS DTP-rel. MOV{N,Z} 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G2); + + /// + /// TLS DTP-rel. MOV{N,Z} 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1); + + /// + /// Likewise; MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC); + + /// + /// TLS DTP-rel. MOV{N,Z} 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0); + + /// + /// Likewise; MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC); + + /// + /// DTP-rel. ADD imm. from 23:12. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_HI12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_HI12); + + /// + /// DTP-rel. ADD imm. from 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12); + + /// + /// Likewise; no ovfl. check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC); + + /// + /// DTP-rel. LD/ST imm. 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC); + + /// + /// DTP-rel. LD/ST imm. 11:1. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC); + + /// + /// DTP-rel. LD/ST imm. 11:2. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC); + + /// + /// DTP-rel. LD/ST imm. 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC); + + /// + /// GOT-rel. MOV{N,Z} 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G1); + + /// + /// GOT-rel. MOVK 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC); + + /// + /// Page-rel. ADRP 32:12. + /// + public static readonly ElfRelocationType R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21); + + /// + /// Direct LD off. 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC); + + /// + /// PC-rel. load imm. 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_LD_GOTTPREL_PREL19); + + /// + /// TLS TP-rel. MOV{N,Z} 47:32. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G2); + + /// + /// TLS TP-rel. MOV{N,Z} 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1); + + /// + /// Likewise; MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1_NC); + + /// + /// TLS TP-rel. MOV{N,Z} 15:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0); + + /// + /// Likewise; MOVK; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0_NC); + + /// + /// TP-rel. ADD imm. 23:12. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_HI12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12); + + /// + /// TP-rel. ADD imm. 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12); + + /// + /// Likewise; no ovfl. check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC); + + /// + /// TP-rel. LD/ST off. 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST8_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12); + + /// + /// Likewise; no ovfl. check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC); + + /// + /// TP-rel. LD/ST off. 11:1. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST16_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC); + + /// + /// TP-rel. LD/ST off. 11:2. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST32_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC); + + /// + /// TP-rel. LD/ST off. 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST64_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC); + + /// + /// PC-rel. load immediate 20:2. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LD_PREL19); + + /// + /// PC-rel. ADR immediate 20:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADR_PREL21); + + /// + /// Page-rel. ADRP imm. 32:12. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21); + + /// + /// Direct LD off. from 11:3. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_LD64_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LD64_LO12); + + /// + /// Direct ADD imm. from 11:0. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADD_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADD_LO12); + + /// + /// GOT-rel. MOV{N,Z} imm. 31:16. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_OFF_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_OFF_G1); + + /// + /// GOT-rel. MOVK imm. 15:0; no ck. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_OFF_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_OFF_G0_NC); + + /// + /// Relax LDR. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_LDR = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LDR); + + /// + /// Relax ADD. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADD); + + /// + /// Relax BLR. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC_CALL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_CALL); + + /// + /// TP-rel. LD/ST off. 11:4. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST128_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC); + + /// + /// DTP-rel. LD/ST imm. 11:4. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12); + + /// + /// Likewise; no check. + /// + public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC); + + /// + /// Copy symbol at runtime. + /// + public static readonly ElfRelocationType R_AARCH64_COPY = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_COPY); + + /// + /// Create GOT entry. + /// + public static readonly ElfRelocationType R_AARCH64_GLOB_DAT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GLOB_DAT); + + /// + /// Create PLT entry. + /// + public static readonly ElfRelocationType R_AARCH64_JUMP_SLOT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_JUMP_SLOT); + + /// + /// Adjust by program base. + /// + public static readonly ElfRelocationType R_AARCH64_RELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_RELATIVE); + + /// + /// Module number, 64 bit. + /// + public static readonly ElfRelocationType R_AARCH64_TLS_DTPMOD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_DTPMOD); + + /// + /// Module-relative offset, 64 bit. + /// + public static readonly ElfRelocationType R_AARCH64_TLS_DTPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_DTPREL); + + /// + /// TP-relative offset, 64 bit. + /// + public static readonly ElfRelocationType R_AARCH64_TLS_TPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_TPREL); + + /// + /// TLS Descriptor. + /// + public static readonly ElfRelocationType R_AARCH64_TLSDESC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC); + + /// + /// STT_GNU_IFUNC relocation. + /// + public static readonly ElfRelocationType R_AARCH64_IRELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_IRELATIVE); + + /// + /// No reloc + /// + public static readonly ElfRelocationType R_ARM_NONE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_NONE); + + /// + /// Deprecated PC relative 26 bit branch. + /// + public static readonly ElfRelocationType R_ARM_PC24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PC24); + + /// + /// Direct 32 bit + /// + public static readonly ElfRelocationType R_ARM_ABS32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS32); + + /// + /// PC relative 32 bit + /// + public static readonly ElfRelocationType R_ARM_REL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_REL32); + + public static readonly ElfRelocationType R_ARM_PC13 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PC13); + + /// + /// Direct 16 bit + /// + public static readonly ElfRelocationType R_ARM_ABS16 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS16); + + /// + /// Direct 12 bit + /// + public static readonly ElfRelocationType R_ARM_ABS12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS12); + + /// + /// Direct + /// & + /// 0x7C (LDR, STR). + /// + public static readonly ElfRelocationType R_ARM_THM_ABS5 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_ABS5); + + /// + /// Direct 8 bit + /// + public static readonly ElfRelocationType R_ARM_ABS8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS8); + + public static readonly ElfRelocationType R_ARM_SBREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SBREL32); + + /// + /// PC relative 24 bit (Thumb32 BL). + /// + public static readonly ElfRelocationType R_ARM_THM_PC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC22); + + /// + /// PC relative + /// & + /// 0x3FC (Thumb16 LDR, ADD, ADR). + /// + public static readonly ElfRelocationType R_ARM_THM_PC8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC8); + + public static readonly ElfRelocationType R_ARM_AMP_VCALL9 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_AMP_VCALL9); + + /// + /// Obsolete static relocation. + /// + public static readonly ElfRelocationType R_ARM_SWI24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SWI24); + + /// + /// Dynamic relocation. + /// + public static readonly ElfRelocationType R_ARM_TLS_DESC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DESC); + + /// + /// Reserved. + /// + public static readonly ElfRelocationType R_ARM_THM_SWI8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_SWI8); + + /// + /// Reserved. + /// + public static readonly ElfRelocationType R_ARM_XPC25 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_XPC25); + + /// + /// Reserved. + /// + public static readonly ElfRelocationType R_ARM_THM_XPC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_XPC22); + + /// + /// ID of module containing symbol + /// + public static readonly ElfRelocationType R_ARM_TLS_DTPMOD32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DTPMOD32); + + /// + /// Offset in TLS block + /// + public static readonly ElfRelocationType R_ARM_TLS_DTPOFF32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DTPOFF32); + + /// + /// Offset in static TLS block + /// + public static readonly ElfRelocationType R_ARM_TLS_TPOFF32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_TPOFF32); + + /// + /// Copy symbol at runtime + /// + public static readonly ElfRelocationType R_ARM_COPY = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_COPY); + + /// + /// Create GOT entry + /// + public static readonly ElfRelocationType R_ARM_GLOB_DAT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GLOB_DAT); + + /// + /// Create PLT entry + /// + public static readonly ElfRelocationType R_ARM_JUMP_SLOT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_JUMP_SLOT); + + /// + /// Adjust by program base + /// + public static readonly ElfRelocationType R_ARM_RELATIVE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RELATIVE); + + /// + /// 32 bit offset to GOT + /// + public static readonly ElfRelocationType R_ARM_GOTOFF = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTOFF); + + /// + /// 32 bit PC relative offset to GOT + /// + public static readonly ElfRelocationType R_ARM_GOTPC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTPC); + + /// + /// 32 bit GOT entry + /// + public static readonly ElfRelocationType R_ARM_GOT32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT32); + + /// + /// Deprecated, 32 bit PLT address. + /// + public static readonly ElfRelocationType R_ARM_PLT32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PLT32); + + /// + /// PC relative 24 bit (BL, BLX). + /// + public static readonly ElfRelocationType R_ARM_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_CALL); + + /// + /// PC relative 24 bit (B, BL + /// <cond + /// >). + /// + public static readonly ElfRelocationType R_ARM_JUMP24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_JUMP24); + + /// + /// PC relative 24 bit (Thumb32 B.W). + /// + public static readonly ElfRelocationType R_ARM_THM_JUMP24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP24); + + /// + /// Adjust by program base. + /// + public static readonly ElfRelocationType R_ARM_BASE_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_BASE_ABS); + + /// + /// Obsolete. + /// + public static readonly ElfRelocationType R_ARM_ALU_PCREL_7_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_7_0); + + /// + /// Obsolete. + /// + public static readonly ElfRelocationType R_ARM_ALU_PCREL_15_8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_15_8); + + /// + /// Obsolete. + /// + public static readonly ElfRelocationType R_ARM_ALU_PCREL_23_15 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_23_15); + + /// + /// Deprecated, prog. base relative. + /// + public static readonly ElfRelocationType R_ARM_LDR_SBREL_11_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SBREL_11_0); + + /// + /// Deprecated, prog. base relative. + /// + public static readonly ElfRelocationType R_ARM_ALU_SBREL_19_12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SBREL_19_12); + + /// + /// Deprecated, prog. base relative. + /// + public static readonly ElfRelocationType R_ARM_ALU_SBREL_27_20 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SBREL_27_20); + + public static readonly ElfRelocationType R_ARM_TARGET1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TARGET1); + + /// + /// Program base relative. + /// + public static readonly ElfRelocationType R_ARM_SBREL31 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SBREL31); + + public static readonly ElfRelocationType R_ARM_V4BX = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_V4BX); + + public static readonly ElfRelocationType R_ARM_TARGET2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TARGET2); + + /// + /// 32 bit PC relative. + /// + public static readonly ElfRelocationType R_ARM_PREL31 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PREL31); + + /// + /// Direct 16-bit (MOVW). + /// + public static readonly ElfRelocationType R_ARM_MOVW_ABS_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_ABS_NC); + + /// + /// Direct high 16-bit (MOVT). + /// + public static readonly ElfRelocationType R_ARM_MOVT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_ABS); + + /// + /// PC relative 16-bit (MOVW). + /// + public static readonly ElfRelocationType R_ARM_MOVW_PREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_PREL_NC); + + /// + /// PC relative (MOVT). + /// + public static readonly ElfRelocationType R_ARM_MOVT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_PREL); + + /// + /// Direct 16 bit (Thumb32 MOVW). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVW_ABS_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_ABS_NC); + + /// + /// Direct high 16 bit (Thumb32 MOVT). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_ABS); + + /// + /// PC relative 16 bit (Thumb32 MOVW). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVW_PREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_PREL_NC); + + /// + /// PC relative high 16 bit (Thumb32 MOVT). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_PREL); + + /// + /// PC relative 20 bit (Thumb32 B + /// <cond + /// >.W). + /// + public static readonly ElfRelocationType R_ARM_THM_JUMP19 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP19); + + /// + /// PC relative X + /// & + /// 0x7E (Thumb16 CBZ, CBNZ). + /// + public static readonly ElfRelocationType R_ARM_THM_JUMP6 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP6); + + /// + /// PC relative 12 bit (Thumb32 ADR.W). + /// + public static readonly ElfRelocationType R_ARM_THM_ALU_PREL_11_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_ALU_PREL_11_0); + + /// + /// PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). + /// + public static readonly ElfRelocationType R_ARM_THM_PC12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC12); + + /// + /// Direct 32-bit. + /// + public static readonly ElfRelocationType R_ARM_ABS32_NOI = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS32_NOI); + + /// + /// PC relative 32-bit. + /// + public static readonly ElfRelocationType R_ARM_REL32_NOI = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_REL32_NOI); + + /// + /// PC relative (ADD, SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_PC_G0_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G0_NC); + + /// + /// PC relative (ADD, SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G0); + + /// + /// PC relative (ADD, SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_PC_G1_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G1_NC); + + /// + /// PC relative (ADD, SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G1); + + /// + /// PC relative (ADD, SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G2); + + /// + /// PC relative (LDR,STR,LDRB,STRB). + /// + public static readonly ElfRelocationType R_ARM_LDR_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_PC_G1); + + /// + /// PC relative (LDR,STR,LDRB,STRB). + /// + public static readonly ElfRelocationType R_ARM_LDR_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_PC_G2); + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public static readonly ElfRelocationType R_ARM_LDRS_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G0); + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public static readonly ElfRelocationType R_ARM_LDRS_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G1); + + /// + /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). + /// + public static readonly ElfRelocationType R_ARM_LDRS_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G2); + + /// + /// PC relative (LDC, STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G0); + + /// + /// PC relative (LDC, STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G1); + + /// + /// PC relative (LDC, STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G2); + + /// + /// Program base relative (ADD,SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_SB_G0_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G0_NC); + + /// + /// Program base relative (ADD,SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G0); + + /// + /// Program base relative (ADD,SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_SB_G1_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G1_NC); + + /// + /// Program base relative (ADD,SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G1); + + /// + /// Program base relative (ADD,SUB). + /// + public static readonly ElfRelocationType R_ARM_ALU_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G2); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDR_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G0); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDR_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G1); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDR_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G2); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDRS_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G0); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDRS_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G1); + + /// + /// Program base relative (LDR, STR, LDRB, STRB). + /// + public static readonly ElfRelocationType R_ARM_LDRS_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G2); + + /// + /// Program base relative (LDC,STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G0); + + /// + /// Program base relative (LDC,STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G1); + + /// + /// Program base relative (LDC,STC). + /// + public static readonly ElfRelocationType R_ARM_LDC_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G2); + + /// + /// Program base relative 16 bit (MOVW). + /// + public static readonly ElfRelocationType R_ARM_MOVW_BREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_BREL_NC); + + /// + /// Program base relative high 16 bit (MOVT). + /// + public static readonly ElfRelocationType R_ARM_MOVT_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_BREL); + + /// + /// Program base relative 16 bit (MOVW). + /// + public static readonly ElfRelocationType R_ARM_MOVW_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_BREL); + + /// + /// Program base relative 16 bit (Thumb32 MOVW). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVW_BREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_BREL_NC); + + /// + /// Program base relative high 16 bit (Thumb32 MOVT). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVT_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_BREL); + + /// + /// Program base relative 16 bit (Thumb32 MOVW). + /// + public static readonly ElfRelocationType R_ARM_THM_MOVW_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_BREL); + + public static readonly ElfRelocationType R_ARM_TLS_GOTDESC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_GOTDESC); + + public static readonly ElfRelocationType R_ARM_TLS_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_CALL); + + /// + /// TLS relaxation. + /// + public static readonly ElfRelocationType R_ARM_TLS_DESCSEQ = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DESCSEQ); + + public static readonly ElfRelocationType R_ARM_THM_TLS_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_CALL); + + public static readonly ElfRelocationType R_ARM_PLT32_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PLT32_ABS); + + /// + /// GOT entry. + /// + public static readonly ElfRelocationType R_ARM_GOT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_ABS); + + /// + /// PC relative GOT entry. + /// + public static readonly ElfRelocationType R_ARM_GOT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_PREL); + + /// + /// GOT entry relative to GOT origin (LDR). + /// + public static readonly ElfRelocationType R_ARM_GOT_BREL12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_BREL12); + + /// + /// 12 bit, GOT entry relative to GOT origin (LDR, STR). + /// + public static readonly ElfRelocationType R_ARM_GOTOFF12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTOFF12); + + public static readonly ElfRelocationType R_ARM_GOTRELAX = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTRELAX); + + public static readonly ElfRelocationType R_ARM_GNU_VTENTRY = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GNU_VTENTRY); + + public static readonly ElfRelocationType R_ARM_GNU_VTINHERIT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GNU_VTINHERIT); + + /// + /// PC relative + /// & + /// 0xFFE (Thumb16 B). + /// + public static readonly ElfRelocationType R_ARM_THM_PC11 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC11); + + /// + /// PC relative + /// & + /// 0x1FE (Thumb16 B/B + /// <cond + /// >). + /// + public static readonly ElfRelocationType R_ARM_THM_PC9 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC9); + + /// + /// PC-rel 32 bit for global dynamic thread local data + /// + public static readonly ElfRelocationType R_ARM_TLS_GD32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_GD32); + + /// + /// PC-rel 32 bit for local dynamic thread local data + /// + public static readonly ElfRelocationType R_ARM_TLS_LDM32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDM32); + + /// + /// 32 bit offset relative to TLS block + /// + public static readonly ElfRelocationType R_ARM_TLS_LDO32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDO32); + + /// + /// PC-rel 32 bit for GOT entry of static TLS block offset + /// + public static readonly ElfRelocationType R_ARM_TLS_IE32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_IE32); + + /// + /// 32 bit offset relative to static TLS block + /// + public static readonly ElfRelocationType R_ARM_TLS_LE32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LE32); + + /// + /// 12 bit relative to TLS block (LDR, STR). + /// + public static readonly ElfRelocationType R_ARM_TLS_LDO12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDO12); + + /// + /// 12 bit relative to static TLS block (LDR, STR). + /// + public static readonly ElfRelocationType R_ARM_TLS_LE12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LE12); + + /// + /// 12 bit GOT entry relative to GOT origin (LDR). + /// + public static readonly ElfRelocationType R_ARM_TLS_IE12GP = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_IE12GP); + + /// + /// Obsolete. + /// + public static readonly ElfRelocationType R_ARM_ME_TOO = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ME_TOO); + + public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ); + + public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ16 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ16); + + public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ32); + + /// + /// GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). + /// + public static readonly ElfRelocationType R_ARM_THM_GOT_BREL12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_GOT_BREL12); + + public static readonly ElfRelocationType R_ARM_IRELATIVE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_IRELATIVE); + + public static readonly ElfRelocationType R_ARM_RXPC25 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RXPC25); + + public static readonly ElfRelocationType R_ARM_RSBREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RSBREL32); + + public static readonly ElfRelocationType R_ARM_THM_RPC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_RPC22); + + public static readonly ElfRelocationType R_ARM_RREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RREL32); + + public static readonly ElfRelocationType R_ARM_RABS22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RABS22); + + public static readonly ElfRelocationType R_ARM_RPC24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RPC24); + + public static readonly ElfRelocationType R_ARM_RBASE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RBASE); + + /// + /// No reloc + /// + public static readonly ElfRelocationType R_X86_64_NONE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_NONE); + + /// + /// Direct 64 bit + /// + public static readonly ElfRelocationType R_X86_64_64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_64); + + /// + /// PC relative 32 bit signed + /// + public static readonly ElfRelocationType R_X86_64_PC32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC32); + + /// + /// 32 bit GOT entry + /// + public static readonly ElfRelocationType R_X86_64_GOT32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOT32); + + /// + /// 32 bit PLT address + /// + public static readonly ElfRelocationType R_X86_64_PLT32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PLT32); + + /// + /// Copy symbol at runtime + /// + public static readonly ElfRelocationType R_X86_64_COPY = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_COPY); + + /// + /// Create GOT entry + /// + public static readonly ElfRelocationType R_X86_64_GLOB_DAT = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GLOB_DAT); + + /// + /// Create PLT entry + /// + public static readonly ElfRelocationType R_X86_64_JUMP_SLOT = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_JUMP_SLOT); + + /// + /// Adjust by program base + /// + public static readonly ElfRelocationType R_X86_64_RELATIVE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_RELATIVE); + + /// + /// 32 bit signed PC relative offset to GOT + /// + public static readonly ElfRelocationType R_X86_64_GOTPCREL = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPCREL); + + /// + /// Direct 32 bit zero extended + /// + public static readonly ElfRelocationType R_X86_64_32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_32); + + /// + /// Direct 32 bit sign extended + /// + public static readonly ElfRelocationType R_X86_64_32S = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_32S); + + /// + /// Direct 16 bit zero extended + /// + public static readonly ElfRelocationType R_X86_64_16 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_16); + + /// + /// 16 bit sign extended pc relative + /// + public static readonly ElfRelocationType R_X86_64_PC16 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC16); + + /// + /// Direct 8 bit sign extended + /// + public static readonly ElfRelocationType R_X86_64_8 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_8); + + /// + /// 8 bit sign extended pc relative + /// + public static readonly ElfRelocationType R_X86_64_PC8 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC8); + + /// + /// ID of module containing symbol + /// + public static readonly ElfRelocationType R_X86_64_DTPMOD64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPMOD64); + + /// + /// Offset in module's TLS block + /// + public static readonly ElfRelocationType R_X86_64_DTPOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPOFF64); + + /// + /// Offset in initial TLS block + /// + public static readonly ElfRelocationType R_X86_64_TPOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TPOFF64); + + /// + /// 32 bit signed PC relative offset to two GOT entries for GD symbol + /// + public static readonly ElfRelocationType R_X86_64_TLSGD = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSGD); + + /// + /// 32 bit signed PC relative offset to two GOT entries for LD symbol + /// + public static readonly ElfRelocationType R_X86_64_TLSLD = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSLD); + + /// + /// Offset in TLS block + /// + public static readonly ElfRelocationType R_X86_64_DTPOFF32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPOFF32); + + /// + /// 32 bit signed PC relative offset to GOT entry for IE symbol + /// + public static readonly ElfRelocationType R_X86_64_GOTTPOFF = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTTPOFF); + + /// + /// Offset in initial TLS block + /// + public static readonly ElfRelocationType R_X86_64_TPOFF32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TPOFF32); + + /// + /// PC relative 64 bit + /// + public static readonly ElfRelocationType R_X86_64_PC64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC64); + + /// + /// 64 bit offset to GOT + /// + public static readonly ElfRelocationType R_X86_64_GOTOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTOFF64); + + /// + /// 32 bit signed pc relative offset to GOT + /// + public static readonly ElfRelocationType R_X86_64_GOTPC32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC32); + + /// + /// 64-bit GOT entry offset + /// + public static readonly ElfRelocationType R_X86_64_GOT64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOT64); + + /// + /// 64-bit PC relative offset to GOT entry + /// + public static readonly ElfRelocationType R_X86_64_GOTPCREL64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPCREL64); + + /// + /// 64-bit PC relative offset to GOT + /// + public static readonly ElfRelocationType R_X86_64_GOTPC64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC64); + + /// + /// like GOT64, says PLT entry needed + /// + public static readonly ElfRelocationType R_X86_64_GOTPLT64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPLT64); + + /// + /// 64-bit GOT relative offset to PLT entry + /// + public static readonly ElfRelocationType R_X86_64_PLTOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PLTOFF64); + + /// + /// Size of symbol plus 32-bit addend + /// + public static readonly ElfRelocationType R_X86_64_SIZE32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_SIZE32); + + /// + /// Size of symbol plus 64-bit addend + /// + public static readonly ElfRelocationType R_X86_64_SIZE64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_SIZE64); + + /// + /// GOT offset for TLS descriptor. + /// + public static readonly ElfRelocationType R_X86_64_GOTPC32_TLSDESC = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC32_TLSDESC); + + /// + /// Marker for call through TLS descriptor. + /// + public static readonly ElfRelocationType R_X86_64_TLSDESC_CALL = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSDESC_CALL); + + /// + /// TLS descriptor. + /// + public static readonly ElfRelocationType R_X86_64_TLSDESC = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSDESC); + + /// + /// Adjust indirectly by program base + /// + public static readonly ElfRelocationType R_X86_64_IRELATIVE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_IRELATIVE); + + /// + /// 64-bit adjust by program base + /// + public static readonly ElfRelocationType R_X86_64_RELATIVE64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_RELATIVE64); + + private string ToStringInternal() + { + switch (((ulong)Value << 16) | (ulong)Arch.Value) + { + case ((ulong)ElfNative.R_386_NONE << 16) | ElfNative.EM_386 : return "R_386_NONE"; + case ((ulong)ElfNative.R_386_32 << 16) | ElfNative.EM_386 : return "R_386_32"; + case ((ulong)ElfNative.R_386_PC32 << 16) | ElfNative.EM_386 : return "R_386_PC32"; + case ((ulong)ElfNative.R_386_GOT32 << 16) | ElfNative.EM_386 : return "R_386_GOT32"; + case ((ulong)ElfNative.R_386_PLT32 << 16) | ElfNative.EM_386 : return "R_386_PLT32"; + case ((ulong)ElfNative.R_386_COPY << 16) | ElfNative.EM_386 : return "R_386_COPY"; + case ((ulong)ElfNative.R_386_GLOB_DAT << 16) | ElfNative.EM_386 : return "R_386_GLOB_DAT"; + case ((ulong)ElfNative.R_386_JMP_SLOT << 16) | ElfNative.EM_386 : return "R_386_JMP_SLOT"; + case ((ulong)ElfNative.R_386_RELATIVE << 16) | ElfNative.EM_386 : return "R_386_RELATIVE"; + case ((ulong)ElfNative.R_386_GOTOFF << 16) | ElfNative.EM_386 : return "R_386_GOTOFF"; + case ((ulong)ElfNative.R_386_GOTPC << 16) | ElfNative.EM_386 : return "R_386_GOTPC"; + case ((ulong)ElfNative.R_386_32PLT << 16) | ElfNative.EM_386 : return "R_386_32PLT"; + case ((ulong)ElfNative.R_386_TLS_TPOFF << 16) | ElfNative.EM_386 : return "R_386_TLS_TPOFF"; + case ((ulong)ElfNative.R_386_TLS_IE << 16) | ElfNative.EM_386 : return "R_386_TLS_IE"; + case ((ulong)ElfNative.R_386_TLS_GOTIE << 16) | ElfNative.EM_386 : return "R_386_TLS_GOTIE"; + case ((ulong)ElfNative.R_386_TLS_LE << 16) | ElfNative.EM_386 : return "R_386_TLS_LE"; + case ((ulong)ElfNative.R_386_TLS_GD << 16) | ElfNative.EM_386 : return "R_386_TLS_GD"; + case ((ulong)ElfNative.R_386_TLS_LDM << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM"; + case ((ulong)ElfNative.R_386_16 << 16) | ElfNative.EM_386 : return "R_386_16"; + case ((ulong)ElfNative.R_386_PC16 << 16) | ElfNative.EM_386 : return "R_386_PC16"; + case ((ulong)ElfNative.R_386_8 << 16) | ElfNative.EM_386 : return "R_386_8"; + case ((ulong)ElfNative.R_386_PC8 << 16) | ElfNative.EM_386 : return "R_386_PC8"; + case ((ulong)ElfNative.R_386_TLS_GD_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_32"; + case ((ulong)ElfNative.R_386_TLS_GD_PUSH << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_PUSH"; + case ((ulong)ElfNative.R_386_TLS_GD_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_CALL"; + case ((ulong)ElfNative.R_386_TLS_GD_POP << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_POP"; + case ((ulong)ElfNative.R_386_TLS_LDM_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_32"; + case ((ulong)ElfNative.R_386_TLS_LDM_PUSH << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_PUSH"; + case ((ulong)ElfNative.R_386_TLS_LDM_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_CALL"; + case ((ulong)ElfNative.R_386_TLS_LDM_POP << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_POP"; + case ((ulong)ElfNative.R_386_TLS_LDO_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LDO_32"; + case ((ulong)ElfNative.R_386_TLS_IE_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_IE_32"; + case ((ulong)ElfNative.R_386_TLS_LE_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LE_32"; + case ((ulong)ElfNative.R_386_TLS_DTPMOD32 << 16) | ElfNative.EM_386 : return "R_386_TLS_DTPMOD32"; + case ((ulong)ElfNative.R_386_TLS_DTPOFF32 << 16) | ElfNative.EM_386 : return "R_386_TLS_DTPOFF32"; + case ((ulong)ElfNative.R_386_TLS_TPOFF32 << 16) | ElfNative.EM_386 : return "R_386_TLS_TPOFF32"; + case ((ulong)ElfNative.R_386_SIZE32 << 16) | ElfNative.EM_386 : return "R_386_SIZE32"; + case ((ulong)ElfNative.R_386_TLS_GOTDESC << 16) | ElfNative.EM_386 : return "R_386_TLS_GOTDESC"; + case ((ulong)ElfNative.R_386_TLS_DESC_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_DESC_CALL"; + case ((ulong)ElfNative.R_386_TLS_DESC << 16) | ElfNative.EM_386 : return "R_386_TLS_DESC"; + case ((ulong)ElfNative.R_386_IRELATIVE << 16) | ElfNative.EM_386 : return "R_386_IRELATIVE"; + case ((ulong)ElfNative.R_AARCH64_NONE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_NONE"; + case ((ulong)ElfNative.R_AARCH64_P32_ABS32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_ABS32"; + case ((ulong)ElfNative.R_AARCH64_P32_COPY << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_COPY"; + case ((ulong)ElfNative.R_AARCH64_P32_GLOB_DAT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_GLOB_DAT"; + case ((ulong)ElfNative.R_AARCH64_P32_JUMP_SLOT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_JUMP_SLOT"; + case ((ulong)ElfNative.R_AARCH64_P32_RELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_RELATIVE"; + case ((ulong)ElfNative.R_AARCH64_P32_TLS_DTPMOD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_DTPMOD"; + case ((ulong)ElfNative.R_AARCH64_P32_TLS_DTPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_DTPREL"; + case ((ulong)ElfNative.R_AARCH64_P32_TLS_TPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_TPREL"; + case ((ulong)ElfNative.R_AARCH64_P32_TLSDESC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLSDESC"; + case ((ulong)ElfNative.R_AARCH64_P32_IRELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_IRELATIVE"; + case ((ulong)ElfNative.R_AARCH64_ABS64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS64"; + case ((ulong)ElfNative.R_AARCH64_ABS32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS32"; + case ((ulong)ElfNative.R_AARCH64_ABS16 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS16"; + case ((ulong)ElfNative.R_AARCH64_PREL64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL64"; + case ((ulong)ElfNative.R_AARCH64_PREL32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL32"; + case ((ulong)ElfNative.R_AARCH64_PREL16 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL16"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G0"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G1"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G1_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G2"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G2_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G3"; + case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G0"; + case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G1"; + case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G2"; + case ((ulong)ElfNative.R_AARCH64_LD_PREL_LO19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD_PREL_LO19"; + case ((ulong)ElfNative.R_AARCH64_ADR_PREL_LO21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_LO21"; + case ((ulong)ElfNative.R_AARCH64_ADR_PREL_PG_HI21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_PG_HI21"; + case ((ulong)ElfNative.R_AARCH64_ADR_PREL_PG_HI21_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_PG_HI21_NC"; + case ((ulong)ElfNative.R_AARCH64_ADD_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADD_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_LDST8_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST8_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TSTBR14 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TSTBR14"; + case ((ulong)ElfNative.R_AARCH64_CONDBR19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_CONDBR19"; + case ((ulong)ElfNative.R_AARCH64_JUMP26 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_JUMP26"; + case ((ulong)ElfNative.R_AARCH64_CALL26 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_CALL26"; + case ((ulong)ElfNative.R_AARCH64_LDST16_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST16_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_LDST32_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST32_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_LDST64_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST64_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G0"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G1"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G1_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G2"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G2_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G3"; + case ((ulong)ElfNative.R_AARCH64_LDST128_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST128_ABS_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G0"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G1"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G1_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G2"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G2_NC"; + case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G3"; + case ((ulong)ElfNative.R_AARCH64_GOTREL64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOTREL64"; + case ((ulong)ElfNative.R_AARCH64_GOTREL32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOTREL32"; + case ((ulong)ElfNative.R_AARCH64_GOT_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOT_LD_PREL19"; + case ((ulong)ElfNative.R_AARCH64_LD64_GOTOFF_LO15 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOTOFF_LO15"; + case ((ulong)ElfNative.R_AARCH64_ADR_GOT_PAGE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_GOT_PAGE"; + case ((ulong)ElfNative.R_AARCH64_LD64_GOT_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOT_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_LD64_GOTPAGE_LO15 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOTPAGE_LO15"; + case ((ulong)ElfNative.R_AARCH64_TLSGD_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADR_PREL21"; + case ((ulong)ElfNative.R_AARCH64_TLSGD_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADR_PAGE21"; + case ((ulong)ElfNative.R_AARCH64_TLSGD_ADD_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADD_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSGD_MOVW_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_MOVW_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSGD_MOVW_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_MOVW_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADR_PREL21"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADR_PAGE21"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LD_PREL19"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G2"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G0"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_HI12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_HI12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST8_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST16_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST32_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST64_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_MOVW_GOTTPREL_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21"; + case ((ulong)ElfNative.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_LD_GOTTPREL_PREL19"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G2"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G1_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G0"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_HI12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST8_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST16_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST32_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST64_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LD_PREL19"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADR_PREL21"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADR_PAGE21"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_LD64_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LD64_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADD_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADD_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_OFF_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_OFF_G1"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_OFF_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_OFF_G0_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_LDR << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LDR"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADD"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC_CALL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_CALL"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST128_TPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST128_DTPREL_LO12"; + case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC"; + case ((ulong)ElfNative.R_AARCH64_COPY << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_COPY"; + case ((ulong)ElfNative.R_AARCH64_GLOB_DAT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GLOB_DAT"; + case ((ulong)ElfNative.R_AARCH64_JUMP_SLOT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_JUMP_SLOT"; + case ((ulong)ElfNative.R_AARCH64_RELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_RELATIVE"; + case ((ulong)ElfNative.R_AARCH64_TLS_DTPMOD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_DTPMOD"; + case ((ulong)ElfNative.R_AARCH64_TLS_DTPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_DTPREL"; + case ((ulong)ElfNative.R_AARCH64_TLS_TPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_TPREL"; + case ((ulong)ElfNative.R_AARCH64_TLSDESC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC"; + case ((ulong)ElfNative.R_AARCH64_IRELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_IRELATIVE"; + case ((ulong)ElfNative.R_ARM_NONE << 16) | ElfNative.EM_ARM : return "R_ARM_NONE"; + case ((ulong)ElfNative.R_ARM_PC24 << 16) | ElfNative.EM_ARM : return "R_ARM_PC24"; + case ((ulong)ElfNative.R_ARM_ABS32 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS32"; + case ((ulong)ElfNative.R_ARM_REL32 << 16) | ElfNative.EM_ARM : return "R_ARM_REL32"; + case ((ulong)ElfNative.R_ARM_PC13 << 16) | ElfNative.EM_ARM : return "R_ARM_PC13"; + case ((ulong)ElfNative.R_ARM_ABS16 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS16"; + case ((ulong)ElfNative.R_ARM_ABS12 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS12"; + case ((ulong)ElfNative.R_ARM_THM_ABS5 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_ABS5"; + case ((ulong)ElfNative.R_ARM_ABS8 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS8"; + case ((ulong)ElfNative.R_ARM_SBREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_SBREL32"; + case ((ulong)ElfNative.R_ARM_THM_PC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC22"; + case ((ulong)ElfNative.R_ARM_THM_PC8 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC8"; + case ((ulong)ElfNative.R_ARM_AMP_VCALL9 << 16) | ElfNative.EM_ARM : return "R_ARM_AMP_VCALL9"; + case ((ulong)ElfNative.R_ARM_SWI24 << 16) | ElfNative.EM_ARM : return "R_ARM_SWI24"; + case ((ulong)ElfNative.R_ARM_THM_SWI8 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_SWI8"; + case ((ulong)ElfNative.R_ARM_XPC25 << 16) | ElfNative.EM_ARM : return "R_ARM_XPC25"; + case ((ulong)ElfNative.R_ARM_THM_XPC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_XPC22"; + case ((ulong)ElfNative.R_ARM_TLS_DTPMOD32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DTPMOD32"; + case ((ulong)ElfNative.R_ARM_TLS_DTPOFF32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DTPOFF32"; + case ((ulong)ElfNative.R_ARM_TLS_TPOFF32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_TPOFF32"; + case ((ulong)ElfNative.R_ARM_COPY << 16) | ElfNative.EM_ARM : return "R_ARM_COPY"; + case ((ulong)ElfNative.R_ARM_GLOB_DAT << 16) | ElfNative.EM_ARM : return "R_ARM_GLOB_DAT"; + case ((ulong)ElfNative.R_ARM_JUMP_SLOT << 16) | ElfNative.EM_ARM : return "R_ARM_JUMP_SLOT"; + case ((ulong)ElfNative.R_ARM_RELATIVE << 16) | ElfNative.EM_ARM : return "R_ARM_RELATIVE"; + case ((ulong)ElfNative.R_ARM_GOTOFF << 16) | ElfNative.EM_ARM : return "R_ARM_GOTOFF"; + case ((ulong)ElfNative.R_ARM_GOTPC << 16) | ElfNative.EM_ARM : return "R_ARM_GOTPC"; + case ((ulong)ElfNative.R_ARM_GOT32 << 16) | ElfNative.EM_ARM : return "R_ARM_GOT32"; + case ((ulong)ElfNative.R_ARM_PLT32 << 16) | ElfNative.EM_ARM : return "R_ARM_PLT32"; + case ((ulong)ElfNative.R_ARM_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_CALL"; + case ((ulong)ElfNative.R_ARM_JUMP24 << 16) | ElfNative.EM_ARM : return "R_ARM_JUMP24"; + case ((ulong)ElfNative.R_ARM_THM_JUMP24 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP24"; + case ((ulong)ElfNative.R_ARM_BASE_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_BASE_ABS"; + case ((ulong)ElfNative.R_ARM_ALU_PCREL_7_0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_7_0"; + case ((ulong)ElfNative.R_ARM_ALU_PCREL_15_8 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_15_8"; + case ((ulong)ElfNative.R_ARM_ALU_PCREL_23_15 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_23_15"; + case ((ulong)ElfNative.R_ARM_LDR_SBREL_11_0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SBREL_11_0"; + case ((ulong)ElfNative.R_ARM_ALU_SBREL_19_12 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SBREL_19_12"; + case ((ulong)ElfNative.R_ARM_ALU_SBREL_27_20 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SBREL_27_20"; + case ((ulong)ElfNative.R_ARM_TARGET1 << 16) | ElfNative.EM_ARM : return "R_ARM_TARGET1"; + case ((ulong)ElfNative.R_ARM_SBREL31 << 16) | ElfNative.EM_ARM : return "R_ARM_SBREL31"; + case ((ulong)ElfNative.R_ARM_V4BX << 16) | ElfNative.EM_ARM : return "R_ARM_V4BX"; + case ((ulong)ElfNative.R_ARM_TARGET2 << 16) | ElfNative.EM_ARM : return "R_ARM_TARGET2"; + case ((ulong)ElfNative.R_ARM_PREL31 << 16) | ElfNative.EM_ARM : return "R_ARM_PREL31"; + case ((ulong)ElfNative.R_ARM_MOVW_ABS_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_ABS_NC"; + case ((ulong)ElfNative.R_ARM_MOVT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_ABS"; + case ((ulong)ElfNative.R_ARM_MOVW_PREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_PREL_NC"; + case ((ulong)ElfNative.R_ARM_MOVT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_PREL"; + case ((ulong)ElfNative.R_ARM_THM_MOVW_ABS_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_ABS_NC"; + case ((ulong)ElfNative.R_ARM_THM_MOVT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_ABS"; + case ((ulong)ElfNative.R_ARM_THM_MOVW_PREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_PREL_NC"; + case ((ulong)ElfNative.R_ARM_THM_MOVT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_PREL"; + case ((ulong)ElfNative.R_ARM_THM_JUMP19 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP19"; + case ((ulong)ElfNative.R_ARM_THM_JUMP6 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP6"; + case ((ulong)ElfNative.R_ARM_THM_ALU_PREL_11_0 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_ALU_PREL_11_0"; + case ((ulong)ElfNative.R_ARM_THM_PC12 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC12"; + case ((ulong)ElfNative.R_ARM_ABS32_NOI << 16) | ElfNative.EM_ARM : return "R_ARM_ABS32_NOI"; + case ((ulong)ElfNative.R_ARM_REL32_NOI << 16) | ElfNative.EM_ARM : return "R_ARM_REL32_NOI"; + case ((ulong)ElfNative.R_ARM_ALU_PC_G0_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G0_NC"; + case ((ulong)ElfNative.R_ARM_ALU_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G0"; + case ((ulong)ElfNative.R_ARM_ALU_PC_G1_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G1_NC"; + case ((ulong)ElfNative.R_ARM_ALU_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G1"; + case ((ulong)ElfNative.R_ARM_ALU_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G2"; + case ((ulong)ElfNative.R_ARM_LDR_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_PC_G1"; + case ((ulong)ElfNative.R_ARM_LDR_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_PC_G2"; + case ((ulong)ElfNative.R_ARM_LDRS_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G0"; + case ((ulong)ElfNative.R_ARM_LDRS_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G1"; + case ((ulong)ElfNative.R_ARM_LDRS_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G2"; + case ((ulong)ElfNative.R_ARM_LDC_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G0"; + case ((ulong)ElfNative.R_ARM_LDC_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G1"; + case ((ulong)ElfNative.R_ARM_LDC_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G2"; + case ((ulong)ElfNative.R_ARM_ALU_SB_G0_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G0_NC"; + case ((ulong)ElfNative.R_ARM_ALU_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G0"; + case ((ulong)ElfNative.R_ARM_ALU_SB_G1_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G1_NC"; + case ((ulong)ElfNative.R_ARM_ALU_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G1"; + case ((ulong)ElfNative.R_ARM_ALU_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G2"; + case ((ulong)ElfNative.R_ARM_LDR_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G0"; + case ((ulong)ElfNative.R_ARM_LDR_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G1"; + case ((ulong)ElfNative.R_ARM_LDR_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G2"; + case ((ulong)ElfNative.R_ARM_LDRS_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G0"; + case ((ulong)ElfNative.R_ARM_LDRS_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G1"; + case ((ulong)ElfNative.R_ARM_LDRS_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G2"; + case ((ulong)ElfNative.R_ARM_LDC_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G0"; + case ((ulong)ElfNative.R_ARM_LDC_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G1"; + case ((ulong)ElfNative.R_ARM_LDC_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G2"; + case ((ulong)ElfNative.R_ARM_MOVW_BREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_BREL_NC"; + case ((ulong)ElfNative.R_ARM_MOVT_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_BREL"; + case ((ulong)ElfNative.R_ARM_MOVW_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_BREL"; + case ((ulong)ElfNative.R_ARM_THM_MOVW_BREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_BREL_NC"; + case ((ulong)ElfNative.R_ARM_THM_MOVT_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_BREL"; + case ((ulong)ElfNative.R_ARM_THM_MOVW_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_BREL"; + case ((ulong)ElfNative.R_ARM_TLS_GOTDESC << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_GOTDESC"; + case ((ulong)ElfNative.R_ARM_TLS_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_CALL"; + case ((ulong)ElfNative.R_ARM_TLS_DESCSEQ << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DESCSEQ"; + case ((ulong)ElfNative.R_ARM_THM_TLS_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_CALL"; + case ((ulong)ElfNative.R_ARM_PLT32_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_PLT32_ABS"; + case ((ulong)ElfNative.R_ARM_GOT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_ABS"; + case ((ulong)ElfNative.R_ARM_GOT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_PREL"; + case ((ulong)ElfNative.R_ARM_GOT_BREL12 << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_BREL12"; + case ((ulong)ElfNative.R_ARM_GOTOFF12 << 16) | ElfNative.EM_ARM : return "R_ARM_GOTOFF12"; + case ((ulong)ElfNative.R_ARM_GOTRELAX << 16) | ElfNative.EM_ARM : return "R_ARM_GOTRELAX"; + case ((ulong)ElfNative.R_ARM_GNU_VTENTRY << 16) | ElfNative.EM_ARM : return "R_ARM_GNU_VTENTRY"; + case ((ulong)ElfNative.R_ARM_GNU_VTINHERIT << 16) | ElfNative.EM_ARM : return "R_ARM_GNU_VTINHERIT"; + case ((ulong)ElfNative.R_ARM_THM_PC11 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC11"; + case ((ulong)ElfNative.R_ARM_THM_PC9 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC9"; + case ((ulong)ElfNative.R_ARM_TLS_GD32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_GD32"; + case ((ulong)ElfNative.R_ARM_TLS_LDM32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDM32"; + case ((ulong)ElfNative.R_ARM_TLS_LDO32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDO32"; + case ((ulong)ElfNative.R_ARM_TLS_IE32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_IE32"; + case ((ulong)ElfNative.R_ARM_TLS_LE32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LE32"; + case ((ulong)ElfNative.R_ARM_TLS_LDO12 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDO12"; + case ((ulong)ElfNative.R_ARM_TLS_LE12 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LE12"; + case ((ulong)ElfNative.R_ARM_TLS_IE12GP << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_IE12GP"; + case ((ulong)ElfNative.R_ARM_ME_TOO << 16) | ElfNative.EM_ARM : return "R_ARM_ME_TOO"; + case ((ulong)ElfNative.R_ARM_THM_TLS_DESCSEQ << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_DESCSEQ"; + case ((ulong)ElfNative.R_ARM_THM_TLS_DESCSEQ32 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_DESCSEQ32"; + case ((ulong)ElfNative.R_ARM_THM_GOT_BREL12 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_GOT_BREL12"; + case ((ulong)ElfNative.R_ARM_IRELATIVE << 16) | ElfNative.EM_ARM : return "R_ARM_IRELATIVE"; + case ((ulong)ElfNative.R_ARM_RXPC25 << 16) | ElfNative.EM_ARM : return "R_ARM_RXPC25"; + case ((ulong)ElfNative.R_ARM_RSBREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_RSBREL32"; + case ((ulong)ElfNative.R_ARM_THM_RPC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_RPC22"; + case ((ulong)ElfNative.R_ARM_RREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_RREL32"; + case ((ulong)ElfNative.R_ARM_RABS22 << 16) | ElfNative.EM_ARM : return "R_ARM_RABS22"; + case ((ulong)ElfNative.R_ARM_RPC24 << 16) | ElfNative.EM_ARM : return "R_ARM_RPC24"; + case ((ulong)ElfNative.R_ARM_RBASE << 16) | ElfNative.EM_ARM : return "R_ARM_RBASE"; + case ((ulong)ElfNative.R_X86_64_NONE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_NONE"; + case ((ulong)ElfNative.R_X86_64_64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_64"; + case ((ulong)ElfNative.R_X86_64_PC32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC32"; + case ((ulong)ElfNative.R_X86_64_GOT32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOT32"; + case ((ulong)ElfNative.R_X86_64_PLT32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PLT32"; + case ((ulong)ElfNative.R_X86_64_COPY << 16) | ElfNative.EM_X86_64 : return "R_X86_64_COPY"; + case ((ulong)ElfNative.R_X86_64_GLOB_DAT << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GLOB_DAT"; + case ((ulong)ElfNative.R_X86_64_JUMP_SLOT << 16) | ElfNative.EM_X86_64 : return "R_X86_64_JUMP_SLOT"; + case ((ulong)ElfNative.R_X86_64_RELATIVE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_RELATIVE"; + case ((ulong)ElfNative.R_X86_64_GOTPCREL << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPCREL"; + case ((ulong)ElfNative.R_X86_64_32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_32"; + case ((ulong)ElfNative.R_X86_64_32S << 16) | ElfNative.EM_X86_64 : return "R_X86_64_32S"; + case ((ulong)ElfNative.R_X86_64_16 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_16"; + case ((ulong)ElfNative.R_X86_64_PC16 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC16"; + case ((ulong)ElfNative.R_X86_64_8 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_8"; + case ((ulong)ElfNative.R_X86_64_PC8 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC8"; + case ((ulong)ElfNative.R_X86_64_DTPMOD64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPMOD64"; + case ((ulong)ElfNative.R_X86_64_DTPOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPOFF64"; + case ((ulong)ElfNative.R_X86_64_TPOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TPOFF64"; + case ((ulong)ElfNative.R_X86_64_TLSGD << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSGD"; + case ((ulong)ElfNative.R_X86_64_TLSLD << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSLD"; + case ((ulong)ElfNative.R_X86_64_DTPOFF32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPOFF32"; + case ((ulong)ElfNative.R_X86_64_GOTTPOFF << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTTPOFF"; + case ((ulong)ElfNative.R_X86_64_TPOFF32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TPOFF32"; + case ((ulong)ElfNative.R_X86_64_PC64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC64"; + case ((ulong)ElfNative.R_X86_64_GOTOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTOFF64"; + case ((ulong)ElfNative.R_X86_64_GOTPC32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC32"; + case ((ulong)ElfNative.R_X86_64_GOT64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOT64"; + case ((ulong)ElfNative.R_X86_64_GOTPCREL64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPCREL64"; + case ((ulong)ElfNative.R_X86_64_GOTPC64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC64"; + case ((ulong)ElfNative.R_X86_64_GOTPLT64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPLT64"; + case ((ulong)ElfNative.R_X86_64_PLTOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PLTOFF64"; + case ((ulong)ElfNative.R_X86_64_SIZE32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_SIZE32"; + case ((ulong)ElfNative.R_X86_64_SIZE64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_SIZE64"; + case ((ulong)ElfNative.R_X86_64_GOTPC32_TLSDESC << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC32_TLSDESC"; + case ((ulong)ElfNative.R_X86_64_TLSDESC_CALL << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSDESC_CALL"; + case ((ulong)ElfNative.R_X86_64_TLSDESC << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSDESC"; + case ((ulong)ElfNative.R_X86_64_IRELATIVE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_IRELATIVE"; + case ((ulong)ElfNative.R_X86_64_RELATIVE64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_RELATIVE64"; + default: return null; + } + } + } + + public readonly partial struct ElfNoteTypeEx + { + /// + /// Contains copy of prstatus struct + /// + public static readonly ElfNoteTypeEx PRSTATUS = new ElfNoteTypeEx(ElfNative.NT_PRSTATUS); + + /// + /// Contains copy of fpregset struct + /// + public static readonly ElfNoteTypeEx FPREGSET = new ElfNoteTypeEx(ElfNative.NT_FPREGSET); + + /// + /// Contains copy of prpsinfo struct + /// + public static readonly ElfNoteTypeEx PRPSINFO = new ElfNoteTypeEx(ElfNative.NT_PRPSINFO); + + /// + /// Contains copy of prxregset struct + /// + public static readonly ElfNoteTypeEx PRXREG = new ElfNoteTypeEx(ElfNative.NT_PRXREG); + + /// + /// Contains copy of task structure + /// + public static readonly ElfNoteTypeEx TASKSTRUCT = new ElfNoteTypeEx(ElfNative.NT_TASKSTRUCT); + + /// + /// String from sysinfo(SI_PLATFORM) + /// + public static readonly ElfNoteTypeEx PLATFORM = new ElfNoteTypeEx(ElfNative.NT_PLATFORM); + + /// + /// Contains copy of auxv array + /// + public static readonly ElfNoteTypeEx AUXV = new ElfNoteTypeEx(ElfNative.NT_AUXV); + + /// + /// Contains copy of gwindows struct + /// + public static readonly ElfNoteTypeEx GWINDOWS = new ElfNoteTypeEx(ElfNative.NT_GWINDOWS); + + /// + /// Contains copy of asrset struct + /// + public static readonly ElfNoteTypeEx ASRS = new ElfNoteTypeEx(ElfNative.NT_ASRS); + + /// + /// Contains copy of pstatus struct + /// + public static readonly ElfNoteTypeEx PSTATUS = new ElfNoteTypeEx(ElfNative.NT_PSTATUS); + + /// + /// Contains copy of psinfo struct + /// + public static readonly ElfNoteTypeEx PSINFO = new ElfNoteTypeEx(ElfNative.NT_PSINFO); + + /// + /// Contains copy of prcred struct + /// + public static readonly ElfNoteTypeEx PRCRED = new ElfNoteTypeEx(ElfNative.NT_PRCRED); + + /// + /// Contains copy of utsname struct + /// + public static readonly ElfNoteTypeEx UTSNAME = new ElfNoteTypeEx(ElfNative.NT_UTSNAME); + + /// + /// Contains copy of lwpstatus struct + /// + public static readonly ElfNoteTypeEx LWPSTATUS = new ElfNoteTypeEx(ElfNative.NT_LWPSTATUS); + + /// + /// Contains copy of lwpinfo struct + /// + public static readonly ElfNoteTypeEx LWPSINFO = new ElfNoteTypeEx(ElfNative.NT_LWPSINFO); + + /// + /// Contains copy of fprxregset struct + /// + public static readonly ElfNoteTypeEx PRFPXREG = new ElfNoteTypeEx(ElfNative.NT_PRFPXREG); + + /// + /// Contains copy of siginfo_t, size might increase + /// + public static readonly ElfNoteTypeEx SIGINFO = new ElfNoteTypeEx(ElfNative.NT_SIGINFO); + + /// + /// Contains information about mapped files + /// + public static readonly ElfNoteTypeEx FILE = new ElfNoteTypeEx(ElfNative.NT_FILE); + + /// + /// Contains copy of user_fxsr_struct + /// + public static readonly ElfNoteTypeEx PRXFPREG = new ElfNoteTypeEx(ElfNative.NT_PRXFPREG); + + /// + /// PowerPC Altivec/VMX registers + /// + public static readonly ElfNoteTypeEx PPC_VMX = new ElfNoteTypeEx(ElfNative.NT_PPC_VMX); + + /// + /// PowerPC SPE/EVR registers + /// + public static readonly ElfNoteTypeEx PPC_SPE = new ElfNoteTypeEx(ElfNative.NT_PPC_SPE); + + /// + /// PowerPC VSX registers + /// + public static readonly ElfNoteTypeEx PPC_VSX = new ElfNoteTypeEx(ElfNative.NT_PPC_VSX); + + /// + /// i386 TLS slots (struct user_desc) + /// + public static readonly ElfNoteTypeEx I386_TLS = new ElfNoteTypeEx(ElfNative.NT_386_TLS); + + /// + /// x86 io permission bitmap (1=deny) + /// + public static readonly ElfNoteTypeEx I386_IOPERM = new ElfNoteTypeEx(ElfNative.NT_386_IOPERM); + + /// + /// x86 extended state using xsave + /// + public static readonly ElfNoteTypeEx X86_XSTATE = new ElfNoteTypeEx(ElfNative.NT_X86_XSTATE); + + /// + /// s390 upper register halves + /// + public static readonly ElfNoteTypeEx S390_HIGH_GPRS = new ElfNoteTypeEx(ElfNative.NT_S390_HIGH_GPRS); + + /// + /// s390 timer register + /// + public static readonly ElfNoteTypeEx S390_TIMER = new ElfNoteTypeEx(ElfNative.NT_S390_TIMER); + + /// + /// s390 TOD clock comparator register + /// + public static readonly ElfNoteTypeEx S390_TODCMP = new ElfNoteTypeEx(ElfNative.NT_S390_TODCMP); + + /// + /// s390 TOD programmable register + /// + public static readonly ElfNoteTypeEx S390_TODPREG = new ElfNoteTypeEx(ElfNative.NT_S390_TODPREG); + + /// + /// s390 control registers + /// + public static readonly ElfNoteTypeEx S390_CTRS = new ElfNoteTypeEx(ElfNative.NT_S390_CTRS); + + /// + /// s390 prefix register + /// + public static readonly ElfNoteTypeEx S390_PREFIX = new ElfNoteTypeEx(ElfNative.NT_S390_PREFIX); + + /// + /// s390 breaking event address + /// + public static readonly ElfNoteTypeEx S390_LAST_BREAK = new ElfNoteTypeEx(ElfNative.NT_S390_LAST_BREAK); + + /// + /// s390 system call restart data + /// + public static readonly ElfNoteTypeEx S390_SYSTEM_CALL = new ElfNoteTypeEx(ElfNative.NT_S390_SYSTEM_CALL); + + /// + /// s390 transaction diagnostic block + /// + public static readonly ElfNoteTypeEx S390_TDB = new ElfNoteTypeEx(ElfNative.NT_S390_TDB); + + /// + /// ARM VFP/NEON registers + /// + public static readonly ElfNoteTypeEx ARM_VFP = new ElfNoteTypeEx(ElfNative.NT_ARM_VFP); + + /// + /// ARM TLS register + /// + public static readonly ElfNoteTypeEx ARM_TLS = new ElfNoteTypeEx(ElfNative.NT_ARM_TLS); + + /// + /// ARM hardware breakpoint registers + /// + public static readonly ElfNoteTypeEx ARM_HW_BREAK = new ElfNoteTypeEx(ElfNative.NT_ARM_HW_BREAK); + + /// + /// ARM hardware watchpoint registers + /// + public static readonly ElfNoteTypeEx ARM_HW_WATCH = new ElfNoteTypeEx(ElfNative.NT_ARM_HW_WATCH); + + /// + /// Contains a version string. + /// + public static readonly ElfNoteTypeEx VERSION = new ElfNoteTypeEx(ElfNative.NT_VERSION); + + public static readonly ElfNoteTypeEx GNU_ABI_TAG = new ElfNoteTypeEx(ElfNative.NT_GNU_ABI_TAG); + + public static readonly ElfNoteTypeEx GNU_HWCAP = new ElfNoteTypeEx(ElfNative.NT_GNU_HWCAP); + + public static readonly ElfNoteTypeEx GNU_BUILD_ID = new ElfNoteTypeEx(ElfNative.NT_GNU_BUILD_ID); + + public static readonly ElfNoteTypeEx GNU_GOLD_VERSION = new ElfNoteTypeEx(ElfNative.NT_GNU_GOLD_VERSION); + + private string ToStringInternal() + { + switch ((uint)Value) + { + case ElfNative.NT_PRSTATUS: return "NT_PRSTATUS"; + case ElfNative.NT_FPREGSET: return "NT_FPREGSET"; + case ElfNative.NT_PRPSINFO: return "NT_PRPSINFO"; + case ElfNative.NT_PRXREG: return "NT_PRXREG"; + case ElfNative.NT_PLATFORM: return "NT_PLATFORM"; + case ElfNative.NT_AUXV: return "NT_AUXV"; + case ElfNative.NT_GWINDOWS: return "NT_GWINDOWS"; + case ElfNative.NT_ASRS: return "NT_ASRS"; + case ElfNative.NT_PSTATUS: return "NT_PSTATUS"; + case ElfNative.NT_PSINFO: return "NT_PSINFO"; + case ElfNative.NT_PRCRED: return "NT_PRCRED"; + case ElfNative.NT_UTSNAME: return "NT_UTSNAME"; + case ElfNative.NT_LWPSTATUS: return "NT_LWPSTATUS"; + case ElfNative.NT_LWPSINFO: return "NT_LWPSINFO"; + case ElfNative.NT_PRFPXREG: return "NT_PRFPXREG"; + case ElfNative.NT_SIGINFO: return "NT_SIGINFO"; + case ElfNative.NT_FILE: return "NT_FILE"; + case ElfNative.NT_PRXFPREG: return "NT_PRXFPREG"; + case ElfNative.NT_PPC_VMX: return "NT_PPC_VMX"; + case ElfNative.NT_PPC_SPE: return "NT_PPC_SPE"; + case ElfNative.NT_PPC_VSX: return "NT_PPC_VSX"; + case ElfNative.NT_386_TLS: return "NT_386_TLS"; + case ElfNative.NT_386_IOPERM: return "NT_386_IOPERM"; + case ElfNative.NT_X86_XSTATE: return "NT_X86_XSTATE"; + case ElfNative.NT_S390_HIGH_GPRS: return "NT_S390_HIGH_GPRS"; + case ElfNative.NT_S390_TIMER: return "NT_S390_TIMER"; + case ElfNative.NT_S390_TODCMP: return "NT_S390_TODCMP"; + case ElfNative.NT_S390_TODPREG: return "NT_S390_TODPREG"; + case ElfNative.NT_S390_CTRS: return "NT_S390_CTRS"; + case ElfNative.NT_S390_PREFIX: return "NT_S390_PREFIX"; + case ElfNative.NT_S390_LAST_BREAK: return "NT_S390_LAST_BREAK"; + case ElfNative.NT_S390_SYSTEM_CALL: return "NT_S390_SYSTEM_CALL"; + case ElfNative.NT_S390_TDB: return "NT_S390_TDB"; + case ElfNative.NT_ARM_VFP: return "NT_ARM_VFP"; + case ElfNative.NT_ARM_TLS: return "NT_ARM_TLS"; + case ElfNative.NT_ARM_HW_BREAK: return "NT_ARM_HW_BREAK"; + case ElfNative.NT_ARM_HW_WATCH: return "NT_ARM_HW_WATCH"; + default: return null; + } + } + } + + public enum ElfNoteType : uint + { + PRSTATUS = ElfNative.NT_PRSTATUS, + + FPREGSET = ElfNative.NT_FPREGSET, + + PRPSINFO = ElfNative.NT_PRPSINFO, + + PRXREG = ElfNative.NT_PRXREG, + + TASKSTRUCT = ElfNative.NT_TASKSTRUCT, + + PLATFORM = ElfNative.NT_PLATFORM, + + AUXV = ElfNative.NT_AUXV, + + GWINDOWS = ElfNative.NT_GWINDOWS, + + ASRS = ElfNative.NT_ASRS, + + PSTATUS = ElfNative.NT_PSTATUS, + + PSINFO = ElfNative.NT_PSINFO, + + PRCRED = ElfNative.NT_PRCRED, + + UTSNAME = ElfNative.NT_UTSNAME, + + LWPSTATUS = ElfNative.NT_LWPSTATUS, + + LWPSINFO = ElfNative.NT_LWPSINFO, + + PRFPXREG = ElfNative.NT_PRFPXREG, + + SIGINFO = ElfNative.NT_SIGINFO, + + FILE = ElfNative.NT_FILE, + + PRXFPREG = ElfNative.NT_PRXFPREG, + + PPC_VMX = ElfNative.NT_PPC_VMX, + + PPC_SPE = ElfNative.NT_PPC_SPE, + + PPC_VSX = ElfNative.NT_PPC_VSX, + + I386_TLS = ElfNative.NT_386_TLS, + + I386_IOPERM = ElfNative.NT_386_IOPERM, + + X86_XSTATE = ElfNative.NT_X86_XSTATE, + + S390_HIGH_GPRS = ElfNative.NT_S390_HIGH_GPRS, + + S390_TIMER = ElfNative.NT_S390_TIMER, + + S390_TODCMP = ElfNative.NT_S390_TODCMP, + + S390_TODPREG = ElfNative.NT_S390_TODPREG, + + S390_CTRS = ElfNative.NT_S390_CTRS, + + S390_PREFIX = ElfNative.NT_S390_PREFIX, + + S390_LAST_BREAK = ElfNative.NT_S390_LAST_BREAK, + + S390_SYSTEM_CALL = ElfNative.NT_S390_SYSTEM_CALL, + + S390_TDB = ElfNative.NT_S390_TDB, + + ARM_VFP = ElfNative.NT_ARM_VFP, + + ARM_TLS = ElfNative.NT_ARM_TLS, + + ARM_HW_BREAK = ElfNative.NT_ARM_HW_BREAK, + + ARM_HW_WATCH = ElfNative.NT_ARM_HW_WATCH, + + VERSION = ElfNative.NT_VERSION, + + GNU_ABI_TAG = ElfNative.NT_GNU_ABI_TAG, + + GNU_HWCAP = ElfNative.NT_GNU_HWCAP, + + GNU_BUILD_ID = ElfNative.NT_GNU_BUILD_ID, + + GNU_GOLD_VERSION = ElfNative.NT_GNU_GOLD_VERSION, + } +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml b/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml new file mode 100644 index 00000000000000..b6e2c66ab4186f --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml @@ -0,0 +1,9 @@ +# configuration file for dotnet-releaser +[msbuild] +project = "LibObjectFile.sln" +build_debug = true +[test] +run_tests_for_debug = true +[github] +user = "xoofx" +repo = "LibObjectFile" diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs new file mode 100644 index 00000000000000..2f5ea0cdb82088 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs @@ -0,0 +1,180 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Iced.Intel; +using LibObjectFile.Ar; +using LibObjectFile.Elf; +using Decoder = Iced.Intel.Decoder; + +namespace LibObjectFile.Disasm +{ + public class ObjDisasmApp + { + public ObjDisasmApp() + { + FunctionRegexFilters = new List(); + Files = new List(); + Output = Console.Out; + } + + public List FunctionRegexFilters { get; } + + public List Files { get; } + + public bool Verbose { get; set; } + + public bool Listing { get; set; } + + public TextWriter Output { get; set; } + + public void Run() + { + foreach (var file in Files) + { + using var stream = new FileStream(file, FileMode.Open, FileAccess.Read); + + if (ArArchiveFile.IsAr(stream)) + { + var options = new ArArchiveFileReaderOptions(ArArchiveKind.GNU); + + var archive = ArArchiveFile.Read(stream, options); + + foreach (var objFile in archive.Files) + { + if (objFile is ArElfFile elfFile) + { + ProcessElf(objFile.Name, elfFile.ElfObjectFile); + } + } + } + else if (ElfObjectFile.IsElf(stream)) + { + var elfObjectFile = ElfObjectFile.Read(stream, new ElfReaderOptions() {ReadOnly = true}); + ProcessElf(Path.GetFileName(file), elfObjectFile); + } + } + } + + private void ProcessElf(string name, ElfObjectFile elfObjectFile) + { + foreach(var symbolTable in elfObjectFile.Sections.OfType()) + { + foreach(var symbol in symbolTable.Entries) + { + if (symbol.Type != ElfSymbolType.Function) continue; + if (symbol.Bind == ElfSymbolBind.Local) continue; + + if (FunctionRegexFilters.Count > 0) + { + foreach (var functionRegexFilter in FunctionRegexFilters) + { + if (functionRegexFilter.Match(symbol.Name).Success) + { + DumpFunction(symbol); + break; + } + } + } + else + { + DumpFunction(symbol); + } + } + } + } + + private void DumpFunction(ElfSymbol symbol) + { + var functionSize = symbol.Size; + var section = symbol.Section.Section; + Output.WriteLine($"Function: {symbol.Name}"); + + if (section is ElfBinarySection binarySection) + { + binarySection.Stream.Position = (long)symbol.Value; + + Disasm(binarySection.Stream, (uint)functionSize, Output); + Output.WriteLine(); + } + } + + private static void Disasm(Stream stream, uint size, TextWriter writer, Formatter formatter = null) + { + var buffer = ArrayPool.Shared.Rent((int)size); + var startPosition = stream.Position; + stream.Read(buffer, 0, (int) size); + stream.Position = startPosition; + + // You can also pass in a hex string, eg. "90 91 929394", or you can use your own CodeReader + // reading data from a file or memory etc + var codeReader = new StreamCodeReader(stream, size); + var decoder = Decoder.Create(IntPtr.Size * 8, codeReader); + decoder.IP = (ulong) 0; + ulong endRip = decoder.IP + (uint)size; + + // This list is faster than List since it uses refs to the Instructions + // instead of copying them (each Instruction is 32 bytes in size). It has a ref indexer, + // and a ref iterator. Add() uses 'in' (ref readonly). + var instructions = new InstructionList(); + while (decoder.IP < endRip) + { + // The method allocates an uninitialized element at the end of the list and + // returns a reference to it which is initialized by Decode(). + decoder.Decode(out instructions.AllocUninitializedElement()); + } + + // Formatters: Masm*, Nasm* and Gas* (AT&T) + if (formatter == null) + { + formatter = new NasmFormatter(); + formatter.Options.DigitSeparator = ""; + formatter.Options.FirstOperandCharIndex = 10; + } + + var output = new StringOutput(); + // Use InstructionList's ref iterator (C# 7.3) to prevent copying 32 bytes every iteration + foreach (ref var instr in instructions) + { + // Don't use instr.ToString(), it allocates more, uses masm syntax and default options + formatter.Format(instr, output); + writer.Write($"{instr.IP:X16} "); + for (int i = 0; i < instr.Length; i++) + { + writer.Write(buffer[(int)instr.IP + i].ToString("X2")); + } + writer.Write(new string(' ', 16 * 2 - instr.Length * 2)); + writer.WriteLine($"{output.ToStringAndReset()}"); + } + } + + private class StreamCodeReader : CodeReader + { + private readonly Stream _stream; + private long _size; + + public StreamCodeReader(Stream stream, uint size) + { + _stream = stream; + _size = size; + } + + public override int ReadByte() + { + if (_size < 0) + { + return -1; + } + + _size--; + return _stream.ReadByte(); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs new file mode 100644 index 00000000000000..56dcba718e3fc1 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs @@ -0,0 +1,87 @@ +using System; +using System.IO; +using System.Text.RegularExpressions; +using Mono.Options; + +namespace LibObjectFile.Disasm +{ + /// + /// A minimalistic program to disassemble functions in .a and ELF files + /// TODO: handle correctly RIP, labels, relocation...etc. + /// + class Program + { + static int Main(string[] args) + { + + var exeName = Path.GetFileNameWithoutExtension(typeof(Program).Assembly.Location); + bool showHelp = false; + + + var objDisasmApp = new ObjDisasmApp(); + + var _ = string.Empty; + var options = new OptionSet + { + "Copyright (C) 2019 Alexandre Mutel. All Rights Reserved", + $"{exeName} - Version: " + + + $"{typeof(Program).Assembly.GetName().Version.Major}.{typeof(Program).Assembly.GetName().Version.Minor}.{typeof(Program).Assembly.GetName().Version.Build}" + string.Empty, + _, + $"Usage: {exeName} [options]+ [.o|.a files]", + _, + "Disassemble the global functions found in a list of ELF object .o files or archive `ar` files.", + _, + "## Options", + _, + {"f|func=", "Add a regex filtering for function symbols. Can add multiples.", v=> objDisasmApp.FunctionRegexFilters.Add(new Regex(v)) }, + {"l|list=", "List functions that can be decompiled.", v=> objDisasmApp.Listing = true}, + _, + {"h|help", "Show this message and exit", v => showHelp = true }, + {"v|verbose", "Show more verbose progress logs", v => objDisasmApp.Verbose = true }, + }; + + try + { + var files = options.Parse(args); + + if (showHelp) + { + options.WriteOptionDescriptions(Console.Out); + return 0; + } + + foreach (var file in files) + { + var filePath = Path.Combine(Environment.CurrentDirectory, file); + if (!File.Exists(filePath)) + { + throw new OptionException($"The file {file} does not exist", "[files]"); + } + + objDisasmApp.Files.Add(filePath); + } + + objDisasmApp.Run(); + } + catch (Exception exception) + { + if (exception is OptionException || exception is ObjectFileException) + { + var backColor = Console.ForegroundColor; + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(exception.Message); + Console.ForegroundColor = backColor; + Console.WriteLine("See --help for usage"); + return 1; + } + else + { + throw; + } + } + + return 0; + } + } +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj new file mode 100644 index 00000000000000..a5926ad96b0fc0 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj @@ -0,0 +1,19 @@ + + + + Exe + net6.0 + LibObjectFile.Disasm + false + + + + + + + + + + + + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh b/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh new file mode 100755 index 00000000000000..0f368076b1dc04 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +export TEST_TAG_NAME=libobjectfile-tests + +# To rebuild the image, simply delete the tag: +# docker rmi $TEST_TAG_NAME + +if [[ "$(docker images -q ${TEST_TAG_NAME}:latest 2> /dev/null)" == "" ]]; then + docker build -t ${TEST_TAG_NAME} . +fi + +# Run unit tests in Docker - See Dockerfile +docker run -v `pwd`:/src --rm -it ${TEST_TAG_NAME} + diff --git a/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln b/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln new file mode 100644 index 00000000000000..c2355ef7d1de9a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.32804.182 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.MachO", "Melanzana.MachO\Melanzana.MachO.csproj", "{22C66789-5A44-4C01-BFB8-8B10B45A2210}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.MachO.Tests", "Melanzana.MachO.Tests\Melanzana.MachO.Tests.csproj", "{B737E062-8A7C-48D2-8A51-645FA72FF378}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.BinaryFormat.Generator", "Melanzana.BinaryFormat.Generator\Melanzana.BinaryFormat.Generator.csproj", "{FD313869-B418-414C-BF94-357B82C5D6EB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.CodeSign", "Melanzana.CodeSign\Melanzana.CodeSign.csproj", "{727881F8-EBCD-42BD-97FE-BEE9917D4A5E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.CodeSign.Tests", "Melanzana.CodeSign.Tests\Melanzana.CodeSign.Tests.csproj", "{30D19045-7A46-4993-B018-1F60397A741D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Release|Any CPU.Build.0 = Release|Any CPU + {B737E062-8A7C-48D2-8A51-645FA72FF378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B737E062-8A7C-48D2-8A51-645FA72FF378}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B737E062-8A7C-48D2-8A51-645FA72FF378}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B737E062-8A7C-48D2-8A51-645FA72FF378}.Release|Any CPU.Build.0 = Release|Any CPU + {FD313869-B418-414C-BF94-357B82C5D6EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD313869-B418-414C-BF94-357B82C5D6EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD313869-B418-414C-BF94-357B82C5D6EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD313869-B418-414C-BF94-357B82C5D6EB}.Release|Any CPU.Build.0 = Release|Any CPU + {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Release|Any CPU.Build.0 = Release|Any CPU + {30D19045-7A46-4993-B018-1F60397A741D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30D19045-7A46-4993-B018-1F60397A741D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30D19045-7A46-4993-B018-1F60397A741D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30D19045-7A46-4993-B018-1F60397A741D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {833B1134-2178-41C7-B073-9287649F065E} + EndGlobalSection +EndGlobal diff --git a/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props b/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props new file mode 100644 index 00000000000000..334783c957d4ae --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props @@ -0,0 +1,13 @@ + + + true + true + true + snupkg + + + + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/LICENSE b/src/coreclr/tools/aot/external/Melanzana/LICENSE new file mode 100644 index 00000000000000..bfbd7349b9ddde --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Filip Navara + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs new file mode 100644 index 00000000000000..28504bf71a34fe --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Immutable; +using System.Diagnostics; +using Microsoft.CodeAnalysis; + +namespace BinaryFormat +{ + /// + /// Represents a member with no arguments, namely a field or property + /// + internal readonly struct DataMemberSymbol + { + private readonly ISymbol _symbol; + public DataMemberSymbol(ISymbol symbol) + { + Debug.Assert(symbol is + IFieldSymbol or + IPropertySymbol { Parameters: { Length: 0 }}); + _symbol = symbol; + } + + public ISymbol Symbol => _symbol; + + public ITypeSymbol Type => _symbol switch + { + IFieldSymbol f => f.Type, + IPropertySymbol p => p.Type, + _ => throw new InvalidOperationException() + }; + + public ImmutableArray Locations => _symbol.Locations; + + public string Name => _symbol.Name; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs new file mode 100644 index 00000000000000..00f30d345c9364 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Text; + +namespace BinaryFormat +{ + public partial class Generator : ISourceGenerator + { + private const string AttributeSource = @" +#nullable disable + +[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] +internal sealed class GenerateReaderWriterAttribute : System.Attribute +{ + public GenerateReaderWriterAttribute() {} +} + +[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] +internal sealed class BigEndianAttribute : System.Attribute +{ + public BigEndianAttribute() {} +} + +[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] +internal sealed class LittleEndianAttribute : System.Attribute +{ + public LittleEndianAttribute() {} +} +"; + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs new file mode 100644 index 00000000000000..8e8e780cf4ac0b --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs @@ -0,0 +1,367 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace BinaryFormat +{ + public partial class Generator : ISourceGenerator + { + private void GenerateReaderWriter( + GeneratorExecutionContext context, + TypeDeclarationSyntax typeDecl, + SemanticModel semanticModel) + { + if (!typeDecl.Modifiers.Any(tok => tok.IsKind(SyntaxKind.PartialKeyword))) + { + // Type must be partial + context.ReportDiagnostic( + Diagnostic.Create( + "TypeMustBePartial", + category: "BinaryFormat", + $"Type {typeDecl.Identifier.ValueText} must be partial", + severity: DiagnosticSeverity.Error, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + warningLevel: 0, + location: typeDecl.Identifier.GetLocation())); + return; + } + + var containerSymbol = semanticModel.GetDeclaredSymbol(typeDecl)!; + ITypeSymbol receiverType = containerSymbol; + + bool hasBigEndianAttribute = containerSymbol.GetAttributes().Any(a => a.AttributeClass.Name == "BigEndianAttribute"); + bool hasLittleEndianAttribute = containerSymbol.GetAttributes().Any(a => a.AttributeClass.Name == "LittleEndianAttribute"); + + var fieldsAndProps = receiverType.GetMembers() + .Where(m => m is { + DeclaredAccessibility: Accessibility.Public, + Kind: SymbolKind.Field or SymbolKind.Property, + }) + .Select(m => new DataMemberSymbol(m)).ToList(); + + var stringBuilder = new StringBuilder(); + string classOrStruct = typeDecl is ClassDeclarationSyntax ? "class" : "struct"; + + // FIXME: modifiers, class/struct/record + stringBuilder.AppendLine($"using System.Buffers.Binary;"); + stringBuilder.AppendLine($""); + stringBuilder.AppendLine($"namespace {containerSymbol.ContainingNamespace}"); + stringBuilder.AppendLine($"{{"); + stringBuilder.AppendLine($" public partial {classOrStruct} {typeDecl.Identifier}"); + stringBuilder.AppendLine($" {{"); + + // Try to generate the static size constant + GenerateBinarySize(context, typeDecl, semanticModel, stringBuilder, fieldsAndProps); + + if (hasLittleEndianAttribute && !hasBigEndianAttribute) + { + GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "", "LittleEndian", fieldsAndProps); + stringBuilder.AppendLine(); + GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "", "LittleEndian", fieldsAndProps); + } + else if (hasBigEndianAttribute && !hasLittleEndianAttribute) + { + GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "", "BigEndian", fieldsAndProps); + stringBuilder.AppendLine(); + GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "", "BigEndian", fieldsAndProps); + } + else + { + GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "LittleEndian", "LittleEndian", fieldsAndProps); + stringBuilder.AppendLine(); + GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "BigEndian", "BigEndian", fieldsAndProps); + stringBuilder.AppendLine(); + stringBuilder.AppendLine($" public static {typeDecl.Identifier} Read(ReadOnlySpan buffer, bool isLittleEndian, out int bytesRead)"); + stringBuilder.AppendLine($" {{"); + stringBuilder.AppendLine($" return isLittleEndian ? ReadLittleEndian(buffer, out bytesRead) : ReadBigEndian(buffer, out bytesRead);"); + stringBuilder.AppendLine($" }}"); + stringBuilder.AppendLine(); + GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "LittleEndian", "LittleEndian", fieldsAndProps); + stringBuilder.AppendLine(); + GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "BigEndian", "BigEndian", fieldsAndProps); + stringBuilder.AppendLine(); + stringBuilder.AppendLine($" public void Write(Span buffer, bool isLittleEndian, out int bytesWritten)"); + stringBuilder.AppendLine($" {{"); + stringBuilder.AppendLine($" if (isLittleEndian)"); + stringBuilder.AppendLine($" {{"); + stringBuilder.AppendLine($" WriteLittleEndian(buffer, out bytesWritten);"); + stringBuilder.AppendLine($" }}"); + stringBuilder.AppendLine($" else"); + stringBuilder.AppendLine($" {{"); + stringBuilder.AppendLine($" WriteBigEndian(buffer, out bytesWritten);"); + stringBuilder.AppendLine($" }}"); + stringBuilder.AppendLine($" }}"); + } + + stringBuilder.AppendLine($" }}"); + stringBuilder.AppendLine($"}}"); + + context.AddSource($"{containerSymbol.Name}.Generated.cs", stringBuilder.ToString()); + } + + private void GenerateBinarySize( + GeneratorExecutionContext context, + TypeDeclarationSyntax typeDecl, + SemanticModel semanticModel, + StringBuilder stringBuilder, + List fieldsAndProps) + { + int size = 0; + //StringBuilder variableOffset = new StringBuilder(); + //int variableOffsetIndex = 1; + + foreach (var m in fieldsAndProps) + { + var memberType = m.Type; + + if (memberType.TypeKind == TypeKind.Enum && + memberType is INamedTypeSymbol nts) + { + memberType = nts.EnumUnderlyingType; + } + + switch (memberType.SpecialType) + { + case SpecialType.System_UInt16: + case SpecialType.System_UInt32: + case SpecialType.System_UInt64: + case SpecialType.System_Int16: + case SpecialType.System_Int32: + case SpecialType.System_Int64: + int basicTypeSize = memberType.SpecialType switch + { + SpecialType.System_UInt16 => 2, + SpecialType.System_UInt32 => 4, + SpecialType.System_UInt64 => 8, + SpecialType.System_Int16 => 2, + SpecialType.System_Int32 => 4, + SpecialType.System_Int64 => 8, + _ => 0 + }; + size += basicTypeSize; + break; + + case SpecialType.System_Byte: + size++; + break; + + default: + var binarySizeField = memberType.GetMembers().OfType().FirstOrDefault(f => f.Name == "BinarySize"); + if (binarySizeField != null && binarySizeField.ConstantValue is int binarySize) + { + // Handle nested types that have `const int BinarySize` + size += binarySize; + break; + } + return; + } + } + + stringBuilder.AppendLine($" public const int BinarySize = {size};"); + stringBuilder.AppendLine(); + } + + private void GenerateReadMethod( + GeneratorExecutionContext context, + TypeDeclarationSyntax typeDecl, + SemanticModel semanticModel, + StringBuilder stringBuilder, + string nameSuffix, + string endianSuffix, + List fieldsAndProps) + { + int offset = 0; + StringBuilder variableOffset = new StringBuilder(); + int variableOffsetIndex = 1; + + stringBuilder.AppendLine($" public static {typeDecl.Identifier} Read{nameSuffix}(ReadOnlySpan buffer, out int bytesRead)"); + stringBuilder.AppendLine($" {{"); + stringBuilder.AppendLine($" var result = new {typeDecl.Identifier}"); + stringBuilder.AppendLine($" {{"); + + foreach (var m in fieldsAndProps) + { + var memberType = m.Type; + string? readExpression; + string castExpression = ""; + + if (memberType.TypeKind == TypeKind.Enum && + memberType is INamedTypeSymbol nts) + { + // FIXME: Namespace + castExpression = $"({memberType.Name})"; + memberType = nts.EnumUnderlyingType; + } + + switch (memberType.SpecialType) + { + // Endianness aware basic types + case SpecialType.System_UInt16: + case SpecialType.System_UInt32: + case SpecialType.System_UInt64: + case SpecialType.System_Int16: + case SpecialType.System_Int32: + case SpecialType.System_Int64: + string? basicTypeName = memberType.SpecialType switch + { + SpecialType.System_UInt16 => "UInt16", + SpecialType.System_UInt32 => "UInt32", + SpecialType.System_UInt64 => "UInt64", + SpecialType.System_Int16 => "Int16", + SpecialType.System_Int32 => "Int32", + SpecialType.System_Int64 => "Int64", + _ => throw new InvalidOperationException() + }; + int basicTypeSize = memberType.SpecialType switch + { + SpecialType.System_UInt16 => 2, + SpecialType.System_UInt32 => 4, + SpecialType.System_UInt64 => 8, + SpecialType.System_Int16 => 2, + SpecialType.System_Int32 => 4, + SpecialType.System_Int64 => 8, + _ => 0 + }; + readExpression = $"{castExpression}BinaryPrimitives.Read{basicTypeName}{endianSuffix}(buffer.Slice({offset}{variableOffset}, {basicTypeSize}))"; + offset += basicTypeSize; + break; + + case SpecialType.System_Byte: + readExpression = $"{castExpression}buffer[{offset}{variableOffset}]"; + offset ++; + break; + + default: + var methods = memberType.GetMembers().OfType(); + if (methods.Any(m => m.Name == $"Read{nameSuffix}")) + { + // FIXME: Missing namespace + readExpression = $"{m.Type.Name}.Read{nameSuffix}(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; + } + else + { + // FIXME: Missing namespace + readExpression = $"{m.Type.Name}.Read(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; + } + + variableOffset.Append($" + _{variableOffsetIndex}"); + variableOffsetIndex++; + + // FIXME: Handle other basic type + // FIXME: Handle nested struct/classes by calling their Read + //throw new NotSupportedException(); + break; + } + + stringBuilder.AppendLine($" {m.Name} = {readExpression},"); + } + + stringBuilder.AppendLine($" }};"); + stringBuilder.AppendLine($" bytesRead = {offset}{variableOffset};"); + stringBuilder.AppendLine($" return result;"); + stringBuilder.AppendLine($" }}"); + } + + private void GenerateWriteMethod( + GeneratorExecutionContext context, + TypeDeclarationSyntax typeDecl, + SemanticModel semanticModel, + StringBuilder stringBuilder, + string nameSuffix, + string endianSuffix, + List fieldsAndProps) + { + int offset = 0; + StringBuilder variableOffset = new StringBuilder(); + int variableOffsetIndex = 1; + + stringBuilder.AppendLine($" public void Write{nameSuffix}(Span buffer, out int bytesWritten)"); + stringBuilder.AppendLine($" {{"); + + foreach (var m in fieldsAndProps) + { + var memberType = m.Type; + string? writeExpression; + string castExpression = ""; + + if (memberType.TypeKind == TypeKind.Enum && + memberType is INamedTypeSymbol nts) + { + // FIXME: Namespace + memberType = nts.EnumUnderlyingType; + castExpression = $"({memberType.Name})"; + } + + switch (memberType.SpecialType) + { + // Endianness aware basic types + case SpecialType.System_UInt16: + case SpecialType.System_UInt32: + case SpecialType.System_UInt64: + case SpecialType.System_Int16: + case SpecialType.System_Int32: + case SpecialType.System_Int64: + string? basicTypeName = memberType.SpecialType switch + { + SpecialType.System_UInt16 => "UInt16", + SpecialType.System_UInt32 => "UInt32", + SpecialType.System_UInt64 => "UInt64", + SpecialType.System_Int16 => "Int16", + SpecialType.System_Int32 => "Int32", + SpecialType.System_Int64 => "Int64", + _ => throw new InvalidOperationException() + }; + int basicTypeSize = memberType.SpecialType switch + { + SpecialType.System_UInt16 => 2, + SpecialType.System_UInt32 => 4, + SpecialType.System_UInt64 => 8, + SpecialType.System_Int16 => 2, + SpecialType.System_Int32 => 4, + SpecialType.System_Int64 => 8, + _ => 0 + }; + writeExpression = $"BinaryPrimitives.Write{basicTypeName}{endianSuffix}(buffer.Slice({offset}{variableOffset}, {basicTypeSize}), {castExpression}{m.Name})"; + offset += basicTypeSize; + break; + + case SpecialType.System_Byte: + writeExpression = $"buffer[{offset}{variableOffset}] = {castExpression}{m.Name}"; + offset ++; + break; + + default: + var methods = memberType.GetMembers().OfType(); + if (methods.Any(m => m.Name == $"Write{nameSuffix}")) + { + // FIXME: Missing namespace + writeExpression = $"{m.Name}.Write{nameSuffix}(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; + } + else + { + // FIXME: Missing namespace + writeExpression = $"{m.Name}.Write(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; + } + + variableOffset.Append($" + _{variableOffsetIndex}"); + variableOffsetIndex++; + + // FIXME: Handle other basic type + // FIXME: Handle nested struct/classes by calling their Read + //throw new NotSupportedException(); + break; + } + + stringBuilder.AppendLine($" {writeExpression};"); + } + + stringBuilder.AppendLine($" bytesWritten = {offset}{variableOffset};"); + stringBuilder.AppendLine($" }}"); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs new file mode 100644 index 00000000000000..5ed215375b5173 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Text; + +namespace BinaryFormat +{ + [Generator] + public partial class Generator : ISourceGenerator + { + public void Initialize(GeneratorInitializationContext context) + { +#if DEBUG + //if (!Debugger.IsAttached) + //{ + // Debugger.Launch(); + //} +#endif + + context.RegisterForPostInitialization((pi) => pi.AddSource("BinaryFormat.Attribute.cs", AttributeSource)); + context.RegisterForSyntaxNotifications(() => new MySyntaxReceiver()); + } + + public void Execute(GeneratorExecutionContext context) + { + MySyntaxReceiver syntaxReceiver = (MySyntaxReceiver)context.SyntaxContextReceiver; + + foreach (var userType in syntaxReceiver.TypesToAugment) + { + GenerateReaderWriter(context, userType, context.Compilation.GetSemanticModel(userType.SyntaxTree)); + } + } + + class MySyntaxReceiver : ISyntaxContextReceiver + { + public List TypesToAugment { get; private set; } = new(); + + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + { + if (context.Node is TypeDeclarationSyntax tds && + context.SemanticModel.GetDeclaredSymbol(tds) is INamedTypeSymbol symbol && + symbol.GetAttributes().Any(a => a.AttributeClass.Name == "GenerateReaderWriterAttribute")) + { + TypesToAugment.Add(tds); + } + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj new file mode 100644 index 00000000000000..5bce006fbb24a3 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj @@ -0,0 +1,12 @@ + + + netstandard2.0 + latest + annotations + + + + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out new file mode 100755 index 0000000000000000000000000000000000000000..ce1e62c9c1815e7e57ab6ca0fa0cb6eac842a59d GIT binary patch literal 34976 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 literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj new file mode 100644 index 00000000000000..50161ce7e9df48 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj @@ -0,0 +1,31 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs new file mode 100644 index 00000000000000..efd7984b572d18 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs @@ -0,0 +1,27 @@ +using Xunit; +using System.IO; +using System.Linq; +using Melanzana.CodeSign.Requirements; + +namespace Melanzana.CodeSign.Tests +{ + public class RequirementTest + { + [Fact] + public void DefaultRequirement() + { + var defaultReq = RequirementSet.CreateDefault("BUNDLE ID", "FRIENDLY NAME")[RequirementType.Designated]; + var stringExpr = "identifier \"BUNDLE ID\" and anchor apple generic and certificate leaf[subject.CN] = \"FRIENDLY NAME\" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */"; + + // Check string representation + Assert.Equal(stringExpr, defaultReq.ToString()); + + // Check binary round-trip + var expr = new byte[defaultReq.Expression.Size]; + defaultReq.Expression.Write(expr, out var exprBytesWritten); + Assert.Equal(expr.Length, exprBytesWritten); + var readExpression = Expression.FromBlob(expr); + Assert.Equal(stringExpr, readExpression.ToString()); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs new file mode 100644 index 00000000000000..23bf073738028f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs @@ -0,0 +1,44 @@ +using Xunit; +using System.IO; +using System.Linq; +using Melanzana.CodeSign.Requirements; +using Melanzana.MachO; +using Melanzana.Streams; + +namespace Melanzana.CodeSign.Tests +{ + public class ResignTest + { + [Fact] + public void Resign() + { + // Read the test executable + var aOutStream = typeof(ResignTest).Assembly.GetManifestResourceStream("Melanzana.CodeSign.Tests.Data.a.out")!; + var objectFile = MachReader.Read(aOutStream).FirstOrDefault(); + Assert.NotNull(objectFile); + + // Strip the signature + var codeSignature = objectFile!.LoadCommands.OfType().FirstOrDefault(); + Assert.NotNull(codeSignature); + var originalSignatureSize = codeSignature!.FileSize; + objectFile!.LoadCommands.Remove(codeSignature); + + // Write the stripped file to disk + var tempFileName = Path.GetTempFileName(); + using (var tempFile = new FileStream(tempFileName, FileMode.Create)) + { + MachWriter.Write(tempFile, objectFile); + Assert.Equal(aOutStream.Length - originalSignatureSize, tempFile.Length); + } + + // Ad-hoc sign the file + var codeSignOptions = new CodeSignOptions { }; + var signer = new Signer(codeSignOptions); + signer.Sign(tempFileName); + + // TODO: Check signature + + File.Delete(tempFileName); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs new file mode 100644 index 00000000000000..8e85bc91ad1682 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs @@ -0,0 +1,74 @@ +using System.Formats.Asn1; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; + +namespace Melanzana.CodeSign +{ + public static class AppleCertificateExtensions + { + private const string OrganizationalUnit = "2.5.4.11"; + + private static string ReadAnyAsnString(this AsnReader tavReader) + { + Asn1Tag tag = tavReader.PeekTag(); + + if (tag.TagClass != TagClass.Universal) + { + throw new CryptographicException("Invalid DER encoding"); + } + + switch ((UniversalTagNumber)tag.TagValue) + { + case UniversalTagNumber.BMPString: + case UniversalTagNumber.IA5String: + case UniversalTagNumber.NumericString: + case UniversalTagNumber.PrintableString: + case UniversalTagNumber.UTF8String: + case UniversalTagNumber.T61String: + // .NET's string comparisons start by checking the length, so a trailing + // NULL character which was literally embedded in the DER would cause a + // failure in .NET whereas it wouldn't have with strcmp. + return tavReader.ReadCharacterString((UniversalTagNumber)tag.TagValue).TrimEnd('\0'); + + default: + throw new CryptographicException("Invalid DER encoding"); + } + } + + public static bool IsAppleDeveloperCertificate(this X509Certificate2 certificate) + { + // FIXME: We should check the certificate anchor and only allow the following OIDs in extensions: + // 1.2.840.113635.100.6.1.2 (WWDR) + // 1.2.840.113635.100.6.1.12 (MACWWDR) + // 1.2.840.113635.100.6.1.13 (Developer ID) + // 1.2.840.113635.100.6.1.7 (Distribution) + // 1.2.840.113635.100.6.1.4 (iPhone Distribution) + return certificate.Extensions.Any(e => e.Oid?.Value?.StartsWith("1.2.840.113635.100.6.1.") ?? false); + } + + public static string GetTeamId(this X509Certificate2 certificate) + { + if (certificate.IsAppleDeveloperCertificate()) + { + AsnReader x500NameReader = new AsnReader(certificate.SubjectName.RawData, AsnEncodingRules.DER); + AsnReader x500NameSequenceReader = x500NameReader.ReadSequence(); + while (x500NameSequenceReader.HasData) + { + var rdnReader = x500NameSequenceReader.ReadSetOf(skipSortOrderValidation: true); + while (rdnReader.HasData) + { + AsnReader tavReader = rdnReader.ReadSequence(); + string oid = tavReader.ReadObjectIdentifier(); + string attributeValue = tavReader.ReadAnyAsnString(); + if (oid == OrganizationalUnit) + { + return attributeValue; + } + } + } + } + + return string.Empty; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs new file mode 100644 index 00000000000000..0d0f2ecbf71fba --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs @@ -0,0 +1,14 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum BlobMagic : uint + { + Requirement = 0xfade0c00, + Requirements = 0xfade0c01, + CodeDirectory = 0xfade0c02, + EmbeddedSignature = 0xfade0cc0, + DetachedSignature = 0xfade0cc1, + CmsWrapper = 0xfade0b01, + Entitlements = 0xfade7171, + EntitlementsDer = 0xfade7172, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs new file mode 100644 index 00000000000000..c30793b8a2283c --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs @@ -0,0 +1,121 @@ +using System.Buffers.Binary; +using System.Diagnostics; +using System.Formats.Asn1; +using System.Security.Cryptography; +using System.Security.Cryptography.Pkcs; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using Claunia.PropertyList; + +namespace Melanzana.CodeSign.Blobs +{ + public class CmsWrapperBlob + { + private readonly static string rootCertificatePath = "Melanzana.CodeSign.Certificates.RootCertificate.cer"; + private readonly static string g1IntermediateCertificatePath = "Melanzana.CodeSign.Certificates.IntermediateG1Certificate.cer"; + private readonly static string g3IntermediateCertificatePath = "Melanzana.CodeSign.Certificates.IntermediateG3Certificate.cer"; + + private static X509Certificate2 GetManifestCertificate(string name) + { + var memoryStream = new MemoryStream(); + using (var manifestStream = typeof(CmsWrapperBlob).Assembly.GetManifestResourceStream(name)) + { + Debug.Assert(manifestStream != null); + manifestStream.CopyTo(memoryStream); + } + return new X509Certificate2(memoryStream.ToArray()); + } + + public static byte[] Create( + X509Certificate2? developerCertificate, + AsymmetricAlgorithm? privateKey, + byte[] dataToSign, + HashType[] hashTypes, + byte[][] cdHashes) + { + if (dataToSign == null) + throw new ArgumentNullException(nameof(dataToSign)); + if (hashTypes == null) + throw new ArgumentNullException(nameof(hashTypes)); + if (cdHashes == null) + throw new ArgumentNullException(nameof(cdHashes)); + if (hashTypes.Length != cdHashes.Length) + throw new ArgumentException($"Length of hashType ({hashTypes.Length} is different from length of cdHashes ({cdHashes.Length})"); + + // Ad-hoc signature + if (developerCertificate == null) + { + var adhocBlobBuffer = new byte[8]; + BinaryPrimitives.WriteUInt32BigEndian(adhocBlobBuffer.AsSpan(0, 4), (uint)BlobMagic.CmsWrapper); + BinaryPrimitives.WriteUInt32BigEndian(adhocBlobBuffer.AsSpan(4, 4), (uint)adhocBlobBuffer.Length); + return adhocBlobBuffer; + } + + var certificatesList = new X509Certificate2Collection(); + + // Try to build full chain + var chain = new X509Chain(); + var chainPolicy = new X509ChainPolicy { TrustMode = X509ChainTrustMode.CustomRootTrust }; + chainPolicy.CustomTrustStore.Add(GetManifestCertificate(rootCertificatePath)); + chainPolicy.CustomTrustStore.Add(GetManifestCertificate(g1IntermediateCertificatePath)); + chainPolicy.CustomTrustStore.Add(GetManifestCertificate(g3IntermediateCertificatePath)); + chain.ChainPolicy = chainPolicy; + if (chain.Build(developerCertificate)) + { + certificatesList.AddRange(chain.ChainElements.Select(e => e.Certificate).ToArray()); + } + else + { + // Retry with default policy and system certificate store + chain.ChainPolicy = new X509ChainPolicy(); + if (chain.Build(developerCertificate)) + { + certificatesList.AddRange(chain.ChainElements.Select(e => e.Certificate).ToArray()); + } + } + + var cmsSigner = privateKey == null ? + new CmsSigner(developerCertificate) : + new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, developerCertificate, privateKey); + cmsSigner.Certificates.AddRange(certificatesList); + cmsSigner.IncludeOption = X509IncludeOption.None; + + cmsSigner.SignedAttributes.Add(new Pkcs9SigningTime()); + + // DER version of the hash attribute + var values = new AsnEncodedDataCollection(); + var oid = new Oid("1.2.840.113635.100.9.2", null); + var plistCdHashes = new NSArray(); + for (int i = 0; i < hashTypes.Length; i++) + { + var codeDirectoryAttrWriter = new AsnWriter(AsnEncodingRules.DER); + using (codeDirectoryAttrWriter.PushSequence()) + { + codeDirectoryAttrWriter.WriteObjectIdentifier(hashTypes[i].GetOid()); + codeDirectoryAttrWriter.WriteOctetString(cdHashes[i]); + } + values.Add(new AsnEncodedData(oid, codeDirectoryAttrWriter.Encode())); + plistCdHashes.Add(new NSData(cdHashes[i].AsSpan(0, 20).ToArray())); + } + cmsSigner.SignedAttributes.Add(new CryptographicAttributeObject(oid, values)); + + // PList version of the hash attribute + var plistBytes = Encoding.UTF8.GetBytes(new NSDictionary() { ["cdhashes"] = plistCdHashes }.ToXmlPropertyList()); + var codeDirectoryPListAttrWriter = new AsnWriter(AsnEncodingRules.DER); + codeDirectoryPListAttrWriter.WriteOctetString(plistBytes); + cmsSigner.SignedAttributes.Add(new AsnEncodedData("1.2.840.113635.100.9.1", codeDirectoryPListAttrWriter.Encode())); + + var signedCms = new SignedCms(new ContentInfo(dataToSign), true); + signedCms.ComputeSignature(cmsSigner); + + var encodedCms = signedCms.Encode(); + + var blobBuffer = new byte[8 + encodedCms.Length]; + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.CmsWrapper); + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); + encodedCms.CopyTo(blobBuffer.AsSpan(8)); + + return blobBuffer; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs new file mode 100644 index 00000000000000..1c563f5139d3d0 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs @@ -0,0 +1,22 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryBaselineHeader + { + public BlobMagic Magic; + public uint Size; + public CodeDirectoryVersion Version; + public CodeDirectoryFlags Flags; + public uint HashesOffset; + public uint IdentifierOffset; + public uint SpecialSlotCount; + public uint CodeSlotCount; + public uint ExecutableLength; + public byte HashSize; + public HashType HashType; + public byte Platform; + public byte Log2PageSize; + public uint Reserved; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs new file mode 100644 index 00000000000000..befdaabdfcea5e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs @@ -0,0 +1,205 @@ +using System.Buffers.Binary; +using System.Diagnostics; +using System.Security.Cryptography; +using System.Text; +using Melanzana.MachO; +using Melanzana.Streams; + +namespace Melanzana.CodeSign.Blobs +{ + class CodeDirectoryBuilder + { + private readonly MachObjectFile executable; + private readonly string identifier; + private readonly string teamId; + private readonly uint pageSize = 4096; + private readonly byte[][] specialSlots = new byte[7][]; + private int specialSlotCount; + + public CodeDirectoryBuilder(MachObjectFile executable, string identifier, string teamId) + { + this.executable = executable; + this.identifier = identifier; + this.teamId = teamId; + + if (executable.FileType == MachFileType.Execute) + ExecutableSegmentFlags |= ExecutableSegmentFlags.MainBinary; + } + + public void SetSpecialSlotData(CodeDirectorySpecialSlot slot, byte[] data) + { + Debug.Assert((int)slot >= 1 && (int)slot <= specialSlots.Length); + specialSlots[(int)(slot - 1)] = data; + specialSlotCount = Math.Max(specialSlotCount, (int)slot); + } + + public HashType HashType { get; set; } = HashType.SHA256; + + public ExecutableSegmentFlags ExecutableSegmentFlags { get; set; } + + public CodeDirectoryFlags Flags { get; set; } + + private static int GetFixedHeaderSize(CodeDirectoryVersion version) + { + int size = CodeDirectoryBaselineHeader.BinarySize; + if (version >= CodeDirectoryVersion.SupportsScatter) + size += CodeDirectoryScatterHeader.BinarySize; + if (version >= CodeDirectoryVersion.SupportsTeamId) + size += CodeDirectoryTeamIdHeader.BinarySize; + if (version >= CodeDirectoryVersion.SupportsCodeLimit64) + size += CodeDirectoryCodeLimit64Header.BinarySize; + if (version >= CodeDirectoryVersion.SupportsExecSegment) + size += CodeDirectoryExecSegmentHeader.BinarySize; + if (version >= CodeDirectoryVersion.SupportsPreEncrypt) + size += CodeDirectoryPreencryptHeader.BinarySize; + return size; + } + + public long Size(CodeDirectoryVersion version) + { + ulong execLength = executable.GetSigningLimit(); + uint codeSlotCount = (uint)((execLength + pageSize - 1) / pageSize); + byte hashSize = HashType.GetSize(); + + byte[] utf8Identifier = Encoding.UTF8.GetBytes(identifier); + byte[] utf8TeamId = Encoding.UTF8.GetBytes(teamId); + + long codeDirectorySize = GetFixedHeaderSize(version); + codeDirectorySize += utf8Identifier.Length + 1; + if (!String.IsNullOrEmpty(teamId)) + codeDirectorySize += utf8TeamId.Length + 1; + codeDirectorySize += (specialSlotCount + codeSlotCount) * hashSize; + if (version >= CodeDirectoryVersion.SupportsPreEncrypt) + codeDirectorySize += codeSlotCount * hashSize; + + return codeDirectorySize; + } + + public byte[] Build(Stream machOStream) + { + CodeDirectoryVersion version = CodeDirectoryVersion.HighestVersion; + + ulong execLength = executable.GetSigningLimit(); + uint codeSlotCount = (uint)((execLength + pageSize - 1) / pageSize); + byte[] utf8Identifier = Encoding.UTF8.GetBytes(identifier); + byte[] utf8TeamId = Encoding.UTF8.GetBytes(teamId); + byte hashSize = HashType.GetSize(); + var size = Size(version); + byte[] blobBuffer = new byte[size]; + + var textSegment = executable.LoadCommands.OfType().First(s => s.Name == "__TEXT"); + Debug.Assert(textSegment != null); + + var baselineHeader = new CodeDirectoryBaselineHeader(); + baselineHeader.Magic = BlobMagic.CodeDirectory; + baselineHeader.Size = (uint)size; + baselineHeader.Version = version; + baselineHeader.Flags = Flags; + // baselineHeader.HashesOffset = 0; -- Filled in later + // baselineHeader.IdentifierOffset = 0; -- Filled in later + baselineHeader.SpecialSlotCount = (uint)specialSlotCount; + baselineHeader.CodeSlotCount = codeSlotCount; + baselineHeader.ExecutableLength = (execLength > uint.MaxValue) ? uint.MaxValue : (uint)execLength; + baselineHeader.HashSize = hashSize; + baselineHeader.HashType = HashType; + baselineHeader.Platform = 0; // TODO + baselineHeader.Log2PageSize = (byte)Math.Log2(pageSize); + baselineHeader.Reserved = 0; + var scatterHeader = new CodeDirectoryScatterHeader(); + scatterHeader.ScatterOffset = 0; + var teamIdHeader = new CodeDirectoryTeamIdHeader(); + // teamIdHeader.TeamIdOffset = 0; -- Filled in later + var codeLimit64Header = new CodeDirectoryCodeLimit64Header(); + codeLimit64Header.Reserved = 0; + codeLimit64Header.CodeLimit64 = execLength >= uint.MaxValue ? execLength : 0; + var execSegementHeader = new CodeDirectoryExecSegmentHeader(); + execSegementHeader.Base = textSegment.FileOffset; + execSegementHeader.Limit = textSegment.FileSize; + execSegementHeader.Flags = ExecutableSegmentFlags; + + // Fill in flexible fields + int flexibleOffset = GetFixedHeaderSize(version); + + if (version >= CodeDirectoryVersion.SupportsScatter) + { + // TODO + } + + // Identifier + baselineHeader.IdentifierOffset = (uint)flexibleOffset; + utf8Identifier.AsSpan().CopyTo(blobBuffer.AsSpan(flexibleOffset, utf8Identifier.Length)); + flexibleOffset += utf8Identifier.Length + 1; + + // Team ID + if (version >= CodeDirectoryVersion.SupportsTeamId && !string.IsNullOrEmpty(teamId)) + { + teamIdHeader.TeamIdOffset = (uint)flexibleOffset; + utf8TeamId.AsSpan().CopyTo(blobBuffer.AsSpan(flexibleOffset, utf8TeamId.Length)); + flexibleOffset += utf8TeamId.Length + 1; + } + + // Pre-encrypt hashes + if (version >= CodeDirectoryVersion.SupportsPreEncrypt) + { + // TODO + } + + var hasher = HashType.GetIncrementalHash(); + + // Special slot hashes + for (int i = specialSlotCount - 1; i >= 0; i--) + { + if (specialSlots[i] != null) + { + hasher.AppendData(specialSlots[i]); + hasher.GetHashAndReset().CopyTo(blobBuffer.AsSpan(flexibleOffset, hashSize)); + } + flexibleOffset += hashSize; + } + + baselineHeader.HashesOffset = (uint)flexibleOffset; + + // Code hashes + Span buffer = stackalloc byte[(int)pageSize]; + long remaining = (long)execLength; + while (remaining > 0) + { + int codePageSize = (int)Math.Min(remaining, 4096); + machOStream.ReadFully(buffer.Slice(0, codePageSize)); + hasher.AppendData(buffer.Slice(0, codePageSize)); + hasher.GetHashAndReset().CopyTo(blobBuffer.AsSpan(flexibleOffset, hashSize)); + remaining -= codePageSize; + flexibleOffset += hashSize; + } + + Debug.Assert(flexibleOffset == blobBuffer.Length); + + // Write headers + int writeOffset = 0; + baselineHeader.Write(blobBuffer, out var bytesWritten); + writeOffset += bytesWritten; + if (version >= CodeDirectoryVersion.SupportsScatter) + { + scatterHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); + writeOffset += bytesWritten; + } + if (version >= CodeDirectoryVersion.SupportsTeamId) + { + teamIdHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); + writeOffset += bytesWritten; + } + if (version >= CodeDirectoryVersion.SupportsCodeLimit64) + { + codeLimit64Header.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); + writeOffset += bytesWritten; + } + if (version >= CodeDirectoryVersion.SupportsExecSegment) + { + execSegementHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); + writeOffset += bytesWritten; + } + + return blobBuffer; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs new file mode 100644 index 00000000000000..451df807981fd7 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs @@ -0,0 +1,10 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryCodeLimit64Header + { + public uint Reserved; + public ulong CodeLimit64; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs new file mode 100644 index 00000000000000..685eb5b038064a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs @@ -0,0 +1,11 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryExecSegmentHeader + { + public ulong Base; + public ulong Limit; + public ExecutableSegmentFlags Flags; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs new file mode 100644 index 00000000000000..ea7e238059f8ba --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs @@ -0,0 +1,7 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum CodeDirectoryFlags : uint + { + Adhoc = 2, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs new file mode 100644 index 00000000000000..10bd00a25b0130 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs @@ -0,0 +1,10 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryPreencryptHeader + { + public uint HardendRuntimeVersion; + public uint PrencryptOffset; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs new file mode 100644 index 00000000000000..ec1ffd9e8155af --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryScatterHeader + { + public uint ScatterOffset; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs new file mode 100644 index 00000000000000..8d56a9236e262d --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs @@ -0,0 +1,18 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum CodeDirectorySpecialSlot + { + InfoPlist = 1, + Requirements = 2, + ResourceDirectory = 3, + TopDirectory = 4, + Entitlements = 5, + RepresentationSpecific = 6, + EntitlementsDer = 7, + HighestSlot = EntitlementsDer, + + CodeDirectory = 0, + AlternativeCodeDirectory = 0x1000, + CmsWrapper = 0x10000, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs new file mode 100644 index 00000000000000..1b6ef46c50be12 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.CodeSign.Blobs +{ + [GenerateReaderWriter] + [BigEndian] + public partial class CodeDirectoryTeamIdHeader + { + public uint TeamIdOffset; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs new file mode 100644 index 00000000000000..3439c78c1c0d3f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs @@ -0,0 +1,13 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum CodeDirectoryVersion : int + { + Baseline = 0x20001, + SupportsScatter = 0x20100, + SupportsTeamId = 0x20200, + SupportsCodeLimit64 = 0x20300, + SupportsExecSegment = 0x20400, + SupportsPreEncrypt = 0x20500, + HighestVersion = SupportsExecSegment, // TODO: We don't support pre-encryption yet + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs new file mode 100644 index 00000000000000..a62f9fdb6da4b6 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs @@ -0,0 +1,21 @@ +using System.Buffers.Binary; +using System.Text; +using Claunia.PropertyList; + +namespace Melanzana.CodeSign.Blobs +{ + public class EntitlementsBlob + { + public static byte[] Create(Entitlements entitlements) + { + var plistBytes = Encoding.UTF8.GetBytes(entitlements.PList.ToXmlPropertyList()); + var blobBuffer = new byte[8 + plistBytes.Length]; + + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Entitlements); + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); + plistBytes.CopyTo(blobBuffer.AsSpan(8, plistBytes.Length)); + + return blobBuffer; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs new file mode 100644 index 00000000000000..a943e479c4f702 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs @@ -0,0 +1,21 @@ +using System.Buffers.Binary; +using System.Text; +using Claunia.PropertyList; + +namespace Melanzana.CodeSign.Blobs +{ + public class EntitlementsDerBlob + { + public static byte[] Create(Entitlements entitlements) + { + var plistBytes = DerPropertyListWriter.Write(entitlements.PList); + var blobBuffer = new byte[8 + plistBytes.Length]; + + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.EntitlementsDer); + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); + plistBytes.CopyTo(blobBuffer.AsSpan(8, plistBytes.Length)); + + return blobBuffer; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs new file mode 100644 index 00000000000000..f32ee3c9914fb7 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs @@ -0,0 +1,13 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum ExecutableSegmentFlags : ulong + { + MainBinary = 1, + AllowUnsigned = 0x10, + Debugger = 0x20, + Jit = 0x40, + SkipLibraryValidation = 0x80, + CanLoadCdHash = 0x100, + CanExecuteCdHash = 0x200, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs new file mode 100644 index 00000000000000..4ba122c7c6cd8a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs @@ -0,0 +1,12 @@ +namespace Melanzana.CodeSign.Blobs +{ + public enum HashType : byte + { + None, + SHA1, + SHA256, + SHA256Truncated, + SHA384, + SHA512, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs new file mode 100644 index 00000000000000..cefbcd2782d58f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs @@ -0,0 +1,47 @@ +using System.Security.Cryptography; + +namespace Melanzana.CodeSign.Blobs +{ + public static class HashTypeExtensions + { + + public static IncrementalHash GetIncrementalHash(this HashType hashType) + { + return hashType switch + { + HashType.SHA1 => IncrementalHash.CreateHash(HashAlgorithmName.SHA1), + HashType.SHA256 => IncrementalHash.CreateHash(HashAlgorithmName.SHA256), + HashType.SHA256Truncated => IncrementalHash.CreateHash(HashAlgorithmName.SHA256), + HashType.SHA384 => IncrementalHash.CreateHash(HashAlgorithmName.SHA384), + HashType.SHA512 => IncrementalHash.CreateHash(HashAlgorithmName.SHA512), + _ => throw new NotSupportedException() + }; + } + + public static byte GetSize(this HashType hashType) + { + return hashType switch + { + HashType.SHA1 => 20, + HashType.SHA256 => 32, + HashType.SHA256Truncated => 20, + HashType.SHA384 => 48, + HashType.SHA512 => 64, + _ => throw new NotSupportedException() + }; + } + + public static string GetOid(this HashType hashType) + { + return hashType switch + { + HashType.SHA1 => "1.3.14.3.2.26", + HashType.SHA256 => "2.16.840.1.101.3.4.2.1", + HashType.SHA256Truncated => "2.16.840.1.101.3.4.2.1", + HashType.SHA384 => "2.16.840.1.101.3.4.2.2", + HashType.SHA512 => "2.16.840.1.101.3.4.2.3", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs new file mode 100644 index 00000000000000..aa4418e19ea440 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs @@ -0,0 +1,130 @@ +using Claunia.PropertyList; + +namespace Melanzana.CodeSign +{ + public class Bundle + { + public string BundlePath { get; private set; } + + public string ContentsPath { get; private set; } + + private readonly bool hasContents; + private readonly bool hasResources; + private readonly string? mainExecutable; + private readonly NSDictionary? infoPList; + private readonly string? bundleIdentifier; + + public Bundle(string path) + { + BundlePath = path; + + // Detect bundle type: + // - Shallow (eg. iOS) + // - `Contents/` (eg. macOS) + // - `Support Files/` + // - `Versions/...` + // - installer package + // - widget + // - etc. + + hasContents = Directory.Exists(Path.Combine(path, "Contents")); + ContentsPath = hasContents ? Path.Combine(path, "Contents") : path; + + // Look for Info.plist, then check CFBundleExecutable + var infoPlistPath = Path.Combine(ContentsPath, "Info.plist"); + if (File.Exists(infoPlistPath)) + { + infoPList = (NSDictionary)PropertyListParser.Parse(infoPlistPath); + + if (infoPList.TryGetValue("CFBundleExecutable", out var temp) && temp is NSString bundleExecutable) + { + if (hasContents) // macOS + { + mainExecutable = Path.Combine("MacOS", (string)bundleExecutable); + } + else + { + mainExecutable = (string)bundleExecutable; + } + + if (!File.Exists(Path.Combine(ContentsPath, mainExecutable))) + { + mainExecutable = null; + } + } + + if (infoPList.TryGetValue("CFBundleIdentifier", out temp) && temp is NSString bundleIdentifier) + { + this.bundleIdentifier = (string)bundleIdentifier; + } + } + else if (!hasContents && Directory.Exists(Path.Combine(BundlePath, "Versions"))) + { + ContentsPath = Path.Combine(BundlePath, "Versions", "Current"); + + // FIXME: Quick hack to get framework executables + var guessedName = Path.GetFileNameWithoutExtension(path); + if (File.Exists(Path.Combine(BundlePath, guessedName))) + { + mainExecutable = guessedName; + } + } + + hasResources = Directory.Exists(Path.Combine(ContentsPath, "Resources")); + } + + public string? MainExecutable => mainExecutable != null ? Path.Combine(ContentsPath, mainExecutable) : null; + + public string? BundleIdentifier => bundleIdentifier; + + public NSDictionary InfoPList => infoPList ?? new NSDictionary(); + + public void AddResourceRules(ResourceBuilder builder, bool useV2Rules = true) + { + string resourcePrefix = hasResources ? "Resources/" : ""; + + if (useV2Rules) + { + builder.AddRule(new ResourceRule("^.*")); + + // On macOS include nested signatures + if (hasResources) + { + builder.AddRule(new ResourceRule("^[^/]+") { IsNested = true, Weight = 10 }); + builder.AddRule(new ResourceRule("^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/") { IsNested = true, Weight = 10 }); + builder.AddRule(new ResourceRule($"^{resourcePrefix}") { Weight = 20 }); + } + + builder.AddRule(new ResourceRule(".*\\.dSYM($|/)") { Weight = 11 }); + + // Exclude specific files: + builder.AddRule(new ResourceRule("^Info\\.plist$") { IsOmitted = true, Weight = 20 }); + builder.AddRule(new ResourceRule("^PkgInfo$") { IsOmitted = true, Weight = 20 }); + + // Include specific files: + builder.AddRule(new ResourceRule("^embedded\\.provisionprofile$") { Weight = 20 }); + builder.AddRule(new ResourceRule("^version.plist$") { Weight = 20 }); + + builder.AddRule(new ResourceRule("^(.*/)?\\.DS_Store$") { IsOmitted = true, Weight = 2000 }); + } + else + { + builder.AddRule(new ResourceRule("^version.plist$")); + builder.AddRule(new ResourceRule(hasResources ? $"^{resourcePrefix}" : "^.*")); + } + + builder.AddRule(new ResourceRule($"^{resourcePrefix}.*\\.lproj/") { IsOptional = true, Weight = 1000 }); + builder.AddRule(new ResourceRule($"^{resourcePrefix}Base\\.lproj/") { Weight = 1010 }); + builder.AddRule(new ResourceRule($"^{resourcePrefix}.*\\.lproj/locversion.plist$") { IsOmitted = true, Weight = 1100 }); + + // Add implicit exclusions + builder.AddExclusion("_CodeSignature"); + builder.AddExclusion("CodeResources"); + builder.AddExclusion("_MASReceipt"); + if (mainExecutable != null) + { + builder.AddExclusion(mainExecutable); + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer new file mode 100644 index 0000000000000000000000000000000000000000..d2bb1da64122c864c872d9b711b176d042462748 GIT binary patch literal 1062 zcmXqLVo@?^V&+=F%*4pV#KCxP&k@Vq1p)@VY@Awc9&O)w85vnw84QvPxeYkkm_u3E zgqcEv4TTK^K^!h&F2{m`oKywRyktE?H3JopAh)nAM9?|4s3bEjGdZy&Ge1wkv9u&3 zzbLb$(ooDm1f-5xm=~fhC_leM!P(J3PMp`!*ucoZ+{nZl`k>Qj@$g1r8WvHYTX!VypjWG%{)c-lQVYXRuCJE(pY=;r$WxRF4-br${9`c}_k`!An>Li0EopDe zv*^E}E$UaTdLwGTU-QAd$KGuPNJ^ruh+PumVL-h)reU3&vOc4_NAnbP|3 z#gVzkGL~*w{3pGxU>8%Qce&F<%bj1(KJXzgbzkmy4MuTzafLDk420{ zq(fbtbLBRPgzh)5cYSk@JQ@_Tc)I~VNLrYY@jnZz0W**?kOv7Uvq%_-HHc_m$aJ4l z#`*6{cCVhpvhVJ`^&D{qdLRYzEb0cT2FeQ*7s$8CW|Wi^Sn2C07v<Nhma(=FU z5ipVI0fh|sKiL>2Sz0$ga7&Wk^6MMZpzW` ze<$2-^n%rNMP7I9$xNP|H^ujq>s(2H^mkUSRbjJu1>%3p6qBF+hu?6 zedkq{<@Qo*x8F5!lFt%JA<5kEuT>H4)frt++IqZRKk^h=we)T%!^(BLy$#kqT(EJE zX2Ubi@~8Vu7BQZxzw?Oene~p{Z+0b3{mh!|*mRcPTGnUklH03)o}Bv9|B3H&wV91C z_x#+Vd5N(q?V(=JH^r`_KPnzJuG@ck!rYZ>Kd=95AvG=CKqhc$%$vflrY$-AJfiXd D2`7-6 literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer new file mode 100644 index 0000000000000000000000000000000000000000..32f96f81dd6ea4c1c0f8e84698a50df773444b83 GIT binary patch literal 1109 zcmXqLVhJ>8Vzyks%*4pVBv7+HlS_5G<-h9LE>#CBj=nSCW#iOp^Jx3d%gD&h%3zRW z$Zf#M#vIDRCd?EXY$$9X2;y)Fb2%0iH*zq6|t6T@0MSI(e)iI>Ymea#G4OQ&JUNQp-|v@(WUn6oOK7z!nxO;Ibd;6K){o*(MkVCXU}R-rZerwT0E%-lH8CYLni>cB0Y1I-s6|D1SjdC!T1#gEpxT}+xg zX~l#D^V*DQXL}#~nf!ynzs^Bts5HBBM?YUi*LCU=8QrPsRL7p`U7PH?oF*7nSE^d5p z(D=qc2pB!G!ijc@}j8RRiS(iVNi1WT9Gi4Pg$!gt>iJm2SVTDg9T1)HbA1Ze zB%z&Z8p%A<-z?u`zz34%2l<2rm_yhM1lYL1`5`%ljfs(k3792Na|kd^Ffy!76@KyU zL1VcKle^Qt_@$N#uaZ{&Jv!lJvGCP-voEaT@9jPPmhpU!hC}r6P!-1?f6gD=s{HcK zn~(XY8f4249ZB?5O<&J{%2IXh<;PWLj5T=q^cIFY6#se_vyLrL^X=nS9{G!0~pME4H^8F=`FYGft6Cx##-<@*tz`>mQ3dQ$4 zudQ=tHhBjnSZuXy%6$`L7`%^vqK~I%N&m9I(=G0PvZd;Idw*Vv`CNY}hnv&vQOc7; z=FB3JS6^jKS+(-^zi+cR(!1Yl?^q@7*}VSz={+ycznWUOVTlFYQsBg2!4D>>yS-j;I@c+L7YuChh5U7`KHvAiEsOqE5wMI&W5Px=0B&b;#hyADPKr1x`dQTTp(jgCTo z!8UtFgP!fq=lSQ_e%AKXkUH`2+}53ZH{)ckownU-we|}?AHyW>jf!G=C0A{DZzqYZ zUR*fIJvj8>dVR;uKYl+hIQwj|k87R0Pjj_t->jT;Rj-bAq&^<-@B zm%W!-{69S|b&uzbviZg$sSC@eoYZAvW@KPo+{9P~43RPeK43h`@-s62XJG-R8#V)e z5MLO?XEk63QUIB4HrbfL%co zBPgB8DzG#$asX{)0b&Md!c0zKWi)8~WT3^yq0I(NqwGwKVsaTJB?ZM+`ugSN<$8&r zl&P1TpQ{gMB`4||G#-X4W-@5pCe^q(C^aWDF)uk)0hmHdGBS%5lHrLqRUxTTAu+E~ zp&+rS1js5bF3n9XR!B@vPAw>b=t%?WNd@6N1&|%Uq@D!K48=g%l*FPGg_6{wT%d-$ z6ouscyp&8(HYirePg5u@PSruNs30Gx7i1YwCER{crYR^&OfJa;IuB@ONosCtUP-YY za{2^jO7!e*{cX?eJDxY@8r; zW8atJ+3zl;@Sm>qH@UIM?q|jS>=W#7YAu_)gB31Y9ND;kmOoeaf9*e!%UL;V#2vx} zUUwk!R<>!CBEM2a=7;zgw~E zguTASugG_6SFxo3)|+Pa2irq$E}yy6$m#cutA+FG76xsX-aFYzMMzw9>OIdRD+ Xyc@&=R&`yy_2kb5PImJRrKO4hMS!&; literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs new file mode 100644 index 00000000000000..d2319aa496dd82 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs @@ -0,0 +1,50 @@ +using Melanzana.MachO; +using Melanzana.Streams; + +namespace Melanzana.CodeSign +{ + /// + /// Rewriter for the Mach-O or universal binaries that resizes the code signature section + /// and all related linker commands to make space for new signature. + /// + public class CodeSignAllocate + { + public IList objectFiles; + + public CodeSignAllocate(IList objectFiles) + { + this.objectFiles = objectFiles; + } + + public void SetArchSize(MachObjectFile machO, uint codeSignatureSize) + { + // Page alignment + codeSignatureSize = (codeSignatureSize + 0x3fffu) & ~0x3fffu; + + UpdateCodeSignatureLayout(machO, codeSignatureSize); + } + + public string Allocate() + { + var tempFileName = Path.GetTempFileName(); + using var output = File.OpenWrite(tempFileName); + MachWriter.Write(output, objectFiles); + return tempFileName; + } + + private static void UpdateCodeSignatureLayout(MachObjectFile machO, uint codeSignatureSize) + { + var linkEditSegment = machO.LoadCommands.OfType().First(s => s.Name == "__LINKEDIT"); + var codeSignatureCommand = machO.LoadCommands.OfType().FirstOrDefault(); + + if (codeSignatureCommand == null) + { + codeSignatureCommand = new MachCodeSignature(machO); + codeSignatureCommand.Data.FileOffset = (uint)machO.GetSigningLimit(); + machO.LoadCommands.Add(codeSignatureCommand); + } + + codeSignatureCommand.Data.Size = codeSignatureSize; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs new file mode 100644 index 00000000000000..902a0b370b41ea --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs @@ -0,0 +1,37 @@ +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; + +namespace Melanzana.CodeSign +{ + public class CodeSignOptions + { + /// + /// Gets or sets the developer certificate used for signing. + /// + /// + /// Set to `null` to use adhoc signing. + /// + public X509Certificate2? DeveloperCertificate { get; set; } + + /// + /// Gets or sets a private key used for signing. + /// + /// + /// This property can be used to augment the developer certificate set through + /// . It can either be used when the developer + /// certificate itself doesn't contain the private key or the private key signing + /// is provided through external service or device. + /// + public AsymmetricAlgorithm? PrivateKey { get; set; } + + /// + /// Gets or sets the entitlements to be embedded in the signature. + /// + public Entitlements? Entitlements { get; set; } + + /// + /// Gets or sets whether the nested exectuables should be signed. + /// + public bool Deep { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs new file mode 100644 index 00000000000000..4fe066fc7498a4 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs @@ -0,0 +1,31 @@ +using System.Buffers.Binary; +using System.Text; +using Claunia.PropertyList; + +namespace Melanzana.CodeSign +{ + public class Entitlements + { + public Entitlements(NSDictionary plist) + { + PList = plist; + } + + public NSDictionary PList { get; set; } + + public bool GetTaskAllow => GetBoolEntitlement("get-task-allow"); + public bool RunUnsignedCode => GetBoolEntitlement("run-unsigned-code"); + public bool Debugger => GetBoolEntitlement("com.apple.private.cs.debugger"); + public bool DynamicCodeSigning => GetBoolEntitlement("dynamic-codesigning"); + public bool SkipLibraryValidation => GetBoolEntitlement("com.apple.private.skip-library-validation"); + public bool CanLoadCdHash => GetBoolEntitlement("com.apple.private.amfi.can-load-cdhash"); + public bool CanExecuteCdHash => GetBoolEntitlement("com.apple.private.amfi.can-execute-cdhash"); + + private bool GetBoolEntitlement(string name) + { + if (PList.TryGetValue(name, out var temp) && temp is NSNumber number && number.isBoolean()) + return number.ToBool(); + return false; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj new file mode 100644 index 00000000000000..28dcb8622ba5fb --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + enable + enable + + true + $(BaseIntermediateOutputPath)/GeneratedFiles + + + + + + + + + + + + + + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs new file mode 100644 index 00000000000000..d7b03624ed6560 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs @@ -0,0 +1,86 @@ +using System.Formats.Asn1; + +namespace Claunia.PropertyList +{ + public static class DerPropertyListWriter + { + public static byte[] Write(NSObject value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + var asnWriter = new AsnWriter(AsnEncodingRules.DER); + Write(asnWriter, value); + return asnWriter.Encode(); + } + + private static void Write(AsnWriter writer, NSObject value) + { + switch (value) + { + case NSDictionary dictionary: + Write(writer, dictionary); + break; + case NSNumber number: + Write(writer, number); + break; + case NSString @string: + Write(writer, @string); + break; + case NSArray array: + Write(writer, array); + break; + } + } + + private static void Write(AsnWriter writer, NSDictionary dictionary) + { + using (writer.PushSetOf()) + { + foreach (KeyValuePair entry in dictionary) + { + using (writer.PushSequence()) + { + writer.WriteCharacterString(UniversalTagNumber.UTF8String, entry.Key); + Write(writer, entry.Value); + } + } + } + } + + private static void Write(AsnWriter writer, NSArray array) + { + using (writer.PushSequence()) + { + foreach (NSObject item in array) + { + Write(writer, item); + } + } + } + + private static void Write(AsnWriter writer, NSString @string) + { + writer.WriteCharacterString(UniversalTagNumber.UTF8String, @string.ToString()); + } + + private static void Write(AsnWriter writer, NSNumber number) + { + if (number.isBoolean()) + { + writer.WriteBoolean(number.ToBool()); + return; + } + else if (number.isInteger()) + { + writer.WriteInteger(number.ToInt()); + } + else + { + throw new NotSupportedException(); + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs new file mode 100644 index 00000000000000..bb56bb099650e5 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs @@ -0,0 +1,29 @@ +using System.Security.Cryptography.Pkcs; +using System.Security.Cryptography.X509Certificates; +using Claunia.PropertyList; + +namespace Melanzana.CodeSign +{ + public class ProvisioningProfile + { + private readonly NSDictionary plist; + + public ProvisioningProfile(string fileName) + { + var signedCms = new SignedCms(); + signedCms.Decode(File.ReadAllBytes(fileName)); + var contentInfo = signedCms.ContentInfo; + var content = contentInfo.Content; + + plist = (NSDictionary)XmlPropertyListParser.Parse(content); + + } + + public IEnumerable TeamIdentifiers => ((NSArray)plist["TeamIdentifier"]).Select(i => i.ToString()!).ToArray(); + + public IEnumerable DeveloperCertificates => + ((NSArray)plist["DeveloperCertificates"]).OfType().Select(d => new X509Certificate2((byte[])d)); + + public NSDictionary Entitlements => (NSDictionary)plist["Entitlements"]; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs new file mode 100644 index 00000000000000..a749a6a047d44f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs @@ -0,0 +1,89 @@ +using System.Buffers.Binary; +using System.Text; +using System.Formats.Asn1; +using Melanzana.MachO; + +namespace Melanzana.CodeSign.Requirements +{ + public abstract partial class Expression + { + private static int Align(int size) => (size + 3) & ~3; + + private static byte[] GetOidBytes(string oid) + { + var asnWriter = new AsnWriter(AsnEncodingRules.DER); + asnWriter.WriteObjectIdentifier(oid); + return asnWriter.Encode().AsSpan(2).ToArray(); + } + + private static string GetOidString(byte[] oid) + { + var oidBytes = new byte[oid.Length + 2]; + oidBytes[0] = 6; + oidBytes[1] = (byte)oid.Length; + oid.CopyTo(oidBytes.AsSpan(2)); + return AsnDecoder.ReadObjectIdentifier(oidBytes, AsnEncodingRules.DER, out _); + } + + private static byte[] GetTimestampBytes(DateTime dateTime) + { + long tsSeconds = (long)(dateTime - new DateTime(2001, 1, 1)).TotalSeconds; + var buffer = new byte[8]; + BinaryPrimitives.WriteInt64BigEndian(buffer, tsSeconds); + return buffer; + } + + private static string GetTimestampString(byte[] dateTime) + { + var tsSeconds = BinaryPrimitives.ReadInt64BigEndian(dateTime); + return new DateTime(2001, 1, 1).AddSeconds(tsSeconds).ToString("yyyyMMddHHmmssZ"); + } + + private static string BinaryValueToString(byte[] bytes) + { + return $"0x{Convert.ToHexString(bytes)}"; + } + + private static string ValueToString(byte[] bytes) + { + bool isPrintable = bytes.All(c => !char.IsControl((char)c) && char.IsAscii((char)c)); + if (!isPrintable) + { + return BinaryValueToString(bytes); + } + + bool needQuoting = + bytes.Length == 0 || + char.IsDigit((char)bytes[0]) || + bytes.Any(c => !char.IsLetterOrDigit((char)c)); + if (needQuoting) + { + var sb = new StringBuilder(); + sb.Append('"'); + foreach (var c in bytes) + { + if (c == (byte)'\\' || c == (byte)'"') + { + sb.Append('\\'); + } + sb.Append((char)c); + } + sb.Append('"'); + return sb.ToString(); + } + else + { + return Encoding.ASCII.GetString(bytes); + } + } + + private static string CertificateSlotToString(int slot) + { + return slot switch { + 0 => "leaf", + -1 => "root", + _ => slot.ToString(), + }; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs new file mode 100644 index 00000000000000..ba1067dddd96e0 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs @@ -0,0 +1,470 @@ +using System.Buffers.Binary; +using System.Text; +using System.Formats.Asn1; +using Melanzana.MachO; + +namespace Melanzana.CodeSign.Requirements +{ + public abstract partial class Expression + { + class SimpleExpression : Expression + { + ExpressionOperation op; + + public SimpleExpression(ExpressionOperation op) + { + this.op = op; + } + + public override int Size => 4; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); + bytesWritten = 4; + } + + public override string ToString() + { + return op switch { + ExpressionOperation.False => "never", + ExpressionOperation.True => "always", + ExpressionOperation.AppleAnchor => "anchor apple", + ExpressionOperation.AppleGenericAnchor => "anchor apple generic", + ExpressionOperation.TrustedCerts => "anchor trusted", + ExpressionOperation.Notarized => "notarized", + ExpressionOperation.LegacyDevID => "legacy", + _ => "unknown", + }; + } + } + + class BinaryOperatorExpression : Expression + { + ExpressionOperation op; + Expression left; + Expression right; + + public BinaryOperatorExpression(ExpressionOperation op, Expression left, Expression right) + { + this.op = op; + this.left = left; + this.right = right; + } + + public override int Size => 4 + left.Size + right.Size; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); + left.Write(buffer.Slice(4), out var bytesWrittenLeft); + right.Write(buffer.Slice(4 + bytesWrittenLeft), out var bytesWrittenRight); + bytesWritten = 4 + bytesWrittenLeft + bytesWrittenRight; + } + + private string? WrapInnerExpression(Expression innerExpression) + { + if (innerExpression is BinaryOperatorExpression boe && + boe.op != op) + { + return $"({boe})"; + } + + return innerExpression.ToString(); + } + + public override string ToString() + { + return op switch { + ExpressionOperation.And => $"{WrapInnerExpression(left)} and {WrapInnerExpression(right)}", + ExpressionOperation.Or => $"{WrapInnerExpression(left)} or {WrapInnerExpression(right)}", + _ => "unknown", + }; + } + } + + class UnaryOperatorExpression : Expression + { + ExpressionOperation op; + Expression inner; + + public UnaryOperatorExpression(ExpressionOperation op, Expression inner) + { + this.op = op; + this.inner = inner; + } + + public override int Size => 4 + inner.Size; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); + inner.Write(buffer.Slice(4), out var bytesWrittenInner); + bytesWritten = 4 + bytesWrittenInner; + } + + public override string ToString() + { + return op switch { + ExpressionOperation.Not => $"! {inner}", + _ => "unknown", + }; + } + } + + class StringExpression : Expression + { + ExpressionOperation op; + string opString; + + public StringExpression(ExpressionOperation op, string opString) + { + this.op = op; + this.opString = opString; + } + + public override int Size => 8 + Align(Encoding.UTF8.GetByteCount(opString)); + + public override void Write(Span buffer, out int bytesWritten) + { + byte[] opStringBytes = Encoding.UTF8.GetBytes(opString); + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), opStringBytes.Length); + opStringBytes.CopyTo(buffer.Slice(8, opStringBytes.Length)); + buffer.Slice(8 + opStringBytes.Length, Align(opStringBytes.Length) - opStringBytes.Length).Fill((byte)0); + bytesWritten = 8 + Align(opStringBytes.Length); + } + + public override string ToString() + { + return op switch { + ExpressionOperation.Ident => $"identifier \"{opString}\"", // FIXME: Escaping + _ => "unknown", + }; + } + } + + class CDHashExpression : Expression + { + private readonly byte[] codeDirectoryHash; + + public CDHashExpression(byte[] codeDirectoryHash) + { + this.codeDirectoryHash = codeDirectoryHash; + } + + public override int Size => 4 + codeDirectoryHash.Length; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)ExpressionOperation.CDHash); + codeDirectoryHash.CopyTo(buffer.Slice(4, codeDirectoryHash.Length)); + bytesWritten = 4 + codeDirectoryHash.Length; + } + + public override string ToString() + { + return $"cdhash H\"{Convert.ToHexString(codeDirectoryHash)}\""; + } + } + + class AnchorHashExpression : Expression + { + private readonly int certificateIndex; + private readonly byte[] anchorHash; + + public AnchorHashExpression(int certificateIndex, byte[] anchorHash) + { + this.certificateIndex = certificateIndex; + this.anchorHash = anchorHash; + } + + public override int Size => 8 + anchorHash.Length; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.AnchorHash); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), anchorHash.Length); + anchorHash.CopyTo(buffer.Slice(8, anchorHash.Length)); + bytesWritten = 8 + anchorHash.Length; + } + + public override string ToString() + { + return $"certificate {CertificateSlotToString(certificateIndex)} = H\"{Convert.ToHexString(anchorHash)}\""; + } + } + + abstract class MatchExpression : Expression + { + ExpressionMatchType matchType; + byte[]? matchValue; + + public MatchExpression(ExpressionMatchType matchType, byte[]? matchValue) + { + this.matchType = matchType; + this.matchValue = matchValue; + } + + public override int Size => + 4 + + (matchValue != null ? 4 + Align(matchValue.Length) : 0); + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)matchType); + if (matchValue != null) + { + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), matchValue.Length); + matchValue.CopyTo(buffer.Slice(8, matchValue.Length)); + buffer.Slice(8 + matchValue.Length, Align(matchValue.Length) - matchValue.Length).Fill((byte)0); + bytesWritten = 8 + Align(matchValue.Length); + } + else + { + bytesWritten = 4; + } + } + + public override string ToString() + { + return matchType switch { + ExpressionMatchType.Exists => "/* exists */", + ExpressionMatchType.Absent => "absent", + ExpressionMatchType.Equal => $"= {ValueToString(matchValue!)}", + ExpressionMatchType.Contains => $"~ {ValueToString(matchValue!)}", + ExpressionMatchType.BeginsWith => $"= {ValueToString(matchValue!)}*", + ExpressionMatchType.EndsWith => $"= *{ValueToString(matchValue!)}", + ExpressionMatchType.LessThan => $"< {ValueToString(matchValue!)}", + ExpressionMatchType.GreaterEqual => $">= {ValueToString(matchValue!)}", + ExpressionMatchType.LessEqual => $"<= {ValueToString(matchValue!)}", + ExpressionMatchType.GreaterThan => $">= {ValueToString(matchValue!)}", + ExpressionMatchType.On => $"= timestamp \"{GetTimestampString(matchValue!)}\"", + ExpressionMatchType.Before => $"< timestamp \"{GetTimestampString(matchValue!)}\"", + ExpressionMatchType.After => $"> timestamp \"{GetTimestampString(matchValue!)}\"", + ExpressionMatchType.OnOrBefore => $"<= timestamp \"{GetTimestampString(matchValue!)}\"", + ExpressionMatchType.OnOrAfter => $">= timestamp \"{GetTimestampString(matchValue!)}\"", + _ => "unknown", + }; + } + } + + class FieldMatchExpression : MatchExpression + { + private readonly ExpressionOperation op; + private readonly object field; + private readonly byte[] fieldBytes; + + public FieldMatchExpression( + ExpressionOperation op, + string field, + ExpressionMatchType matchType, + byte[]? matchValue) + : base(matchType, matchValue) + { + this.op = op; + this.field = field; + fieldBytes = Encoding.ASCII.GetBytes(field); + } + + public override int Size => + 8 + + Align(fieldBytes.Length) + + base.Size; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)op); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), fieldBytes.Length); + fieldBytes.CopyTo(buffer.Slice(8, fieldBytes.Length)); + buffer.Slice(8 + fieldBytes.Length, Align(fieldBytes.Length) - fieldBytes.Length).Fill((byte)0); + bytesWritten = 8 + Align(fieldBytes.Length); + base.Write(buffer.Slice(bytesWritten), out var matchExpressionSize); + bytesWritten += matchExpressionSize; + } + + + public override string ToString() + { + return op switch { + ExpressionOperation.InfoKeyField => $"info[{field}] {base.ToString()}", + ExpressionOperation.EntitlementField => $"entitlement[{field}] {base.ToString()}", + _ => "unknown", + }; + } + } + + class CertExpression : MatchExpression + { + private readonly ExpressionOperation op; + private readonly int certificateIndex; + private readonly byte[] certificateField; + + public CertExpression( + ExpressionOperation op, + int certificateIndex, + byte[] certificateField, + ExpressionMatchType matchType, + byte[]? matchValue) + : base(matchType, matchValue) + { + this.op = op; + this.certificateIndex = certificateIndex; + this.certificateField = certificateField; + } + + public override int Size => + 12 + + Align(certificateField.Length) + + base.Size; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), certificateIndex); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(8), certificateField.Length); + certificateField.CopyTo(buffer.Slice(12, certificateField.Length)); + buffer.Slice(12 + certificateField.Length, Align(certificateField.Length) - certificateField.Length).Fill((byte)0); + bytesWritten = 12 + Align(certificateField.Length); + base.Write(buffer.Slice(bytesWritten), out var matchExpressionSize); + bytesWritten += matchExpressionSize; + } + + + public override string ToString() + { + return op switch { + ExpressionOperation.CertField => $"certificate {CertificateSlotToString(certificateIndex)}[{Encoding.ASCII.GetString(certificateField)}] {base.ToString()}", + ExpressionOperation.CertGeneric => $"certificate {CertificateSlotToString(certificateIndex)}[field.{GetOidString(certificateField)}] {base.ToString()}", + ExpressionOperation.CertPolicy => $"certificate {CertificateSlotToString(certificateIndex)}[policy.{GetOidString(certificateField)}] {base.ToString()}", + ExpressionOperation.CertFieldDate => $"certificate {CertificateSlotToString(certificateIndex)}[timestamp.{GetOidString(certificateField)}] {base.ToString()}", + _ => "unknown", + }; + } + } + + class InfoKeyValueExpression : Expression + { + private readonly object field; + private readonly byte[] fieldBytes; + private readonly byte[] matchValue; + + public InfoKeyValueExpression( + string field, + byte[] matchValue) + { + this.field = field; + this.matchValue = matchValue; + + fieldBytes = Encoding.ASCII.GetBytes(field); + } + + public override int Size => + 12 + + Align(fieldBytes.Length) + + Align(matchValue.Length); + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.InfoKeyValue); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), fieldBytes.Length); + fieldBytes.CopyTo(buffer.Slice(8, fieldBytes.Length)); + buffer.Slice(8 + fieldBytes.Length, Align(fieldBytes.Length) - fieldBytes.Length).Fill((byte)0); + bytesWritten = 8 + Align(fieldBytes.Length); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(bytesWritten, 4), matchValue.Length); + fieldBytes.CopyTo(buffer.Slice(bytesWritten + 4, matchValue.Length)); + buffer.Slice(4 + bytesWritten + matchValue.Length, Align(matchValue.Length) - matchValue.Length).Fill((byte)0); + bytesWritten += 4 + Align(matchValue.Length); + } + + public override string ToString() + { + return $"info[{field}] = {ValueToString(matchValue)}"; + } + } + + class NamedExpression : Expression + { + private readonly ExpressionOperation op; + private readonly byte[] name; + + public NamedExpression( + ExpressionOperation op, + byte[] name) + { + this.op = op; + this.name = name; + } + + public override int Size => + 8 + + Align(name.Length); + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)op); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), name.Length); + name.CopyTo(buffer.Slice(8, name.Length)); + buffer.Slice(8 + name.Length, Align(name.Length) - name.Length).Fill((byte)0); + bytesWritten = 8 + Align(name.Length); + } + + public override string ToString() + { + return op switch { + ExpressionOperation.NamedAnchor => $"anchor apple {ValueToString(name)}", + ExpressionOperation.NamedCode => $"({ValueToString(name)})", + _ => "unknown", + }; + } + } + + class TrustedCertExpression : Expression + { + private readonly int certificateIndex; + + public TrustedCertExpression(int certificateIndex) + { + this.certificateIndex = certificateIndex; + } + + public override int Size => 8; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.TrustedCert); + BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), certificateIndex); + bytesWritten = 8; + } + + public override string ToString() + { + return $"certificate {CertificateSlotToString(certificateIndex)} trusted"; + } + } + + class PlatformExpression : Expression + { + private readonly MachPlatform platform; + + public PlatformExpression(MachPlatform platform) + { + this.platform = platform; + } + + public override int Size => 8; + + public override void Write(Span buffer, out int bytesWritten) + { + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.Platform); + BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(4, 4), (uint)platform); + bytesWritten = 8; + } + + public override string ToString() + { + return $"platform = {platform}"; + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs new file mode 100644 index 00000000000000..6bf4ae60bd5f2a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs @@ -0,0 +1,157 @@ +using System.Buffers.Binary; +using System.Text; +using Melanzana.MachO; + +namespace Melanzana.CodeSign.Requirements +{ + public abstract partial class Expression + { + private static byte[] GetData(ReadOnlySpan expr, out int bytesRead) + { + var length = BinaryPrimitives.ReadInt32BigEndian(expr); + bytesRead = 4 + Align(length); + return expr.Slice(4, length).ToArray(); + } + + private static byte[]? GetMatchData(ReadOnlySpan expr, ExpressionMatchType matchType, out int bytesRead) + { + if (matchType != ExpressionMatchType.Exists && matchType != ExpressionMatchType.Absent) + { + return GetData(expr, out bytesRead); + } + + bytesRead = 0; + return null; + } + + private static Expression FromBlob(ReadOnlySpan expr, out int bytesRead) + { + if (expr.Length == 0) + throw new NotImplementedException(); + + var op = (ExpressionOperation)BinaryPrimitives.ReadUInt32BigEndian(expr); + switch (op) + { + case ExpressionOperation.False: + bytesRead = 4; + return False; + + case ExpressionOperation.True: + bytesRead = 4; + return True; + + case ExpressionOperation.Ident: + var identifier = GetData(expr.Slice(4), out bytesRead); + bytesRead += 4; + return Ident(Encoding.ASCII.GetString(identifier)); + + case ExpressionOperation.AppleAnchor: + bytesRead = 4; + return AppleAnchor; + + case ExpressionOperation.AnchorHash: + var certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); + var hash = GetData(expr.Slice(8), out bytesRead); + bytesRead += 8; + return AnchorHash(certificateIndex, hash); + + case ExpressionOperation.InfoKeyValue: + var field = GetData(expr.Slice(4), out var fieldBytesRead); + var value = GetData(expr.Slice(4 + fieldBytesRead), out bytesRead); + bytesRead += 4 + fieldBytesRead; + return InfoKeyValue(Encoding.ASCII.GetString(field), Encoding.ASCII.GetString(value)); + + case ExpressionOperation.And: + var left = FromBlob(expr.Slice(4), out var leftBytesRead); + var right = FromBlob(expr.Slice(4 + leftBytesRead), out bytesRead); + bytesRead += 4 + leftBytesRead; + return And(left, right); + + case ExpressionOperation.Or: + left = FromBlob(expr.Slice(4), out leftBytesRead); + right = FromBlob(expr.Slice(4 + leftBytesRead), out bytesRead); + bytesRead += 4 + leftBytesRead; + return Or(left, right); + + case ExpressionOperation.CDHash: + hash = GetData(expr.Slice(4), out bytesRead); + bytesRead += 4; + return CDHash(hash); + + case ExpressionOperation.Not: + var inner = FromBlob(expr.Slice(4), out bytesRead); + bytesRead += 4; + return Not(inner); + + case ExpressionOperation.InfoKeyField: + field = GetData(expr.Slice(4), out fieldBytesRead); + var matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(4 + fieldBytesRead, 4)); + var matchValue = GetMatchData(expr.Slice(8 + fieldBytesRead), matchType, out var matchValueBytesRead); + bytesRead = 8 + fieldBytesRead + matchValueBytesRead; + return InfoKeyField(Encoding.ASCII.GetString(field), matchType, matchValue != null ? Encoding.ASCII.GetString(matchValue) : null); + + case ExpressionOperation.CertField: + case ExpressionOperation.CertGeneric: + case ExpressionOperation.CertPolicy: + case ExpressionOperation.CertFieldDate: + certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); + field = GetData(expr.Slice(8), out fieldBytesRead); + matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(8 + fieldBytesRead, 4)); + matchValue = GetMatchData(expr.Slice(12 + fieldBytesRead), matchType, out matchValueBytesRead); + bytesRead = 12 + fieldBytesRead + matchValueBytesRead; + return new CertExpression(op, certificateIndex, field, matchType, matchValue); + + case ExpressionOperation.TrustedCert: + certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); + bytesRead = 8; + return TrustedCert(certificateIndex); + + case ExpressionOperation.TrustedCerts: + bytesRead = 4; + return TrustedCerts; + + case ExpressionOperation.AppleGenericAnchor: + bytesRead = 4; + return AppleGenericAnchor; + + case ExpressionOperation.EntitlementField: + field = GetData(expr.Slice(4), out fieldBytesRead); + matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(4 + fieldBytesRead, 4)); + matchValue = GetMatchData(expr.Slice(8 + fieldBytesRead), matchType, out matchValueBytesRead); + bytesRead = 8 + fieldBytesRead + matchValueBytesRead; + return EntitlementField(Encoding.ASCII.GetString(field), matchType, matchValue != null ? Encoding.ASCII.GetString(matchValue) : null); + + case ExpressionOperation.NamedAnchor: + var anchorName = GetData(expr.Slice(4), out bytesRead); + bytesRead += 4; + return NamedAnchor(Encoding.ASCII.GetString(anchorName)); + + case ExpressionOperation.NamedCode: + var codeName = GetData(expr.Slice(4), out bytesRead); + bytesRead += 4; + return NamedCode(Encoding.ASCII.GetString(codeName)); + + case ExpressionOperation.Platform: + var platform = (MachPlatform)BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); + bytesRead = 8; + return Platform(platform); + + case ExpressionOperation.Notarized: + bytesRead = 4; + return Notarized; + + case ExpressionOperation.LegacyDevID: + bytesRead = 4; + return LegacyDevID; + + default: + throw new NotSupportedException(); + } + } + + public static Expression FromBlob(ReadOnlySpan expr) + { + return FromBlob(expr, out _); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs new file mode 100644 index 00000000000000..da58f6a742519e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs @@ -0,0 +1,42 @@ +using System.Buffers.Binary; +using System.Text; +using System.Formats.Asn1; +using Melanzana.MachO; + +namespace Melanzana.CodeSign.Requirements +{ + public abstract partial class Expression + { + public static Expression False { get; } = new SimpleExpression(ExpressionOperation.False); + public static Expression True { get; } = new SimpleExpression(ExpressionOperation.True); + public static Expression Ident(string identifier) => new StringExpression(ExpressionOperation.Ident, identifier); + public static Expression AppleAnchor { get; } = new SimpleExpression(ExpressionOperation.AppleAnchor); + public static Expression AnchorHash(int certificateIndex, byte[] anchorHash) => new AnchorHashExpression(certificateIndex, anchorHash); + public static Expression InfoKeyValue(string field, string matchValue) + => new InfoKeyValueExpression(field, Encoding.ASCII.GetBytes(matchValue)); + public static Expression And(Expression left, Expression right) => new BinaryOperatorExpression(ExpressionOperation.And, left, right); + public static Expression Or(Expression left, Expression right) => new BinaryOperatorExpression(ExpressionOperation.Or, left, right); + public static Expression CDHash(byte[] codeDirectoryHash) => new CDHashExpression(codeDirectoryHash); + public static Expression Not(Expression inner) => new UnaryOperatorExpression(ExpressionOperation.Not, inner); + public static Expression InfoKeyField(string field, ExpressionMatchType matchType, string? matchValue = null) + => new FieldMatchExpression(ExpressionOperation.InfoKeyField, field, matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); + public static Expression CertField(int certificateIndex, string certificateField, ExpressionMatchType matchType, string? matchValue = null) + => new CertExpression(ExpressionOperation.CertField, certificateIndex, Encoding.ASCII.GetBytes(certificateField), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); + public static Expression TrustedCert(int certificateIndex) => new TrustedCertExpression(certificateIndex); + public static Expression TrustedCerts { get; } = new SimpleExpression(ExpressionOperation.TrustedCerts); + public static Expression CertGeneric(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, string? matchValue = null) + => new CertExpression(ExpressionOperation.CertGeneric, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); + public static Expression AppleGenericAnchor { get; } = new SimpleExpression(ExpressionOperation.AppleGenericAnchor); + public static Expression EntitlementField(string field, ExpressionMatchType matchType, string? matchValue = null) + => new FieldMatchExpression(ExpressionOperation.EntitlementField, field, matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); + public static Expression CertPolicy(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, string? matchValue = null) + => new CertExpression(ExpressionOperation.CertPolicy, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); + public static Expression NamedAnchor(string anchorName) => new NamedExpression(ExpressionOperation.NamedAnchor, Encoding.ASCII.GetBytes(anchorName)); + public static Expression NamedCode(string code) => new NamedExpression(ExpressionOperation.NamedCode, Encoding.ASCII.GetBytes(code)); + public static Expression Platform(MachPlatform platform) => new PlatformExpression(platform); + public static Expression Notarized { get; } = new SimpleExpression(ExpressionOperation.Notarized); + public static Expression CertFieldDate(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, DateTime? matchValue = null) + => new CertExpression(ExpressionOperation.CertFieldDate, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue.HasValue ? GetTimestampBytes(matchValue.Value) : null); + public static Expression LegacyDevID { get; } = new SimpleExpression(ExpressionOperation.LegacyDevID); + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs new file mode 100644 index 00000000000000..488ffb979f9d8e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs @@ -0,0 +1,9 @@ +namespace Melanzana.CodeSign.Requirements +{ + public abstract partial class Expression + { + public abstract int Size { get; } + + public abstract void Write(Span buffer, out int bytesWritten); + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs new file mode 100644 index 00000000000000..b571ed373bb76f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs @@ -0,0 +1,21 @@ +namespace Melanzana.CodeSign.Requirements +{ + public enum ExpressionMatchType : int + { + Exists, + Equal, + Contains, + BeginsWith, + EndsWith, + LessThan, + GreaterThan, + LessEqual, + GreaterEqual, + On, + Before, + After, + OnOrBefore, + OnOrAfter, + Absent, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs new file mode 100644 index 00000000000000..8ab1c93cc056be --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs @@ -0,0 +1,30 @@ +namespace Melanzana.CodeSign.Requirements +{ + public enum ExpressionOperation : int + { + False, + True, + Ident, + AppleAnchor, + AnchorHash, + InfoKeyValue, + And, + Or, + CDHash, + Not, + InfoKeyField, + CertField, + TrustedCert, + TrustedCerts, + CertGeneric, + AppleGenericAnchor, + EntitlementField, + CertPolicy, + NamedAnchor, + NamedCode, + Platform, + Notarized, + CertFieldDate, + LegacyDevID, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs new file mode 100644 index 00000000000000..4f5d8b0e437216 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs @@ -0,0 +1,41 @@ +using System.Buffers.Binary; +using System.Diagnostics; +using Melanzana.CodeSign.Blobs; + +namespace Melanzana.CodeSign.Requirements +{ + public class Requirement + { + public Requirement(Expression expression) + { + Expression = expression; + } + + public Expression Expression { get; private set; } + + public static Requirement FromBlob(ReadOnlySpan blob) + { + var blobMagic = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(0, 4)); + var blobSize = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(4, 4)); + var matchType = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(8, 4)); + Debug.Assert(blobMagic == (uint)BlobMagic.Requirement); + Debug.Assert(blobSize == blob.Length); + Debug.Assert(matchType == 1u); // Expression + return new Requirement(Expression.FromBlob(blob.Slice(12))); + } + + public byte[] AsBlob() + { + byte[] blobBuffer = new byte[Expression.Size + 12]; + + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Requirement); + BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(4, 4), blobBuffer.Length); + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(8, 4), 1u); // Expression + Expression.Write(blobBuffer.AsSpan(12), out var _); + + return blobBuffer; + } + + public override string? ToString() => Expression.ToString(); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs new file mode 100644 index 00000000000000..67dbcb6d418e81 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs @@ -0,0 +1,73 @@ +using System.Buffers.Binary; +using System.Diagnostics; +using Melanzana.CodeSign.Blobs; + +namespace Melanzana.CodeSign.Requirements +{ + public class RequirementSet : Dictionary + { + public RequirementSet() + { + } + + public static RequirementSet FromBlob(ReadOnlySpan blob) + { + var requirementSet = new RequirementSet(); + var superBlobMagic = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(0, 4)); + var subBlobCount = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(8, 4)); + Debug.Assert(superBlobMagic == (uint)BlobMagic.Requirements); + for (int i = 0; i < subBlobCount; i++) + { + var requirementType = (RequirementType)BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(12 + i * 8, 4)); + var blobOffset = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(16 + i * 8, 4)); + var blobSize = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(blobOffset + 4, 4)); + requirementSet[requirementType] = Requirement.FromBlob(blob.Slice(blobOffset, blobSize)); + } + return requirementSet; + } + + public byte[] AsBlob() + { + var requirentBlobs = this.Select(i => new { Type = i.Key, Blob = i.Value.AsBlob() }).ToArray(); + var blobBuffer = new byte[12 + requirentBlobs.Sum(i => i.Blob.Length + 8)]; + + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Requirements); + BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(4, 4), blobBuffer.Length); + BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(8, 4), requirentBlobs.Length); + + int offset = 12 + (requirentBlobs.Length * 8); + for (int i = 0; i < requirentBlobs.Length; i++) + { + BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(12 + (i * 8), 4), (uint)requirentBlobs[i].Type); + BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(16 + (i * 8), 4), offset); + requirentBlobs[i].Blob.CopyTo(blobBuffer.AsSpan(offset, requirentBlobs[i].Blob.Length)); + offset += requirentBlobs[i].Blob.Length; + } + + return blobBuffer; + } + + //public override string? ToString() => Expression.ToString(); + + public static RequirementSet CreateDefault(string bundleIdentifier, string certificateFriendlyName) + { + if (string.IsNullOrEmpty(bundleIdentifier)) + throw new ArgumentNullException(nameof(bundleIdentifier)); + if (string.IsNullOrEmpty(certificateFriendlyName)) + throw new ArgumentNullException(nameof(certificateFriendlyName)); + + var expression = Expression.And( + Expression.Ident(bundleIdentifier), + Expression.And( + Expression.AppleGenericAnchor, + Expression.And( + Expression.CertField(0, "subject.CN", ExpressionMatchType.Equal, certificateFriendlyName), + Expression.CertGeneric(1, "1.2.840.113635.100.6.2.1", ExpressionMatchType.Exists) + ) + ) + ); + return new RequirementSet { { RequirementType.Designated, new Requirement(expression) }}; + } + + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs new file mode 100644 index 00000000000000..c75bcbe7f32e01 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs @@ -0,0 +1,12 @@ +namespace Melanzana.CodeSign.Requirements +{ + public enum RequirementType : uint + { + Host = 1u, + Guest, + Designated, + Library, + Plugin, + Invalid + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs new file mode 100644 index 00000000000000..b3246242a934b4 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs @@ -0,0 +1,98 @@ +namespace Melanzana.CodeSign +{ + public class ResourceBuilder + { + private readonly HashSet exclusions = new(); + private readonly List rules = new(); + + public ResourceBuilder() + { + } + + public void AddRule(ResourceRule rule) + { + rules.Add(rule); + } + + public void AddExclusion(string path) + { + exclusions.Add(path); + } + + public ResourceRule? FindRule(string path) + { + ResourceRule? bestRule = null; + + foreach (var candidateRule in rules) + { + if (bestRule == null || candidateRule.Weight >= bestRule.Weight) + { + if (candidateRule.IsMatch(path)) + { + if (bestRule == null || candidateRule.Weight > bestRule.Weight) + { + bestRule = candidateRule; + } + else if (bestRule.Weight == candidateRule.Weight && !bestRule.IsOmitted && candidateRule.IsOmitted) + { + // In case of matching weight compare by IsOmitted. Apple tools do this only + // for watchOS but we opt to do it everywhere. + bestRule = candidateRule; + } + } + } + } + + return bestRule; + } + + private IEnumerable<(string Path, FileSystemInfo Info, ResourceRule Rule)> Scan(string path, string relativePath) + { + var rootDirectoryInfo = new DirectoryInfo(path); + + foreach (var fsEntryInfo in rootDirectoryInfo.EnumerateFileSystemInfos().OrderBy(i => i.Name, StringComparer.Ordinal)) + { + string fsEntryPath = Path.Combine(relativePath, fsEntryInfo.Name); + + if (exclusions.Contains(fsEntryPath, StringComparer.OrdinalIgnoreCase)) + { + continue; + } + + var rule = FindRule(fsEntryPath); + + // TODO: Check symlinks (should be treated as files) + if (fsEntryInfo is FileInfo) + { + if (rule != null && !rule.IsOmitted) + { + yield return (fsEntryPath, fsEntryInfo, rule); + } + } + else if (fsEntryInfo is DirectoryInfo) + { + // Directories cannot be matched with omit/optional rules but + // they can be matched with a rule for nested bundle. + if (rule != null && rule.IsNested && fsEntryInfo.Extension.Length > 0) + { + yield return (fsEntryPath, fsEntryInfo, rule); + } + else + { + foreach (var nestedResult in Scan(fsEntryInfo.FullName, fsEntryPath)) + { + yield return nestedResult; + } + } + } + } + } + + public IEnumerable <(string Path, FileSystemInfo Info, ResourceRule Rule)> Scan(string bundlePath) + { + return Scan(bundlePath, ""); + } + + public IEnumerable Rules => rules; + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs new file mode 100644 index 00000000000000..8848cf2a239a3a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs @@ -0,0 +1,32 @@ +using System.Text.RegularExpressions; + +namespace Melanzana.CodeSign +{ + public class ResourceRule + { + /// Resource may be absent at runtime + public bool IsOptional { get; init; } + + /// Resource is not sealed even if present in the bundle + public bool IsOmitted { get; init; } + + /// Recursively signed code + public bool IsNested { get; init; } + + /// Precedence weight of the rule (rules with higher weight override rules with lower weight) + public uint Weight { get; init; } = 1; + + /// Regular expression pattern for match full path in the bundle + public string Pattern { get; private set; } + + private readonly Regex regex; + + public ResourceRule(string pattern) + { + Pattern = pattern; + regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); + } + + public bool IsMatch(string path) => regex.IsMatch(path); + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs new file mode 100644 index 00000000000000..5e3219679da567 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs @@ -0,0 +1,459 @@ +using Claunia.PropertyList; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using Melanzana.CodeSign.Blobs; +using Melanzana.MachO; +using Melanzana.Streams; +using Melanzana.CodeSign.Requirements; + +namespace Melanzana.CodeSign +{ + public class Signer + { + private readonly CodeSignOptions codeSignOptions; + + public Signer(CodeSignOptions codeSignOptions) + { + this.codeSignOptions = codeSignOptions; + } + + private string GetTeamId() + { + return codeSignOptions.DeveloperCertificate?.GetTeamId() ?? string.Empty; + } + + /// + /// Determine ideal set of hash types necessary for code signing. + /// + /// + /// macOS 10.11.4 and iOS/tvOS 11 have support for SHA-256. If the minimum platform + /// version specified in the executable is equal or higher than those we only + /// generate SHA-256. Otherwise we fallback to generating both SHA-1 and SHA-256. + /// + private static HashType[] GetHashTypesForObjectFile(MachObjectFile objectFile) + { + var buildVersion = objectFile.LoadCommands.OfType().FirstOrDefault(); + if (buildVersion != null) + { + switch (buildVersion.Platform) + { + case MachPlatform.MacOS: + if (buildVersion.MinimumPlatformVersion >= new Version(10, 11, 4)) + return new[] { HashType.SHA256 }; + break; + case MachPlatform.IOS: + case MachPlatform.TvOS: + if (buildVersion.MinimumPlatformVersion.Major >= 11) + return new[] { HashType.SHA256 }; + break; + } + } + return new[] { HashType.SHA1, HashType.SHA256 }; + } + + private void SignMachO(string executablePath, string? bundleIdentifier = null, byte[]? resourceSealBytes = null) + { + var teamId = GetTeamId(); + + bundleIdentifier ??= Path.GetFileName(executablePath); + + byte[]? requirementsBlob = null; + byte[]? entitlementsBlob = null; + byte[]? entitlementsDerBlob = null; + + var hashTypesPerArch = new Dictionary<(MachCpuType cpuType, uint cpuSubType), HashType[]>(); + var cdBuildersPerArch = new Dictionary<(MachCpuType cpuType, uint cpuSubType), CodeDirectoryBuilder[]>(); + + ExecutableSegmentFlags executableSegmentFlags = 0; + + if (codeSignOptions.DeveloperCertificate != null) + { + requirementsBlob = RequirementSet.CreateDefault( + bundleIdentifier, + codeSignOptions.DeveloperCertificate.GetNameInfo(X509NameType.SimpleName, false)).AsBlob(); + } + + if (codeSignOptions.Entitlements is Entitlements entitlements) + { + executableSegmentFlags |= entitlements.GetTaskAllow ? ExecutableSegmentFlags.AllowUnsigned : 0; + executableSegmentFlags |= entitlements.RunUnsignedCode ? ExecutableSegmentFlags.AllowUnsigned : 0; + executableSegmentFlags |= entitlements.Debugger ? ExecutableSegmentFlags.Debugger : 0; + executableSegmentFlags |= entitlements.DynamicCodeSigning ? ExecutableSegmentFlags.Jit : 0; + executableSegmentFlags |= entitlements.SkipLibraryValidation ? ExecutableSegmentFlags.SkipLibraryValidation : 0; + executableSegmentFlags |= entitlements.CanLoadCdHash ? ExecutableSegmentFlags.CanLoadCdHash : 0; + executableSegmentFlags |= entitlements.CanExecuteCdHash ? ExecutableSegmentFlags.CanExecuteCdHash : 0; + + entitlementsBlob = EntitlementsBlob.Create(entitlements); + entitlementsDerBlob = EntitlementsDerBlob.Create(entitlements); + } + + var inputFile = File.OpenRead(executablePath); + var objectFiles = MachReader.Read(inputFile).ToList(); + var codeSignAllocate = new CodeSignAllocate(objectFiles); + foreach (var objectFile in objectFiles) + { + var hashTypes = GetHashTypesForObjectFile(objectFile); + var cdBuilders = new CodeDirectoryBuilder[hashTypes.Length]; + + hashTypesPerArch.Add((objectFile.CpuType, objectFile.CpuSubType), hashTypes); + cdBuildersPerArch.Add((objectFile.CpuType, objectFile.CpuSubType), cdBuilders); + + long signatureSizeEstimate = 18000; // Blob Wrapper (CMS) + for (int i = 0; i < hashTypes.Length; i++) + { + cdBuilders[i] = new CodeDirectoryBuilder(objectFile, bundleIdentifier, teamId) + { + HashType = hashTypes[i], + }; + + cdBuilders[i].ExecutableSegmentFlags |= executableSegmentFlags; + + if (codeSignOptions.DeveloperCertificate == null) + cdBuilders[i].Flags |= CodeDirectoryFlags.Adhoc; + if (requirementsBlob != null) + cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.Requirements, requirementsBlob); + if (entitlementsBlob != null) + cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.Entitlements, entitlementsBlob); + if (entitlementsDerBlob != null) + cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.EntitlementsDer, entitlementsDerBlob); + if (resourceSealBytes != null) + cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.ResourceDirectory, resourceSealBytes); + + signatureSizeEstimate += cdBuilders[i].Size(CodeDirectoryVersion.HighestVersion); + } + + signatureSizeEstimate += requirementsBlob?.Length ?? 0; + signatureSizeEstimate += entitlementsBlob?.Length ?? 0; + signatureSizeEstimate += entitlementsBlob?.Length ?? 0; + + var codeSignatureCommand = objectFile.LoadCommands.OfType().FirstOrDefault(); + if (codeSignatureCommand == null || + codeSignatureCommand.FileSize < signatureSizeEstimate) + { + codeSignAllocate.SetArchSize(objectFile, (uint)signatureSizeEstimate); + } + } + + string tempFileName = codeSignAllocate.Allocate(); + inputFile.Close(); + + // Re-read the object files + inputFile = File.OpenRead(tempFileName); + objectFiles = MachReader.Read(inputFile).ToList(); + foreach (var objectFile in objectFiles) + { + var hashTypes = hashTypesPerArch[(objectFile.CpuType, objectFile.CpuSubType)]; + var cdBuilders = cdBuildersPerArch[(objectFile.CpuType, objectFile.CpuSubType)]; + + var blobs = new List<(CodeDirectorySpecialSlot Slot, byte[] Data)>(); + var codeDirectory = cdBuilders[0].Build(objectFile.GetOriginalStream()); + + blobs.Add((CodeDirectorySpecialSlot.CodeDirectory, codeDirectory)); + if (requirementsBlob != null) + blobs.Add((CodeDirectorySpecialSlot.Requirements, requirementsBlob)); + if (entitlementsBlob != null) + blobs.Add((CodeDirectorySpecialSlot.Entitlements, entitlementsBlob)); + if (entitlementsDerBlob != null) + blobs.Add((CodeDirectorySpecialSlot.EntitlementsDer, entitlementsDerBlob)); + + var cdHashes = new byte[hashTypes.Length][]; + var hasher = hashTypes[0].GetIncrementalHash(); + hasher.AppendData(codeDirectory); + cdHashes[0] = hasher.GetHashAndReset(); + for (int i = 1; i < hashTypes.Length; i++) + { + byte[] alternativeCodeDirectory = cdBuilders[i].Build(objectFile.GetOriginalStream()); + blobs.Add((CodeDirectorySpecialSlot.AlternativeCodeDirectory + i - 1, alternativeCodeDirectory)); + hasher = hashTypes[i].GetIncrementalHash(); + hasher.AppendData(alternativeCodeDirectory); + cdHashes[i] = hasher.GetHashAndReset(); + } + + var cmsWrapperBlob = CmsWrapperBlob.Create( + codeSignOptions.DeveloperCertificate, + codeSignOptions.PrivateKey, + codeDirectory, + hashTypes, + cdHashes); + blobs.Add((CodeDirectorySpecialSlot.CmsWrapper, cmsWrapperBlob)); + + /// TODO: Hic sunt leones (all code below) + + // Rewrite LC_CODESIGNATURE data + var codeSignatureCommand = objectFile.LoadCommands.OfType().First(); + + // FIXME: Adjust the size to match LinkEdit section? + long size = blobs.Sum(b => b.Data != null ? b.Data.Length + 8 : 0); + + var embeddedSignatureBuffer = new byte[12 + (blobs.Count * 8)]; + BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(0, 4), (uint)BlobMagic.EmbeddedSignature); + BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(4, 4), (uint)(12 + size)); + BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(8, 4), (uint)blobs.Count); + int bufferOffset = 12; + int dataOffset = embeddedSignatureBuffer.Length; + foreach (var (slot, data) in blobs) + { + BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(bufferOffset, 4), (uint)slot); + BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(bufferOffset + 4, 4), (uint)dataOffset); + dataOffset += data.Length; + bufferOffset += 8; + } + uint codeSignatureSize = codeSignatureCommand.FileSize; + using var codeSignatureStream = codeSignatureCommand.Data.GetWriteStream(); + codeSignatureStream.Write(embeddedSignatureBuffer); + foreach (var (slot, data) in blobs) + { + codeSignatureStream.Write(data); + } + codeSignatureStream.WritePadding(codeSignatureSize - codeSignatureStream.Position); + } + + using var outputFile = File.OpenWrite(executablePath); + MachWriter.Write(outputFile, objectFiles); + inputFile.Close(); + } + + public void SignBundle(Bundle bundle) + { + var resourceSeal = BuildResourceSeal(bundle); + var resourceSealBytes = Encoding.UTF8.GetBytes(resourceSeal.ToXmlPropertyList()); + + Directory.CreateDirectory(Path.Combine(bundle.ContentsPath, "_CodeSignature")); + File.WriteAllBytes(Path.Combine(bundle.ContentsPath, "_CodeSignature", "CodeResources"), resourceSealBytes); + + if (bundle.MainExecutable != null) + { + SignMachO(bundle.MainExecutable, bundle.BundleIdentifier, resourceSealBytes); + } + } + + public void Sign(string path) + { + var attributes = File.GetAttributes(path); + + // Assume a directory is a bundle + if (attributes.HasFlag(FileAttributes.Directory)) + { + var bundle = new Bundle(path); + SignBundle(bundle); + } + else + { + // TODO: Add support for signing regular files, etc. + SignMachO(path); + } + } + + private static NSDictionary BuildResourceRulesPList(IEnumerable rules) + { + var rulesPList = new NSDictionary(); + + foreach (var rule in rules) + { + if (rule.Weight == 1 && !rule.IsNested && !rule.IsOmitted && !rule.IsOptional) + { + rulesPList.Add(rule.Pattern, true); + } + else + { + var rulePList = new NSDictionary(); + if (rule.Weight != 1) + rulePList.Add("weight", (double)rule.Weight); + if (rule.IsOmitted) + rulePList.Add("omit", true); + if (rule.IsOptional) + rulePList.Add("optional", true); + if (rule.IsNested) + rulePList.Add("nested", true); + rulesPList.Add(rule.Pattern, rulePList); + } + } + + return rulesPList; + } + + private NSDictionary BuildResourceSeal(Bundle bundle) + { + var sha1 = IncrementalHash.CreateHash(HashAlgorithmName.SHA1); + var sha256 = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); + var buffer = new byte[65536]; + + var resourceBuilder = new ResourceBuilder(); + bundle.AddResourceRules(resourceBuilder, useV2Rules: true); + + var rules2 = BuildResourceRulesPList(resourceBuilder.Rules); + var files2 = new NSDictionary(); + foreach (var resourceAndRule in resourceBuilder.Scan(bundle.ContentsPath)) + { + var files2Value = new NSDictionary(2); + + if (resourceAndRule.Rule.IsNested) + { + if (codeSignOptions.Deep) + { + Sign(resourceAndRule.Info.FullName); + } + + var nestedInfo = ReadNested(resourceAndRule.Info.FullName); + if (nestedInfo.HasValue) + { + files2Value.Add("cdhash", new NSData(nestedInfo.Value.CodeDirectoryHash)); + if (nestedInfo.Value.DesignatedRequirement != null) + files2Value.Add("requirement", nestedInfo.Value.DesignatedRequirement.ToString()); + } + } + else if (resourceAndRule.Info.LinkTarget != null) + { + files2Value.Add("symlink", resourceAndRule.Info.LinkTarget); + } + else + { + using (var fileStream = File.OpenRead(resourceAndRule.Info.FullName)) + { + int bytesRead; + while ((bytesRead = fileStream.Read(buffer)) > 0) + { + sha1.AppendData(buffer.AsSpan(0, bytesRead)); + sha256.AppendData(buffer.AsSpan(0, bytesRead)); + } + } + + files2Value.Add("hash", new NSData(sha1.GetHashAndReset())); + files2Value.Add("hash2", new NSData(sha256.GetHashAndReset())); + + if (resourceAndRule.Rule.IsOptional) + { + files2Value.Add("optional", true); + } + } + + files2.Add(resourceAndRule.Path, files2Value); + }; + + // Version 1 resources + resourceBuilder = new ResourceBuilder(); + bundle.AddResourceRules(resourceBuilder, useV2Rules: false); + + var rules = BuildResourceRulesPList(resourceBuilder.Rules); + var files = new NSDictionary(); + foreach (var resourceAndRule in resourceBuilder.Scan(bundle.ContentsPath)) + { + NSData hash; + + Debug.Assert(resourceAndRule.Info is FileInfo); + + if (resourceAndRule.Info.LinkTarget != null) + { + continue; + } + + if (files2.TryGetValue(resourceAndRule.Path, out var files2Value)) + { + hash = (NSData)((NSDictionary)files2Value)["hash"]; + } + else + { + using (var fileStream = File.OpenRead(resourceAndRule.Info.FullName)) + { + int bytesRead; + while ((bytesRead = fileStream.Read(buffer)) > 0) + { + sha1.AppendData(buffer.AsSpan(0, bytesRead)); + } + } + + hash = new NSData(sha1.GetHashAndReset()); + } + + if (resourceAndRule.Rule.IsOptional) + { + var filesValue = new NSDictionary(2); + filesValue.Add("hash", hash); + filesValue.Add("optional", true); + files.Add(resourceAndRule.Path, filesValue); + } + else + { + files.Add(resourceAndRule.Path, hash); + } + } + + // Write down the rules and hashes + return new NSDictionary { { "files", files }, { "files2", files2 }, { "rules", rules }, { "rules2", rules2 } }; + } + + private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNestedMachO(string executablePath) + { + using var f = File.OpenRead(executablePath); + var objectFile = MachReader.Read(f).First(); + var codeSignature = objectFile.LoadCommands.OfType().FirstOrDefault(); + if (codeSignature == null) + return null; + + var codeSignatureStream = objectFile.GetStreamAtFileOffset(codeSignature.FileOffset, codeSignature.FileSize); + var superBlob = new byte[codeSignature.FileSize]; + codeSignatureStream.ReadFully(superBlob); + + var superBlobMagic = BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(0, 4)); + var superBlobSize = BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(4, 4)); + var superBlobCount = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(8, 4)); + + Debug.Assert(superBlobMagic == (uint)BlobMagic.EmbeddedSignature); + var slotOffsetDictionary = new Dictionary(superBlobCount); + + for (int i = 0; i < superBlobCount; i++) + { + var slot = (CodeDirectorySpecialSlot)BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(i * 8 + 12, 4)); + var slotOffset = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(i * 8 + 16, 4)); + slotOffsetDictionary[slot] = slotOffset; + } + + Requirement? designatedRequirement = null; + if (slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.Requirements, out var requirementsOffset)) + { + var requirementsSize = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(requirementsOffset + 4, 4)); + var requirementSet = RequirementSet.FromBlob(superBlob.AsSpan(requirementsOffset, requirementsSize)); + requirementSet.TryGetValue(RequirementType.Designated, out designatedRequirement); + } + + // FIXME: Get correct CD + if (slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.AlternativeCodeDirectory, out var codeDirectoryOffset) || + slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.CodeDirectory, out codeDirectoryOffset)) + { + var codeDirectorySize = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(codeDirectoryOffset + 4, 4)); + var codeDirectoryBlob = superBlob.AsSpan(codeDirectoryOffset, codeDirectorySize); + var codeDirectoryHeader = CodeDirectoryBaselineHeader.Read(codeDirectoryBlob, out _); + var hasher = codeDirectoryHeader.HashType.GetIncrementalHash(); + hasher.AppendData(codeDirectoryBlob); + return (designatedRequirement, hasher.GetHashAndReset().AsSpan(0, 20).ToArray()); + } + + return null; + } + + private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNestedBundle(string bundlePath) + { + var bundle = new Bundle(bundlePath); + return bundle.MainExecutable != null ? ReadNestedMachO(bundle.MainExecutable) : null; + } + + private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNested(string path) + { + var attributes = File.GetAttributes(path); + + // Assume a directory is a bundle + if (attributes.HasFlag(FileAttributes.Directory)) + { + return ReadNestedBundle(path); + } + else + { + // TODO: Add support for signing regular files, etc. + return ReadNestedMachO(path); + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs new file mode 100644 index 00000000000000..e6d0461ba8554c --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs @@ -0,0 +1,176 @@ +using Xunit; +using System.IO; +using System.Linq; +using Melanzana.Streams; +using System; + +namespace Melanzana.MachO.Tests +{ + public class CreateTests + { + [Fact] + public void CreateExecutable() + { + // Let's try to build a new macho! + var objectFile = new MachObjectFile(); + + // Header + objectFile.CpuType = MachCpuType.Arm64; + objectFile.FileType = MachFileType.Execute; + objectFile.Flags = MachHeaderFlags.PIE | MachHeaderFlags.TwoLevel | MachHeaderFlags.DynamicLink | MachHeaderFlags.NoUndefinedReferences; + + // Segments + var pageZeroSegment = new MachSegment(objectFile, "__PAGEZERO") + { + VirtualAddress = 0, + Size = 0x100000000, + }; + + var textSegment = new MachSegment(objectFile, "__TEXT") + { + FileOffset = 0, + VirtualAddress = 0x100000000, + Size = 0x4000, + InitialProtection = MachVmProtection.Execute | MachVmProtection.Read, + MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read, + }; + + var textSection = new MachSection(objectFile, "__TEXT", "__text") + { + Log2Alignment = 2, + Type = MachSectionType.Regular, + Attributes = MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, + }; + + using (var textWriter = textSection.GetWriteStream()) + { + textWriter.Write(new byte[] { 0x00, 0x00, 0x80, 0x52 }); // mov w0, #0 + textWriter.Write(new byte[] { 0xc0, 0x03, 0x5f, 0xd6 }); // ret + textSection.FileOffset = 0x4000u - (uint)textWriter.Position; + textSection.VirtualAddress = textSegment.VirtualAddress + textSection.FileOffset; + } + + var linkEditSegment = new MachSegment(objectFile, "__LINKEDIT") + { + VirtualAddress = textSection.VirtualAddress + textSection.Size, + // FileOffset = + // FileSize = + InitialProtection = MachVmProtection.Read, + MaximumProtection = MachVmProtection.Read, + }; + + // TODO: This test is incomplete. We should have a layout calculator and a validation. + } + + [Fact] + public void CreateObjectFile() + { + var objectFile = new MachObjectFile(); + + objectFile.CpuType = MachCpuType.Arm64; + objectFile.CpuSubType = 0; + objectFile.FileType = MachFileType.Object; + objectFile.Flags = MachHeaderFlags.SubsectionsViaSymbols; + objectFile.IsLittleEndian = true; + + var segment = new MachSegment(objectFile, "") + { + InitialProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, + MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, + }; + + var textSection = new MachSection(objectFile, "__TEXT", "__text") + { + Log2Alignment = 2, + Type = MachSectionType.Regular, + Attributes = MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, + }; + + var compactUnwindSection = new MachSection(objectFile, "__LD", "__compact_unwind") + { + Log2Alignment = 3, + Type = MachSectionType.Regular, + Attributes = MachSectionAttributes.Debug, + }; + + segment.Sections.Add(textSection); + segment.Sections.Add(compactUnwindSection); + objectFile.LoadCommands.Add(segment); + + using (var textWriter = textSection.GetWriteStream()) + { + textWriter.Write(new byte[] { 0xff, 0x43, 0x00, 0xd1 }); // sub sp, sp, #0x10 + textWriter.Write(new byte[] { 0x00, 0x00, 0x80, 0x52 }); // mov w0, #0 + textWriter.Write(new byte[] { 0xff, 0x0f, 0x00, 0xb9 }); // str wzr, [sp, #0xc] + textWriter.Write(new byte[] { 0xff, 0x43, 0x00, 0x91 }); // add sp, sp, #0x10 + textWriter.Write(new byte[] { 0xc0, 0x03, 0x5f, 0xd6 }); // ret + } + + using (var compactUnwindWriter = compactUnwindSection.GetWriteStream()) + { + // Address of _main + compactUnwindSection.Relocations.Add(new MachRelocation + { + Address = 0, + SymbolOrSectionIndex = 1, // TODO: Better symbolic reference? + Length = 8, + RelocationType = MachRelocationType.Arm64Unsigned, + IsExternal = false, + IsPCRelative = false, + }); + compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); + + compactUnwindWriter.Write(new byte[] { 0x14, 0x00, 0x00, 0x00 }); // Length of _main + compactUnwindWriter.Write(new byte[] { 0x00, 0x10, 0x00, 0x02 }); // Unwind code + compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); // No personality + compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); // No LSDA + } + + // Verify the relocation was written correctly + Assert.NotNull(compactUnwindSection.RelocationData); + Assert.Equal(8u, compactUnwindSection.RelocationData!.Size); + using (var s = compactUnwindSection.RelocationData.GetReadStream()) + { + byte[] r = new byte[8]; + s.ReadFully(r); + Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06 }, r); + } + + objectFile.LoadCommands.Add(new MachBuildVersion + { + TargetPlatform = MachPlatform.MacOS, + MinimumPlatformVersion = new Version(12, 0, 0), + SdkVersion = new Version(12, 0, 0), + }); + + var symbolTable = new MachSymbolTable(objectFile); + objectFile.LoadCommands.Add(symbolTable); + // FIXME: Values + symbolTable.Symbols.Add(new MachSymbol { Name = "ltmp0", Section = textSection, Value = 0, Descriptor = 0, Type = MachSymbolType.Section }); + symbolTable.Symbols.Add(new MachSymbol { Name = "ltmp1", Section = compactUnwindSection, Value = 0x18, Descriptor = 0, Type = MachSymbolType.Section }); + symbolTable.Symbols.Add(new MachSymbol { Name = "_main", Section = textSection, Value = 0, Descriptor = 0, Type = MachSymbolType.Section | MachSymbolType.External }); + objectFile.LoadCommands.Add(new MachDynamicLinkEditSymbolTable(symbolTable)); + + objectFile.UpdateLayout(); + Assert.Equal(0u, segment.VirtualAddress); + Assert.Equal(0x38u, segment.Size); + Assert.Equal(0x188u, segment.FileOffset); + Assert.Equal(0x38u, segment.FileSize); + Assert.Equal(0u, textSection.VirtualAddress); + Assert.Equal(0x14u, textSection.Size); + Assert.Equal(0x188u, textSection.FileOffset); + Assert.Equal(0x18u, compactUnwindSection.VirtualAddress); + Assert.Equal(0x20u, compactUnwindSection.Size); + Assert.Equal(0x1a0u, compactUnwindSection.FileOffset); + + // Ensure that write doesn't crash + var binaryFile = new MemoryStream(); + MachWriter.Write(binaryFile, objectFile); + Assert.Equal(528, binaryFile.Length); + + // Ensure that the file can be read again + binaryFile.Position = 0; + _ = MachReader.Read(binaryFile); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out new file mode 100755 index 0000000000000000000000000000000000000000..be993902e6128edc3e2e86341e48b8ca38bdd2a6 GIT binary patch literal 84128 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 literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out new file mode 100755 index 0000000000000000000000000000000000000000..ce1e62c9c1815e7e57ab6ca0fa0cb6eac842a59d GIT binary patch literal 34976 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 literal 0 HcmV?d00001 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj new file mode 100644 index 00000000000000..e32ea378566372 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj @@ -0,0 +1,31 @@ + + + + net6.0 + enable + + false + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs new file mode 100644 index 00000000000000..ef4aef8710ec32 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs @@ -0,0 +1,82 @@ +using Xunit; +using System.IO; +using System.Linq; +using Melanzana.Streams; +using System; + +namespace Melanzana.MachO.Tests +{ + public class ReadTests + { + [Fact] + public void ReadExecutable() + { + var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.out")!; + var objectFile = MachReader.Read(aOutStream).First(); + + var segments = objectFile.LoadCommands.OfType().ToArray(); + Assert.Equal("__PAGEZERO", segments[0].Name); + Assert.Equal("__TEXT", segments[1].Name); + Assert.Equal("__LINKEDIT", segments[2].Name); + + var symbolTable = objectFile.LoadCommands.OfType().FirstOrDefault(); + Assert.NotNull(symbolTable); + var symbols = symbolTable!.Symbols.ToArray(); + Assert.Equal(2, symbols.Length); + Assert.Equal("__mh_execute_header", symbols[0].Name); + Assert.Equal(0x100000000u, symbols[0].Value); + Assert.Equal("_main", symbols[1].Name); + Assert.Equal(0x100003fa4u, symbols[1].Value); + + var buildVersion = objectFile.LoadCommands.OfType().FirstOrDefault(); + Assert.NotNull(buildVersion); + Assert.Equal(MachPlatform.MacOS, buildVersion!.Platform); + Assert.Equal("12.0.0", buildVersion!.MinimumPlatformVersion.ToString()); + Assert.Equal("12.0.0", buildVersion!.SdkVersion.ToString()); + Assert.Equal(1, buildVersion!.ToolVersions.Count); + Assert.Equal(MachBuildTool.Ld, buildVersion!.ToolVersions[0].BuildTool); + Assert.Equal("711.0.0", buildVersion!.ToolVersions[0].Version.ToString()); + } + + [Fact] + public void ReadObjectFile() + { + var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.o")!; + var objectFile = MachReader.Read(aOutStream).First(); + + var segments = objectFile.LoadCommands.OfType().ToArray(); + Assert.Single(segments); + + var textSection = segments[0].Sections[0]; + var compactUnwindSection = segments[0].Sections[1]; + + Assert.Equal("__TEXT", textSection.SegmentName); + Assert.Equal("__text", textSection.SectionName); + Assert.Equal("__LD", compactUnwindSection.SegmentName); + Assert.Equal("__compact_unwind", compactUnwindSection.SectionName); + + var relocations = compactUnwindSection.Relocations; + Assert.Single(relocations); + var relec0 = relocations.First(); + Assert.Equal(0, relec0.Address); + Assert.False(relec0.IsPCRelative); + Assert.False(relec0.IsExternal); + Assert.Equal(1u, relec0.SymbolOrSectionIndex); + Assert.Equal(8, relec0.Length); + Assert.Equal(MachRelocationType.Arm64Unsigned, relec0.RelocationType); + + var symbolTable = objectFile.LoadCommands.OfType().FirstOrDefault(); + Assert.NotNull(symbolTable); + var symbols = symbolTable!.Symbols.ToArray(); + Assert.Equal("ltmp0", symbols[0].Name); + Assert.Equal(textSection, symbols[0].Section); + Assert.Equal(0u, symbols[0].Value); + Assert.Equal("ltmp1", symbols[1].Name); + Assert.Equal(compactUnwindSection, symbols[1].Section); + Assert.Equal(0x18u, symbols[1].Value); + Assert.Equal("_main", symbols[2].Name); + Assert.Equal(textSection, symbols[2].Section); + Assert.Equal(0u, symbols[2].Value); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs new file mode 100644 index 00000000000000..0091d91330fdef --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs @@ -0,0 +1,48 @@ +using Xunit; +using System.IO; +using System.Linq; +using Melanzana.Streams; + +namespace Melanzana.MachO.Tests +{ + public class RoundtripTests + { + private static void TestRoundtrip(Stream aOutStream) + { + var outputStream = new MemoryStream(); + var objectFiles = MachReader.Read(aOutStream).ToList(); + MachWriter.Write(outputStream, objectFiles); + + aOutStream.Position = 0; + outputStream.Position = 0; + Assert.Equal(aOutStream.Length, outputStream.Length); + + var input = new byte[aOutStream.Length]; + var output = new byte[aOutStream.Length]; + aOutStream.ReadFully(input); + outputStream.ReadFully(output); + Assert.Equal(input, output); + } + + [Fact] + public void BasicRoundtrip() + { + var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.out")!; + TestRoundtrip(aOutStream); + } + + [Fact] + public void FatRoundtrip() + { + var aFatOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.fat.out")!; + TestRoundtrip(aFatOutStream); + } + + [Fact] + public void ObjectFileRoundtrip() + { + var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.o")!; + TestRoundtrip(aOutStream); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs new file mode 100644 index 00000000000000..10a40a357bb87e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class BuildToolVersionHeader + { + public MachBuildTool BuildTool; + public uint Version { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs new file mode 100644 index 00000000000000..e9b0be7a10b05b --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class BuildVersionCommandHeader + { + public MachPlatform Platform; + public uint MinimumPlatformVersion { get; set; } + public uint SdkVersion { get; set; } + public uint NumberOfTools { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs new file mode 100644 index 00000000000000..6833845e31900c --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs @@ -0,0 +1,17 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class DyldInfoHeader + { + public uint RebaseOffset { get; set; } + public uint RebaseSize { get; set; } + public uint BindOffset { get; set; } + public uint BindSize { get; set; } + public uint WeakBindOffset { get; set; } + public uint WeakBindSize { get; set; } + public uint LazyBindOffset { get; set; } + public uint LazyBindSize { get; set; } + public uint ExportOffset { get; set; } + public uint ExportSize { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs new file mode 100644 index 00000000000000..3820a59d03ea15 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class DylibCommandHeader + { + public uint NameOffset { get; set; } + public uint Timestamp { get; set; } + public uint CurrentVersion { get; set; } + public uint CompatibilityVersion { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs new file mode 100644 index 00000000000000..701a19e288e4c0 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs @@ -0,0 +1,25 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class DynamicSymbolTableCommandHeader + { + public uint LocalSymbolsIndex { get; set; } + public uint LocalSymbolsCount { get; set; } + public uint ExternalSymbolsIndex { get; set; } + public uint ExternalSymbolsCount { get; set; } + public uint UndefinedSymbolsIndex { get; set; } + public uint UndefinedSymbolsCount { get; set; } + public uint TableOfContentsOffset { get; set; } + public uint TableOfContentsCount { get; set; } + public uint ModuleTableOffset { get; set; } + public uint ModuleTableCount { get; set; } + public uint ExternalReferenceTableOffset { get; set; } + public uint ExternalReferenceTableCount { get; set; } + public uint IndirectSymbolTableOffset { get; set; } + public uint IndirectSymbolTableCount { get; set; } + public uint ExternalRelocationTableOffset { get; set; } + public uint ExternalRelocationTableCount { get; set; } + public uint LocalRelocationTableOffset { get; set; } + public uint LocalRelocationTableCount { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs new file mode 100644 index 00000000000000..0e34ef88a70671 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs @@ -0,0 +1,12 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class FatArchHeader + { + public MachCpuType CpuType { get; set; } + public uint CpuSubType { get; set; } + public uint Offset { get; set; } + public uint Size { get; set; } + public uint Alignment { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs new file mode 100644 index 00000000000000..31a9042c7dfe9f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs @@ -0,0 +1,8 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class FatHeader + { + public uint NumberOfFatArchitectures { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs new file mode 100644 index 00000000000000..65cde3de4dbaca --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs @@ -0,0 +1,12 @@ +namespace Melanzana.MachO.BinaryFormat +{ + public interface IMachHeader + { + MachCpuType CpuType { get; set; } + uint CpuSubType { get; set; } + MachFileType FileType { get; set; } + uint NumberOfCommands { get; set; } + uint SizeOfCommands { get; set; } + MachHeaderFlags Flags { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs new file mode 100644 index 00000000000000..fd3d5b95c5f546 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class LinkEditHeader + { + public uint FileOffset { get; set; } + public uint FileSize { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs new file mode 100644 index 00000000000000..a05bdfda4b4acd --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class LoadCommandHeader + { + public MachLoadCommandType CommandType { get; set; } + public uint CommandSize { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs new file mode 100644 index 00000000000000..ceb7ce40b6f32d --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs @@ -0,0 +1,52 @@ +using System.Text; + +namespace Melanzana.MachO.BinaryFormat +{ + /// + /// Represents 16-byte null-terminated UTF-8 string + /// + public class MachFixedName + { + public const int BinarySize = 16; + + public static MachFixedName Empty = new MachFixedName(""); + + public MachFixedName(string name) + { + Name = name; + } + + public static MachFixedName Read(ReadOnlySpan buffer, out int bytesRead) + { + bytesRead = BinarySize; + var slice = buffer.Slice(0, BinarySize); + var zeroIndex = slice.IndexOf((byte)0); + if (zeroIndex >= 0) + return new MachFixedName(Encoding.UTF8.GetString(slice.Slice(0, zeroIndex))); + return new MachFixedName(Encoding.UTF8.GetString(slice)); + } + + public void Write(Span buffer, out int bytesWritten) + { + // FIXME: Write this correctly + byte[] utf8Name = Encoding.UTF8.GetBytes(Name); + if (utf8Name.Length >= 16) + { + utf8Name.CopyTo(buffer.Slice(0, 16)); + } + else + { + utf8Name.CopyTo(buffer.Slice(0, utf8Name.Length)); + buffer.Slice(utf8Name.Length, 16 - utf8Name.Length).Clear(); + } + bytesWritten = 16; + } + + public string Name { get; init; } + + public static implicit operator string(MachFixedName n) => n.Name; + public static implicit operator MachFixedName(string n) => new MachFixedName(n); + + public override string ToString() => Name; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs new file mode 100644 index 00000000000000..c0188f3758acbe --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs @@ -0,0 +1,13 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class MachHeader : IMachHeader + { + public MachCpuType CpuType { get; set; } + public uint CpuSubType { get; set; } + public MachFileType FileType { get; set; } + public uint NumberOfCommands { get; set; } + public uint SizeOfCommands { get; set; } + public MachHeaderFlags Flags { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs new file mode 100644 index 00000000000000..efee1460539b06 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs @@ -0,0 +1,14 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class MachHeader64 : IMachHeader + { + public MachCpuType CpuType { get; set; } + public uint CpuSubType { get; set; } + public MachFileType FileType { get; set; } + public uint NumberOfCommands { get; set; } + public uint SizeOfCommands { get; set; } + public MachHeaderFlags Flags { get; set; } + public uint Reserved { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs new file mode 100644 index 00000000000000..bb4aca9882761a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class MainCommandHeader + { + public ulong FileOffset { get; set; } + public ulong StackSize { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs new file mode 100644 index 00000000000000..86142e1b5efbfe --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs @@ -0,0 +1,19 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class Section64Header + { + public MachFixedName SectionName { get; set; } = MachFixedName.Empty; + public MachFixedName SegmentName { get; set; } = MachFixedName.Empty; + public ulong Address { get; set; } + public ulong Size { get; set; } + public uint FileOffset { get; set; } + public uint Log2Alignment { get; set; } + public uint RelocationOffset { get; set; } + public uint NumberOfReloationEntries { get; set; } + public uint Flags { get; set; } + public uint Reserved1 { get; set; } + public uint Reserved2 { get; set; } + public uint Reserved3 { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs new file mode 100644 index 00000000000000..d815550702336d --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs @@ -0,0 +1,18 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class SectionHeader + { + public MachFixedName SectionName { get; set; } = MachFixedName.Empty; + public MachFixedName SegmentName { get; set; } = MachFixedName.Empty; + public uint Address { get; set; } + public uint Size { get; set; } + public uint FileOffset { get; set; } + public uint Log2Alignment { get; set; } + public uint RelocationOffset { get; set; } + public uint NumberOfReloationEntries { get; set; } + public uint Flags { get; set; } + public uint Reserved1 { get; set; } + public uint Reserved2 { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs new file mode 100644 index 00000000000000..6e332edc6c440f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs @@ -0,0 +1,16 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class Segment64Header + { + public MachFixedName Name { get; set; } = MachFixedName.Empty; + public ulong Address { get; set; } + public ulong Size { get; set; } + public ulong FileOffset { get; set; } + public ulong FileSize { get; set; } + public MachVmProtection MaximumProtection { get; set; } + public MachVmProtection InitialProtection { get; set; } + public uint NumberOfSections { get; set; } + public MachSegmentFlags Flags { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs new file mode 100644 index 00000000000000..e8b66da2c13a1a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs @@ -0,0 +1,16 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class SegmentHeader + { + public MachFixedName Name { get; set; } = MachFixedName.Empty; + public uint Address { get; set; } + public uint Size { get; set; } + public uint FileOffset { get; set; } + public uint FileSize { get; set; } + public MachVmProtection MaximumProtection { get; set; } + public MachVmProtection InitialProtection { get; set; } + public uint NumberOfSections { get; set; } + public MachSegmentFlags Flags { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs new file mode 100644 index 00000000000000..987835ff68f035 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class SymbolHeader + { + public uint NameIndex { get; set; } + public byte Type { get; set; } + public byte Section { get; set; } + public ushort Descriptor { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs new file mode 100644 index 00000000000000..f9dbb996fc1047 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class SymbolTableCommandHeader + { + public uint SymbolTableOffset { get; set; } + public uint NumberOfSymbols { get; set; } + public uint StringTableOffset { get; set; } + public uint StringTableSize { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs new file mode 100644 index 00000000000000..c93a4a11b90695 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class TwoLevelHintsHeader + { + public uint FileOffset { get; set; } + public uint NumberOfHints { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs new file mode 100644 index 00000000000000..6a62b1c2cdcf95 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO.BinaryFormat +{ + [GenerateReaderWriter] + public partial class VersionMinCommandHeader + { + public uint MinimumPlatformVersion { get; set; } + public uint SdkVersion { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs new file mode 100644 index 00000000000000..d8d23fabb0d1fb --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO +{ + public enum MachBuildTool + { + Clang = 1, + Swift = 2, + Ld = 3, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs new file mode 100644 index 00000000000000..b3bed8a712dd46 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO +{ + public class MachBuildToolVersion + { + public MachBuildTool BuildTool { get; set; } + + public Version Version { get; set; } = MachBuildVersionBase.EmptyVersion; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs new file mode 100644 index 00000000000000..6a6af7cc524126 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO +{ + public class MachBuildVersion : MachBuildVersionBase + { + public override MachPlatform Platform => TargetPlatform; + + public MachPlatform TargetPlatform { get; set; } + + public IList ToolVersions { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs new file mode 100644 index 00000000000000..6a896fd7d319d8 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs @@ -0,0 +1,13 @@ +namespace Melanzana.MachO +{ + public abstract class MachBuildVersionBase : MachLoadCommand + { + internal static readonly Version EmptyVersion = new Version(0, 0, 0); + + public abstract MachPlatform Platform { get; } + + public Version MinimumPlatformVersion { get; set; } = EmptyVersion; + + public Version SdkVersion { get; set; } = EmptyVersion; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs new file mode 100644 index 00000000000000..f0f77cd43fff65 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachCodeSignature : MachLinkEdit + { + public MachCodeSignature(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachCodeSignature(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs new file mode 100644 index 00000000000000..2952e4718ee3f2 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs @@ -0,0 +1,17 @@ +using Melanzana.MachO.BinaryFormat; + +namespace Melanzana.MachO +{ + public class MachCustomLoadCommand : MachLoadCommand + { + public MachCustomLoadCommand(MachLoadCommandType type, byte[] data) + { + this.Type = type; + this.Data = data; + } + + public MachLoadCommandType Type { get; set; } + + public byte[] Data { get; set; } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs new file mode 100644 index 00000000000000..69a90983b82f86 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachDataInCode : MachLinkEdit + { + public MachDataInCode(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachDataInCode(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs new file mode 100644 index 00000000000000..ac44b3eb08a16b --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachDyldChainedFixups : MachLinkEdit + { + public MachDyldChainedFixups(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachDyldChainedFixups(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs new file mode 100644 index 00000000000000..63b61e21322114 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachDyldExportsTrie : MachLinkEdit + { + public MachDyldExportsTrie(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachDyldExportsTrie(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs new file mode 100644 index 00000000000000..12fb8ffd9c75d8 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs @@ -0,0 +1,56 @@ +namespace Melanzana.MachO +{ + public class MachDyldInfo : MachLoadCommand + { + public MachDyldInfo(MachObjectFile objectFile) + { + ArgumentNullException.ThrowIfNull(objectFile); + + RebaseData = new MachLinkEditData(); + BindData = new MachLinkEditData(); + WeakBindData = new MachLinkEditData(); + LazyBindData = new MachLinkEditData(); + ExportData = new MachLinkEditData(); + } + + public MachDyldInfo( + MachObjectFile objectFile, + MachLinkEditData rebaseData, + MachLinkEditData bindData, + MachLinkEditData weakBindData, + MachLinkEditData lazyBindData, + MachLinkEditData exportData) + { + ArgumentNullException.ThrowIfNull(objectFile); + ArgumentNullException.ThrowIfNull(rebaseData); + ArgumentNullException.ThrowIfNull(bindData); + ArgumentNullException.ThrowIfNull(weakBindData); + ArgumentNullException.ThrowIfNull(lazyBindData); + ArgumentNullException.ThrowIfNull(exportData); + + RebaseData = rebaseData; + BindData = bindData; + WeakBindData = weakBindData; + LazyBindData = lazyBindData; + ExportData = exportData; + } + + public MachLinkEditData RebaseData { get; private init; } + public MachLinkEditData BindData { get; private init; } + public MachLinkEditData WeakBindData { get; private init; } + public MachLinkEditData LazyBindData { get; private init; } + public MachLinkEditData ExportData { get; private init; } + + internal override IEnumerable LinkEditData + { + get + { + yield return RebaseData; + yield return BindData; + yield return WeakBindData; + yield return LazyBindData; + yield return ExportData; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs new file mode 100644 index 00000000000000..f1afd9ea09ac80 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs @@ -0,0 +1,21 @@ +namespace Melanzana.MachO +{ + public class MachDyldInfoOnly : MachDyldInfo + { + public MachDyldInfoOnly(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachDyldInfoOnly( + MachObjectFile objectFile, + MachLinkEditData rebaseData, + MachLinkEditData bindData, + MachLinkEditData weakBindData, + MachLinkEditData lazyBindData, + MachLinkEditData exportData) + : base(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs new file mode 100644 index 00000000000000..798aa9aeb0fd9b --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachDylibCodeSigningDirs : MachLinkEdit + { + public MachDylibCodeSigningDirs(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachDylibCodeSigningDirs(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs new file mode 100644 index 00000000000000..1c35f44ec92a9f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs @@ -0,0 +1,16 @@ +using System.Text; +using Melanzana.MachO.BinaryFormat; + +namespace Melanzana.MachO +{ + public abstract class MachDylibCommand : MachLoadCommand + { + public string Name { get; set; } = string.Empty; + + public uint Timestamp { get; set; } + + public uint CurrentVersion { get; set; } + + public uint CompatibilityVersion { get; set; } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs new file mode 100644 index 00000000000000..0fcf164962f936 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs @@ -0,0 +1,180 @@ +using Melanzana.MachO.BinaryFormat; + +namespace Melanzana.MachO +{ + public class MachDynamicLinkEditSymbolTable : MachLoadCommand + { + internal DynamicSymbolTableCommandHeader Header; + + public MachDynamicLinkEditSymbolTable() + { + this.Header = new DynamicSymbolTableCommandHeader(); + } + + public MachDynamicLinkEditSymbolTable(MachSymbolTable symbolTable) + : this() + { + Span bucketUsed = stackalloc bool[3]; + var symbols = symbolTable.Symbols; + int lastBucket = -1; + bool needsSort = false; + + for (int i = 0; i < symbols.Count; i++) + { + int bucket = + symbols[i].IsUndefined ? 2 : + (symbols[i].IsExternal ? 1 : 0); + + if (bucket != lastBucket) + { + switch (lastBucket) + { + case 0: LocalSymbolsCount = (uint)i - LocalSymbolsIndex; break; + case 1: ExternalSymbolsCount = (uint)i - ExternalSymbolsIndex; break; + case 2: UndefinedSymbolsCount = (uint)i - UndefinedSymbolsIndex; break; + } + + if (bucketUsed[bucket]) + { + // Same types of symbols have to be next to each other + throw new InvalidOperationException("Symbol table is not in correct order"); + } + bucketUsed[bucket] = true; + + switch (bucket) + { + case 0: LocalSymbolsIndex = (uint)i; needsSort = false; break; + case 1: ExternalSymbolsIndex = (uint)i; needsSort = true; break; + case 2: UndefinedSymbolsIndex = (uint)i; needsSort = true; break; + } + lastBucket = bucket; + } + else if (needsSort && string.CompareOrdinal(symbols[i - 1].Name, symbols[i].Name) > 0) + { + // External and undefined symbols have to be lexicographically sorted + throw new InvalidOperationException("Symbol table is not sorted"); + } + } + + switch (lastBucket) + { + case 0: LocalSymbolsCount = (uint)symbols.Count - LocalSymbolsIndex; break; + case 1: ExternalSymbolsCount = (uint)symbols.Count - ExternalSymbolsIndex; break; + case 2: UndefinedSymbolsCount = (uint)symbols.Count - UndefinedSymbolsIndex; break; + } + } + + internal MachDynamicLinkEditSymbolTable(DynamicSymbolTableCommandHeader header) + { + this.Header = header; + } + + public uint LocalSymbolsIndex + { + get => Header.LocalSymbolsIndex; + set => Header.LocalSymbolsIndex = value; + } + + public uint LocalSymbolsCount + { + get => Header.LocalSymbolsCount; + set => Header.LocalSymbolsCount = value; + } + + public uint ExternalSymbolsIndex + { + get => Header.ExternalSymbolsIndex; + set => Header.ExternalSymbolsIndex = value; + } + + public uint ExternalSymbolsCount + { + get => Header.ExternalSymbolsCount; + set => Header.ExternalSymbolsCount = value; + } + + public uint UndefinedSymbolsIndex + { + get => Header.UndefinedSymbolsIndex; + set => Header.UndefinedSymbolsIndex = value; + } + + public uint UndefinedSymbolsCount + { + get => Header.UndefinedSymbolsCount; + set => Header.UndefinedSymbolsCount = value; + } + + public uint TableOfContentsOffset + { + get => Header.TableOfContentsOffset; + set => Header.TableOfContentsOffset = value; + } + + public uint TableOfContentsCount + { + get => Header.TableOfContentsCount; + set => Header.TableOfContentsCount = value; + } + + public uint ModuleTableOffset + { + get => Header.ModuleTableOffset; + set => Header.ModuleTableOffset = value; + } + + public uint ModuleTableCount + { + get => Header.ModuleTableCount; + set => Header.ModuleTableCount = value; + } + + public uint ExternalReferenceTableOffset + { + get => Header.ExternalReferenceTableOffset; + set => Header.ExternalReferenceTableOffset = value; + } + + public uint ExternalReferenceTableCount + { + get => Header.ExternalReferenceTableCount; + set => Header.ExternalReferenceTableCount = value; + } + + public uint IndirectSymbolTableOffset + { + get => Header.IndirectSymbolTableOffset; + set => Header.IndirectSymbolTableOffset = value; + } + + public uint IndirectSymbolTableCount + { + get => Header.IndirectSymbolTableCount; + set => Header.IndirectSymbolTableCount = value; + } + + public uint ExternalRelocationTableOffset + { + get => Header.ExternalRelocationTableOffset; + set => Header.ExternalRelocationTableOffset = value; + } + + public uint ExternalRelocationTableCount + { + get => Header.ExternalRelocationTableCount; + set => Header.ExternalRelocationTableCount = value; + } + + public uint LocalRelocationTableOffset + { + get => Header.LocalRelocationTableOffset; + set => Header.LocalRelocationTableOffset = value; + } + + public uint LocalRelocationTableCount + { + get => Header.LocalRelocationTableCount; + set => Header.LocalRelocationTableCount = value; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs new file mode 100644 index 00000000000000..e1e06f3404fbe5 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs @@ -0,0 +1,12 @@ +using System.Text; +using Melanzana.MachO.BinaryFormat; + +namespace Melanzana.MachO +{ + public class MachEntrypointCommand : MachLoadCommand + { + public ulong FileOffset { get; set; } + + public ulong StackSize { get; set; } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs new file mode 100644 index 00000000000000..71ea880385309e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachFunctionStarts : MachLinkEdit + { + public MachFunctionStarts(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachFunctionStarts(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs new file mode 100644 index 00000000000000..2db4417fee5cdf --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs @@ -0,0 +1,38 @@ +namespace Melanzana.MachO +{ + public abstract class MachLinkEdit : MachLoadCommand + { + protected readonly MachObjectFile objectFile; + + protected MachLinkEdit(MachObjectFile objectFile) + { + ArgumentNullException.ThrowIfNull(objectFile); + + Data = new MachLinkEditData(); + this.objectFile = objectFile; + } + + protected MachLinkEdit(MachObjectFile objectFile, MachLinkEditData data) + { + ArgumentNullException.ThrowIfNull(objectFile); + ArgumentNullException.ThrowIfNull(data); + + Data = data; + this.objectFile = objectFile; + } + + public uint FileOffset => Data.FileOffset; + + public uint FileSize => (uint)Data.Size; + + public MachLinkEditData Data { get; private init; } + + internal override IEnumerable LinkEditData + { + get + { + yield return Data; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs new file mode 100644 index 00000000000000..2c6dbc27bd3d49 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachLinkerOptimizationHint : MachLinkEdit + { + public MachLinkerOptimizationHint(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachLinkerOptimizationHint(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs new file mode 100644 index 00000000000000..12bf9463f76a53 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs @@ -0,0 +1,6 @@ +namespace Melanzana.MachO +{ + public class MachLoadDylibCommand : MachDylibCommand + { + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs new file mode 100644 index 00000000000000..5b84bc1d84d0ea --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs @@ -0,0 +1,6 @@ +namespace Melanzana.MachO +{ + public class MachLoadWeakDylibCommand : MachDylibCommand + { + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs new file mode 100644 index 00000000000000..4ab3a19f290daa --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs @@ -0,0 +1,6 @@ +namespace Melanzana.MachO +{ + public class MachReexportDylibCommand : MachDylibCommand + { + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs new file mode 100644 index 00000000000000..ff3b55e183c81a --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs @@ -0,0 +1,163 @@ +using System.ComponentModel; +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + public class MachSection + { + private readonly MachObjectFile objectFile; + private Stream? dataStream; + private MachLinkEditData? relocationData; + private MachRelocationCollection? relocationCollection; + private ulong size; + + public MachSection(MachObjectFile objectFile, string segmentName, string sectionName) + : this(objectFile, segmentName, sectionName, null) + { + } + + public MachSection(MachObjectFile objectFile, string segmentName, string sectionName, Stream? stream) + : this(objectFile, segmentName, sectionName, stream, null) + { + } + + internal MachSection( + MachObjectFile objectFile, + string segmentName, + string sectionName, + Stream? stream, + MachLinkEditData? relocationData) + { + ArgumentNullException.ThrowIfNull(objectFile); + ArgumentNullException.ThrowIfNull(segmentName); + ArgumentNullException.ThrowIfNull(sectionName); + + this.objectFile = objectFile; + this.SegmentName = segmentName; + this.SectionName = sectionName; + this.dataStream = stream; + this.relocationData = relocationData; + } + + /// + /// Gets or sets the name of this section. + /// + public string SectionName { get; private init; } + + /// + /// Gets or sets the name of the segment. + /// + /// + /// For fully linked executables or dynamic libraries this should always be the same as + /// the name of the containing segment. However, intermediate object files + /// () use compact format where all sections are + /// listed under single segment. + /// + public string SegmentName { get; private init; } + + /// + /// Gets or sets the virtual address of this section. + /// + public ulong VirtualAddress { get; set; } + + public ulong Size + { + get => dataStream != null ? (ulong)dataStream.Length : size; + set + { + size = value; + if (dataStream != null) + { + if (!HasContentChanged) + { + var oldStream = dataStream; + HasContentChanged = true; + dataStream = new UnclosableMemoryStream(); + oldStream?.CopyTo(dataStream); + } + dataStream.SetLength((long)size); + } + } + } + + public uint FileOffset { get; set; } + + /// + /// Gets or sets the alignment requirement of this section. + /// + public uint Log2Alignment { get; set; } + + /// + /// Gets the file offset to relocation entries of this section. + /// + public uint RelocationOffset => RelocationData?.FileOffset ?? 0u; + + /// + /// Gets or sets the number of relocation entries of this section. + /// + public uint NumberOfRelocationEntries => (uint)((RelocationData?.Size ?? 0u) / 8); + + internal uint Flags { get; set; } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + public uint Reserved1 { get; set; } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + public uint Reserved2 { get; set; } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + public uint Reserved3 { get; set; } + + public MachSectionAttributes Attributes + { + get => (MachSectionAttributes)(Flags & ~0xffu); + set => Flags = (Flags & 0xffu) | (uint)value; + } + + public MachSectionType Type + { + get => (MachSectionType)(Flags & 0xff); + set => Flags = (Flags & ~0xffu) | (uint)value; + } + + public bool IsInFile => Size > 0 && Type != MachSectionType.ZeroFill && Type != MachSectionType.GBZeroFill && Type != MachSectionType.ThreadLocalZeroFill; + + internal bool HasContentChanged { get; set; } + + public MachLinkEditData? RelocationData + { + get + { + relocationCollection?.FlushIfDirty(); + return relocationData; + } + } + + public IList Relocations + { + get + { + relocationData ??= new MachLinkEditData(); + relocationCollection ??= new MachRelocationCollection(objectFile, relocationData); + return relocationCollection; + } + } + + public Stream GetReadStream() + { + if (Size == 0 || dataStream == null) + { + return Stream.Null; + } + + return dataStream.Slice(0, (long)this.Size); + } + + public Stream GetWriteStream() + { + HasContentChanged = true; + dataStream = new UnclosableMemoryStream(); + return dataStream; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs new file mode 100644 index 00000000000000..32c21dcbdfa47e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs @@ -0,0 +1,17 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachSectionAttributes : uint + { + LocalRelocations = 0x100, + ExternalRelocations = 0x200, + SomeInstructions = 0x400, + Debug = 0x2000000, + SelfModifyingCode = 0x4000000, + LiveSupport = 0x8000000, + NoDeadStrip = 0x10000000, + StripStaticSymbols = 0x20000000, + NoTableOfContents = 0x40000000, + PureInstructions = 0x80000000, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs new file mode 100644 index 00000000000000..c0bb2992320de9 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs @@ -0,0 +1,28 @@ +namespace Melanzana.MachO +{ + public enum MachSectionType : byte + { + Regular = 0, + ZeroFill = 1, + CStringLiterals = 2, + FourByteLiterals = 3, + EightByteLiterals = 4, + LiteralPointers = 5, + NonLazySymbolPointers = 6, + LazySymbolPointers = 7, + SymbolStubs = 8, + ModInitFunctionPointers = 9, + ModTermFunctionPointers = 10, + Coalesced = 11, + GBZeroFill = 12, + Interposing = 13, + SixteenByteLiterals = 14, + DTraceObjectFormat = 15, + LazyDylibSymbolPointers = 16, + ThreadLocalRegular = 17, + ThreadLocalZeroFill = 18, + ThreadLocalVariables = 19, + ThreadLocalVariablePointers = 20, + ThreadLocalInitFunctionPointers = 21, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs new file mode 100644 index 00000000000000..835fc4e7ff3b69 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs @@ -0,0 +1,189 @@ +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + /// + /// Defines a segment in the object file. + /// + /// + /// Segments represent how parts of the object file are mapped into virtual memory. + /// + /// Segment may contain zero or more sections. Some segments have special properties by + /// convention: + /// + /// - The `__TEXT` segment has to start at file offset zero and it contains the file + /// header and load commands. These metadata are not part of any of the segment's + /// sections though. + /// - The `__LINKEDIT` segment needs to be the last segment in the file. It should not + /// contain any sections. It's contents are mapped by other load commands, such as + /// symbol table, function starts and code signature (collectively derived from + /// class). + /// + public class MachSegment : MachLoadCommand + { + private readonly MachObjectFile objectFile; + private Stream? dataStream; + private ulong size; + private ulong fileSize; + + public MachSegment(MachObjectFile objectFile, string name) + : this(objectFile, name, null) + { + } + + public MachSegment(MachObjectFile objectFile, string name, Stream? stream) + { + this.objectFile = objectFile; + this.dataStream = stream; + this.Name = name; + } + + /// + /// Gets the position of the segement in the object file. + /// + /// + /// The position is relative to the beginning of the architecture-specific object + /// file. In fat binaries it needs to be adjusted to account for the envelope. + /// + public ulong FileOffset { get; set; } + + /// + /// Gets the size of the segment in the file. + /// + /// + /// We preserve the original FileSize when no editing on section contents was + /// performed. ld64 aligns either to 16Kb or 4Kb page size based on compile time + /// options. The __LINKEDIT segment is an exception that doesn't get aligned but + /// since that one doesn't contain sections we don't do the special treatment. + /// + public ulong FileSize + { + get + { + if (IsLinkEditSegment) + { + return objectFile.LinkEditData.Select(d => d.FileOffset + d.Size).Max() - FileOffset; + } + + return Sections.Count > 0 ? fileSize : (ulong)(dataStream?.Length ?? 0); + } + internal set + { + // Used by MachReader and MachObjectFile.UpdateLayout + fileSize = value; + } + } + + /// + /// Gets or sets the name of this segment. + /// + public string Name { get; private set; } = string.Empty; + + /// + /// Gets or sets the virtual address of this section. + /// + public ulong VirtualAddress { get; set; } + + /// + /// Gets or sets the size in bytes occupied in memory by this segment. + /// + public ulong Size + { + get + { + if (IsLinkEditSegment) + { + const uint pageAlignment = 0x4000 - 1; + return (FileSize + pageAlignment) & ~pageAlignment; + } + + return size; + } + set + { + // NOTE: We silently ignore setting Size for __LINKEDIT to make it easier + // for the reader. + size = value; + } + } + + /// + /// Gets or sets the maximum permitted protection of this segment. + /// + public MachVmProtection MaximumProtection { get; set; } + + /// + /// Gets or sets the initial protection of this segment. + /// + public MachVmProtection InitialProtection { get; set; } + + public MachSegmentFlags Flags { get; set; } + + /// + /// List of sections contained in this segment. + /// + public IList Sections { get; } = new List(); + + public bool IsLinkEditSegment => Name == "__LINKEDIT"; + + public Stream GetReadStream() + { + if (Sections.Count != 0) + { + throw new NotSupportedException("Segment can only be read directly if there are no sections"); + } + + if (IsLinkEditSegment) + { + // NOTE: We can support reading the link edit segment by constructing the stream + // from objectFile.LinkEditData on-demand. + throw new NotSupportedException("Reading __LINKEDIT segment is unsupported"); + } + + if (FileSize == 0 || dataStream == null) + { + return Stream.Null; + } + + return dataStream.Slice(0, (long)this.FileSize); + } + + /// + /// Gets the stream for updating the contents of this segment if it has no sections. + /// + /// + /// This method is primarily useful for the `__LINKEDIT` segment. The other primary + /// segments (`__TEXT`, `__DATA`) are divided into sections and each section has to + /// be updated individually. + /// + public Stream GetWriteStream() + { + if (Sections.Count != 0) + { + throw new NotSupportedException("Segment can only be written to directly if there are no sections"); + } + + if (IsLinkEditSegment) + { + throw new NotSupportedException("Writing __LINKEDIT segment is unsupported"); + } + + dataStream = new UnclosableMemoryStream(); + return dataStream; + } + + internal override IEnumerable LinkEditData + { + get + { + foreach (var section in Sections) + { + if (section.RelocationData is MachLinkEditData relocationData) + { + yield return relocationData; + } + } + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs new file mode 100644 index 00000000000000..c33856a500fc37 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs @@ -0,0 +1,9 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachSegmentFlags : uint + { + HighVirtualMemory = 1, + NoRelocations = 4, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs new file mode 100644 index 00000000000000..0c7a122b45a1ba --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs @@ -0,0 +1,15 @@ +namespace Melanzana.MachO +{ + public class MachSegmentSplitInfo : MachLinkEdit + { + public MachSegmentSplitInfo(MachObjectFile objectFile) + : base(objectFile) + { + } + + public MachSegmentSplitInfo(MachObjectFile objectFile, MachLinkEditData data) + : base(objectFile, data) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs new file mode 100644 index 00000000000000..eaf43019fa6ad1 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs @@ -0,0 +1,82 @@ +using System.Diagnostics; + +namespace Melanzana.MachO +{ + public class MachSymbolTable : MachLoadCommand + { + private readonly MachObjectFile objectFile; + private readonly MachLinkEditData symbolTableData; + private readonly MachLinkEditData stringTableData; + private readonly Dictionary sectionMap; + private MachSymbolTableCollection? symbolTableCollection; + + public MachSymbolTable(MachObjectFile objectFile) + { + ArgumentNullException.ThrowIfNull(objectFile); + + this.objectFile = objectFile; + this.symbolTableData = new MachLinkEditData(); + this.stringTableData = new MachLinkEditData(); + this.sectionMap = new Dictionary(); + } + + internal MachSymbolTable( + MachObjectFile objectFile, + MachLinkEditData symbolTableData, + MachLinkEditData stringTableData) + { + ArgumentNullException.ThrowIfNull(objectFile); + ArgumentNullException.ThrowIfNull(symbolTableData); + ArgumentNullException.ThrowIfNull(stringTableData); + + this.objectFile = objectFile; + this.symbolTableData = symbolTableData; + this.stringTableData = stringTableData; + + // Create a section map now since the section indexes may change later + sectionMap = new Dictionary(); + byte sectionIndex = 1; + foreach (var section in objectFile.Segments.SelectMany(segment => segment.Sections)) + { + sectionMap.Add(sectionIndex++, section); + Debug.Assert(sectionIndex != 0); + } + } + + public MachLinkEditData SymbolTableData + { + get + { + symbolTableCollection?.FlushIfDirty(); + return symbolTableData; + } + } + + public MachLinkEditData StringTableData + { + get + { + symbolTableCollection?.FlushIfDirty(); + return stringTableData; + } + } + + public IList Symbols + { + get + { + symbolTableCollection ??= new MachSymbolTableCollection(objectFile, symbolTableData, stringTableData, sectionMap); + return symbolTableCollection; + } + } + + internal override IEnumerable LinkEditData + { + get + { + yield return SymbolTableData; + yield return StringTableData; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs new file mode 100644 index 00000000000000..2575f5f4ba8fa5 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs @@ -0,0 +1,26 @@ +using System.Diagnostics; + +namespace Melanzana.MachO +{ + public class MachTwoLevelHints : MachLoadCommand + { + public MachTwoLevelHints(MachObjectFile objectFile, MachLinkEditData data) + { + Data = data; + } + + public uint FileOffset => Data.FileOffset; + + public uint FileSize => (uint)Data.Size; + + public MachLinkEditData Data { get; private init; } + + internal override IEnumerable LinkEditData + { + get + { + yield return Data; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs new file mode 100644 index 00000000000000..a7cdec3462e733 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs @@ -0,0 +1,7 @@ +namespace Melanzana.MachO +{ + public class MachVersionMinIOS : MachBuildVersionBase + { + public override MachPlatform Platform => MachPlatform.IOS; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs new file mode 100644 index 00000000000000..a186089a40be35 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs @@ -0,0 +1,7 @@ +namespace Melanzana.MachO +{ + public class MachVersionMinMacOS : MachBuildVersionBase + { + public override MachPlatform Platform => MachPlatform.MacOS; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs new file mode 100644 index 00000000000000..422e9eda986e41 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs @@ -0,0 +1,7 @@ +namespace Melanzana.MachO +{ + public class MachVersionMinTvOS : MachBuildVersionBase + { + public override MachPlatform Platform => MachPlatform.TvOS; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs new file mode 100644 index 00000000000000..6018da7cf42370 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs @@ -0,0 +1,7 @@ +namespace Melanzana.MachO +{ + public class MachVersionMinWatchOS : MachBuildVersionBase + { + public override MachPlatform Platform => MachPlatform.WatchOS; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs new file mode 100644 index 00000000000000..13b15c94232082 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs @@ -0,0 +1,34 @@ +namespace Melanzana.MachO +{ + /// + /// Defines the subtypes of the ARM 64 . + /// Defined in machine.h. + /// + /// + /// This enumeration matches version 7195.141.2 of XNU. + /// + /// + [Flags] + public enum MachArm64CpuSubType : uint + { + /// + /// All ARM64 subtypes. + /// + All = MachCpuSubType.All, + + /// + /// The ARM64v8 CPU architecture subtype. + /// + V8 = 1, + + /// + /// The ARM64e CPU architecture subtype. + /// + E = 2, + + /// + /// Pointer authentication with versioned ABI. + /// + PointerAuthenticationWithVersionedAbi = 0x80000000, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs new file mode 100644 index 00000000000000..03b1de1192ef26 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs @@ -0,0 +1,83 @@ +namespace Melanzana.MachO +{ + /// + /// Defines the subtypes of the ARM . + /// Defined in machine.h. + /// + /// + /// This enumeration matches version 7195.141.2 of XNU. + /// + /// + public enum MachArmCpuSubType : uint + { + /// + /// All ARM subtypes. + /// + All = MachCpuSubType.All, + + /// + /// The ARMv4T architecture CPU. Part of the ARM7TDMI family. + /// + V4T = 5, + + /// + /// The ARMv6 architecture CPU. Part of the ARMv6 family. + /// + V6 = 6, + + /// + /// The ARMv5TEJ architecture CPU. Part of the ARM9E family. + /// + V5TEJ = 7, + + /// + /// The XScale family of ARMv5TE CPUs. + /// + XSCALE = 8, + + /// + /// The ARMv7 CPU + /// + V7 = 9, + + /// + /// The ARMv7F CPU. + /// + V7F = 10, + + /// + /// The ARMv7S CPU. + /// + V7S = 11, + + /// + /// The ARMv7K CPU. + /// + V7K = 12, + + /// + /// An ARMv8 architecture CPU. + /// + V8 = 13, + + /// + /// The ARMv6-M architecture CPU. Part of the Cortex-M family. + /// + V6M = 14, + + /// + /// The ARMv7-M architecture CPU. Part of the Cortex-M family. + /// + V7M = 15, + + /// + /// An ARMv7E-M architecture CPU. Part of the Cortex-M family. + /// + V7EM = 16, + + /// + /// An ARMv8M architecture CPU. + /// + V8M = 17, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs new file mode 100644 index 00000000000000..79a561c56f47c1 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs @@ -0,0 +1,19 @@ +namespace Melanzana.MachO +{ + /// + /// Defines the general flags for CPU subtypes. Depending on the , + /// you should cast the value to a more specialized enumeration, such as . + /// Defined in machine.h. + /// + /// + /// This enumeration matches version 7195.141.2 of XNU. + /// + /// + public enum MachCpuSubType : uint + { + /// + /// All subtypes. + /// + All = 0, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs new file mode 100644 index 00000000000000..2ae2a4c659ec1f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs @@ -0,0 +1,20 @@ +namespace Melanzana.MachO +{ + public enum MachCpuType : uint + { + Vax = 1, + M68k = 6, + X86 = 7, + X86_64 = X86 | Architecture64, + M98k = 10, + PaRisc = 11, + Arm = 12, + Arm64 = Arm | Architecture64, + M88k = 13, + Sparc = 14, + I860 = 15, + PowerPC = 18, + PowerPC64 = PowerPC | Architecture64, + Architecture64 = 0x1000000, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs new file mode 100644 index 00000000000000..5825de8c8e0a32 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs @@ -0,0 +1,17 @@ +namespace Melanzana.MachO +{ + public enum MachFileType : uint + { + Object = 1, + Execute = 2, + FixedVM = 3, + Core = 4, + Preload = 5, + DynamicLibrary = 6, + DynamicLinker = 7, + Bundle = 8, + DynamicLibraryStub = 9, + Debug = 10, + Kext = 11 + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs new file mode 100644 index 00000000000000..c7536f1bcbbac7 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs @@ -0,0 +1,32 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachHeaderFlags : uint + { + NoUndefinedReferences = 0x1, + IncrementalLink = 0x2, + DynamicLink = 0x4, + BindAtLoad = 0x8, + Prebound = 0x10, + SplitSegments = 0x20, + LazyInit = 0x40, + TwoLevel = 0x80, + ForceFlat = 0x100, + NoMultiDefs = 0x200, + NoFixPrebinding = 0x400, + Prebindable = 0x800, + AllModsBound = 0x1000, + SubsectionsViaSymbols = 0x2000, + Canonical = 0x4000, + WeakDefines = 0x8000, + BindsToWeak = 0x10000, + AllowStackExecution = 0x20000, + RootSafe = 0x40000, + SetuidSafe = 0x80000, + NoReexportedDylibs = 0x100000, + PIE = 0x200000, + DeadStrippableDylib = 0x400000, + HasTlvDescriptors = 0x800000, + NoHeapExecution = 0x1000000 + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs new file mode 100644 index 00000000000000..ba3ea5fa98e564 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs @@ -0,0 +1,118 @@ +namespace Melanzana.MachO +{ + /// + /// Defines the subtypes of the i386 . + /// Defined in machine.h. + /// + /// + /// This enumeration matches version 7195.141.2 of XNU. + /// + /// + public enum MachI386CpuSubType : uint + { + /// + /// All i386 subtypes + /// + All = 3 + (0 << 4), + + /// + /// The Intel 386 processor. + /// + _386 = 3 + (0 << 4), + + /// + /// The Intel 486 processor. + /// + _486 = 4 + (0 << 4), + + /// + /// The Intel 486SX processor. + /// + _486SX = 4 + (8 << 4), + + /// + /// The Intel 586 processor. + /// + _586 = 5 + (0 << 4), + + /// + /// The Intel Pentium processor. + /// + Pentium = 5 + (0 << 4), + + /// + /// The Intel Pentium Pro processor. + /// + PentiumPro = 6 + (1 << 4), + + /// + /// The Intel Pentium II (M3) processor. + /// + PentiumIIM3 = 6 + (3 << 4), + + /// + /// The Intel Penium II (M5) processor. + /// + PentiumIIM5 = 6 + (5 << 4), + + /// + /// The Intel Celeron processor. + /// + Celeron = 7 + (6 << 4), + + /// + /// The Intel Celeron Mobile processor. + /// + CeleronMobile = 7 + (7 << 4), + + /// + /// The Intel Pentium 3 processor. + /// + Pentium3 = 8 + (0 << 4), + + /// + /// The Intel Pentium 3 M processor. + /// + Pentium3M = 8 + (1 << 4), + + /// + /// The Intel Pentium 3 Xeon processor. + /// + Pentium3Xeon = 8 + (2 << 4), + + /// + /// The Intel Pentium M processor. + /// + PentiumM = 9 + (0 << 4), + + /// + /// The Intel Pentium 4 processor. + /// + Pentium4 = 10 + (0 << 4), + + /// + /// The Intel Pentium 4 M processor. + /// + Pentium4M = 10 + (1 << 4), + + /// + /// The Intel Itanium processor. + /// + Itanium = 11 + (0 << 4), + + /// + /// The Intel Itanium 2 processor. + /// + Itanium2 = 11 + (1 << 4), + + /// + /// The Intel Xeon processor. + /// + Xeon = 12 + (0 << 4), + + /// + /// The Intel Xeon MP processor. + /// + XeonMP = 12 + (1 << 4), + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs new file mode 100644 index 00000000000000..06ab7bd1069e9f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs @@ -0,0 +1,32 @@ +namespace Melanzana.MachO +{ + public class MachLayoutOptions + { + public MachLayoutOptions(MachObjectFile objectFile) + { + if (objectFile.FileType == MachFileType.Object) + { + // Unlinked object + BaseAddress = 0; + // There's single segment, so no alignment is necessary + SegmentAlignment = 1; + } + else + { + // Presumably there's a __PAGEZERO section at zero address + BaseAddress = 0; + + SegmentAlignment = objectFile.CpuType switch + { + MachCpuType.Arm64 => 0x4000, + MachCpuType.Arm => 0x4000, + _ => 0x1000, + }; + } + } + + public uint BaseAddress { get; set; } + + public uint SegmentAlignment { get; set; } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs new file mode 100644 index 00000000000000..fc3e8d1aa51241 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs @@ -0,0 +1,67 @@ +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + /// + /// Linker data representation. + /// + /// This holds data for relocations, symbol tables, string tables and various + /// other linking related information. It's either part of the __LINKEDIT + /// segment for fully linked files, or appended at the end of the object file + /// for unlinked Mach-O files. + /// + public class MachLinkEditData + { + private Stream dataStream; + + internal MachLinkEditData() + { + this.dataStream = Stream.Null; + this.FileOffset = 0; + } + + internal MachLinkEditData(Stream objectStream, uint offset, uint size) + { + this.dataStream = size == 0 ? Stream.Null : objectStream.Slice(offset, size); + this.FileOffset = offset; + } + + public uint FileOffset { get; set; } + + public ulong Size + { + get => (ulong)dataStream.Length; + set + { + if (dataStream != null) + { + if (!HasContentChanged) + { + HasContentChanged = true; + dataStream = new UnclosableMemoryStream(); + } + dataStream.SetLength((long)value); + } + } + } + + internal bool HasContentChanged { get; set; } + + public Stream GetReadStream() + { + if (dataStream.Length == 0) + { + return Stream.Null; + } + + return dataStream.Slice(0, (long)this.Size); + } + + public Stream GetWriteStream() + { + HasContentChanged = true; + dataStream = new UnclosableMemoryStream(); + return dataStream; + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs new file mode 100644 index 00000000000000..5c724b4190755e --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO +{ + public abstract class MachLoadCommand + { + protected MachLoadCommand() + { + } + + internal virtual IEnumerable LinkEditData => Array.Empty(); + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs new file mode 100644 index 00000000000000..ecffc071ea1a4d --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs @@ -0,0 +1,63 @@ +namespace Melanzana.MachO +{ + public enum MachLoadCommandType : uint + { + Segment = 0x1, + SymbolTable = 0x2, + SymbolSegment = 0x3, + Thread = 0x4, + UnixThread = 0x5, + LoadFixedVMSharedLibrary = 0x6, + IdFixedVMSharedLibrary = 0x7, + ObjectIdentification = 0x8, + FixedVMFileInclusion = 0x9, + Prepage = 0xa, + DynamicLinkEditSymbolTable = 0xb, + LoadDylib = 0xc, + IdDylib = 0xd, + LoadDylinker = 0xe, + IdDylinker = 0xf, + PreboundDylib = 0x10, + Routines = 0x11, + SubFramework = 0x12, + SubUmbrella = 0x13, + SubClient = 0x14, + SubLibrary = 0x15, + TowLevelHints = 0x16, + PrebindChecksum = 0x17, + LoadWeakDylib = 0x18 | ReqDyld, + Segment64 = 0x19, + Routines64 = 0x1a, + Uuid = 0x1b, + Rpath = 0x1c | ReqDyld, + CodeSignature = 0x1d, + SegmentSplitInfo = 0x1e, + ReexportDylib = 0x1f | ReqDyld, + LazyLoadDylib = 0x20, + EncryptionInfo = 0x21, + DyldInfo = 0x22, + DyldInfoOnly = 0x22 | ReqDyld, + LoadUpwardDylib = 0x23 | ReqDyld, + VersionMinMacOS = 0x24, + VersionMinIPhoneOS = 0x25, + FunctionStarts = 0x26, + DyldEnvironment = 0x27, + Main = 0x28 | ReqDyld, + DataInCode = 0x29, + SourceVersion = 0x2a, + DylibCodeSigningDRs = 0x2b, + EncryptionInfo64 = 0x2c, + LinkerOption = 0x2d, + LinkerOptimizationHint = 0x2e, + VersionMinTvOS = 0x2f, + VersionMinWatchOS = 0x30, + Note = 0x31, + BuildVersion = 0x32, + DyldExportsTrie = 0x33 | ReqDyld, + DyldChainedFixups = 0x34 | ReqDyld, + FileSetEntry = 0x35, + + /// Flag that marks any command that needs to be understood by DyLD or load will fail + ReqDyld = 0x80000000, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs new file mode 100644 index 00000000000000..7a86b5decc7a45 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs @@ -0,0 +1,12 @@ +namespace Melanzana.MachO +{ + public enum MachMagic : uint + { + MachHeaderLittleEndian = 0xcefaedfe, + MachHeaderBigEndian = 0xfeedface, + MachHeader64LittleEndian = 0xcffaedfe, + MachHeader64BigEndian = 0xfeedfacf, + FatMagicLittleEndian = 0xbebafeca, + FatMagicBigEndian = 0xcafebabe, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs new file mode 100644 index 00000000000000..b122483b2c2b31 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs @@ -0,0 +1,321 @@ +using Melanzana.Streams; +using Melanzana.MachO.BinaryFormat; +using System.Text; +using System.Diagnostics; + +namespace Melanzana.MachO +{ + public class MachObjectFile + { + private readonly Stream stream; + + public MachObjectFile() + : this(Stream.Null) + { + } + + internal MachObjectFile(Stream stream) + { + this.stream = stream; + } + + public bool Is64Bit => CpuType.HasFlag(MachCpuType.Architecture64); + + public bool IsLittleEndian { get; set; } + + public MachCpuType CpuType { get; set; } + + public uint CpuSubType { get; set; } + + public MachFileType FileType { get; set; } + + public MachHeaderFlags Flags { get; set; } + + public IList LoadCommands { get; } = new List(); + + /// + /// For object files the relocation, symbol tables and other data are stored at the end of the + /// file but not covered by any segment/section. We maintain a list of these data to make it + /// easier to address. + /// + /// For linked files this points to the real __LINKEDIT segment. We slice it into subsections + /// based on the known LinkEdit commands though. + /// + public IEnumerable LinkEditData => LoadCommands.SelectMany(command => command.LinkEditData); + + public IEnumerable Segments => LoadCommands.OfType(); + + /// + /// Get the lowest file offset of any section in the file. This allows calculating space that is + /// reserved for adding new load commands (header pad). + /// + public ulong GetLowestSectionFileOffset() + { + ulong lowestFileOffset = ulong.MaxValue; + + foreach (var segment in Segments) + { + foreach (var section in segment.Sections) + { + if (section.IsInFile && + section.FileOffset < lowestFileOffset) + { + lowestFileOffset = section.FileOffset; + } + } + } + + return lowestFileOffset == ulong.MaxValue ? 0 : lowestFileOffset; + } + + public ulong GetSize() + { + // Assume the size is the highest file offset+size of any segment + return Segments.Max(s => s.FileOffset + s.FileSize); + } + + public ulong GetSigningLimit() + { + var codeSignature = LoadCommands.OfType().FirstOrDefault(); + if (codeSignature != null) + { + // If code signature is present it has to be at the end of the file + return codeSignature.FileOffset; + } + else + { + // If no code signature is present then we return the whole file size + return GetSize(); + } + } + + /// + /// Gets a stream for a given part of range of the file. + /// + /// + /// The range must be fully contained in a single section or segment with no sections. + /// Accessing file header or link commands through this API is currently not supported. + /// + public Stream GetStreamAtFileOffset(uint fileOffset, uint fileSize) + { + // FIXME: Should we dispose the original stream? At the moment it would be no-op + // anyway since it's always SliceStream or UnclosableMemoryStream. + + foreach (var segment in Segments) + { + if (fileOffset >= segment.FileOffset && + fileOffset < segment.FileOffset + segment.FileSize) + { + if (segment.Sections.Count == 0) + { + return segment.GetReadStream().Slice( + (long)(fileOffset - segment.FileOffset), + fileSize); + } + + foreach (var section in segment.Sections) + { + if (fileOffset >= section.FileOffset && + fileOffset < section.FileOffset + section.Size) + { + return section.GetReadStream().Slice( + (long)(fileOffset - section.FileOffset), + fileSize); + } + } + + return Stream.Null; + } + } + + return Stream.Null; + } + + public Stream GetStreamAtVirtualAddress(ulong address, uint length) + { + // FIXME: Should we dispose the original stream? At the moment it would be no-op + // anyway since it's always SliceStream or UnclosableMemoryStream. + + foreach (var segment in Segments) + { + if (address >= segment.VirtualAddress && + address < segment.VirtualAddress + segment.Size) + { + if (segment.Sections.Count == 0) + { + return segment.GetReadStream().Slice( + (long)(address - segment.VirtualAddress), + (long)Math.Min(length, segment.VirtualAddress + segment.FileSize - address)); + } + + foreach (var section in segment.Sections) + { + if (address >= section.VirtualAddress && + address < section.VirtualAddress + section.Size) + { + return section.GetReadStream().Slice( + (long)(address - section.VirtualAddress), + (long)Math.Min(length, section.VirtualAddress + section.Size - address)); + } + } + + return Stream.Null; + } + } + + return Stream.Null; + } + + public Stream GetOriginalStream() + { + if (stream == null) + return Stream.Null; + + return stream.Slice(0, stream.Length); + } + + /// + /// Update layout of segments, sections and link edit data to valid + /// non-overlapping values that can be written to disk. + /// + /// Option bag to specify additional requirements for the layout + public void UpdateLayout(MachLayoutOptions? options = null) + { + // If no layout options were specified then infer the details + // from the object file. + if (options == null) + { + options = new MachLayoutOptions(this); + } + + ulong segmentAlignment = options.SegmentAlignment; + ulong fileOffset = 0; + + // First we need to place the load commands + + // 4 bytes magic number + fileOffset += 4u; + // Mach header + fileOffset += (ulong)(Is64Bit ? MachHeader64.BinarySize : MachHeader.BinarySize); + // Calculate size of load command + foreach (var loadCommand in LoadCommands) + { + fileOffset += LoadCommandHeader.BinarySize; + + switch (loadCommand) + { + case MachSegment segment: + if (Is64Bit) + { + fileOffset += (ulong)(Segment64Header.BinarySize + segment.Sections.Count * Section64Header.BinarySize); + } + else + { + fileOffset += (ulong)(SegmentHeader.BinarySize + segment.Sections.Count * SectionHeader.BinarySize); + } + break; + + case MachCodeSignature: + case MachDylibCodeSigningDirs: + case MachSegmentSplitInfo: + case MachFunctionStarts: + case MachDataInCode: + case MachLinkerOptimizationHint: + case MachDyldExportsTrie: + case MachDyldChainedFixups: + fileOffset += LinkEditHeader.BinarySize; + break; + + case MachLoadDylibCommand: + case MachLoadWeakDylibCommand: + case MachReexportDylibCommand: + fileOffset += (ulong)AlignedSize( + DylibCommandHeader.BinarySize + + Encoding.UTF8.GetByteCount(((MachDylibCommand)loadCommand).Name) + 1, + Is64Bit); + break; + + case MachEntrypointCommand entrypointCommand: + fileOffset += MainCommandHeader.BinarySize; + break; + + case MachVersionMinMacOS: + case MachVersionMinIOS: + case MachVersionMinTvOS: + case MachVersionMinWatchOS: + fileOffset += VersionMinCommandHeader.BinarySize; + break; + + case MachBuildVersion versionCommand: + fileOffset += (ulong)(BuildVersionCommandHeader.BinarySize + (versionCommand.ToolVersions.Count * BuildToolVersionHeader.BinarySize)); + break; + + case MachSymbolTable: + fileOffset += SymbolTableCommandHeader.BinarySize; + break; + + case MachDynamicLinkEditSymbolTable: + fileOffset += DynamicSymbolTableCommandHeader.BinarySize; + break; + + case MachCustomLoadCommand customLoadCommand: + fileOffset += (ulong)customLoadCommand.Data.Length; + break; + } + } + + fileOffset = (fileOffset + segmentAlignment) & ~segmentAlignment; + ulong virtualAddress = options.BaseAddress; + foreach (var segment in Segments) + { + ulong segmentFileSize = 0; + ulong segmentSize = 0; + + segment.VirtualAddress = virtualAddress; + segment.FileOffset = fileOffset; + + if (!segment.IsLinkEditSegment && segment.Sections.Count > 0) + { + foreach (var section in segment.Sections) + { + ulong alignment = 1u << (int)section.Log2Alignment; + + fileOffset = (fileOffset + alignment - 1) & ~(alignment - 1); + virtualAddress = (virtualAddress + alignment - 1) & ~(alignment - 1); + + if (section.Type is not MachSectionType.ZeroFill or MachSectionType.GBZeroFill or MachSectionType.ThreadLocalZeroFill) + { + section.FileOffset = (uint)fileOffset; + fileOffset += section.Size; + segmentFileSize = Math.Max(segmentFileSize, fileOffset - segment.FileOffset); + } + else + { + // The offset is unused for virtual sections. + section.FileOffset = 0; + } + + section.VirtualAddress = virtualAddress; + virtualAddress += section.Size; + + segmentSize = Math.Max(segmentSize, virtualAddress - segment.VirtualAddress); + } + + segment.FileSize = (segmentFileSize + segmentAlignment - 1) & ~(segmentAlignment - 1); + segment.Size = (segmentSize + segmentAlignment - 1) & ~(segmentAlignment - 1); + + virtualAddress = (virtualAddress + segmentAlignment - 1) & ~(segmentAlignment - 1); + } + } + + var linkEditData = new List(LinkEditData); + foreach (var data in linkEditData) + { + data.FileOffset = (uint)fileOffset; + fileOffset += data.Size; + } + + static int AlignedSize(int size, bool is64bit) => is64bit ? (size + 7) & ~7 : (size + 3) & ~3; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs new file mode 100644 index 00000000000000..6c67d6dd1728e5 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs @@ -0,0 +1,16 @@ +namespace Melanzana.MachO +{ + public enum MachPlatform : uint + { + MacOS = 1, + IOS = 2, + TvOS = 3, + WatchOS = 4, + BridgeOS = 5, + MacCatalyst = 6, + IOSSimulator = 7, + TvOSSimulator = 8, + WatchOSSimulator = 9, + DriverKit = 10, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs new file mode 100644 index 00000000000000..c5b19a494a00d9 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs @@ -0,0 +1,371 @@ +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using Melanzana.MachO.BinaryFormat; +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + public static class MachReader + { + private static MachSegment ReadSegment(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) + { + var segmentHeader = SegmentHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + + var machSegment = segmentHeader.NumberOfSections == 0 && segmentHeader.FileSize != 0 ? + new MachSegment(objectFile, segmentHeader.Name, stream.Slice(segmentHeader.FileOffset, segmentHeader.FileSize)) : + new MachSegment(objectFile, segmentHeader.Name); + machSegment.FileOffset = segmentHeader.FileOffset; + machSegment.FileSize = segmentHeader.FileSize; + machSegment.VirtualAddress = segmentHeader.Address; + machSegment.Size = segmentHeader.Size; + machSegment.MaximumProtection = segmentHeader.MaximumProtection; + machSegment.InitialProtection = segmentHeader.InitialProtection; + machSegment.Flags = segmentHeader.Flags; + + for (int s = 0; s < segmentHeader.NumberOfSections; s++) + { + var sectionHeader = SectionHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize + SegmentHeader.BinarySize + s * SectionHeader.BinarySize), objectFile.IsLittleEndian, out var _); + var sectionType = (MachSectionType)(sectionHeader.Flags & 0xff); + MachSection section; + + if (sectionHeader.Size != 0 && + sectionType != MachSectionType.ZeroFill && + sectionType != MachSectionType.GBZeroFill && + sectionType != MachSectionType.ThreadLocalZeroFill) + { + section = new MachSection( + objectFile, + sectionHeader.SegmentName, + sectionHeader.SectionName, + stream.Slice(sectionHeader.FileOffset, sectionHeader.Size), + new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)); + } + else + { + section = new MachSection( + objectFile, + sectionHeader.SegmentName, + sectionHeader.SectionName, + null, + new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)) + { + Size = sectionHeader.Size + }; + } + + section.VirtualAddress = sectionHeader.Address; + section.FileOffset = sectionHeader.FileOffset; + section.Log2Alignment = sectionHeader.Log2Alignment; + section.Flags = sectionHeader.Flags; + section.Reserved1 = sectionHeader.Reserved1; + section.Reserved2 = sectionHeader.Reserved2; + machSegment.Sections.Add(section); + } + + return machSegment; + } + + private static MachSegment ReadSegment64(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) + { + var segmentHeader = Segment64Header.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + + var machSegment = segmentHeader.NumberOfSections == 0 && segmentHeader.FileSize != 0 ? + new MachSegment(objectFile, segmentHeader.Name, stream.Slice((long)segmentHeader.FileOffset, (long)segmentHeader.FileSize)) : + new MachSegment(objectFile, segmentHeader.Name); + machSegment.FileOffset = segmentHeader.FileOffset; + machSegment.FileSize = segmentHeader.FileSize; + machSegment.VirtualAddress = segmentHeader.Address; + machSegment.Size = segmentHeader.Size; + machSegment.MaximumProtection = segmentHeader.MaximumProtection; + machSegment.InitialProtection = segmentHeader.InitialProtection; + machSegment.Flags = segmentHeader.Flags; + + for (int s = 0; s < segmentHeader.NumberOfSections; s++) + { + var sectionHeader = Section64Header.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize + Segment64Header.BinarySize + s * Section64Header.BinarySize), objectFile.IsLittleEndian, out var _); + var sectionType = (MachSectionType)(sectionHeader.Flags & 0xff); + MachSection section; + + if (sectionHeader.Size != 0 && + sectionType != MachSectionType.ZeroFill && + sectionType != MachSectionType.GBZeroFill && + sectionType != MachSectionType.ThreadLocalZeroFill) + { + section = new MachSection( + objectFile, + sectionHeader.SegmentName, + sectionHeader.SectionName, + stream.Slice(sectionHeader.FileOffset, (long)sectionHeader.Size), + new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)); + } + else + { + section = new MachSection( + objectFile, + sectionHeader.SegmentName, + sectionHeader.SectionName, + null, + new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)) + { + Size = sectionHeader.Size + }; + } + + section.VirtualAddress = sectionHeader.Address; + section.FileOffset = sectionHeader.FileOffset; + section.Log2Alignment = sectionHeader.Log2Alignment; + section.Flags = sectionHeader.Flags; + section.Reserved1 = sectionHeader.Reserved1; + section.Reserved2 = sectionHeader.Reserved2; + section.Reserved3 = sectionHeader.Reserved3; + machSegment.Sections.Add(section); + } + + return machSegment; + } + + private static MachLinkEditData ReadLinkEdit(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) + { + var linkEditHeader = LinkEditHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + return new MachLinkEditData(stream, linkEditHeader.FileOffset, linkEditHeader.FileSize); + } + + private static T ReadDylibCommand(ReadOnlySpan loadCommandPtr, uint commandSize, bool isLittleEndian) + where T : MachDylibCommand, new() + { + var dylibCommandHeader = DylibCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); + + Debug.Assert(dylibCommandHeader.NameOffset == LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize); + var nameSlice = loadCommandPtr.Slice((int)dylibCommandHeader.NameOffset, (int)commandSize - (int)dylibCommandHeader.NameOffset); + int zeroIndex = nameSlice.IndexOf((byte)0); + string name = zeroIndex >= 0 ? Encoding.UTF8.GetString(nameSlice.Slice(0, zeroIndex)) : Encoding.UTF8.GetString(nameSlice); + + return new T + { + Name = name, + Timestamp = dylibCommandHeader.Timestamp, + CurrentVersion = dylibCommandHeader.CurrentVersion, + CompatibilityVersion = dylibCommandHeader.CompatibilityVersion, + }; + } + + private static MachEntrypointCommand ReadMainCommand(ReadOnlySpan loadCommandPtr, bool isLittleEndian) + { + var mainCommandHeader = MainCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); + + return new MachEntrypointCommand + { + FileOffset = mainCommandHeader.FileOffset, + StackSize = mainCommandHeader.StackSize, + }; + } + + private static Version ConvertVersion(uint version) + => new Version((int)(version >> 16), (int)((version >> 8) & 0xff), (int)(version & 0xff)); + + private static T ReadVersionMinCommand(ReadOnlySpan loadCommandPtr, bool isLittleEndian) + where T : MachBuildVersionBase, new() + { + var versionMinCommandHeader = VersionMinCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); + + return new T + { + MinimumPlatformVersion = ConvertVersion(versionMinCommandHeader.MinimumPlatformVersion), + SdkVersion = ConvertVersion(versionMinCommandHeader.SdkVersion), + }; + } + + private static MachBuildVersion ReadBuildVersion(ReadOnlySpan loadCommandPtr, bool isLittleEndian) + { + var buildVersionCommandHeader = BuildVersionCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); + var buildVersion = new MachBuildVersion + { + TargetPlatform = buildVersionCommandHeader.Platform, + MinimumPlatformVersion = ConvertVersion(buildVersionCommandHeader.MinimumPlatformVersion), + SdkVersion = ConvertVersion(buildVersionCommandHeader.SdkVersion), + }; + + + loadCommandPtr = loadCommandPtr.Slice(LoadCommandHeader.BinarySize + BuildVersionCommandHeader.BinarySize); + for (int i = 0; i < buildVersionCommandHeader.NumberOfTools; i++) + { + var buildToolVersionHeader = BuildToolVersionHeader.Read(loadCommandPtr, isLittleEndian, out var _); + buildVersion.ToolVersions.Add(new MachBuildToolVersion + { + BuildTool = buildToolVersionHeader.BuildTool, + Version = ConvertVersion(buildToolVersionHeader.Version), + }); + loadCommandPtr = loadCommandPtr.Slice(BuildToolVersionHeader.BinarySize); + } + + return buildVersion; + } + + private static MachSymbolTable ReadSymbolTable(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) + { + var symbolTableHeader = SymbolTableCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + + uint symbolTableSize = + symbolTableHeader.NumberOfSymbols * + (SymbolHeader.BinarySize + (objectFile.Is64Bit ? 8u : 4u)); + + return new MachSymbolTable( + objectFile, + new MachLinkEditData(stream, symbolTableHeader.SymbolTableOffset, symbolTableSize), + new MachLinkEditData(stream, symbolTableHeader.StringTableOffset, symbolTableHeader.StringTableSize)); + } + + private static MachDynamicLinkEditSymbolTable ReadDynamicLinkEditSymbolTable(ReadOnlySpan loadCommandPtr, bool isLittleEndian) + { + var dynamicSymbolTableHeader = DynamicSymbolTableCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); + + // TODO: Clean up + return new MachDynamicLinkEditSymbolTable(dynamicSymbolTableHeader); + } + + private static MachDyldInfo ReadDyldInfo( + MachLoadCommandType loadCommandType, + ReadOnlySpan loadCommandPtr, + MachObjectFile objectFile, + Stream stream) + { + var dyldInfoHeader = DyldInfoHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + + var rebaseData = new MachLinkEditData(stream, dyldInfoHeader.RebaseOffset, dyldInfoHeader.RebaseSize); + var bindData = new MachLinkEditData(stream, dyldInfoHeader.BindOffset, dyldInfoHeader.BindSize); + var weakBindData = new MachLinkEditData(stream, dyldInfoHeader.WeakBindOffset, dyldInfoHeader.WeakBindSize); + var lazyBindData = new MachLinkEditData(stream, dyldInfoHeader.LazyBindOffset, dyldInfoHeader.LazyBindSize); + var exportData = new MachLinkEditData(stream, dyldInfoHeader.ExportOffset, dyldInfoHeader.ExportSize); + + if (loadCommandType == MachLoadCommandType.DyldInfo) + { + return new MachDyldInfo(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData); + } + + return new MachDyldInfoOnly(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData); + } + + private static MachTwoLevelHints ReadTwoLevelHints(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) + { + var twoLevelHintsHeader = TwoLevelHintsHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); + + return new MachTwoLevelHints(objectFile, + new MachLinkEditData( + stream, + twoLevelHintsHeader.FileOffset, + twoLevelHintsHeader.NumberOfHints * sizeof(uint))); + } + + private static MachObjectFile ReadSingle(FatArchHeader? fatArchHeader, MachMagic magic, Stream stream) + { + Span headerBuffer = stackalloc byte[Math.Max(MachHeader.BinarySize, MachHeader64.BinarySize)]; + MachObjectFile objectFile; + IMachHeader machHeader; + bool isLittleEndian; + + switch (magic) + { + case MachMagic.MachHeaderLittleEndian: + case MachMagic.MachHeaderBigEndian: + stream.Read(headerBuffer.Slice(0, MachHeader.BinarySize)); + isLittleEndian = magic == MachMagic.MachHeaderLittleEndian; + machHeader = MachHeader.Read(headerBuffer, isLittleEndian, out var _); + Debug.Assert(!machHeader.CpuType.HasFlag(MachCpuType.Architecture64)); + objectFile = new MachObjectFile(stream); + break; + + case MachMagic.MachHeader64LittleEndian: + case MachMagic.MachHeader64BigEndian: + stream.Read(headerBuffer.Slice(0, MachHeader64.BinarySize)); + isLittleEndian = magic == MachMagic.MachHeader64LittleEndian; + machHeader = MachHeader64.Read(headerBuffer, isLittleEndian, out var _); + Debug.Assert(machHeader.CpuType.HasFlag(MachCpuType.Architecture64)); + objectFile = new MachObjectFile(stream); + break; + + default: + throw new NotSupportedException(); + } + + objectFile.IsLittleEndian = isLittleEndian; + objectFile.CpuType = machHeader.CpuType; + objectFile.CpuSubType = machHeader.CpuSubType; + objectFile.FileType = machHeader.FileType; + objectFile.Flags = machHeader.Flags; + + // Read load commands + // + // Mach-O uses the load command both to describe the segments/sections and content + // within them. The commands, like "Code Signature" overlap with the segments. For + // code signature in particular it will overlap with the LINKEDIT segment. + var loadCommands = new byte[machHeader.SizeOfCommands]; + Span loadCommandPtr = loadCommands; + stream.ReadFully(loadCommands); + for (int i = 0; i < machHeader.NumberOfCommands; i++) + { + var loadCommandHeader = LoadCommandHeader.Read(loadCommandPtr, isLittleEndian, out var _); + objectFile.LoadCommands.Add(loadCommandHeader.CommandType switch + { + MachLoadCommandType.Segment => ReadSegment(loadCommandPtr, objectFile, stream), + MachLoadCommandType.Segment64 => ReadSegment64(loadCommandPtr, objectFile, stream), + MachLoadCommandType.CodeSignature => new MachCodeSignature(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.DylibCodeSigningDRs => new MachDylibCodeSigningDirs(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.SegmentSplitInfo => new MachSegmentSplitInfo(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.FunctionStarts => new MachFunctionStarts(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.DataInCode => new MachDataInCode(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.LinkerOptimizationHint => new MachLinkerOptimizationHint(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.DyldExportsTrie => new MachDyldExportsTrie(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.DyldChainedFixups => new MachDyldChainedFixups(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), + MachLoadCommandType.LoadDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), + MachLoadCommandType.LoadWeakDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), + MachLoadCommandType.ReexportDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), + MachLoadCommandType.Main => ReadMainCommand(loadCommandPtr, isLittleEndian), + MachLoadCommandType.VersionMinMacOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), + MachLoadCommandType.VersionMinIPhoneOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), + MachLoadCommandType.VersionMinTvOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), + MachLoadCommandType.VersionMinWatchOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), + MachLoadCommandType.BuildVersion => ReadBuildVersion(loadCommandPtr, isLittleEndian), + MachLoadCommandType.SymbolTable => ReadSymbolTable(loadCommandPtr, objectFile, stream), + MachLoadCommandType.DynamicLinkEditSymbolTable => ReadDynamicLinkEditSymbolTable(loadCommandPtr, isLittleEndian), + MachLoadCommandType.DyldInfo => ReadDyldInfo(loadCommandHeader.CommandType, loadCommandPtr, objectFile, stream), + MachLoadCommandType.DyldInfoOnly => ReadDyldInfo(loadCommandHeader.CommandType, loadCommandPtr, objectFile, stream), + MachLoadCommandType.TowLevelHints => ReadTwoLevelHints(loadCommandPtr, objectFile, stream), + _ => new MachCustomLoadCommand(loadCommandHeader.CommandType, loadCommandPtr.Slice(LoadCommandHeader.BinarySize, (int)loadCommandHeader.CommandSize - LoadCommandHeader.BinarySize).ToArray()), + }); + loadCommandPtr = loadCommandPtr.Slice((int)loadCommandHeader.CommandSize); + } + + return objectFile; + } + + public static IEnumerable Read(Stream stream) + { + var magicBuffer = new byte[4]; + stream.ReadFully(magicBuffer); + + var magic = (MachMagic)BinaryPrimitives.ReadUInt32BigEndian(magicBuffer); + if (magic == MachMagic.FatMagicLittleEndian || magic == MachMagic.FatMagicBigEndian) + { + var headerBuffer = new byte[Math.Max(FatHeader.BinarySize, FatArchHeader.BinarySize)]; + stream.ReadFully(headerBuffer.AsSpan(0, FatHeader.BinarySize)); + var fatHeader = FatHeader.Read(headerBuffer, isLittleEndian: magic == MachMagic.FatMagicLittleEndian, out var _); + for (int i = 0; i < fatHeader.NumberOfFatArchitectures; i++) + { + stream.ReadFully(headerBuffer.AsSpan(0, FatArchHeader.BinarySize)); + var fatArchHeader = FatArchHeader.Read(headerBuffer, isLittleEndian: magic == MachMagic.FatMagicLittleEndian, out var _); + + var machOSlice = stream.Slice(fatArchHeader.Offset, fatArchHeader.Size); + machOSlice.ReadFully(magicBuffer); + magic = (MachMagic)BinaryPrimitives.ReadUInt32BigEndian(magicBuffer); + yield return ReadSingle(fatArchHeader, magic, machOSlice); + } + } + else + { + yield return ReadSingle(null, magic, stream); + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs new file mode 100644 index 00000000000000..43455f2bf2cd2f --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Melanzana.MachO +{ + public class MachRelocation + { + /// + /// Address from the start of the section. + /// + public int Address { get; init; } + + /// + /// Symbol index (for internal symbols) or section index (for external symbols). + /// + public uint SymbolOrSectionIndex { get; init; } + + /// + /// Specifies whether the relocation is program counter relative. + /// + public bool IsPCRelative { get; init; } + + /// + /// Specifies whether the relocation is external. + /// + public bool IsExternal { get; init; } + + /// + /// Length of the relocation in bytes (valid values are 1, 2, 4, and 8). + /// + public byte Length { get; init; } + + /// + /// Machine specific relocation type. + /// + public MachRelocationType RelocationType { get; init; } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs new file mode 100644 index 00000000000000..13d104896325ff --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs @@ -0,0 +1,146 @@ +using System.Buffers.Binary; +using System.Collections; +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + public class MachRelocationCollection : IList + { + private readonly MachObjectFile objectFile; + private readonly MachLinkEditData relocationData; + private readonly List innerList; + private bool isDirty; + + internal MachRelocationCollection(MachObjectFile objectFile, MachLinkEditData relocationData) + { + int relocationCount = (int)(relocationData.Size / 8); + + this.objectFile = objectFile; + this.relocationData = relocationData; + this.innerList = new List(relocationCount); + this.isDirty = false; + + // Read existing relocations + using var relocationStream = relocationData.GetReadStream(); + Span relocationBuffer = stackalloc byte[8]; + + for (uint i = 0; i < relocationCount; i++) + { + relocationStream.ReadFully(relocationBuffer); + + int address = + objectFile.IsLittleEndian ? + BinaryPrimitives.ReadInt32LittleEndian(relocationBuffer) : + BinaryPrimitives.ReadInt32BigEndian(relocationBuffer); + + uint info = + objectFile.IsLittleEndian ? + BinaryPrimitives.ReadUInt32LittleEndian(relocationBuffer.Slice(4)) : + BinaryPrimitives.ReadUInt32BigEndian(relocationBuffer.Slice(4)); + + innerList.Add(new MachRelocation + { + Address = address, + SymbolOrSectionIndex = info & 0xff_ff_ff, + IsPCRelative = (info & 0x1_00_00_00) > 0, + Length = ((info >> 25) & 3) switch { 0 => 1, 1 => 2, 2 => 4, _ => 8 }, + IsExternal = (info & 0x8_00_00_00) > 0, + RelocationType = (MachRelocationType)(info >> 28) + }); + } + } + + public MachRelocation this[int index] + { + get => innerList[index]; + set + { + innerList[index] = value; + isDirty = true; + } + } + + public int Count => innerList.Count; + + public bool IsReadOnly => false; + + public void Add(MachRelocation item) + { + innerList.Add(item); + isDirty = true; + } + + public void Clear() + { + innerList.Clear(); + isDirty = true; + } + + public void Insert(int index, MachRelocation item) + { + innerList.Insert(index, item); + isDirty = true; + } + + public bool Remove(MachRelocation item) + { + if (innerList.Remove(item)) + { + isDirty = true; + return true; + } + + return false; + } + + public void RemoveAt(int index) + { + innerList.RemoveAt(index); + isDirty = true; + } + + IEnumerator IEnumerable.GetEnumerator() => innerList.GetEnumerator(); + + public bool Contains(MachRelocation item) => innerList.Contains(item); + + public void CopyTo(MachRelocation[] array, int arrayIndex) => innerList.CopyTo(array, arrayIndex); + + public IEnumerator GetEnumerator() => innerList.GetEnumerator(); + + public int IndexOf(MachRelocation item) => innerList.IndexOf(item); + + internal void FlushIfDirty() + { + if (isDirty) + { + Span relocationBuffer = stackalloc byte[8]; + using var stream = relocationData.GetWriteStream(); + uint info; + + foreach (var relocation in innerList) + { + info = relocation.SymbolOrSectionIndex; + info |= relocation.IsPCRelative ? 0x1_00_00_00u : 0u; + info |= relocation.Length switch { 1 => 0u << 25, 2 => 1u << 25, 4 => 2u << 25, _ => 3u << 25 }; + info |= relocation.IsExternal ? 0x8_00_00_00u : 0u; + info |= (uint)relocation.RelocationType << 28; + + if (objectFile.IsLittleEndian) + { + BinaryPrimitives.WriteInt32LittleEndian(relocationBuffer, relocation.Address); + BinaryPrimitives.WriteUInt32LittleEndian(relocationBuffer.Slice(4), info); + } + else + { + BinaryPrimitives.WriteInt32BigEndian(relocationBuffer, relocation.Address); + BinaryPrimitives.WriteUInt32BigEndian(relocationBuffer.Slice(4), info); + } + + stream.Write(relocationBuffer); + } + + isDirty = false; + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs new file mode 100644 index 00000000000000..6454696b1d1ebb --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs @@ -0,0 +1,35 @@ +namespace Melanzana.MachO +{ + public enum MachRelocationType : byte + { + GenericVanilla = 0, + GenericPair = 1, + GenericSectionDiff = 2, + GenericPreboundLazyPtr = 3, + GenericLocalSectionDiff = 4, + GenericTlv = 5, + + X86_64Unsigned = 0, + X86_64Signed = 1, + X86_64Branch = 2, + X86_64GotLoad = 3, + X86_64Got = 4, + X86_64Subtractor = 5, + X86_64Signed1 = 6, + X86_64Signed2 = 7, + X86_64Signed4 = 8, + X86_64Tlv = 9, + + Arm64Unsigned = 0, + Arm64Subtractor = 1, + Arm64Branch26 = 2, + Arm64Page21 = 3, + Arm64PageOffset21 = 4, + Arm64GotLoadPage21 = 5, + Arm64GotLoadPageOffset21 = 6, + Arm64PointerToGot = 7, + Arm64TlvpLoadPage21 = 8, + Arm64TlvpLoadPageOffset21 = 9, + Arm64Addend = 10, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs new file mode 100644 index 00000000000000..ecce79785a38b1 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs @@ -0,0 +1,16 @@ +using System.Diagnostics; + +namespace Melanzana.MachO +{ + public class MachSymbol + { + public string Name { get; init; } = string.Empty; + public MachSymbolType Type { get; init; } + public MachSection? Section { get; init; } + public MachSymbolDescriptor Descriptor { get; init; } + public ulong Value { get; init; } + + public bool IsExternal => Type.HasFlag(MachSymbolType.External); + public bool IsUndefined => (Type & MachSymbolType.TypeMask) == MachSymbolType.Undefined; + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs new file mode 100644 index 00000000000000..07a3c17c6e2e20 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs @@ -0,0 +1,19 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachSymbolDescriptor : ushort + { + ReferenceTypeMask = 0xf, + UndefinedNonLazy = 0, + UndefinedLazy = 1, + Defined = 2, + PrivateDefined = 3, + PrivateUndefinedNonLazy = 4, + PrivateUndefinedLazy = 5, + + ReferencedDynamically = 0x10, + NoDeadStrip = 0x20, + WeakReference = 0x40, + WeakDefinition = 0x80, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs new file mode 100644 index 00000000000000..2fd1341e667787 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs @@ -0,0 +1,222 @@ +using System.Buffers.Binary; +using System.Collections; +using System.Diagnostics; +using System.Text; +using Melanzana.MachO.BinaryFormat; +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + internal class MachSymbolTableCollection : IList + { + private readonly MachObjectFile objectFile; + private readonly MachLinkEditData symbolTableData; + private readonly MachLinkEditData stringTableData; + private readonly List innerList = new(); + + bool isDirty; + + public MachSymbolTableCollection( + MachObjectFile objectFile, + MachLinkEditData symbolTableData, + MachLinkEditData stringTableData, + Dictionary sectionMap) + { + this.objectFile = objectFile; + this.symbolTableData = symbolTableData; + this.stringTableData = stringTableData; + + // Read existing symbols + if (symbolTableData.Size > 0) + { + byte[] stringTable = new byte[stringTableData.Size]; + using var stringTableStream = stringTableData.GetReadStream(); + stringTableStream.ReadFully(stringTable); + + uint symbolSize = SymbolHeader.BinarySize + (objectFile.Is64Bit ? 8u : 4u); + innerList.Capacity = (int)(symbolTableData.Size / symbolSize); + + byte[] symbolBuffer = new byte[symbolSize]; + using var symbolTableStream = symbolTableData.GetReadStream(); + while (symbolTableStream.Position < symbolTableStream.Length) + { + symbolTableStream.ReadFully(symbolBuffer); + var symbolHeader = SymbolHeader.Read(symbolBuffer, objectFile.IsLittleEndian, out var _); + ulong symbolValue; + if (objectFile.IsLittleEndian) + { + symbolValue = objectFile.Is64Bit ? + BinaryPrimitives.ReadUInt64LittleEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)) : + BinaryPrimitives.ReadUInt32LittleEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)); + } + else + { + symbolValue = objectFile.Is64Bit ? + BinaryPrimitives.ReadUInt64BigEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)) : + BinaryPrimitives.ReadUInt32BigEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)); + } + + string name = string.Empty; + if (symbolHeader.NameIndex != 0) + { + int nameLength = stringTable.AsSpan((int)symbolHeader.NameIndex).IndexOf((byte)0); + Debug.Assert(nameLength >= 0); + name = Encoding.UTF8.GetString(stringTable.AsSpan((int)symbolHeader.NameIndex, nameLength)); + } + + var symbol = new MachSymbol + { + Name = name, + Descriptor = (MachSymbolDescriptor)symbolHeader.Descriptor, + Section = symbolHeader.Section == 0 ? null : sectionMap[symbolHeader.Section], + Type = (MachSymbolType)symbolHeader.Type, + Value = symbolValue, + }; + + innerList.Add(symbol); + } + } + } + + public int Count => innerList.Count; + + public bool IsReadOnly => false; + + public MachSymbol this[int index] + { + get => innerList[index]; + set + { + innerList[index] = value; + isDirty = true; + } + } + + public void Add(MachSymbol symbol) + { + innerList.Add(symbol); + isDirty = true; + } + + public void Clear() + { + innerList.Clear(); + isDirty = true; + } + + public bool Contains(MachSymbol symbol) + { + return innerList.Contains(symbol); + } + + public void CopyTo(MachSymbol[] array, int arrayIndex) + { + innerList.CopyTo(array, arrayIndex); + } + + public IEnumerator GetEnumerator() + { + return innerList.GetEnumerator(); + } + + public bool Remove(MachSymbol item) + { + if (innerList.Remove(item)) + { + isDirty = true; + return true; + } + + return false; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void FlushIfDirty() + { + if (isDirty) + { + var sectionMap = new Dictionary(); + byte sectionIndex = 1; + foreach (var section in objectFile.Segments.SelectMany(segment => segment.Sections)) + { + sectionMap.Add(section, sectionIndex++); + Debug.Assert(sectionIndex != 0); + } + + using var stringTableWriter = stringTableData.GetWriteStream(); + using var symbolTableWriter = symbolTableData.GetWriteStream(); + + // Start the table with a NUL byte. + stringTableWriter.WriteByte(0); + + SymbolHeader symbolHeader = new SymbolHeader(); + Span symbolHeaderBuffer = stackalloc byte[SymbolHeader.BinarySize]; + Span symbolValueBuffer = new byte[objectFile.Is64Bit ? 8 : 4]; + + foreach (var symbol in innerList) + { + var nameBytes = Encoding.UTF8.GetBytes(symbol.Name); + var nameOffset = stringTableWriter.Position; + + stringTableWriter.Write(nameBytes); + stringTableWriter.WriteByte(0); + + symbolHeader.NameIndex = (uint)nameOffset; + symbolHeader.Section = symbol.Section == null ? (byte)0 : sectionMap[symbol.Section]; + symbolHeader.Descriptor = (ushort)symbol.Descriptor; + symbolHeader.Type = (byte)symbol.Type; + + symbolHeader.Write(symbolHeaderBuffer, objectFile.IsLittleEndian, out _); + symbolTableWriter.Write(symbolHeaderBuffer); + + if (objectFile.Is64Bit) + { + if (objectFile.IsLittleEndian) + { + BinaryPrimitives.WriteUInt64LittleEndian(symbolValueBuffer, symbol.Value); + } + else + { + BinaryPrimitives.WriteUInt64BigEndian(symbolValueBuffer, symbol.Value); + } + } + else if (objectFile.IsLittleEndian) + { + BinaryPrimitives.WriteUInt32LittleEndian(symbolValueBuffer, (uint)symbol.Value); + } + else + { + BinaryPrimitives.WriteUInt32BigEndian(symbolValueBuffer, (uint)symbol.Value); + } + + symbolTableWriter.Write(symbolValueBuffer); + } + + // Pad the string table + int alignment = objectFile.Is64Bit ? 8 : 4; + while ((stringTableWriter.Position & (alignment - 1)) != 0) + stringTableWriter.WriteByte(0); + + isDirty = false; + } + } + + public int IndexOf(MachSymbol symbol) => innerList.IndexOf(symbol); + + public void Insert(int index, MachSymbol symbol) + { + innerList.Insert(index, symbol); + isDirty = true; + } + + public void RemoveAt(int index) + { + innerList.RemoveAt(index); + isDirty = true; + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs new file mode 100644 index 00000000000000..ccad0268e701c5 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs @@ -0,0 +1,17 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachSymbolType : byte + { + Stab = 0xe0, + PrivateExternal = 0x10, + + TypeMask = 0xe, + + Undefined = 0, + External = 1, + Section = 0xe, + Prebound = 0xc, + Indirect = 0xa, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs new file mode 100644 index 00000000000000..435e185cd52d13 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs @@ -0,0 +1,11 @@ +namespace Melanzana.MachO +{ + [Flags] + public enum MachVmProtection : uint + { + None = 0x0, + Read = 0x1, + Write = 0x2, + Execute = 0x4, + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs new file mode 100644 index 00000000000000..dadbd8073ee147 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs @@ -0,0 +1,562 @@ +using System.Buffers.Binary; +using System.Diagnostics; +using System.IO; +using System.Text; +using Melanzana.MachO.BinaryFormat; +using Melanzana.Streams; + +namespace Melanzana.MachO +{ + public static class MachWriter + { + private static void WriteLoadCommandHeader(Stream stream, MachLoadCommandType commandType, int commandSize, bool isLittleEndian) + { + Span loadCommandHeaderBuffer = stackalloc byte[LoadCommandHeader.BinarySize]; + var loadCommandHeader = new LoadCommandHeader + { + CommandType = commandType, + CommandSize = (uint)commandSize, + }; + loadCommandHeader.Write(loadCommandHeaderBuffer, isLittleEndian, out var _); + stream.Write(loadCommandHeaderBuffer); + } + + private static void WriteSegment(Stream stream, MachSegment segment, bool isLittleEndian, bool is64bit) + { + if (is64bit) + { + Span sectionBuffer = stackalloc byte[Section64Header.BinarySize]; + Span segmentBuffer = stackalloc byte[Segment64Header.BinarySize]; + + WriteLoadCommandHeader( + stream, + MachLoadCommandType.Segment64, + LoadCommandHeader.BinarySize + Segment64Header.BinarySize + segment.Sections.Count * Section64Header.BinarySize, + isLittleEndian); + + var segmentHeader = new Segment64Header + { + Name = segment.Name, + Address = segment.VirtualAddress, + Size = segment.Size, + FileOffset = (ulong)segment.FileOffset, + FileSize = (ulong)segment.FileSize, + MaximumProtection = segment.MaximumProtection, + InitialProtection = segment.InitialProtection, + NumberOfSections = (uint)segment.Sections.Count, + Flags = segment.Flags, + }; + segmentHeader.Write(segmentBuffer, isLittleEndian, out var _); + stream.Write(segmentBuffer); + + foreach (var section in segment.Sections) + { + var sectionHeader = new Section64Header + { + SectionName = section.SectionName, + SegmentName = section.SegmentName, + Address = section.VirtualAddress, + Size = section.Size, + FileOffset = section.FileOffset, + Log2Alignment = section.Log2Alignment, + RelocationOffset = section.RelocationOffset, + NumberOfReloationEntries = section.NumberOfRelocationEntries, + Flags = section.Flags, + Reserved1 = section.Reserved1, + Reserved2 = section.Reserved2, + Reserved3 = section.Reserved3, + }; + sectionHeader.Write(sectionBuffer, isLittleEndian, out var _); + stream.Write(sectionBuffer); + } + } + else + { + Span sectionBuffer = stackalloc byte[SectionHeader.BinarySize]; + Span segmentBuffer = stackalloc byte[SegmentHeader.BinarySize]; + + WriteLoadCommandHeader( + stream, + MachLoadCommandType.Segment, + LoadCommandHeader.BinarySize + SegmentHeader.BinarySize + segment.Sections.Count * SectionHeader.BinarySize, + isLittleEndian); + + // FIXME: Validation + + var segmentHeader = new SegmentHeader + { + Name = segment.Name, + Address = (uint)segment.VirtualAddress, + Size = (uint)segment.Size, + FileOffset = (uint)segment.FileOffset, + FileSize = (uint)segment.FileSize, + MaximumProtection = segment.MaximumProtection, + InitialProtection = segment.InitialProtection, + NumberOfSections = (uint)segment.Sections.Count, + Flags = segment.Flags, + }; + segmentHeader.Write(segmentBuffer, isLittleEndian, out var _); + stream.Write(segmentBuffer); + + foreach (var section in segment.Sections) + { + var sectionHeader = new SectionHeader + { + SectionName = section.SectionName, + SegmentName = section.SegmentName, + Address = (uint)section.VirtualAddress, + Size = (uint)section.Size, + FileOffset = section.FileOffset, + Log2Alignment = section.Log2Alignment, + RelocationOffset = section.RelocationOffset, + NumberOfReloationEntries = section.NumberOfRelocationEntries, + Flags = section.Flags, + Reserved1 = section.Reserved1, + Reserved2 = section.Reserved2, + }; + sectionHeader.Write(sectionBuffer, isLittleEndian, out var _); + stream.Write(sectionBuffer); + } + } + } + + private static void WriteLinkEdit(Stream stream, MachLoadCommandType commandType, MachLinkEdit linkEdit, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + commandType, + LoadCommandHeader.BinarySize + LinkEditHeader.BinarySize, + isLittleEndian); + + var linkEditHeaderBuffer = new byte[LinkEditHeader.BinarySize]; + var linkEditHeader = new LinkEditHeader + { + FileOffset = linkEdit.FileOffset, + FileSize = linkEdit.FileSize, + }; + linkEditHeader.Write(linkEditHeaderBuffer, isLittleEndian, out var _); + stream.Write(linkEditHeaderBuffer); + } + + private static int AlignedSize(int size, bool is64bit) + => is64bit ? (size + 7) & ~7 : (size + 3) & ~3; + + private static void WriteDylibCommand(Stream stream, MachLoadCommandType commandType, MachDylibCommand dylibCommand, bool isLittleEndian, bool is64Bit) + { + byte[] nameBytes = Encoding.UTF8.GetBytes(dylibCommand.Name); + int commandSize = AlignedSize(LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize + nameBytes.Length + 1, is64Bit); + + WriteLoadCommandHeader( + stream, + commandType, + commandSize, + isLittleEndian); + + Span dylibCommandHeaderBuffer = stackalloc byte[DylibCommandHeader.BinarySize]; + var dylibCommandHeader = new DylibCommandHeader + { + NameOffset = LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize, + Timestamp = dylibCommand.Timestamp, + CurrentVersion = dylibCommand.CurrentVersion, + CompatibilityVersion = dylibCommand.CompatibilityVersion, + }; + dylibCommandHeader.Write(dylibCommandHeaderBuffer, isLittleEndian, out var _); + stream.Write(dylibCommandHeaderBuffer); + stream.Write(nameBytes); + // The name is always written with terminating `\0` and aligned to platform + // pointer size. + stream.WritePadding(commandSize - dylibCommandHeader.NameOffset - nameBytes.Length); + } + + private static void WriteMainCommand(Stream stream, MachEntrypointCommand entrypointCommand, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + MachLoadCommandType.Main, + LoadCommandHeader.BinarySize + MainCommandHeader.BinarySize, + isLittleEndian); + + Span mainCommandHeaderBuffer = stackalloc byte[MainCommandHeader.BinarySize]; + var mainCommandHeader = new MainCommandHeader + { + FileOffset = entrypointCommand.FileOffset, + StackSize = entrypointCommand.StackSize, + }; + mainCommandHeader.Write(mainCommandHeaderBuffer, isLittleEndian, out var _); + stream.Write(mainCommandHeaderBuffer); + } + + private static uint ConvertVersion(Version version) + => ((uint)version.Major << 16) | (uint)((version.Minor & 0xff) << 8) | (uint)(version.Build & 0xff); + + private static void WriteVersionMinCommand(Stream stream, MachLoadCommandType commandType, MachBuildVersionBase versionCommand, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + commandType, + LoadCommandHeader.BinarySize + VersionMinCommandHeader.BinarySize, + isLittleEndian); + + Span versionMinHeaderBuffer = stackalloc byte[VersionMinCommandHeader.BinarySize]; + var versionMinHeader = new VersionMinCommandHeader + { + MinimumPlatformVersion = ConvertVersion(versionCommand.MinimumPlatformVersion), + SdkVersion = ConvertVersion(versionCommand.SdkVersion), + }; + versionMinHeader.Write(versionMinHeaderBuffer, isLittleEndian, out var _); + stream.Write(versionMinHeaderBuffer); + } + + private static void WriteBuildVersion(Stream stream, MachBuildVersion versionCommand, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + MachLoadCommandType.BuildVersion, + LoadCommandHeader.BinarySize + BuildVersionCommandHeader.BinarySize + (versionCommand.ToolVersions.Count * BuildToolVersionHeader.BinarySize), + isLittleEndian); + + Span buildVersionBuffer = stackalloc byte[BuildVersionCommandHeader.BinarySize]; + Span buildToolVersionBuffer = stackalloc byte[BuildToolVersionHeader.BinarySize]; + var buildVersionHeader = new BuildVersionCommandHeader + { + Platform = versionCommand.Platform, + MinimumPlatformVersion = ConvertVersion(versionCommand.MinimumPlatformVersion), + SdkVersion = ConvertVersion(versionCommand.SdkVersion), + NumberOfTools = (uint)versionCommand.ToolVersions.Count, + }; + buildVersionHeader.Write(buildVersionBuffer, isLittleEndian, out var _); + stream.Write(buildVersionBuffer); + + foreach (var toolVersion in versionCommand.ToolVersions) + { + var buildToolVersionHeader = new BuildToolVersionHeader + { + BuildTool = toolVersion.BuildTool, + Version = ConvertVersion(toolVersion.Version), + }; + buildToolVersionHeader.Write(buildToolVersionBuffer, isLittleEndian, out var _); + stream.Write(buildToolVersionBuffer); + } + } + + private static void WriteSymbolTableCommand(Stream stream, MachSymbolTable symbolTable, bool isLittleEndian, bool is64Bit) + { + WriteLoadCommandHeader( + stream, + MachLoadCommandType.SymbolTable, + LoadCommandHeader.BinarySize + SymbolTableCommandHeader.BinarySize, + isLittleEndian); + + uint symbolSize = SymbolHeader.BinarySize + (is64Bit ? 8u : 4u); + + Span symbolTableHeaderBuffer = stackalloc byte[SymbolTableCommandHeader.BinarySize]; + var symbolTableHeader = new SymbolTableCommandHeader + { + SymbolTableOffset = symbolTable.SymbolTableData.FileOffset, + NumberOfSymbols = (uint)(symbolTable.SymbolTableData.Size / symbolSize), + StringTableOffset = symbolTable.StringTableData.FileOffset, + StringTableSize = (uint)symbolTable.StringTableData.Size, + }; + symbolTableHeader.Write(symbolTableHeaderBuffer, isLittleEndian, out var _); + stream.Write(symbolTableHeaderBuffer); + } + + private static void WriteDynamicLinkEditSymbolTableCommand(Stream stream, MachDynamicLinkEditSymbolTable dySymbolTable, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + MachLoadCommandType.DynamicLinkEditSymbolTable, + LoadCommandHeader.BinarySize + DynamicSymbolTableCommandHeader.BinarySize, + isLittleEndian); + + Span symbolTableHeaderBuffer = stackalloc byte[DynamicSymbolTableCommandHeader.BinarySize]; + var symbolTableHeader = dySymbolTable.Header; + symbolTableHeader.Write(symbolTableHeaderBuffer, isLittleEndian, out var _); + stream.Write(symbolTableHeaderBuffer); + } + + private static void WriteDyldInfoCommand(Stream stream, MachLoadCommandType commandType, MachDyldInfo dyldInfo, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + commandType, + LoadCommandHeader.BinarySize + DyldInfoHeader.BinarySize, + isLittleEndian); + + Span dyldInfoHeaderBuffer = stackalloc byte[DyldInfoHeader.BinarySize]; + var dyldInfoHeader = new DyldInfoHeader + { + RebaseOffset = dyldInfo.RebaseData.FileOffset, + RebaseSize = (uint)dyldInfo.RebaseData.Size, + BindOffset = dyldInfo.BindData.FileOffset, + BindSize = (uint)dyldInfo.BindData.Size, + WeakBindOffset = dyldInfo.WeakBindData.FileOffset, + WeakBindSize = (uint)dyldInfo.WeakBindData.Size, + LazyBindOffset = dyldInfo.LazyBindData.FileOffset, + LazyBindSize = (uint)dyldInfo.LazyBindData.Size, + ExportOffset = dyldInfo.ExportData.FileOffset, + ExportSize = (uint)dyldInfo.ExportData.Size, + }; + dyldInfoHeader.Write(dyldInfoHeaderBuffer, isLittleEndian, out var _); + stream.Write(dyldInfoHeaderBuffer); + } + + private static void WriteTwoLevelHintsCommand(Stream stream, MachTwoLevelHints twoLevelHints, bool isLittleEndian) + { + WriteLoadCommandHeader( + stream, + MachLoadCommandType.TowLevelHints, + LoadCommandHeader.BinarySize + DyldInfoHeader.BinarySize, + isLittleEndian); + + Span twoLevelHintsHeaderBuffer = stackalloc byte[TwoLevelHintsHeader.BinarySize]; + var twoLevelHintsHeader = new TwoLevelHintsHeader + { + FileOffset = twoLevelHints.Data.FileOffset, + NumberOfHints = (uint)(twoLevelHints.Data.Size / sizeof(uint)) + }; + twoLevelHintsHeader.Write(twoLevelHintsHeaderBuffer, isLittleEndian, out var _); + stream.Write(twoLevelHintsHeaderBuffer); + } + + public static void Write(Stream stream, MachObjectFile objectFile) + { + long initialOffset = stream.Position; + bool isLittleEndian = objectFile.IsLittleEndian; + var machMagicBuffer = new byte[4]; + var machHeaderBuffer = new byte[Math.Max(MachHeader.BinarySize, MachHeader64.BinarySize)]; + + uint magic = isLittleEndian ? + (objectFile.Is64Bit ? (uint)MachMagic.MachHeader64LittleEndian : (uint)MachMagic.MachHeaderLittleEndian) : + (objectFile.Is64Bit ? (uint)MachMagic.MachHeader64BigEndian : (uint)MachMagic.MachHeaderBigEndian); + BinaryPrimitives.WriteUInt32BigEndian(machMagicBuffer, magic); + + var loadCommandsStream = new MemoryStream(); + foreach (var loadCommand in objectFile.LoadCommands) + { + switch (loadCommand) + { + case MachSegment segment: WriteSegment(loadCommandsStream, segment, isLittleEndian, objectFile.Is64Bit); break; + case MachCodeSignature codeSignature: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.CodeSignature, codeSignature, isLittleEndian); break; + case MachDylibCodeSigningDirs codeSigningDirs: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DylibCodeSigningDRs, codeSigningDirs, isLittleEndian); break; + case MachSegmentSplitInfo segmentSplitInfo: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.SegmentSplitInfo, segmentSplitInfo, isLittleEndian); break; + case MachFunctionStarts functionStarts: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.FunctionStarts, functionStarts, isLittleEndian); break; + case MachDataInCode dataInCode: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DataInCode, dataInCode, isLittleEndian); break; + case MachLinkerOptimizationHint linkerOptimizationHint: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.LinkerOptimizationHint, linkerOptimizationHint, isLittleEndian); break; + case MachDyldExportsTrie dyldExportsTrie: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DyldExportsTrie, dyldExportsTrie, isLittleEndian); break; + case MachDyldChainedFixups dyldChainedFixups: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DyldChainedFixups, dyldChainedFixups, isLittleEndian); break; + case MachLoadDylibCommand loadDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.LoadDylib, loadDylibCommand, isLittleEndian, objectFile.Is64Bit); break; + case MachLoadWeakDylibCommand loadWeakDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.LoadWeakDylib, loadWeakDylibCommand, isLittleEndian, objectFile.Is64Bit); break; + case MachReexportDylibCommand reexportDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.ReexportDylib, reexportDylibCommand, isLittleEndian, objectFile.Is64Bit); break; + case MachEntrypointCommand entrypointCommand: WriteMainCommand(loadCommandsStream, entrypointCommand, isLittleEndian); break; + case MachVersionMinMacOS macOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinMacOS, macOSBuildVersion, isLittleEndian); break; + case MachVersionMinIOS iOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinIPhoneOS, iOSBuildVersion, isLittleEndian); break; + case MachVersionMinTvOS tvOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinTvOS, tvOSBuildVersion, isLittleEndian); break; + case MachVersionMinWatchOS watchOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinWatchOS, watchOSBuildVersion, isLittleEndian); break; + case MachBuildVersion buildVersion: WriteBuildVersion(loadCommandsStream, buildVersion, isLittleEndian); break; + case MachSymbolTable symbolTable: WriteSymbolTableCommand(loadCommandsStream, symbolTable, isLittleEndian, objectFile.Is64Bit); break; + case MachDynamicLinkEditSymbolTable dySymbolTable: WriteDynamicLinkEditSymbolTableCommand(loadCommandsStream, dySymbolTable, isLittleEndian); break; + case MachDyldInfoOnly dyldInfoOnly: WriteDyldInfoCommand(loadCommandsStream, MachLoadCommandType.DyldInfoOnly, dyldInfoOnly, isLittleEndian); break; + case MachDyldInfo dyldInfo: WriteDyldInfoCommand(loadCommandsStream, MachLoadCommandType.DyldInfo, dyldInfo, isLittleEndian); break; + case MachTwoLevelHints twoLevelHints: WriteTwoLevelHintsCommand(loadCommandsStream, twoLevelHints, isLittleEndian); break; + case MachCustomLoadCommand customLoadCommand: + WriteLoadCommandHeader(loadCommandsStream, customLoadCommand.Type, customLoadCommand.Data.Length + LoadCommandHeader.BinarySize, isLittleEndian); + loadCommandsStream.Write(customLoadCommand.Data); + break; + default: + Debug.Fail("Unknown load command"); + break; + } + } + + if (objectFile.Is64Bit) + { + var machHeader = new MachHeader64 + { + CpuType = objectFile.CpuType, + CpuSubType = objectFile.CpuSubType, + FileType = objectFile.FileType, + NumberOfCommands = (uint)objectFile.LoadCommands.Count, + SizeOfCommands = (uint)loadCommandsStream.Length, + Flags = objectFile.Flags, + Reserved = 0, // TODO + }; + + stream.Write(machMagicBuffer); + machHeader.Write(machHeaderBuffer, isLittleEndian, out int bytesWritten); + stream.Write(machHeaderBuffer.AsSpan(0, bytesWritten)); + } + else + { + var machHeader = new MachHeader + { + CpuType = objectFile.CpuType, + CpuSubType = objectFile.CpuSubType, + FileType = objectFile.FileType, + NumberOfCommands = (uint)objectFile.LoadCommands.Count, + SizeOfCommands = (uint)loadCommandsStream.Length, + Flags = objectFile.Flags, + }; + + stream.Write(machMagicBuffer); + machHeader.Write(machHeaderBuffer, isLittleEndian, out int bytesWritten); + stream.Write(machHeaderBuffer.AsSpan(0, bytesWritten)); + } + + loadCommandsStream.Position = 0; + loadCommandsStream.CopyTo(stream); + + // Save the current position within the Mach-O file. Now we need to output the segments + // and fill in the gaps as we go. + ulong currentOffset = (ulong)(stream.Position - initialOffset); + var orderedSegments = objectFile.Segments.OrderBy(s => s.FileOffset).ToList(); + + foreach (var segment in orderedSegments) + { + if (segment.FileSize != 0) + { + if (segment.Sections.Count == 0) + { + Debug.Assert(segment.FileOffset >= currentOffset); + + if (segment.FileOffset > currentOffset) + { + ulong paddingSize = segment.FileOffset - currentOffset; + stream.WritePadding((long)paddingSize); + currentOffset += paddingSize; + } + + if (segment.IsLinkEditSegment) + { + // __LINKEDIT always has to be the last segment in object file, so break + // out of the loop. + break; + } + + using var segmentStream = segment.GetReadStream(); + segmentStream.CopyTo(stream); + currentOffset += (ulong)segmentStream.Length; + } + else + { + byte paddingByte = 0; + + foreach (var section in segment.Sections) + { + if (section.IsInFile) + { + Debug.Assert(section.FileOffset >= currentOffset); + + if (section.FileOffset > currentOffset) + { + ulong paddingSize = section.FileOffset - currentOffset; + stream.WritePadding((long)paddingSize, paddingByte); + currentOffset += paddingSize; + } + + using var sectionStream = section.GetReadStream(); + sectionStream.CopyTo(stream); + currentOffset += (ulong)sectionStream.Length; + + bool isCodeSection = + section.Type == MachSectionType.Regular && + section.Attributes.HasFlag(MachSectionAttributes.SomeInstructions) && + section.Attributes.HasFlag(MachSectionAttributes.PureInstructions); + + if (isCodeSection) + { + // Padding of code sections is done with NOP bytes if possible + paddingByte = objectFile.CpuType switch + { + // TODO: Arm32 / Thumb + MachCpuType.X86_64 => (byte)0x90, + MachCpuType.X86 => (byte)0x90, + _ => (byte)0, + }; + } + else + { + paddingByte = 0; + } + } + } + } + } + } + + // We are either writing an unlinked object file or a __LINKEDIT segment + var linkEditData = new List(objectFile.LinkEditData); + + // Sort by file offset first + linkEditData.Sort((sectionA, sectionB) => + sectionA.FileOffset < sectionB.FileOffset ? -1 : + (sectionA.FileOffset > sectionB.FileOffset ? 1 : 0)); + + foreach (var data in linkEditData) + { + if (data.FileOffset > currentOffset) + { + ulong paddingSize = data.FileOffset - currentOffset; + stream.WritePadding((long)paddingSize); + currentOffset += paddingSize; + } + + using var segmentStream = data.GetReadStream(); + segmentStream.CopyTo(stream); + currentOffset += (ulong)segmentStream.Length; + } + } + + public static void Write(Stream stream, IList objectFiles) + { + if (objectFiles.Count == 1) + { + Write(stream, objectFiles[0]); + } + else if (objectFiles.Count > 1) + { + var fatMagic = new byte[4]; + var fatHeader = new FatHeader { NumberOfFatArchitectures = (uint)objectFiles.Count }; + var fatHeaderBytes = new byte[FatHeader.BinarySize]; + var fatArchHeaderBytes = new byte[FatArchHeader.BinarySize]; + + BinaryPrimitives.WriteUInt32BigEndian(fatMagic, (uint)MachMagic.FatMagicBigEndian); + fatHeader.Write(fatHeaderBytes, isLittleEndian: false, out var _); + stream.Write(fatMagic); + stream.Write(fatHeaderBytes); + + uint offset = (uint)(4 + FatHeader.BinarySize + objectFiles.Count * FatArchHeader.BinarySize); + uint alignment = 0x4000; + foreach (var objectFile in objectFiles) + { + uint size = (uint)objectFile.GetSize(); + + offset = (offset + alignment - 1) & ~(alignment - 1); + var fatArchHeader = new FatArchHeader + { + CpuType = objectFile.CpuType, + CpuSubType = objectFile.CpuSubType, + Offset = offset, + Size = size, + Alignment = (uint)Math.Log2(alignment), + }; + + fatArchHeader.Write(fatArchHeaderBytes, isLittleEndian: false, out var _); + stream.Write(fatArchHeaderBytes); + + offset += size; + } + + offset = (uint)(4 + FatHeader.BinarySize + objectFiles.Count * FatArchHeader.BinarySize); + foreach (var objectFile in objectFiles) + { + uint size = (uint)objectFile.GetSize(); + uint alignedOffset = (offset + alignment - 1) & ~(alignment - 1); + stream.WritePadding(alignedOffset - offset); + Write(stream, objectFile); + offset = alignedOffset + size; + } + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs new file mode 100644 index 00000000000000..cdf397c7754207 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs @@ -0,0 +1,23 @@ +namespace Melanzana.MachO +{ + /// + /// Defines the subtypes of the x86_64 . + /// Defined in machine.h. + /// + /// + /// This enumeration matches version 7195.141.2 of XNU. + /// + /// + public enum X8664CpuSubType : uint + { + /// + /// All x86_64 CPUs + /// + All = 3, + + /// + /// Haswell feature subset. + /// + Haswell = 8, + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj new file mode 100644 index 00000000000000..d88ee4f08d4742 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + true + $(BaseIntermediateOutputPath)/GeneratedFiles + + + + + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md new file mode 100644 index 00000000000000..88e4610f88cd32 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md @@ -0,0 +1,18 @@ +# Mach-O manipulation library + +The `Melanzana.MachO` library implements object model for manipulation of Mach-O files. It allows reading files from disk into the in-memory object model, modifying it and then writing it back to disk. Additionally, universal binaries targeting more architectures can be read and written. + +## Status + +- `MachObjectFile` implements the in-memory representation of Mach-O file; it allows access to header fields and load commands (including sections and segments) +- Universal binaries and Mach-O files can be read using `MachReader.Read` method into the in-memory object model +- Universal binaries and Mach-O files can be written to disk using `MachWriter.Write` method from the in-memory object model +- Segments (`MachSegment`) and sections (`MachSection`) can be manipulated and content can be rewritten, the model is unified for 32-/64-bit Mach-O files + +Minimal set of load commands is mapped to the strongly typed object model (eg. dynamicly linked dependencies, required platform versions). + +Validation is completely missing. + +## Acknowledgments + +Many design decisions in this library were inspired by [LibObjectFile](https://github.com/xoofx/LibObjectFile), [LIEF project](https://github.com/lief-project/LIEF) and [go-macho](https://github.com/blacktop/go-macho). diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj new file mode 100644 index 00000000000000..132c02c59c2364 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs new file mode 100644 index 00000000000000..eafd0c21f64935 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs @@ -0,0 +1,152 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.IO; + +namespace Melanzana.Streams +{ + /// + /// Defines a stream as a slice of another existing stream. + /// + public class SliceStream : Stream + { + private Stream _baseStream; + private readonly long _length; + private readonly long _basePosition; + private long _localPosition; + + public SliceStream(Stream baseStream, long position, long length) + { + if (baseStream == null) throw new ArgumentNullException(nameof(baseStream)); + if (!baseStream.CanSeek) throw new ArgumentException("Invalid base stream that can't be seek."); + if (position < 0) throw new ArgumentOutOfRangeException(nameof(position)); + if (length < 0) throw new ArgumentOutOfRangeException(nameof(length)); + if (position + length > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(position), $"The position {position} + length {length} > baseStream.Length {baseStream.Length}"); + + _baseStream = baseStream; + _length = length; + _basePosition = position; + } + public override int Read(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + + long remaining = _length - _localPosition; + if (remaining <= 0) return 0; + if (remaining < count) count = (int)remaining; + + var savedPosition = _baseStream.Position; + _baseStream.Position = _basePosition + _localPosition; + int read = _baseStream.Read(buffer, offset, count); + _localPosition += read; + _baseStream.Position = savedPosition; + + return read; + } + private void ThrowIfDisposed() + { + if (_baseStream == null) throw new ObjectDisposedException(GetType().Name); + } + public override long Length + { + get { ThrowIfDisposed(); return _length; } + } + public override bool CanRead + { + get { ThrowIfDisposed(); return _baseStream.CanRead; } + } + public override bool CanWrite + { + get { ThrowIfDisposed(); return _baseStream.CanWrite; } + } + public override bool CanSeek + { + get { ThrowIfDisposed(); return _baseStream.CanSeek; } + } + public override long Position + { + get + { + ThrowIfDisposed(); + return _localPosition; + } + set => Seek(value, SeekOrigin.Begin); + } + public override long Seek(long offset, SeekOrigin origin) + { + long newPosition = _localPosition; + switch (origin) + { + case SeekOrigin.Begin: + newPosition = offset; + break; + case SeekOrigin.Current: + newPosition += offset; + break; + case SeekOrigin.End: + newPosition = _length - offset; + break; + default: + throw new ArgumentOutOfRangeException(nameof(origin), origin, null); + } + + if (newPosition < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is < 0"); + if (newPosition > _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is > Length {_length}"); + + // Check that we can seek on the origin stream + _baseStream.Position = _basePosition + newPosition; + _localPosition = newPosition; + + return newPosition; + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Flush() + { + ThrowIfDisposed(); _baseStream.Flush(); + } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + /*if (_baseStream != null) + { + try + { + _baseStream.Dispose(); + } + catch + { + // ignored + }*/ + _baseStream = Stream.Null; + //} + } + } + public override void Write(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); + if (count == 0) return; + + var isOverLength = _localPosition + count > Length; + var maxLength = isOverLength ? (int)(Length - _localPosition) : count; + var savedPosition = _baseStream.Position; + _baseStream.Position = _basePosition + _localPosition; + _baseStream.Write(buffer, offset, maxLength); + _baseStream.Position = savedPosition; + _localPosition += maxLength; + if (isOverLength) + { + throw new InvalidOperationException("Cannot write outside of this stream slice"); + } + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs new file mode 100644 index 00000000000000..5ae88af1ec1da8 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs @@ -0,0 +1,34 @@ +namespace Melanzana.Streams +{ + public static class StreamExtensions + { + public static Stream Slice(this Stream stream, long offset, long size) + { + //if (stream is MemoryStream memoryStream && memoryStream.TryGetBuffer()) + // return new MemoryStream(memoryStream.GetBuffer(), (int)offset, (int)size); + return new SliceStream(stream, offset, size); + } + + public static void ReadFully(this Stream stream, Span buffer) + { + int totalRead = 0; + int bytesRead; + while ((bytesRead = stream.Read(buffer.Slice(totalRead))) > 0 && buffer.Length < totalRead) + totalRead += bytesRead; + if (bytesRead <= 0) + throw new EndOfStreamException(); + } + + public static void WritePadding(this Stream stream, long paddingSize, byte paddingByte = 0) + { + Span paddingBuffer = stackalloc byte[4096]; + paddingBuffer.Fill(paddingByte); + while (paddingSize > 0) + { + long chunkSize = paddingSize > paddingBuffer.Length ? paddingBuffer.Length : paddingSize; + stream.Write(paddingBuffer.Slice(0, (int)chunkSize)); + paddingSize -= chunkSize; + } + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs new file mode 100644 index 00000000000000..7dc4e6bd0688d4 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs @@ -0,0 +1,9 @@ +namespace Melanzana.Streams +{ + public class UnclosableMemoryStream : MemoryStream + { + protected override void Dispose(bool disposing) + { + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/README.md b/src/coreclr/tools/aot/external/Melanzana/README.md new file mode 100644 index 00000000000000..7210ddf21d63c2 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/README.md @@ -0,0 +1,9 @@ +# Project "Melanzana" + +Implements framework for Apple Code Signing of bundles and Mach-O files in .NET. + +## Status + +The code is very much work in progress. It can sign simple application bundles and Mach-O executables. + +There's a simple command line tool for testing that can sign with ad-hoc signatures, certificates from system keychain, or certificates from Azure Key Vault. For Azure Key Vault the only supported authentication is logging in with the Azure CLI tool. diff --git a/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs b/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs new file mode 100644 index 00000000000000..0154e81150d9d3 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs @@ -0,0 +1,103 @@ +using Azure.Identity; +using Azure.Security.KeyVault.Certificates; +using Claunia.PropertyList; +using System.CommandLine; +using System.Security.Cryptography.X509Certificates; +using RSAKeyVaultProvider; + +namespace Melanzana.CodeSign +{ + public class Program + { + public static int Main(string[] args) + { + var identity = new Argument("identity", "Name of signing identity or \"-\" for ad-hoc signing"); + var path = new Argument("path", "Path to bundle or executable on disk"); + var entitlements = new Option("--entitlements", "Path to entitlements to embed into the signature"); + var azureKekVaultUrl = new Option("--azure-key-vault-url", "URL to an Azure Key Vault"); + + var signCommand = new Command("sign", "Sign code at path using given identity") + { + identity, + path, + entitlements, + azureKekVaultUrl, + }; + + signCommand.SetHandler(HandleSign, identity, path, entitlements, azureKekVaultUrl); + + return new RootCommand { signCommand }.Invoke(args); + } + + private static X509Certificate2? FindCertificate(string identity) + { + if (identity == "-") + { + // Ad-hoc signing + return null; + } + + var store = new X509Store(StoreLocation.CurrentUser); + store.Open(OpenFlags.ReadOnly); + X509Certificate2Collection collection; + + if (identity.Length == 40 && identity.All(Uri.IsHexDigit)) + { + collection = store.Certificates.Find( + X509FindType.FindByThumbprint, + identity, + true); + } + else + { + collection = store.Certificates.Find( + X509FindType.FindBySubjectName, + identity, + true); + } + + var certificate = collection.Where(c => c.IsAppleDeveloperCertificate()).FirstOrDefault(); + if (certificate == null) + { + throw new Exception($"Certificate for identity \"{identity}\" not found"); + } + + return certificate; + } + + public static void HandleSign( + string identity, + string path, + string? entitlements, + string? azureKeyVaultUrl) + { + var codeSignOptions = new CodeSignOptions(); + + if (String.IsNullOrEmpty(azureKeyVaultUrl)) + { + codeSignOptions.DeveloperCertificate = FindCertificate(identity); + } + else + { + // Azure key vault + var credential = new AzureCliCredential(); + var certClient = new CertificateClient(new Uri(azureKeyVaultUrl), credential); + var azureCertificate = certClient.GetCertificate(identity).Value; + codeSignOptions.DeveloperCertificate = new X509Certificate2(azureCertificate.Cer); + codeSignOptions.PrivateKey = RSAFactory.Create(credential, azureCertificate.KeyId, codeSignOptions.DeveloperCertificate); + } + + if (!String.IsNullOrEmpty(entitlements)) + { + codeSignOptions.Entitlements = new Entitlements( + (NSDictionary)PropertyListParser.Parse( + new FileInfo(entitlements) + ) + ); + } + + var signer = new Signer(codeSignOptions); + signer.Sign(path); + } + } +} diff --git a/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj b/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj new file mode 100644 index 00000000000000..71f2a18b66a712 --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj @@ -0,0 +1,23 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/src/coreclr/tools/aot/external/Melanzana/version.json b/src/coreclr/tools/aot/external/Melanzana/version.json new file mode 100644 index 00000000000000..75c8ef3d38975d --- /dev/null +++ b/src/coreclr/tools/aot/external/Melanzana/version.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.1", + "publicReleaseRefSpec": [ + "^refs/heads/main$", + "^refs/heads/releases/*" + ] +} From 55094c956d7012181e19e6887ce004b99591c422 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 18 Oct 2022 18:59:36 +0200 Subject: [PATCH 003/144] Disable versioning NuGets in external projects (MinVer, Nerdbank.GitVersioning), reference the projects --- .../tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj | 3 +++ .../LibObjectFile/src/LibObjectFile/LibObjectFile.csproj | 4 ++-- .../tools/aot/external/Melanzana/Directory.Build.props | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 11090daf397298..d64ce30490b628 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -23,6 +23,9 @@ + + + all contentfiles diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj index d68d78241fb4f3..031c1981ef64d2 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj @@ -31,10 +31,10 @@ - + diff --git a/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props b/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props index 334783c957d4ae..03043b5e30be77 100644 --- a/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props +++ b/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props @@ -7,7 +7,7 @@ - + From ee4bf6108d68b8873ecd286e31d3faa822dff732 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 10 Oct 2022 20:20:23 +0200 Subject: [PATCH 004/144] Add first draft of MachO and ELF object writers --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 753 ++++++++++++++++++ .../Compiler/ObjectWriter/DwarfCie.cs | 79 ++ .../Compiler/ObjectWriter/DwarfEhFrame.cs | 211 +++++ .../Compiler/ObjectWriter/DwarfFde.cs | 117 +++ .../Compiler/ObjectWriter/DwarfNative.cs | 77 ++ .../Compiler/ObjectWriter/ElfObjectWriter.cs | 258 ++++++ .../Compiler/ObjectWriter/MachObjectWriter.cs | 624 +++++++++++++++ .../Compiler/ObjectWriter/UnixObjectWriter.cs | 461 +++++++++++ .../ILCompiler.Compiler.csproj | 10 +- .../Compiler/RyuJitCompilation.cs | 9 +- 10 files changed, 2597 insertions(+), 2 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs new file mode 100644 index 00000000000000..4134defa1ff4e6 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -0,0 +1,753 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +using ILCompiler.DependencyAnalysis; +using Internal.JitInterface; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; + +using LibObjectFile.Dwarf; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class DwarfBuilder : ITypesDebugInfoWriter + { + private NameMangler _nameMangler; + private TargetArchitecture _architecture; + private int _targetPointerSize; + private int _frameRegister; + private DwarfFile _dwarfFile; + private DwarfDIECompileUnit _rootDIE; + private DwarfLineProgramTable _lineTable; + private DwarfLineSequence _lineSequence; + private Dictionary _emittedFileName; + + private List _memberFunctionTypeInfos = new(); + private List _memberFunctions = new(); + private Dictionary _primitiveDwarfTypes = new(); + private Dictionary<(uint, uint), uint> _simpleArrayDwarfTypes = new(); // (elementTypeIndex, size) -> arrayTypeIndex + //std::vector ClassesWithStaticFields; + + public DwarfFile DwarfFile => _dwarfFile; + + public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture) + { + _nameMangler = nameMangler; + _architecture = targetArchitecture; + + if (targetArchitecture == TargetArchitecture.ARM64) + { + _targetPointerSize = 8; + _frameRegister = 29; // FP + } + else if (targetArchitecture == TargetArchitecture.X64) + { + _targetPointerSize = 8; + _frameRegister = 6; // RBP + } + else + { + throw new NotSupportedException("Unsupported architecture"); + } + + _dwarfFile = new DwarfFile(); + + _lineSequence = new DwarfLineSequence(); + + _lineTable = new DwarfLineProgramTable(); + _lineTable.AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; + _lineTable.AddLineSequence(_lineSequence); + + _rootDIE = new DwarfDIECompileUnit + { + Producer = "CoreRT", // TODO: Change + Language = DwarfLanguageKind.CPlusPlus, + Name = "IL.c", + CompDir = "/tmp", + StmtList = _lineTable, + }; + + var compilationUnit = new DwarfCompilationUnit() + { + AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32, + Root = _rootDIE + }; + + _dwarfFile.InfoSection.AddUnit(compilationUnit); + _dwarfFile.LineSection.AddLineProgramTable(_lineTable); + + _emittedFileName = new(); + } + + public uint GetPrimitiveTypeIndex(TypeDesc type) + { + Debug.Assert(type.IsPrimitive, "it is not a primitive type"); + return GetPrimitiveTypeIndex(type.Category); + } + + private uint GetPrimitiveTypeIndex(TypeFlags typeFlags) + { + if (_primitiveDwarfTypes.TryGetValue(typeFlags, out uint index)) + { + return index; + } + + if (typeFlags == TypeFlags.Void) + { + _rootDIE.AddChild(new DwarfDIEUnspecifiedType { Name = "void" }); + } + else + { + var (name, encoding, byteSize) = typeFlags switch { + TypeFlags.Boolean => ("bool", DW_ATE_boolean, 1), + TypeFlags.Char => ("char16_t", DW_ATE_UTF, 2), + TypeFlags.SByte => ("sbyte", DW_ATE_signed, 1), + TypeFlags.Byte => ("byte", DW_ATE_unsigned, 1), + TypeFlags.Int16 => ("short", DW_ATE_signed, 2), + TypeFlags.UInt16 => ("ushort", DW_ATE_unsigned, 2), + TypeFlags.Int32 => ("int", DW_ATE_signed, 4), + TypeFlags.UInt32 => ("uint", DW_ATE_unsigned, 4), + TypeFlags.Int64 => ("long", DW_ATE_signed, 8), + TypeFlags.UInt64 => ("ulong", DW_ATE_unsigned, 8), + TypeFlags.IntPtr => ("nint", DW_ATE_signed, _targetPointerSize), + TypeFlags.UIntPtr => ("nuint", DW_ATE_unsigned, _targetPointerSize), + TypeFlags.Single => ("float", DW_ATE_float, 4), + TypeFlags.Double => ("double", DW_ATE_float, 8), + _ => ("", 0, 0), + }; + + _rootDIE.AddChild(new DwarfDIEBaseType { Name = name, Encoding = encoding, ByteSize = byteSize}); + } + + uint typeIndex = (uint)_rootDIE.Children.Count; + _primitiveDwarfTypes.Add(typeFlags, typeIndex); + + return typeIndex; + } + + public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) + { + uint voidTypeIndex = GetPrimitiveTypeIndex(TypeFlags.Void); + + // Creating a pointer to what DWARF considers Void type (DW_TAG_unspecified_type - + // per http://eagercon.com/dwarf/issues/minutes-001017.htm) leads to unhappines + // since debuggers don't really know how to handle that. The Clang symbol parser + // in LLDB only handles DW_TAG_unspecified_type if it's named + // "nullptr_t" or "decltype(nullptr)". + // + // We resort to this kludge to generate the exact same debug info for void* that + // clang would generate (pointer type with no element type specified). + if (pointerDescriptor.ElementType == voidTypeIndex) + { + _rootDIE.AddChild(new DwarfDIEPointerType()); + } + else + { + _rootDIE.AddChild(new DwarfDIEPointerType + { + Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], + ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, + }); + } + + return (uint)_rootDIE.Children.Count; + } + + private uint GetSimpleArrayTypeIndex(uint elementIndex, uint size) + { + if (_simpleArrayDwarfTypes.TryGetValue((elementIndex, size), out uint index)) + { + return index; + } + + var arrayType = new DwarfDIEArrayType { Type = _rootDIE.Children[(int)elementIndex - 1] }; + arrayType.AddChild(new DwarfDIESubrangeType { UpperBound = (int)size }); + _rootDIE.AddChild(arrayType); + + uint typeIndex = (uint)_rootDIE.Children.Count; + _simpleArrayDwarfTypes.Add((elementIndex, size), typeIndex); + + return typeIndex; + } + + public uint GetArrayTypeIndex( + ClassTypeDescriptor classDescriptor, + ArrayTypeDescriptor arrayDescriptor) + { + int fieldOffset = _targetPointerSize; + var classType = new DwarfDIEClassType { Name = classDescriptor.Name }; + + if (classDescriptor.BaseClassId != 0) + { + classType.AddChild(new DwarfDIEInheritance + { + Type = _rootDIE.Children[(int)classDescriptor.BaseClassId - 1], + DataMemberLocation = new DwarfLocation(0), + }); + } + + classType.AddChild(new DwarfDIEMember + { + Name = "m_NumComponents", + Type = _rootDIE.Children[(int)GetPrimitiveTypeIndex(TypeFlags.Int32) - 1], + DataMemberLocation = new DwarfLocation(fieldOffset), + }); + fieldOffset += _targetPointerSize; + + if (arrayDescriptor.IsMultiDimensional == 1) + { + classType.AddChild(new DwarfDIEMember + { + Name = "m_Bounds", + Type = _rootDIE.Children[(int)GetSimpleArrayTypeIndex(GetPrimitiveTypeIndex(TypeFlags.Int32), arrayDescriptor.Rank) - 1], + DataMemberLocation = new DwarfLocation(fieldOffset), + }); + fieldOffset += 2 * 4 * (int)arrayDescriptor.Rank; + } + + classType.AddChild(new DwarfDIEMember + { + Name = "m_Data", + Type = _rootDIE.Children[(int)GetSimpleArrayTypeIndex(arrayDescriptor.ElementType, 0) - 1], + DataMemberLocation = new DwarfLocation(fieldOffset), + }); + + classType.ByteSize = fieldOffset; + + _rootDIE.AddChild(classType); + + return (uint)_rootDIE.Children.Count; + } + + public uint GetEnumTypeIndex( + EnumTypeDescriptor typeDescriptor, + EnumRecordTypeDescriptor[] typeRecords) + { + var elementType = _rootDIE.Children[(int)typeDescriptor.ElementType - 1]; + var enumerationType = new DwarfDIEEnumerationType + { + Name = typeDescriptor.Name, + Type = elementType, + ByteSize = ((DwarfDIEBaseType)elementType).ByteSize, + }; + + foreach (EnumRecordTypeDescriptor typeRecord in typeRecords) + { + enumerationType.AddChild(new DwarfDIEEnumerator + { + Name = typeRecord.Name, + ConstValue = (int)typeRecord.Value, + }); + } + + _rootDIE.AddChild(enumerationType); + + return (uint)_rootDIE.Children.Count; + } + + public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) + { + _dwarfFile.StringTable.GetOrCreateString(classDescriptor.Name); + + var classType = new DwarfDIEClassType + { + Name = classDescriptor.Name, + Declaration = true, + }; + + if (classDescriptor.BaseClassId != 0) + { + classType.AddChild(new DwarfDIEInheritance + { + Type = _rootDIE.Children[(int)classDescriptor.BaseClassId - 1], + DataMemberLocation = new DwarfLocation(0), + }); + } + + // Size = ClassDescriptor.InstanceSize? + + _rootDIE.AddChild(classType); + + return (uint)_rootDIE.Children.Count; + } + + public uint GetCompleteClassTypeIndex( + ClassTypeDescriptor classTypeDescriptor, + ClassFieldsTypeDescriptor classFieldsTypeDescriptor, + DataFieldDescriptor[] fields, + StaticDataFieldDescriptor[] statics) + { + _dwarfFile.StringTable.GetOrCreateString(classTypeDescriptor.Name); + + var classType = new DwarfDIEClassType + { + Name = classTypeDescriptor.Name, + ByteSize = (int)classTypeDescriptor.InstanceSize, + }; + + if (classTypeDescriptor.BaseClassId != 0) + { + classType.AddChild(new DwarfDIEInheritance + { + Type = _rootDIE.Children[(int)classTypeDescriptor.BaseClassId - 1], + DataMemberLocation = new DwarfLocation(0), + }); + } + + foreach (DataFieldDescriptor fieldDescriptor in fields) + { + if (fieldDescriptor.Offset != 0xFFFFFFFFu) + { + _dwarfFile.StringTable.GetOrCreateString(fieldDescriptor.Name); + + classType.AddChild(new DwarfDIEMember + { + Name = fieldDescriptor.Name, + Type = _rootDIE.Children[(int)fieldDescriptor.FieldTypeIndex - 1], + DataMemberLocation = new DwarfLocation((int)fieldDescriptor.Offset), + }); + } + } + + // TODO: static members + + _rootDIE.AddChild(classType); + + return (uint)_rootDIE.Children.Count; + } + + private sealed class DwarfMemberFunctionTypeInfo : DwarfDIEDeclaration + { + public MemberFunctionTypeDescriptor MemberDescriptor { get; init; } + public uint[] ArgumentTypes { get; init; } + public bool IsStatic { get; init; } + }; + + public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) + { + _memberFunctionTypeInfos.Add(new DwarfMemberFunctionTypeInfo + { + MemberDescriptor = memberDescriptor, + ArgumentTypes = argumentTypes, + IsStatic = memberDescriptor.TypeIndexOfThisPointer == GetPrimitiveTypeIndex(TypeFlags.Void), + }); + + return (uint)_memberFunctionTypeInfos.Count; + } + + public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor) + { + DwarfMemberFunctionTypeInfo memberFunctionTypeInfo = + _memberFunctionTypeInfos[(int)memberIdDescriptor.MemberFunction - 1]; + MemberFunctionTypeDescriptor memberDescriptor = memberFunctionTypeInfo.MemberDescriptor; + DwarfDIEClassType parentClass = + (DwarfDIEClassType)_rootDIE.Children[(int)memberIdDescriptor.ParentClass - 1]; + + _dwarfFile.StringTable.GetOrCreateString(memberIdDescriptor.Name); + + var subprogram = new DwarfDIESubprogram + { + Name = memberIdDescriptor.Name, + LinkageName = memberIdDescriptor.Name, + Type = _rootDIE.Children[(int)memberDescriptor.ReturnType - 1], + // decl file, decl line + External = true, + Declaration = true, + }; + + if (!memberFunctionTypeInfo.IsStatic) + { + subprogram.ObjectPointer = new DwarfDIEFormalParameter + { + Type = _rootDIE.Children[(int)memberDescriptor.TypeIndexOfThisPointer - 1], + Artificial = true, + }; + subprogram.AddChild(subprogram.ObjectPointer); + } + + foreach (var argType in memberFunctionTypeInfo.ArgumentTypes) + { + subprogram.AddChild(new DwarfDIEFormalParameter + { + Type = _rootDIE.Children[(int)argType - 1], + }); + } + + parentClass.AddChild(subprogram); + _memberFunctions.Add(subprogram); + + return (uint)_memberFunctions.Count; + } + + public string GetMangledName(TypeDesc type) + { + return _nameMangler.GetMangledTypeName(type); + } + + private sealed class LexicalScope + { + private uint _start; + private uint _end; + private bool _isFuncScope; + private List<(DebugVarInfoMetadata, DwarfDIE)> _vars = new(); + private List _innerScopes = new(); + + public uint Start => _start; + public uint End => _end; + public bool IsFuncScope => _isFuncScope; + public List<(DebugVarInfoMetadata, DwarfDIE)> Vars => _vars; + public List InnerScopes => _innerScopes; + + public LexicalScope(uint start, uint end, bool isFuncScope) + { + _start = start; + _end = end; + _isFuncScope = isFuncScope; + } + + public LexicalScope(DebugVarRangeInfo rangeInfo) + { + _start = rangeInfo.StartOffset; + _end = rangeInfo.EndOffset; + _isFuncScope = false; + } + + private bool IsContains(DebugVarRangeInfo rangeInfo) + => _start <= rangeInfo.StartOffset && _end >= rangeInfo.EndOffset; + + public void AddVar(DebugVarInfoMetadata metadataInfo, DwarfDIE type) + { + if (metadataInfo.IsParameter && _isFuncScope) + { + _vars.Add((metadataInfo, type)); + return; + } + + foreach (var rangeInfo in metadataInfo.DebugVarInfo.Ranges) + { + if (!IsContains(rangeInfo)) + return; + + // Var belongs to inner scope + if (rangeInfo.StartOffset != _start || rangeInfo.EndOffset != _end) + { + // Try to add variable to one the inner scopes + foreach (var innerScope in _innerScopes) + { + if (innerScope.IsContains(rangeInfo)) + { + innerScope.AddVar(metadataInfo, type); + return; + } + } + + // We need to create new inner scope for this var + var newInnerScope = new LexicalScope(rangeInfo); + newInnerScope.AddVar(metadataInfo, type); + _innerScopes.Add(newInnerScope); + } + else + { + _vars.Add((metadataInfo, type)); + } + } + } + }; + + private int DwarfRegNum(int regNum) + { + _ = _architecture; + if (regNum >= 33) + regNum = regNum - 33 + 64; // FP + // ARM64 + // FIXME: FP regs + return regNum; + } + + + private DwarfOperation DwarfReg(int regNum) + { + int dwarfRegNum = DwarfRegNum(regNum); + if (dwarfRegNum < 32) + { + return new DwarfOperation { Kind = (DwarfOperationKind)((int)DwarfOperationKind.Reg0 + dwarfRegNum) }; + } + else + { + return new DwarfOperation + { + Kind = DwarfOperationKind.Regx, + Operand1 = { U64 = (uint)dwarfRegNum }, + }; + } + } + + private DwarfOperation DwarfBreg(int regNum, int offset = 0) + { + int dwarfRegNum = DwarfRegNum(regNum); + if (dwarfRegNum < 32) + { + return new DwarfOperation + { + Kind = (DwarfOperationKind)((int)DwarfOperationKind.Breg0 + dwarfRegNum), + Operand2 = { I64 = offset }, + }; + } + else + { + return new DwarfOperation + { + Kind = DwarfOperationKind.Bregx, + Operand1 = { U64 = (uint)dwarfRegNum }, + Operand2 = { I64 = offset }, + }; + } + } + + private DwarfExpression DwarfVarLocation(VarLoc loc) + { + var e = new DwarfExpression(); + + switch (loc.LocationType) + { + case VarLocType.VLT_REG: + case VarLocType.VLT_REG_FP: + e.AddOperation(DwarfReg(loc.B)); + break; + case VarLocType.VLT_REG_BYREF: + e.AddOperation(DwarfBreg(loc.B)); + break; + case VarLocType.VLT_STK: + case VarLocType.VLT_STK2: + case VarLocType.VLT_FPSTK: + case VarLocType.VLT_STK_BYREF: + e.AddOperation(DwarfBreg(loc.B, loc.C)); + if (loc.LocationType == VarLocType.VLT_STK_BYREF) + { + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); + } + break; + case VarLocType.VLT_REG_REG: + e.AddOperation(DwarfReg(loc.C)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + e.AddOperation(DwarfReg(loc.B)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + break; + case VarLocType.VLT_REG_STK: + case VarLocType.VLT_STK_REG: + if (loc.LocationType == VarLocType.VLT_REG_STK) + { + e.AddOperation(DwarfReg(loc.B)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + e.AddOperation(DwarfBreg(loc.C, loc.D)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + } + else + { + e.AddOperation(DwarfBreg(loc.C, loc.D)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + e.AddOperation(DwarfReg(loc.B)); + e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); + } + break; + default: + // Unsupported + Debug.Assert(loc.LocationType != VarLocType.VLT_FIXED_VA); + return null; + } + + return e; + } + + private DwarfDIE EmitVar(DebugVarInfoMetadata metadataInfo, ulong methodPCStart, DwarfDIE type, bool isThis) + { + string varName = metadataInfo.Name; + DwarfLocation? location = null; + + if (metadataInfo.DebugVarInfo.Ranges.Length == 1) + { + var e = DwarfVarLocation(metadataInfo.DebugVarInfo.Ranges[0].VarLoc); + if (e != null) + { + location = new DwarfLocation(e); + } + else + { + Console.WriteLine("F: " + metadataInfo.Name); + } + } + else + { + var locationList = new DwarfLocationList(); + foreach (var range in metadataInfo.DebugVarInfo.Ranges) + { + var e = DwarfVarLocation(range.VarLoc); + if (e != null) + { + locationList.AddLocationListEntry(new DwarfLocationListEntry + { + Start = range.StartOffset + methodPCStart, + End = range.EndOffset + methodPCStart, + Expression = e, + }); + } + else + { + Console.WriteLine("F: " + metadataInfo.Name); + } + } + _dwarfFile.LocationSection.AddLocationList(locationList); + location = locationList; + } + + if (metadataInfo.IsParameter) + { + var formalParameter = new DwarfDIEFormalParameter + { + Name = isThis ? "this" : varName, + // decl file, line + Type = type, + }; + + if (location != null) + { + formalParameter.Location = location; + } + + if (isThis) + { + formalParameter.Artificial = true; + } + + return formalParameter; + } + else + { + var variable = new DwarfDIEVariable + { + Name = varName, + Type = type, + }; + + if (location != null) + { + variable.Location = location; + } + + return variable; + } + } + + private void EmitLexicalBlock(LexicalScope lexicalScope, ulong methodPCStart, bool methodIsStatic, DwarfDIE die) + { + if (!lexicalScope.IsFuncScope) + { + var lexicalBlock = new DwarfDIELexicalBlock + { + LowPC = methodPCStart + lexicalScope.Start, + HighPC = (int)(lexicalScope.End - lexicalScope.Start), + }; + + die.AddChild(lexicalBlock); + die = lexicalBlock; + } + + foreach (var (var, type) in lexicalScope.Vars) + { + bool isThis = var.IsParameter && var.DebugVarInfo.VarNumber == 0 && !methodIsStatic; + var dwarfVar = EmitVar(var, methodPCStart, type, isThis); + die.AddChild(dwarfVar); + if (isThis) + { + ((DwarfDIESubprogram)die).ObjectPointer = dwarfVar; + } + } + + foreach (var innerScope in lexicalScope.InnerScopes) + { + EmitLexicalBlock(innerScope, methodPCStart, methodIsStatic, die); + } + } + + public void EmitSubprogramInfo( + string methodName, + ulong methodPCStart, + int methodPCLength, + uint methodTypeIndex, + IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, + IEnumerable debugEHClauseInfos) + { + var subprogramSpec = _memberFunctions[(int)methodTypeIndex - 1]; + + _dwarfFile.StringTable.GetOrCreateString(methodName); + subprogramSpec.LinkageName = methodName; + + var frameExpression = new DwarfExpression(); + frameExpression.AddOperation(new DwarfOperation { Kind = (DwarfOperationKind)((int)DwarfOperationKind.Reg0 + _frameRegister) }); + var subprogram = new DwarfDIESubprogram + { + Specification = subprogramSpec, + LowPC = methodPCStart, + HighPC = methodPCLength, + FrameBase = new DwarfLocation(frameExpression), + }; + + var methodScope = new LexicalScope(0u, (uint)methodPCLength, true); + foreach (var (debugVar, typeIndex) in debugVars) + { + methodScope.AddVar(debugVar, typeIndex == 0 ? null : _rootDIE.Children[(int)typeIndex - 1]); + } + EmitLexicalBlock(methodScope, methodPCStart, subprogramSpec.ObjectPointer == null, subprogram); + + foreach (var clause in debugEHClauseInfos) + { + subprogram.AddChild(new DwarfDIETryBlock + { + LowPC = methodPCStart + clause.TryOffset, + HighPC = (int)clause.TryLength, + }); + + subprogram.AddChild(new DwarfDIECatchBlock + { + LowPC = methodPCStart + clause.HandlerOffset, + HighPC = (int)clause.HandlerLength, + }); + } + + _rootDIE.AddChild(subprogram); + } + + public void EmitLineInfo(ulong methodPCStart, IEnumerable sequencePoints) + { + foreach (var sequencePoint in sequencePoints) + { + DwarfFileName dwarfFileName; + + if (!_emittedFileName.TryGetValue(sequencePoint.FileName, out dwarfFileName)) + { + dwarfFileName = new DwarfFileName + { + Name = Path.GetFileName(sequencePoint.FileName), + Directory = Path.GetDirectoryName(sequencePoint.FileName), + }; + _emittedFileName.Add(sequencePoint.FileName, dwarfFileName); + _lineTable.FileNames.Add(dwarfFileName); + } + + _lineSequence.Add(new DwarfLine + { + File = dwarfFileName, + Address = methodPCStart + (ulong)sequencePoint.NativeOffset, + Column = (uint)sequencePoint.ColNumber, + Line = (uint)sequencePoint.LineNumber, + }); + } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs new file mode 100644 index 00000000000000..463c22af11c623 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Buffers.Binary; + +using Internal.TypeSystem; + +using Melanzana.MachO; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public class DwarfCie + { + public byte PointerEncoding; + public byte LsdaEncoding; + public byte PersonalityEncoding; + public string PersonalitySymbolName; + public uint CodeAlignFactor; + public int DataAlignFactor; + public bool IsSignalFrame; + public bool FdesHaveAugmentationData; + public byte ReturnAddressRegister; + public byte[] Instructions; + public byte InitialCFAOffset; + + public DwarfCie(TargetArchitecture targetArchitecture) + { + IsSignalFrame = false; + + // Each FDE has LSDA pointer + FdesHaveAugmentationData = true; + + // Unused + PersonalityEncoding = 0; + PersonalitySymbolName = null; + + // NOTE: Apple linker only knows how to handle DW_EH_PE_pcrel in combination with + // DW_EH_PE_sdata4 or DW_EH_PE_ptr. + PointerEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4; + LsdaEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4; + + if (targetArchitecture == TargetArchitecture.ARM64) + { + CodeAlignFactor = 1; + DataAlignFactor = -8; + ReturnAddressRegister = 30; // LR + Instructions = new byte[] + { + DW_CFA_def_cfa, + 31, // SP + 0, // Offset from SP + }; + InitialCFAOffset = 0; + } + else if (targetArchitecture == TargetArchitecture.X64) + { + CodeAlignFactor = 1; + DataAlignFactor = -8; + ReturnAddressRegister = 16; // RA + Instructions = new byte[] + { + DW_CFA_def_cfa, + 7, // RSP + 8, // Offset from RSP + DW_CFA_offset | 16, // RIP + 1, // RIP is at -8 + }; + InitialCFAOffset = 8; + } + else + { + throw new NotSupportedException(); + } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs new file mode 100644 index 00000000000000..e8e8a48af8e853 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs @@ -0,0 +1,211 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using Internal.Text; + +using LibObjectFile.Dwarf; +using Melanzana.MachO; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public class DwarfEhFrame + { + public delegate void EmitRelocationAction(int offset, Span data, RelocType relocationType, string symbolName); + + private Stream _stream; + private EmitRelocationAction _emitRelocation; + private bool _is64Bit; + private Dictionary _cieOffset; + + public DwarfEhFrame(Stream stream, EmitRelocationAction emitRelocation, bool is64Bit) + { + _stream = stream; + _emitRelocation = emitRelocation; + _is64Bit = is64Bit; + _cieOffset = new Dictionary(); + } + + public void AddCie(DwarfCie cie) + { + _cieOffset.Add(cie, (uint)_stream.Position); + WriteCie(cie); + } + + public void AddFde(DwarfFde fde) + { + uint cieOffset; + + if (!_cieOffset.TryGetValue(fde.Cie, out cieOffset)) + { + AddCie(fde.Cie); + cieOffset = _cieOffset[fde.Cie]; + } + + WriteFde(fde, cieOffset); + } + + private void WriteCie(DwarfCie cie) + { + Utf8StringBuilder augmentationString = new Utf8StringBuilder(); + uint augmentationLength = 0; + Span tempBuffer = stackalloc byte[8]; + + if (cie.FdesHaveAugmentationData) + { + augmentationString.Append('z'); + } + if (cie.PersonalitySymbolName != null) + { + augmentationString.Append('P'); + augmentationLength += 1u + AddressSize(cie.PersonalityEncoding); + } + if (cie.LsdaEncoding != 0) + { + augmentationString.Append('L'); + augmentationLength++; + } + if (cie.PointerEncoding != 0) + { + augmentationString.Append('R'); + augmentationLength++; + } + if (cie.IsSignalFrame) + { + augmentationString.Append('S'); + } + + uint length = + 4u + // Length + 4u + // CIE Offset (0) + 1u + // Version + (uint)augmentationString.Length + 1u + + DwarfHelper.SizeOfULEB128(cie.CodeAlignFactor) + + DwarfHelper.SizeOfILEB128(cie.DataAlignFactor) + + DwarfHelper.SizeOfULEB128(cie.ReturnAddressRegister) + + (uint)(augmentationLength > 0 ? DwarfHelper.SizeOfULEB128(augmentationLength) + augmentationLength : 0) + + (uint)cie.Instructions.Length; + uint padding = ((length + 7u) & ~7u) - length; + + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); + _stream.Write(tempBuffer); + + _stream.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version + _stream.Write(augmentationString.UnderlyingArray); + + _stream.WriteULEB128(cie.CodeAlignFactor); + _stream.WriteILEB128(cie.DataAlignFactor); + _stream.WriteULEB128(cie.ReturnAddressRegister); + + _stream.WriteULEB128(augmentationLength); + if (cie.PersonalitySymbolName != null) + { + _stream.WriteByte(cie.PersonalityEncoding); + WriteAddress(cie.PersonalityEncoding, cie.PersonalitySymbolName); + } + if (cie.LsdaEncoding != 0) + { + _stream.WriteByte(cie.LsdaEncoding); + } + if (cie.PointerEncoding != 0) + { + _stream.WriteByte(cie.PointerEncoding); + } + + _stream.Write(cie.Instructions); + + _stream.Write(stackalloc byte[(int)padding]); + } + + private void WriteFde(DwarfFde fde, uint cieOffset) + { + Span tempBuffer = stackalloc byte[8]; + + uint augmentationLength = + fde.Cie.FdesHaveAugmentationData ? + 1u + // Length + (fde.Cie.PersonalityEncoding != 0 ? AddressSize(fde.Cie.PersonalityEncoding) : 0) + + (fde.Cie.LsdaEncoding != 0 ? AddressSize(fde.Cie.LsdaEncoding) : 0) : 0; + + uint length = + 4u + // Length + 4u + // CIE offset + AddressSize(fde.Cie.PointerEncoding) + // PC start + AddressSize(fde.Cie.PointerEncoding) + // PC end + augmentationLength + + (uint)fde.Instructions.Length; + uint padding = ((length + 7u) & ~7u) - length; + + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); + _stream.Write(tempBuffer.Slice(0, 4)); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(_stream.Position - cieOffset)); + _stream.Write(tempBuffer.Slice(0, 4)); + WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName); + WriteSize(fde.Cie.PointerEncoding, fde.PcLength); + + if (fde.Cie.FdesHaveAugmentationData) + { + _stream.WriteByte((byte)(augmentationLength - 1)); + if (fde.Cie.PersonalityEncoding != 0) + { + WriteAddress(fde.Cie.PersonalityEncoding, fde.PersonalitySymbolName); + } + if (fde.Cie.LsdaEncoding != 0) + { + WriteAddress(fde.Cie.LsdaEncoding, fde.LsdaSymbolName); + } + } + + _stream.Write(fde.Instructions); + _stream.Write(stackalloc byte[(int)padding]); + } + + private uint AddressSize(byte encoding) + { + switch (encoding & 0xf) + { + case DW_EH_PE_ptr: return _is64Bit ? 8u : 4u; + case DW_EH_PE_sdata4: return 4u; + default: + throw new NotSupportedException(); + } + } + + private void WriteAddress(byte encoding, string symbolName) + { + Span address = stackalloc byte[(int)AddressSize(encoding)]; + if (symbolName != null) + { + RelocType relocationType = encoding switch + { + DW_EH_PE_pcrel | DW_EH_PE_sdata4 => RelocType.IMAGE_REL_BASED_RELPTR32, + DW_EH_PE_absptr => RelocType.IMAGE_REL_BASED_DIR64, + _ => throw new NotSupportedException() + }; + _emitRelocation((int)_stream.Position, address, relocationType, symbolName); + } + _stream.Write(address); + } + + private void WriteSize(byte encoding, ulong size) + { + Span buffer = stackalloc byte[(int)AddressSize(encoding)]; + if (buffer.Length == 4) + { + BinaryPrimitives.WriteUInt32LittleEndian(buffer, (uint)size); + } + else + { + BinaryPrimitives.WriteUInt64LittleEndian(buffer, size); + } + _stream.Write(buffer); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs new file mode 100644 index 00000000000000..abdc6aa190ed1f --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs @@ -0,0 +1,117 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Diagnostics; +using System.IO; +using System.Buffers; +using System.Buffers.Binary; + +using Internal.TypeSystem; + +using Melanzana.MachO; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public class DwarfFde + { + public DwarfCie Cie; + public string PcStartSymbolName; + public ulong PcLength; + public string LsdaSymbolName; + public string PersonalitySymbolName; + public byte[] Instructions; + + public DwarfFde(DwarfCie cie, byte[] instructions) + { + Cie = cie; + Instructions = instructions; + } + + private enum CFI_OPCODE + { + CFI_ADJUST_CFA_OFFSET, // Offset is adjusted relative to the current one. + CFI_DEF_CFA_REGISTER, // New register is used to compute CFA + CFI_REL_OFFSET, // Register is saved at offset from the current CFA + CFI_DEF_CFA // Take address from register and add offset to it. + } + + /// + /// Convert JIT version of CFI blob into the the DWARF byte code form. + /// + public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) + { + int cfaOffset = cie.InitialCFAOffset; + var cfiCode = ArrayPool.Shared.Rent(4096); + int cfiCodeOffset = 0; + byte codeOffset = 0; + byte lastCodeOffset = 0; + int offset = 0; + uint temp; + while (offset < blobData.Length) + { + codeOffset = Math.Max(codeOffset, blobData[offset++]); + CFI_OPCODE opcode = (CFI_OPCODE)blobData[offset++]; + short dwarfReg = BitConverter.ToInt16(blobData, offset); + offset += sizeof(short); + int cfiOffset = BitConverter.ToInt32(blobData, offset); + offset += sizeof(int); + + if (codeOffset != lastCodeOffset) + { + // Advance + int diff = (int)((codeOffset - lastCodeOffset) / cie.CodeAlignFactor); + if (diff < 0x3f) + { + cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_advance_loc | diff); + } + else + { + cfiCode[cfiCodeOffset++] = (byte)DW_CFA_advance_loc1; + cfiCode[cfiCodeOffset++] = (byte)diff; + } + lastCodeOffset = codeOffset; + } + + switch (opcode) + { + case CFI_OPCODE.CFI_DEF_CFA_REGISTER: + cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa_register; + cfiCode[cfiCodeOffset++] = (byte)dwarfReg; + break; + + case CFI_OPCODE.CFI_REL_OFFSET: + Debug.Assert(dwarfReg <= 0x3f); + cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_offset | (byte)dwarfReg); + temp = (uint)((cfiOffset - cfaOffset) / cie.DataAlignFactor); + do + { + cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); + temp >>= 7; + } + while (temp > 0); + break; + + case CFI_OPCODE.CFI_ADJUST_CFA_OFFSET: + cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa_offset; + cfaOffset += cfiOffset; + temp = (uint)(cfaOffset); + do + { + cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); + temp >>= 7; + } + while (temp > 0); + break; + + // TODO: CFI_DEF_CFA + } + } + + var result = cfiCode[0..cfiCodeOffset]; + ArrayPool.Shared.Return(cfiCode); + return result; + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs new file mode 100644 index 00000000000000..0cbce71c9316ea --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILCompiler.ObjectWriter +{ + public static class DwarfNative + { + public const byte DW_EH_PE_absptr = 0x00; + public const byte DW_EH_PE_omit = 0xff; + public const byte DW_EH_PE_ptr = 0x00; + public const byte DW_EH_PE_uleb128 = 0x01; + public const byte DW_EH_PE_udata2 = 0x02; + public const byte DW_EH_PE_udata4 = 0x03; + public const byte DW_EH_PE_udata8 = 0x04; + public const byte DW_EH_PE_sleb128 = 0x09; + public const byte DW_EH_PE_sdata2 = 0x0a; + public const byte DW_EH_PE_sdata4 = 0x0b; + public const byte DW_EH_PE_sdata8 = 0x0c; + public const byte DW_EH_PE_signed = 0x08; + public const byte DW_EH_PE_pcrel = 0x10; + public const byte DW_EH_PE_textrel = 0x20; + public const byte DW_EH_PE_datarel = 0x30; + public const byte DW_EH_PE_funcrel = 0x40; + public const byte DW_EH_PE_aligned = 0x50; + public const byte DW_EH_PE_indirect = 0x80; + + public const byte DW_CFA_nop = 0x0; + public const byte DW_CFA_set_loc = 0x1; + public const byte DW_CFA_advance_loc1 = 0x2; + public const byte DW_CFA_advance_loc2 = 0x3; + public const byte DW_CFA_advance_loc4 = 0x4; + public const byte DW_CFA_offset_extended = 0x5; + public const byte DW_CFA_restore_extended = 0x6; + public const byte DW_CFA_undefined = 0x7; + public const byte DW_CFA_same_value = 0x8; + public const byte DW_CFA_register = 0x9; + public const byte DW_CFA_remember_state = 0xa; + public const byte DW_CFA_restore_state = 0xb; + public const byte DW_CFA_def_cfa = 0xc; + public const byte DW_CFA_def_cfa_register = 0xd; + public const byte DW_CFA_def_cfa_offset = 0xe; + public const byte DW_CFA_def_cfa_expression = 0xf; + public const byte DW_CFA_expression = 0x10; + public const byte DW_CFA_offset_extended_sf = 0x11; + public const byte DW_CFA_def_cfa_sf = 0x12; + public const byte DW_CFA_def_cfa_offset_sf = 0x13; + public const byte DW_CFA_val_offset = 0x14; + public const byte DW_CFA_val_offset_sf = 0x15; + public const byte DW_CFA_val_expression = 0x16; + public const byte DW_CFA_advance_loc = 0x40; + public const byte DW_CFA_offset = 0x80; + public const byte DW_CFA_restore = 0xc0; + public const byte DW_CFA_GNU_window_save = 0x2d; + public const byte DW_CFA_GNU_args_size = 0x2e; + public const byte DW_CFA_GNU_negative_offset_extended = 0x2f; + public const byte DW_CFA_AARCH64_negate_ra_state = 0x2d; + + public const int DW_ATE_address = 0x01; + public const int DW_ATE_boolean = 0x02; + public const int DW_ATE_complex_float = 0x03; + public const int DW_ATE_float = 0x04; + public const int DW_ATE_signed = 0x05; + public const int DW_ATE_signed_char = 0x06; + public const int DW_ATE_unsigned = 0x07; + public const int DW_ATE_unsigned_char = 0x08; + public const int DW_ATE_imaginary_float = 0x09; /* DWARF3 */ + public const int DW_ATE_packed_decimal = 0x0a; /* DWARF3f */ + public const int DW_ATE_numeric_string = 0x0b; /* DWARF3f */ + public const int DW_ATE_edited = 0x0c; /* DWARF3f */ + public const int DW_ATE_signed_fixed = 0x0d; /* DWARF3f */ + public const int DW_ATE_unsigned_fixed = 0x0e; /* DWARF3f */ + public const int DW_ATE_decimal_float = 0x0f; /* DWARF3f */ + public const int DW_ATE_UTF = 0x10; /* DWARF4 */ + public const int DW_ATE_UCS = 0x11; /* DWARF5 */ + public const int DW_ATE_ASCII = 0x12; /* DWARF5 */ + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs new file mode 100644 index 00000000000000..e507e78af73bbd --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -0,0 +1,258 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Linq; +using System.Numerics; +using System.Buffers; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +using Melanzana.MachO; +using LibObjectFile; +using LibObjectFile.Elf; +using LibObjectFile.Dwarf; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public sealed class ElfObjectWriter : UnixObjectWriter + { + private ElfObjectFile _objectFile; + private int _sectionIndex; + private int _bssSectionIndex; + private Stream _bssStream; + private Dictionary _sectionIndexToElfSection = new(); + private Dictionary _sectionToRelocationTable = new(); + + // Symbol table + private Dictionary _symbolNameToIndex = new(); + private ElfSymbolTable _symbolTable; + + private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) + : base(factory, options) + { + if (factory.Target.Architecture != TargetArchitecture.X64) + { + throw new NotSupportedException("Unsupported architecture"); + } + + _objectFile = new ElfObjectFile(ElfArch.X86_64); + + var stringSection = new ElfStringTable(); + _objectFile.AddSection(stringSection); + _symbolTable = new ElfSymbolTable { Link = stringSection }; + _objectFile.AddSection(_symbolTable); + } + + protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + { + if (section.Name == "bss") + { + Debug.Assert(_bssStream == null); + + _bssSectionIndex = _sectionIndex; + _bssStream = sectionStream = new MemoryStream(); + ElfSection elfSection = new ElfBinarySection() + { + Name = ".bss", + Type = ElfSectionType.NoBits, + Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write, + }; + + _sectionIndexToElfSection[_sectionIndex++] = elfSection; + _objectFile.AddSection(elfSection); + } + else + { + string sectionName = + section.Name == "rdata" ? ".rodata" : + (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); + + sectionStream = new MemoryStream(); + ElfSection elfSection = new ElfBinarySection(sectionStream) + { + Name = sectionName, + Type = section.Name == ".eh_frame" ? (ElfSectionType)ElfNative.SHT_IA_64_UNWIND : ElfSectionType.ProgBits, + Flags = + section.Type == SectionType.Executable ? ElfSectionFlags.Alloc | ElfSectionFlags.Executable : + (section.Type == SectionType.Writeable ? ElfSectionFlags.Alloc | ElfSectionFlags.Write : + ElfSectionFlags.Alloc) + }; + + var elfRelocationTable = new ElfRelocationTable + { + Name = ".rela" + sectionName, + Link = _symbolTable, + Info = elfSection, + Alignment = 8, + }; + + _sectionIndexToElfSection[_sectionIndex++] = elfSection; + _sectionToRelocationTable[elfSection] = elfRelocationTable; + _objectFile.AddSection(elfSection); + _objectFile.AddSection(elfRelocationTable); + } + } + + protected override void EmitRelocation( + int sectionIndex, + List relocationList, + int offset, + Span data, + RelocType relocType, + string symbolName, + int addend) + { + if (relocType == RelocType.IMAGE_REL_BASED_REL32 || + relocType == RelocType.IMAGE_REL_BASED_RELPTR32) + { + addend += BinaryPrimitives.ReadInt32LittleEndian(data); + BinaryPrimitives.WriteInt32LittleEndian(data, 0); + } + else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) + { + var a = BinaryPrimitives.ReadUInt64LittleEndian(data); + addend += checked((int)a); + BinaryPrimitives.WriteUInt64LittleEndian(data, 0); + } + relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + } + + protected override void EmitSymbolTable() + { + uint symbolIndex = (uint)_symbolTable.Entries.Count; + + var definedSymbols = GetDefinedSymbols(); + var sortedSymbols = new List(definedSymbols.Count); + foreach (var (name, definition) in definedSymbols) + { + sortedSymbols.Add(new ElfSymbol + { + Name = name, + Bind = ElfSymbolBind.Global, + Section = _sectionIndexToElfSection[definition.SectionIndex], + Value = (ulong)definition.Value, + Type = definition.Size > 0 ? ElfSymbolType.Function : 0, + Size = (ulong)definition.Size, + Visibility = ElfSymbolVisibility.Hidden, + }); + } + + foreach (var externSymbol in GetUndefinedSymbols()) + { + sortedSymbols.Add(new ElfSymbol + { + Name = externSymbol, + Bind = ElfSymbolBind.Global, + }); + } + + sortedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); + foreach (var definedSymbol in sortedSymbols) + { + _symbolTable.Entries.Add(definedSymbol); + _symbolNameToIndex[definedSymbol.Name] = symbolIndex; + symbolIndex++; + } + } + + protected override void EmitRelocations(int sectionIndex, List relocationList) + { + var elfSection = _sectionIndexToElfSection[sectionIndex]; + if (_sectionToRelocationTable.TryGetValue(elfSection, out var relocationTable)) + { + foreach (var symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + + ElfRelocationType type = symbolicRelocation.Type switch { + RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_X86_64_64, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_X86_64_PC32, + RelocType.IMAGE_REL_BASED_REL32 => ElfRelocationType.R_X86_64_PLT32, + _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) + }; + + var addend = symbolicRelocation.Addend; + if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + { + addend -= 4; + } + + relocationTable.Entries.Add(new ElfRelocation + { + SymbolIndex = symbolIndex, + Type = type, + Offset = (ulong)symbolicRelocation.Offset, + Addend = addend + }); + } + } + else + { + Debug.Assert(relocationList.Count == 0); + } + } + + protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) + { + var elfSection = _sectionIndexToElfSection[sectionIndex]; + elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); + isExecutable = elfSection.Flags.HasFlag(ElfSectionFlags.Executable); + } + + protected override void EmitDebugSections(DwarfFile dwarfFile) + { + // TODO: Pretty much broken in all possible ways since we have multiple + // code sections and no LowPC relocations + + var elfDiagnostics = new DiagnosticBag(); + _objectFile.UpdateLayout(elfDiagnostics); + + foreach (var unit in dwarfFile.InfoSection.Units) + { + dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; + dwarfFile.AddressRangeTable.Unit = unit; + dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, _objectFile.Layout.TotalSize)); + } + + var dwarfElfContext = new DwarfElfContext(_objectFile); + dwarfFile.WriteToElf(dwarfElfContext); + } + + protected override void EmitSectionsAndLayout() + { + _objectFile.AddSection(new ElfSectionHeaderStringTable()); + if (_bssStream != null) + { + _sectionIndexToElfSection[_bssSectionIndex].Size = (ulong)_bssStream.Length; + } + } + + protected override void EmitObjectFile(string objectFilePath) + { + using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) + { + _objectFile.Write(outputFileStream); + } + } + + public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) + { + using ElfObjectWriter writer = new ElfObjectWriter(factory, options); + writer.EmitObject(objectFilePath, nodes, dumper, logger); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs new file mode 100644 index 00000000000000..e2e3c8b170ee1c --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -0,0 +1,624 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Linq; +using System.Numerics; +using System.Buffers; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +using Melanzana.MachO; +using LibObjectFile.Dwarf; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public class MachObjectWriter : UnixObjectWriter + { + private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); + + private MachObjectFile _objectFile; + private MachSegment _segment; + + // Standard sections + private Dictionary _sectionIndexToMachSection = new(); + + // Exception handling sections + private MachSection _compactUnwindSection; + private List _compactUnwindCodes = new(); + private uint _compactUnwindDwarfCode; + + // Symbol table + private Dictionary _sectionIndexToSymbolIndex = new(); + private Dictionary _symbolNameToIndex = new(); + private MachSymbolTable _symbolTable; + private MachDynamicLinkEditSymbolTable _dySymbolTable; + + private MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) + : base(factory, options) + { + _objectFile = new MachObjectFile(); + _objectFile.FileType = MachFileType.Object; + _objectFile.IsLittleEndian = true; + + switch (factory.Target.Architecture) + { + case TargetArchitecture.ARM64: + _objectFile.CpuType = MachCpuType.Arm64; + _objectFile.CpuSubType = (uint)MachArm64CpuSubType.All; + _compactUnwindDwarfCode = 0x3_00_00_00u; + break; + case TargetArchitecture.X64: + _objectFile.CpuType = MachCpuType.X86_64; + _objectFile.CpuSubType = (uint)X8664CpuSubType.All; + _compactUnwindDwarfCode = 0x4_00_00_00u; + break; + default: + throw new NotSupportedException("Unsupported architecture"); + } + + // Mach-O object files have single segment with no name + _segment = new MachSegment(_objectFile, "") + { + InitialProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, + MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, + }; + _objectFile.LoadCommands.Add(_segment); + } + + protected override void EmitSectionsAndLayout() + { + _compactUnwindSection = new MachSection(_objectFile, "__LD", "__compact_unwind") + { + Log2Alignment = 3, + Type = MachSectionType.Regular, + Attributes = MachSectionAttributes.Debug, + // Preset the size of the compact unwind section which is not generated yet + Size = 32u * (ulong)_compactUnwindCodes.Count, + }; + _segment.Sections.Add(_compactUnwindSection); + + // Insert all the load commands to ensure we have correct layout + _symbolTable = new MachSymbolTable(_objectFile); + _dySymbolTable = new MachDynamicLinkEditSymbolTable(); + _objectFile.LoadCommands.Add(_symbolTable); + _objectFile.LoadCommands.Add(_dySymbolTable); + _objectFile.LoadCommands.Add(new MachVersionMinMacOS + { + MinimumPlatformVersion = new Version(10, 12, 0) + }); + + // Layout the sections + _objectFile.UpdateLayout(); + + EmitCompactUnwindTable(); + } + + protected override void EmitObjectFile(string objectFilePath) + { + // Update layout again to account for symbol table and relocation tables + _objectFile.UpdateLayout(); + + using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) + { + MachWriter.Write(outputFileStream, _objectFile); + } + } + + protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + { + string segmentName = section.Name switch + { + "rdata" => "__TEXT", + ".eh_frame" => "__TEXT", + _ => section.Type == SectionType.Executable ? "__TEXT" : "__DATA" + }; + + string sectionName = section.Name switch + { + "text" => "__text", + "data" => "__data", + "rdata" => "__const", + "bss" => "__bss", + ".eh_frame" => "__eh_frame", + _ => section.Name + }; + + MachSectionAttributes attributes = section.Name switch + { + ".dotnet_eh_table" => MachSectionAttributes.Debug, + ".eh_frame" => MachSectionAttributes.LiveSupport | MachSectionAttributes.StripStaticSymbols | MachSectionAttributes.NoTableOfContents, + _ => section.Type == SectionType.Executable ? + MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions : 0 + }; + + MachSectionType type = section.Name switch + { + "bss" => MachSectionType.ZeroFill, + ".eh_frame" => MachSectionType.Coalesced, + _ => MachSectionType.Regular + }; + + MachSection machSection = new MachSection(_objectFile, segmentName, sectionName) + { + Log2Alignment = 1, + Type = type, + Attributes = attributes, + }; + + _sectionIndexToMachSection[_segment.Sections.Count] = machSection; + sectionStream = machSection.GetWriteStream(); + _segment.Sections.Add(machSection); + } + + protected override void EmitRelocation( + int sectionIndex, + List relocationList, + int offset, + Span data, + RelocType relocType, + string symbolName, + int addend) + { + if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + { + Debug.Assert(_objectFile.CpuType == MachCpuType.Arm64); + Debug.Assert(addend == 0); + } + else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) + { + if (addend != 0) + { + BinaryPrimitives.WriteInt64LittleEndian( + data, + BinaryPrimitives.ReadInt64LittleEndian(data) + + addend); + } + } + else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) + { + if (_objectFile.CpuType == MachCpuType.Arm64) + { + // On ARM64 we need to represent PC relative relocations as + // subtraction and the PC offset is baked into the addend. + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend - offset); + } + else if (sectionIndex == EhFrameSectionIndex) + { + // ld64 requires X86_64_RELOC_SUBTRACTOR + X86_64_RELOC_UNSIGNED + // for DWARF CFI sections + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend - offset); + } + else + { + addend += 4; + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + } + } + } + else if (relocType == RelocType.IMAGE_REL_BASED_REL32) + { + Debug.Assert(_objectFile.CpuType != MachCpuType.Arm64); + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + } + } + + relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + } + + protected override void EmitSymbolTable() + { + uint symbolIndex = 0; + + // Create section base symbols. They're used for PC relative relocations + // to subtract the base of the section. + int sectionIndex = 0; + foreach (var machSection in _segment.Sections) + { + var machSymbol = new MachSymbol + { + Name = "lsection" + sectionIndex, + Section = machSection, + Value = machSection.VirtualAddress, + Descriptor = 0, + Type = MachSymbolType.Section, + }; + _symbolTable.Symbols.Add(machSymbol); + _sectionIndexToSymbolIndex[sectionIndex] = symbolIndex; + symbolIndex++; + sectionIndex++; + } + + _dySymbolTable.LocalSymbolsIndex = 0; + _dySymbolTable.LocalSymbolsCount = symbolIndex; + + // Sort and insert all defined symbols + var definedSymbols = GetDefinedSymbols(); + var sortedDefinedSymbols = new List(definedSymbols.Count); + foreach (var (name, definition) in definedSymbols) + { + var section = _segment.Sections[definition.SectionIndex]; + sortedDefinedSymbols.Add(new MachSymbol + { + Name = name, + Section = section, + Value = section.VirtualAddress + (ulong)definition.Value, + Descriptor = 0, + Type = MachSymbolType.Section | MachSymbolType.External, + }); + } + sortedDefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); + foreach (var definedSymbol in sortedDefinedSymbols) + { + _symbolTable.Symbols.Add(definedSymbol); + _symbolNameToIndex[definedSymbol.Name] = symbolIndex; + symbolIndex++; + } + + _dySymbolTable.ExternalSymbolsIndex = _dySymbolTable.LocalSymbolsCount; + _dySymbolTable.ExternalSymbolsCount = (uint)definedSymbols.Count; + + List undefinedSymbols = new List(); + foreach (var externSymbol in GetUndefinedSymbols()) + { + var machSymbol = new MachSymbol + { + Name = externSymbol, + Section = null, + Value = 0, + Descriptor = 0, + Type = MachSymbolType.Undefined | MachSymbolType.External, + }; + undefinedSymbols.Add(machSymbol); + } + + // Sort and insert all undefined external symbols + undefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); + foreach (var undefinedSymbol in undefinedSymbols) + { + _symbolTable.Symbols.Add(undefinedSymbol); + _symbolNameToIndex[undefinedSymbol.Name] = symbolIndex; + symbolIndex++; + } + + _dySymbolTable.UndefinedSymbolsIndex = _dySymbolTable.LocalSymbolsCount + _dySymbolTable.ExternalSymbolsCount; + _dySymbolTable.UndefinedSymbolsCount = (uint)undefinedSymbols.Count; + } + + protected override void EmitRelocations(int sectionIndex, List relocationList) + { + if (_objectFile.CpuType == MachCpuType.Arm64) + { + EmitRelocationsArm64(sectionIndex, relocationList); + } + else + { + EmitRelocationsX64(sectionIndex, relocationList); + } + } + + private void EmitRelocationsX64(int sectionIndex, List relocationList) + { + ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; + + relocationList.Reverse(); + foreach (var symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + + if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 8, + RelocationType = MachRelocationType.X86_64Unsigned, + IsExternal = true, + IsPCRelative = false, + }); + } + else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32 && sectionIndex == EhFrameSectionIndex) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = _sectionIndexToSymbolIndex[sectionIndex], + Length = 4, + RelocationType = MachRelocationType.X86_64Subtractor, + IsExternal = true, + IsPCRelative = false, + }); + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 4, + RelocationType = MachRelocationType.X86_64Unsigned, + IsExternal = true, + IsPCRelative = false, + }); + } + else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32 || + symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 4, + RelocationType = MachRelocationType.X86_64Branch, + IsExternal = true, + IsPCRelative = true, + }); + } + else + { + throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type); + } + } + } + + private void EmitRelocationsArm64(int sectionIndex, List relocationList) + { + ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; + + relocationList.Reverse(); + foreach (var symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + + if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 4, + RelocationType = MachRelocationType.Arm64Branch26, + IsExternal = true, + IsPCRelative = true, + }); + } + else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || + symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + { + if (symbolicRelocation.Addend != 0) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = (uint)symbolicRelocation.Addend, + Length = 4, + RelocationType = MachRelocationType.Arm64Addend, + IsExternal = false, + IsPCRelative = false, + }); + } + + MachRelocationType type = symbolicRelocation.Type switch + { + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => MachRelocationType.Arm64Page21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => MachRelocationType.Arm64PageOffset21, + _ => 0 + }; + + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 4, + RelocationType = type, + IsExternal = true, + IsPCRelative = symbolicRelocation.Type != RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A, + }); + } + else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) + { + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 8, + RelocationType = MachRelocationType.Arm64Unsigned, + IsExternal = true, + IsPCRelative = false, + }); + } + else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32) + { + // This one is tough... needs to be represented by ARM64_RELOC_SUBTRACTOR + ARM64_RELOC_UNSIGNED. + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = _sectionIndexToSymbolIndex[sectionIndex], + Length = 4, + RelocationType = MachRelocationType.Arm64Subtractor, + IsExternal = true, + IsPCRelative = false, + }); + sectionRelocations.Add( + new MachRelocation + { + Address = symbolicRelocation.Offset, + SymbolOrSectionIndex = symbolIndex, + Length = 4, + RelocationType = MachRelocationType.Arm64Unsigned, + IsExternal = true, + IsPCRelative = false, + }); + } + else + { + throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type); + } + } + } + + private void EmitCompactUnwindTable() + { + using var compactUnwindStream = _compactUnwindSection.GetWriteStream(); + var definedSymbols = GetDefinedSymbols(); + + IList symbols = _symbolTable.Symbols; + Span tempBuffer = stackalloc byte[8]; + foreach (var cu in _compactUnwindCodes) + { + EmitCompactUnwindSymbol(cu.PcStartSymbolName); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, cu.PcLength); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer.Slice(4), cu.Code); + compactUnwindStream.Write(tempBuffer); + EmitCompactUnwindSymbol(cu.PersonalitySymbolName); + EmitCompactUnwindSymbol(cu.LsdaSymbolName); + } + + void EmitCompactUnwindSymbol(string symbolName) + { + Span tempBuffer = stackalloc byte[8]; + if (symbolName != null) + { + SymbolDefinition symbol = definedSymbols[symbolName]; + MachSection section = _segment.Sections[symbol.SectionIndex]; + BinaryPrimitives.WriteUInt64LittleEndian(tempBuffer, section.VirtualAddress + (ulong)symbol.Value); + _compactUnwindSection.Relocations.Add( + new MachRelocation + { + Address = (int)compactUnwindStream.Position, + SymbolOrSectionIndex = (byte)(1 + symbol.SectionIndex), // 1-based + Length = 8, + RelocationType = MachRelocationType.Arm64Unsigned, + IsExternal = false, + IsPCRelative = false, + } + ); + } + compactUnwindStream.Write(tempBuffer); + } + } + + protected override string ExternCName(string name) => "_" + name; + + protected override bool EmitCompactUnwinding(DwarfFde fde) + { + _compactUnwindCodes.Add(new CompactUnwindCode( + PcStartSymbolName: fde.PcStartSymbolName, + PcLength: (uint)fde.PcLength, + Code: _compactUnwindDwarfCode // Use DWARF + )); + + return false; + } + + protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) + { + var machSection = _segment.Sections[sectionIndex]; + Debug.Assert(BitOperations.IsPow2(alignment)); + machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); + isExecutable = machSection.Attributes.HasFlag(MachSectionAttributes.SomeInstructions); + } + + protected override ulong GetSectionVirtualAddress(int sectionIndex) + { + var machSection = _segment.Sections[sectionIndex]; + Debug.Assert(machSection.VirtualAddress != 0); + return machSection.VirtualAddress; + } + + protected override void EmitDebugSections(DwarfFile dwarfFile) + { + _objectFile.UpdateLayout(); + + ulong highPC = 0; + foreach (var machSection in _segment.Sections) + { + if (machSection.Attributes.HasFlag(MachSectionAttributes.SomeInstructions)) + { + highPC = Math.Max(highPC, machSection.VirtualAddress + machSection.Size); + } + } + + foreach (var unit in dwarfFile.InfoSection.Units) + { + var rootDIE = (DwarfDIECompileUnit)unit.Root; + rootDIE.LowPC = 0u; + rootDIE.HighPC = (int)highPC; + dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; + dwarfFile.AddressRangeTable.Unit = unit; + dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, highPC)); + } + + var debugInfoSection = new MachSection(_objectFile, "__DWARF", "__debug_info") { Attributes = MachSectionAttributes.Debug }; + var debugAbbrevSection = new MachSection(_objectFile, "__DWARF", "__debug_abbrev") { Attributes = MachSectionAttributes.Debug }; + var debugAddressRangeSection = new MachSection(_objectFile, "__DWARF", "__debug_aranges") { Attributes = MachSectionAttributes.Debug }; + var debugStringSection = new MachSection(_objectFile, "__DWARF", "__debug_str") { Attributes = MachSectionAttributes.Debug }; + var debugLineSection = new MachSection(_objectFile, "__DWARF", "__debug_line") { Attributes = MachSectionAttributes.Debug }; + var debugLocationSection = new MachSection(_objectFile, "__DWARF", "__debug_loc") { Attributes = MachSectionAttributes.Debug }; + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = _objectFile.IsLittleEndian, + EnableRelocation = false, + AddressSize = DwarfAddressSize.Bit64, + DebugLineStream = debugLineSection.GetWriteStream(), + DebugAbbrevStream = debugAbbrevSection.GetWriteStream(), + DebugStringStream = debugStringSection.GetWriteStream(), + DebugAddressRangeStream = debugAddressRangeSection.GetWriteStream(), + DebugInfoStream = debugInfoSection.GetWriteStream(), + DebugLocationStream = debugLocationSection.GetWriteStream(), + }; + + dwarfFile.Write(outputContext); + + _segment.Sections.Add(debugInfoSection); + _segment.Sections.Add(debugAbbrevSection); + _segment.Sections.Add(debugAddressRangeSection); + _segment.Sections.Add(debugStringSection); + _segment.Sections.Add(debugLineSection); + _segment.Sections.Add(debugLocationSection); + } + + public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) + { + using MachObjectWriter objectWriter = new MachObjectWriter(factory, options); + objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs new file mode 100644 index 00000000000000..ea79019ad77b7c --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -0,0 +1,461 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Linq; +using System.Numerics; +using System.Buffers; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +using LibObjectFile; +using LibObjectFile.Dwarf; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + public abstract class UnixObjectWriter : IDisposable + { + protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0); + protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); + + private NodeFactory _nodeFactory; + private ObjectWritingOptions _options; + + // Debugging + private DwarfBuilder _dwarfBuilder; + private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; + + private byte _insPaddingByte; + + // Standard sections + private Dictionary _sectionNameToSectionIndex = new(); + private List _sectionIndexToStream = new(); + private List> _sectionIndexToRelocations = new(); + + // Exception handling sections + private int _lsdaSectionIndex; + private int _ehFrameSectionIndex; + private DwarfCie _dwarfCie; + private DwarfEhFrame _dwarfEhFrame; + + // Symbol table + private Dictionary _definedSymbols = new(); + + protected int EhFrameSectionIndex => _ehFrameSectionIndex; + + protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) + { + _nodeFactory = factory; + _options = options; + + // Padding byte for code sections (NOP for x86/x64) + _insPaddingByte = factory.Target.Architecture switch + { + TargetArchitecture.X86 => 0x90, + TargetArchitecture.X64 => 0x90, + _ => 0 + }; + } + + public void Dispose() + { + // Close all the streams + foreach (var sectionStream in _sectionIndexToStream) + { + sectionStream.Close(); + } + } + + protected abstract void CreateSection(ObjectNodeSection section, out Stream sectionStream); + + protected abstract void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable); + + protected int GetOrCreateSection( + ObjectNodeSection section, + out Stream sectionStream, + out List relocationList) + { + int sectionIndex; + + if (!_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) + { + CreateSection(section, out sectionStream); + sectionIndex = _sectionNameToSectionIndex.Count; + _sectionNameToSectionIndex[section.Name] = sectionIndex; + _sectionIndexToStream.Add(sectionStream); + _sectionIndexToRelocations.Add(relocationList = new()); + } + else + { + sectionStream = _sectionIndexToStream[sectionIndex]; + relocationList = _sectionIndexToRelocations[sectionIndex]; + } + + return sectionIndex; + } + + protected abstract void EmitRelocation( + int sectionIndex, + List relocationList, + int offset, + Span data, + RelocType relocType, + string symbolName, + int addend); + + /// + /// Emit symbolic definitions into object file symbols. + /// + protected abstract void EmitSymbolTable(); + + /// + /// Emit symbolic relocations into object file as format specific + /// relocations. + /// + /// + /// This methods is guaranteed to run after . + /// + protected abstract void EmitRelocations(int sectionIndex, List relocationList); + + protected virtual string ExternCName(string name) => name; + + protected void EmitSymbolDefinition(string name, SymbolDefinition definition) + { + _definedSymbols.Add(name, definition); + } + + protected virtual bool EmitCompactUnwinding(DwarfFde fde) => false; + + private void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) + { + if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && + nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) + { + var lsdaStream = _sectionIndexToStream[_lsdaSectionIndex]; + Span tempBuffer = stackalloc byte[4]; + long mainLsdaOffset = lsdaStream.Position; + string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); + + for (int i = 0; i < frameInfos.Length; i++) + { + FrameInfo frameInfo = frameInfos[i]; + + int start = frameInfo.StartOffset; + int end = frameInfo.EndOffset; + int len = frameInfo.BlobData.Length; + byte[] blob = frameInfo.BlobData; + + string lsdaSymbolName = $"_lsda{i}{currentSymbolName}"; + string framSymbolName = $"_fram{i}{currentSymbolName}"; + + EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(_lsdaSectionIndex, lsdaStream.Position)); + if (start != 0) + { + EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); + } + + FrameInfoFlags flags = frameInfo.Flags; + + if (i != 0) + { + lsdaStream.WriteByte((byte)flags); + + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaStream.Position)); + lsdaStream.Write(tempBuffer); + + // Emit relative offset from the main function + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(start - frameInfos[0].StartOffset)); + lsdaStream.Write(tempBuffer); + } + else + { + MethodExceptionHandlingInfoNode ehInfo = nodeWithCodeInfo.EHInfo; + ISymbolNode associatedDataNode = nodeWithCodeInfo.GetAssociatedDataNode(_nodeFactory) as ISymbolNode; + + flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; + flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; + + lsdaStream.WriteByte((byte)flags); + + if (associatedDataNode != null) + { + string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); + tempBuffer.Clear(); + EmitRelocation( + _lsdaSectionIndex, + _sectionIndexToRelocations[_lsdaSectionIndex], + (int)lsdaStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_RELPTR32, + symbolName, + 0); + lsdaStream.Write(tempBuffer); + } + + if (ehInfo != null) + { + string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); + tempBuffer.Clear(); + EmitRelocation( + _lsdaSectionIndex, + _sectionIndexToRelocations[_lsdaSectionIndex], + (int)lsdaStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_RELPTR32, + symbolName, + 0); + lsdaStream.Write(tempBuffer); + } + + if (nodeWithCodeInfo.GCInfo != null) + { + lsdaStream.Write(nodeWithCodeInfo.GCInfo); + } + } + + var fde = new DwarfFde(_dwarfCie, DwarfFde.CfiCodeToInstructions(_dwarfCie, frameInfo.BlobData)) + { + PcStartSymbolName = start != 0 ? framSymbolName : currentSymbolName, + PcLength = (ulong)(end - start), + LsdaSymbolName = lsdaSymbolName, + }; + + _dwarfEhFrame.AddFde(fde); + + EmitCompactUnwinding(fde); + } + } + } + + private void EmitAlignment(int sectionIndex, Stream sectionStream, int alignment) + { + UpdateSectionAlignment(sectionIndex, alignment, out bool isExecutable); + + int padding = (int)(((sectionStream.Position + alignment - 1) & ~(alignment - 1)) - sectionStream.Position); + Span buffer = stackalloc byte[padding]; + byte paddingByte = isExecutable ? _insPaddingByte : (byte)0; + buffer.Fill(paddingByte); + sectionStream.Write(buffer); + } + + private uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) + { + uint typeIndex; + try + { + if (isStateMachineMoveNextMethod && debugVar.DebugVarInfo.VarNumber == 0) + { + typeIndex = _userDefinedTypeDescriptor.GetStateMachineThisVariableTypeIndex(debugVar.Type); + // FIXME + // varName = "locals"; + } + else + { + typeIndex = _userDefinedTypeDescriptor.GetVariableTypeIndex(debugVar.Type); + } + } + catch (TypeSystemException) + { + typeIndex = 0; // T_NOTYPE + // FIXME + // Debug.Fail(); + } + return typeIndex; + } + + protected virtual ulong GetSectionVirtualAddress(int sectionIndex) => 0; + + private void EmitDebugFunctionInfo(ObjectNode node) + { + if (node is IMethodNode methodNode) + { + uint methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method); + string methodName = ExternCName(methodNode.GetMangledName(_nodeFactory.NameMangler)); + + if (node is INodeWithDebugInfo debugNode && + _definedSymbols.TryGetValue(methodName, out var methodSymbol)) + { + var lowPC = GetSectionVirtualAddress(methodSymbol.SectionIndex) + (ulong)methodSymbol.Value; + DebugEHClauseInfo[] clauses = null; + + if (node is INodeWithCodeInfo nodeWithCodeInfo) + { + clauses = nodeWithCodeInfo.DebugEHClauseInfos; + } + + _dwarfBuilder.EmitSubprogramInfo( + methodName, + lowPC, + methodSymbol.Size, + methodTypeIndex, + debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), + clauses ?? Array.Empty()); + + _dwarfBuilder.EmitLineInfo(lowPC, debugNode.GetNativeSequencePoints()); + } + } + } + + protected abstract void EmitSectionsAndLayout(); + + protected abstract void EmitObjectFile(string objectFilePath); + + protected abstract void EmitDebugSections(DwarfFile dwarfFile); + + protected IDictionary GetDefinedSymbols() => _definedSymbols; + + protected ISet GetUndefinedSymbols() + { + HashSet undefinedSymbolSet = new HashSet(); + foreach (var relocationList in _sectionIndexToRelocations) + foreach (var symbolicRelocation in relocationList) + { + if (!_definedSymbols.ContainsKey(symbolicRelocation.SymbolName)) + { + undefinedSymbolSet.Add(symbolicRelocation.SymbolName); + } + } + return undefinedSymbolSet; + } + + protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) + { + // Pre-create some of the sections + GetOrCreateSection(ObjectNodeSection.TextSection, out _, out _); + GetOrCreateSection(ObjectNodeSection.ManagedCodeUnixContentSection, out _, out _); + + // Create sections for exception handling + _lsdaSectionIndex = GetOrCreateSection(new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null), out _, out _); + _ehFrameSectionIndex = GetOrCreateSection(new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), out _, out _); + UpdateSectionAlignment(_lsdaSectionIndex, 8, out _); + UpdateSectionAlignment(_ehFrameSectionIndex, 8, out _); + + // We always use the same CIE in DWARF EH frames, so create and emit it now + bool is64Bit = _nodeFactory.Target.Architecture switch + { + TargetArchitecture.X86 => false, + TargetArchitecture.ARM => false, + _ => true + }; + _dwarfCie = new DwarfCie(_nodeFactory.Target.Architecture); + _dwarfEhFrame = new DwarfEhFrame( + _sectionIndexToStream[_ehFrameSectionIndex], + (offset, data, relocType, symbolName) => EmitRelocation( + _ehFrameSectionIndex, _sectionIndexToRelocations[_ehFrameSectionIndex], + offset, data, relocType, symbolName, 0), + is64Bit); + _dwarfEhFrame.AddCie(_dwarfCie); + + // Debugging + if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) + { + _dwarfBuilder = new DwarfBuilder(_nodeFactory.NameMangler, _nodeFactory.Target.Architecture); + _userDefinedTypeDescriptor = new UserDefinedTypeDescriptor(_dwarfBuilder, _nodeFactory); + } + + foreach (DependencyNode depNode in nodes) + { + ObjectNode node = depNode as ObjectNode; + if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) + { + continue; + } + + ObjectData nodeContents = node.GetData(_nodeFactory); + + Stream sectionStream; + List relocationList; + int sectionIndex = GetOrCreateSection(node.Section, out sectionStream, out relocationList); + + EmitAlignment(sectionIndex, sectionStream, nodeContents.Alignment); + + long methodStart = sectionStream.Position; + + foreach (ISymbolDefinitionNode n in nodeContents.DefinedSymbols) + { + var symbolDefinition = new SymbolDefinition( + sectionIndex, + methodStart + n.Offset, + n.Offset == 0 ? nodeContents.Data.Length : 0); + EmitSymbolDefinition(ExternCName(n.GetMangledName(_nodeFactory.NameMangler)), symbolDefinition); + if (_nodeFactory.GetSymbolAlternateName(n) is string alternateName) + { + EmitSymbolDefinition(ExternCName(alternateName), symbolDefinition); + } + } + + if (nodeContents.Relocs != null) + { + foreach (var reloc in nodeContents.Relocs) + { + EmitRelocation( + sectionIndex, + relocationList, + (int)(methodStart + reloc.Offset), + nodeContents.Data.AsSpan(reloc.Offset), + reloc.RelocType, + ExternCName(reloc.Target.GetMangledName(_nodeFactory.NameMangler)), + reloc.Target.Offset); + } + } + + sectionStream.Write(nodeContents.Data); + + // Emit unwinding frames and LSDA + if (node is INodeWithCodeInfo nodeWithCodeInfo) + { + EmitUnwindInfo(sectionIndex, methodStart, nodeWithCodeInfo); + } + + // Emit debug type information + if (node is ConstructedEETypeNode MethodTable && + _options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) + { + _userDefinedTypeDescriptor.GetTypeIndex(MethodTable.Type, needsCompleteType: true); + } + } + + EmitSectionsAndLayout(); + + EmitSymbolTable(); + + int relocSectionIndex = 0; + foreach (var relocationList in _sectionIndexToRelocations) + { + EmitRelocations(relocSectionIndex, relocationList); + relocSectionIndex++; + } + + if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) + { + foreach (DependencyNode depNode in nodes) + { + ObjectNode node = depNode as ObjectNode; + if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) + { + continue; + } + + EmitDebugFunctionInfo(node); + } + + EmitDebugSections(_dwarfBuilder.DwarfFile); + } + + EmitObjectFile(objectFilePath); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index d64ce30490b628..c2b2aab4e8b258 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -22,7 +22,7 @@ - + @@ -588,8 +588,16 @@ + + + + + + + + diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index e6ed38a4b83d4f..45c366bf435e9f 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -107,7 +107,14 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) if ((_compilationOptions & RyuJitCompilationOptions.ControlFlowGuardAnnotations) != 0) options |= ObjectWritingOptions.ControlFlowGuard; - LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + if (Environment.GetEnvironmentVariable("DOTNET_USE_LLVM_OBJWRITER") == "1") + LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + else if (NodeFactory.Target.OperatingSystem == TargetOS.OSX) + MachObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + else if (NodeFactory.Target.OperatingSystem == TargetOS.Linux) + ElfObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + else + LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); } protected override void ComputeDependencyNodeDependencies(List> obj) From a9ead973e4b94ccc8f08a242b8e933b99681d7ea Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 19 Oct 2022 15:18:48 +0200 Subject: [PATCH 005/144] Generate relocatable DWARF info in ELF, fix X64 register mapping --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 84 +++++++++-- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 142 ++++++++++++++++-- .../Compiler/ObjectWriter/MachObjectWriter.cs | 4 - .../Compiler/ObjectWriter/UnixObjectWriter.cs | 20 +-- .../Dwarf/DwarfLocationListEntry.cs | 4 +- 5 files changed, 215 insertions(+), 39 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 4134defa1ff4e6..34ccc2136ba09e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -25,7 +25,7 @@ internal sealed class DwarfBuilder : ITypesDebugInfoWriter private DwarfFile _dwarfFile; private DwarfDIECompileUnit _rootDIE; private DwarfLineProgramTable _lineTable; - private DwarfLineSequence _lineSequence; + private Dictionary _lineSequences = new(); private Dictionary _emittedFileName; private List _memberFunctionTypeInfos = new(); @@ -58,11 +58,8 @@ public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitectu _dwarfFile = new DwarfFile(); - _lineSequence = new DwarfLineSequence(); - _lineTable = new DwarfLineProgramTable(); _lineTable.AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; - _lineTable.AddLineSequence(_lineSequence); _rootDIE = new DwarfDIECompileUnit { @@ -460,14 +457,66 @@ public void AddVar(DebugVarInfoMetadata metadataInfo, DwarfDIE type) } }; + // TODO: Clean-up and share with R2R code + private enum RegNumAmd64 : int + { + REGNUM_RAX, + REGNUM_RCX, + REGNUM_RDX, + REGNUM_RBX, + REGNUM_RSP, + REGNUM_RBP, + REGNUM_RSI, + REGNUM_RDI, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_R13, + REGNUM_R14, + REGNUM_R15, + REGNUM_COUNT, + REGNUM_SP = REGNUM_RSP, + REGNUM_FP = REGNUM_RBP + }; + private int DwarfRegNum(int regNum) { - _ = _architecture; - if (regNum >= 33) - regNum = regNum - 33 + 64; // FP - // ARM64 - // FIXME: FP regs - return regNum; + if (_architecture == TargetArchitecture.ARM64) + { + // Normal registers are directly mapped + if (regNum >= 33) + regNum = regNum - 33 + 64; // FP + return regNum; + } + else if (_architecture == TargetArchitecture.X64) + { + return (RegNumAmd64)regNum switch + { + RegNumAmd64.REGNUM_RAX => 0, + RegNumAmd64.REGNUM_RDX => 1, + RegNumAmd64.REGNUM_RCX => 2, + RegNumAmd64.REGNUM_RBX => 3, + RegNumAmd64.REGNUM_RSI => 4, + RegNumAmd64.REGNUM_RDI => 5, + RegNumAmd64.REGNUM_RBP => 6, + RegNumAmd64.REGNUM_RSP => 7, + RegNumAmd64.REGNUM_R8 => 8, + RegNumAmd64.REGNUM_R9 => 9, + RegNumAmd64.REGNUM_R10 => 10, + RegNumAmd64.REGNUM_R11 => 11, + RegNumAmd64.REGNUM_R12 => 12, + RegNumAmd64.REGNUM_R13 => 13, + RegNumAmd64.REGNUM_R14 => 14, + RegNumAmd64.REGNUM_R15 => 15, + _ => regNum - (int)RegNumAmd64.REGNUM_COUNT + 17 // FP registers + }; + } + else + { + throw new NotSupportedException(); + } } @@ -723,8 +772,19 @@ public void EmitSubprogramInfo( _rootDIE.AddChild(subprogram); } - public void EmitLineInfo(ulong methodPCStart, IEnumerable sequencePoints) + public void EmitLineInfo(int sectionIndex, ulong methodPCStart, IEnumerable sequencePoints) { + DwarfLineSequence lineSequence; + + // Create line sequence for every section so they can get the + // base address relocated properly. + if (!_lineSequences.TryGetValue(sectionIndex, out lineSequence)) + { + lineSequence = new DwarfLineSequence(); + _lineTable.AddLineSequence(lineSequence); + _lineSequences.Add(sectionIndex, lineSequence); + } + foreach (var sequencePoint in sequencePoints) { DwarfFileName dwarfFileName; @@ -740,7 +800,7 @@ public void EmitLineInfo(ulong methodPCStart, IEnumerable s _lineTable.FileNames.Add(dwarfFileName); } - _lineSequence.Add(new DwarfLine + lineSequence.Add(new DwarfLine { File = dwarfFileName, Address = methodPCStart + (ulong)sequencePoint.NativeOffset, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index e507e78af73bbd..42423978acf281 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -52,9 +52,7 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) _objectFile = new ElfObjectFile(ElfArch.X86_64); var stringSection = new ElfStringTable(); - _objectFile.AddSection(stringSection); _symbolTable = new ElfSymbolTable { Link = stringSection }; - _objectFile.AddSection(_symbolTable); } protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) @@ -213,32 +211,154 @@ protected override void UpdateSectionAlignment(int sectionIndex, int alignment, isExecutable = elfSection.Flags.HasFlag(ElfSectionFlags.Executable); } - protected override void EmitDebugSections(DwarfFile dwarfFile) + protected override ulong GetSectionVirtualAddress(int sectionIndex) { - // TODO: Pretty much broken in all possible ways since we have multiple - // code sections and no LowPC relocations - - var elfDiagnostics = new DiagnosticBag(); - _objectFile.UpdateLayout(elfDiagnostics); + // Use file offset + return _sectionIndexToElfSection[sectionIndex].Offset; + } + protected override void EmitDebugSections(DwarfFile dwarfFile) + { foreach (var unit in dwarfFile.InfoSection.Units) { + var rootDIE = (DwarfDIECompileUnit)unit.Root; dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; dwarfFile.AddressRangeTable.Unit = unit; - dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, _objectFile.Layout.TotalSize)); + ulong lowPC = ulong.MaxValue; + ulong highPC = 0; + foreach (var elfSection in _objectFile.Sections) + { + if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) + { + dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, elfSection.Offset, elfSection.Size)); + lowPC = Math.Max(lowPC, elfSection.Offset); + highPC = Math.Max(highPC, elfSection.Offset + elfSection.Size); + } + } + rootDIE.LowPC = 0u; + rootDIE.HighPC = (int)highPC; + } + + var outputContext = new DwarfWriterContext + { + IsLittleEndian = _objectFile.Encoding == ElfEncoding.Lsb, + EnableRelocation = true, + AddressSize = _objectFile.FileClass == ElfFileClass.Is64 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32, + DebugLineStream = new MemoryStream(), + DebugAbbrevStream = new MemoryStream(), + DebugStringStream = new MemoryStream(), + DebugAddressRangeStream = new MemoryStream(), + DebugInfoStream = new MemoryStream(), + DebugLocationStream = new MemoryStream(), + }; + + dwarfFile.Write(outputContext); + + var debugInfoSection = new ElfBinarySection(outputContext.DebugInfoStream) { Name = ".debug_info", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugInfoRelocation = new ElfRelocationTable { Name = ".rela.debug_info", Link = _symbolTable, Info = debugInfoSection, Alignment = 8 }; + var debugAbbrevSection = new ElfBinarySection(outputContext.DebugAbbrevStream) { Name = ".debug_abbrev", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugAddressRangeSection = new ElfBinarySection(outputContext.DebugAddressRangeStream) { Name = ".debug_aranges", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugAddressRangeRelocation = new ElfRelocationTable { Name = ".rela.debug_aranges", Link = _symbolTable, Info = debugAddressRangeSection, Alignment = 8 }; + var debugStringSection = new ElfBinarySection(outputContext.DebugStringStream) { Name = ".debug_str", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugLineSection = new ElfBinarySection(outputContext.DebugLineStream) { Name = ".debug_line", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugLineRelocation = new ElfRelocationTable { Name = ".rela.debug_line", Link = _symbolTable, Info = debugLineSection, Alignment = 8 }; + var debugLocationSection = new ElfBinarySection(outputContext.DebugLocationStream) { Name = ".debug_loc", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugLocationRelocation = new ElfRelocationTable { Name = ".rela.debug_loc", Link = _symbolTable, Info = debugLocationSection, Alignment = 8 }; + + _objectFile.AddSection(debugInfoSection); + _objectFile.AddSection(debugInfoRelocation); + _objectFile.AddSection(debugAbbrevSection); + _objectFile.AddSection(debugAddressRangeSection); + _objectFile.AddSection(debugAddressRangeRelocation); + _objectFile.AddSection(debugStringSection); + _objectFile.AddSection(debugLineSection); + _objectFile.AddSection(debugLineRelocation); + _objectFile.AddSection(debugLocationSection); + _objectFile.AddSection(debugLocationRelocation); + + uint stringSectionIndex = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugStringSection }); + uint abbrevSectionIndex = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugAbbrevSection }); + uint infoSectionIndex = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugInfoSection }); + + Dictionary codeSectionToSymbolIndex = new(); + foreach (var elfSection in _objectFile.Sections) + { + if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) + { + codeSectionToSymbolIndex[elfSection] = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); + } } - var dwarfElfContext = new DwarfElfContext(_objectFile); - dwarfFile.WriteToElf(dwarfElfContext); + CopyRelocationsX64(dwarfFile.InfoSection, debugInfoRelocation); + CopyRelocationsX64(dwarfFile.AddressRangeTable, debugAddressRangeRelocation); + CopyRelocationsX64(dwarfFile.LineSection, debugLineRelocation); + CopyRelocationsX64(dwarfFile.LocationSection, debugLocationRelocation); + + void CopyRelocationsX64(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTable relocTable) + { + relocTable.Entries.Clear(); + + foreach (var reloc in dwarfRelocSection.Relocations) + { + if (reloc.Target != DwarfRelocationTarget.Code) + { + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; + + switch (reloc.Target) + { + case DwarfRelocationTarget.DebugString: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, stringSectionIndex, (long)reloc.Addend)); + break; + case DwarfRelocationTarget.DebugAbbrev: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, abbrevSectionIndex, (long)reloc.Addend)); + break; + case DwarfRelocationTarget.DebugInfo: + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, infoSectionIndex, (long)reloc.Addend)); + break; + default: + Debug.Fail("Unknown relocation"); + break; + } + } + } + + // TODO: Sort the relocations and then linerly walk the relocation and section list at the same time + foreach (var elfSection in _objectFile.Sections) + { + if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) + { + uint symbolIndex = codeSectionToSymbolIndex[elfSection]; + foreach (var reloc in dwarfRelocSection.Relocations) + { + if (reloc.Target == DwarfRelocationTarget.Code && + reloc.Addend >= elfSection.Offset && reloc.Addend < elfSection.Offset + elfSection.Size) + { + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, symbolIndex, (long)(reloc.Addend - elfSection.Offset))); + } + } + } + } + } } protected override void EmitSectionsAndLayout() { + _objectFile.AddSection(_symbolTable.Link.Section); + _objectFile.AddSection(_symbolTable); _objectFile.AddSection(new ElfSectionHeaderStringTable()); if (_bssStream != null) { _sectionIndexToElfSection[_bssSectionIndex].Size = (ulong)_bssStream.Length; } + + var elfDiagnostics = new DiagnosticBag(); + _objectFile.UpdateLayout(elfDiagnostics); + Debug.Assert(!elfDiagnostics.HasErrors); } protected override void EmitObjectFile(string objectFilePath) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index e2e3c8b170ee1c..f1f9574d7e13fe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -33,9 +33,6 @@ private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, private MachObjectFile _objectFile; private MachSegment _segment; - // Standard sections - private Dictionary _sectionIndexToMachSection = new(); - // Exception handling sections private MachSection _compactUnwindSection; private List _compactUnwindCodes = new(); @@ -159,7 +156,6 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect Attributes = attributes, }; - _sectionIndexToMachSection[_segment.Sections.Count] = machSection; sectionStream = machSection.GetWriteStream(); _segment.Sections.Add(machSection); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index ea79019ad77b7c..3dda681e906c02 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -304,7 +304,7 @@ private void EmitDebugFunctionInfo(ObjectNode node) debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? Array.Empty()); - _dwarfBuilder.EmitLineInfo(lowPC, debugNode.GetNativeSequencePoints()); + _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); } } } @@ -430,15 +430,6 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Wed, 19 Oct 2022 15:58:08 +0200 Subject: [PATCH 006/144] Fix writing base address with relocations --- .../LibObjectFile/Dwarf/DwarfLocationListEntry.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs index 96bf9e09bd602b..d3c262f84a81fc 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs @@ -57,8 +57,19 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext) protected override void Write(DwarfWriter writer) { - writer.WriteAddress(DwarfRelocationTarget.Code, Start); - writer.WriteAddress(DwarfRelocationTarget.Code, End); + bool isBaseAddress = + (writer.AddressSize == DwarfAddressSize.Bit64 && Start == ulong.MaxValue) || + (writer.AddressSize == DwarfAddressSize.Bit32 && Start == uint.MaxValue); + if (isBaseAddress) + { + writer.WriteUInt(Start); + writer.WriteAddress(DwarfRelocationTarget.Code, End); + } + else + { + writer.WriteAddress(DwarfRelocationTarget.Code, Start); + writer.WriteAddress(DwarfRelocationTarget.Code, End); + } if (Expression != null) { From f160dc883cdfaca00629a479adf14dbd44319800 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 19 Oct 2022 19:17:55 +0200 Subject: [PATCH 007/144] Emit information about static variables, minor DWARF fixes --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 95 +++++++++++++++---- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 22 +++-- 2 files changed, 93 insertions(+), 24 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 34ccc2136ba09e..1c7d932b4f53e2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -32,7 +32,7 @@ internal sealed class DwarfBuilder : ITypesDebugInfoWriter private List _memberFunctions = new(); private Dictionary _primitiveDwarfTypes = new(); private Dictionary<(uint, uint), uint> _simpleArrayDwarfTypes = new(); // (elementTypeIndex, size) -> arrayTypeIndex - //std::vector ClassesWithStaticFields; + private List<(DwarfDIEMember, StaticDataFieldDescriptor)> _staticFields = new(); public DwarfFile DwarfFile => _dwarfFile; @@ -146,11 +146,22 @@ public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) } else { - _rootDIE.AddChild(new DwarfDIEPointerType + if (pointerDescriptor.IsReference == 1) { - Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], - ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, - }); + _rootDIE.AddChild(new DwarfDIEReferenceType + { + Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], + ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, + }); + } + else + { + _rootDIE.AddChild(new DwarfDIEPointerType + { + Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], + ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, + }); + } } return (uint)_rootDIE.Children.Count; @@ -297,19 +308,30 @@ public uint GetCompleteClassTypeIndex( }); } + int staticIndex = 0; foreach (DataFieldDescriptor fieldDescriptor in fields) { - if (fieldDescriptor.Offset != 0xFFFFFFFFu) + _dwarfFile.StringTable.GetOrCreateString(fieldDescriptor.Name); + + var member = new DwarfDIEMember { - _dwarfFile.StringTable.GetOrCreateString(fieldDescriptor.Name); + Name = fieldDescriptor.Name, + Type = _rootDIE.Children[(int)fieldDescriptor.FieldTypeIndex - 1], + }; - classType.AddChild(new DwarfDIEMember - { - Name = fieldDescriptor.Name, - Type = _rootDIE.Children[(int)fieldDescriptor.FieldTypeIndex - 1], - DataMemberLocation = new DwarfLocation((int)fieldDescriptor.Offset), - }); + if (fieldDescriptor.Offset != 0xFFFFFFFFu) + { + member.DataMemberLocation = new DwarfLocation((int)fieldDescriptor.Offset); + } + else + { + member.Declaration = true; + member.AddAttribute(new DwarfAttribute { Kind = DwarfAttributeKind.External, ValueAsU64 = 1 }); + _staticFields.Add((member, statics[staticIndex])); + staticIndex++; } + + classType.AddChild(member); } // TODO: static members @@ -646,10 +668,6 @@ private DwarfDIE EmitVar(DebugVarInfoMetadata metadataInfo, ulong methodPCStart, Expression = e, }); } - else - { - Console.WriteLine("F: " + metadataInfo.Name); - } } _dwarfFile.LocationSection.AddLocationList(locationList); location = locationList; @@ -809,5 +827,48 @@ public void EmitLineInfo(int sectionIndex, ulong methodPCStart, IEnumerable resolveNameToAddress) + { + foreach (var (memberSpec, staticVarInfo) in _staticFields) + { + var staticAddress = resolveNameToAddress(staticVarInfo.StaticDataName); + + if (staticAddress == 0) + { + continue; + } + + var expression = new DwarfExpression(); + expression.AddOperation(new DwarfOperation + { + Kind = DwarfOperationKind.Addr, + Operand1 = { U64 = staticAddress }, + }); + + if (staticVarInfo.IsStaticDataInObject == 1) + { + expression.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); + expression.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); + } + + if (staticVarInfo.StaticOffset != 0) + { + expression.AddOperation(new DwarfOperation + { + Kind = DwarfOperationKind.PlusUconst, + Operand1 = { U64 = staticVarInfo.StaticOffset }, + }); + } + + var variable = new DwarfDIEVariable + { + Specification = memberSpec, + Location = new DwarfLocation(expression), + }; + + _rootDIE.AddChild(variable); + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 3dda681e906c02..51d36c2c5ca7ae 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -419,13 +419,6 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection + { + if (_definedSymbols.TryGetValue(ExternCName(symbolName), out var symbolDef)) + return GetSectionVirtualAddress(symbolDef.SectionIndex) + (ulong)symbolDef.Value; + return 0; + } + ); + EmitDebugSections(_dwarfBuilder.DwarfFile); } From 490495d991f0d4df673eb026ffdf201f33fa7e72 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 19 Oct 2022 21:47:36 +0200 Subject: [PATCH 008/144] Fix generated section layout in symbol table for Mach-O after EmitSymbolTable was moved past EmitDebugSections --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index f1f9574d7e13fe..8f2f2373bf76a4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -560,8 +560,6 @@ protected override ulong GetSectionVirtualAddress(int sectionIndex) protected override void EmitDebugSections(DwarfFile dwarfFile) { - _objectFile.UpdateLayout(); - ulong highPC = 0; foreach (var machSection in _segment.Sections) { @@ -609,6 +607,8 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) _segment.Sections.Add(debugStringSection); _segment.Sections.Add(debugLineSection); _segment.Sections.Add(debugLocationSection); + + _objectFile.UpdateLayout(); } public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) From 685fcb867a11b965cfb1b446264f670f7e4583a0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 19 Oct 2022 22:47:23 +0000 Subject: [PATCH 009/144] Add support for ARM64 ELF --- .../Compiler/ObjectWriter/DwarfFde.cs | 13 ++- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 106 ++++++++++++++++-- 2 files changed, 106 insertions(+), 13 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs index abdc6aa190ed1f..d209c7443eb49b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs @@ -105,7 +105,18 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) while (temp > 0); break; - // TODO: CFI_DEF_CFA + case CFI_OPCODE.CFI_DEF_CFA: + cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa; + cfiCode[cfiCodeOffset++] = (byte)dwarfReg; + cfaOffset = cfiOffset; + temp = (uint)(cfaOffset); + do + { + cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); + temp >>= 7; + } + while (temp > 0); + break; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 42423978acf281..65b9aa0f4eb471 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -44,12 +44,14 @@ public sealed class ElfObjectWriter : UnixObjectWriter private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { - if (factory.Target.Architecture != TargetArchitecture.X64) + ElfArch arch = factory.Target.Architecture switch { - throw new NotSupportedException("Unsupported architecture"); - } + TargetArchitecture.X64 => ElfArch.X86_64, + TargetArchitecture.ARM64 => ElfArch.AARCH64, + _ => throw new NotSupportedException("Unsupported architecture") + }; - _objectFile = new ElfObjectFile(ElfArch.X86_64); + _objectFile = new ElfObjectFile(arch); var stringSection = new ElfStringTable(); _symbolTable = new ElfSymbolTable { Link = stringSection }; @@ -83,7 +85,8 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect ElfSection elfSection = new ElfBinarySection(sectionStream) { Name = sectionName, - Type = section.Name == ".eh_frame" ? (ElfSectionType)ElfNative.SHT_IA_64_UNWIND : ElfSectionType.ProgBits, + Type = section.Name == ".eh_frame" && _objectFile.Arch == ElfArch.X86_64 ? + (ElfSectionType)ElfNative.SHT_IA_64_UNWIND : ElfSectionType.ProgBits, Flags = section.Type == SectionType.Executable ? ElfSectionFlags.Alloc | ElfSectionFlags.Executable : (section.Type == SectionType.Writeable ? ElfSectionFlags.Alloc | ElfSectionFlags.Write : @@ -126,6 +129,17 @@ protected override void EmitRelocation( addend += checked((int)a); BinaryPrimitives.WriteUInt64LittleEndian(data, 0); } + else if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || + relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || + relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + { + // NOTE: Zero addend in code is currently always used for these. + // R2R object writer has the same assumption. + } + else + { + throw new NotSupportedException($"Unsupported relocation: {relocType}"); + } relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } @@ -168,6 +182,58 @@ protected override void EmitSymbolTable() } protected override void EmitRelocations(int sectionIndex, List relocationList) + { + switch ((ElfArch)_objectFile.Arch) + { + case ElfArch.X86_64: + EmitRelocationsX64(sectionIndex, relocationList); + break; + case ElfArch.AARCH64: + EmitRelocationsARM64(sectionIndex, relocationList); + break; + default: + Debug.Fail("Unsupported architecture"); + break; + } + } + + private void EmitRelocationsARM64(int sectionIndex, List relocationList) + { + var elfSection = _sectionIndexToElfSection[sectionIndex]; + if (_sectionToRelocationTable.TryGetValue(elfSection, out var relocationTable)) + { + foreach (var symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + + ElfRelocationType type = symbolicRelocation.Type switch { + RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_AARCH64_ABS64, + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfRelocationType.R_AARCH64_ABS32, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_AARCH64_PREL32, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfRelocationType.R_AARCH64_CALL26, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfRelocationType.R_AARCH64_ADR_PREL_PG_HI21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfRelocationType.R_AARCH64_ADD_ABS_LO12_NC, + _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) + }; + + var addend = symbolicRelocation.Addend; + + relocationTable.Entries.Add(new ElfRelocation + { + SymbolIndex = symbolIndex, + Type = type, + Offset = (ulong)symbolicRelocation.Offset, + Addend = addend + }); + } + } + else + { + Debug.Assert(relocationList.Count == 0); + } + } + + private void EmitRelocationsX64(int sectionIndex, List relocationList) { var elfSection = _sectionIndexToElfSection[sectionIndex]; if (_sectionToRelocationTable.TryGetValue(elfSection, out var relocationTable)) @@ -293,12 +359,28 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) } } - CopyRelocationsX64(dwarfFile.InfoSection, debugInfoRelocation); - CopyRelocationsX64(dwarfFile.AddressRangeTable, debugAddressRangeRelocation); - CopyRelocationsX64(dwarfFile.LineSection, debugLineRelocation); - CopyRelocationsX64(dwarfFile.LocationSection, debugLocationRelocation); + ElfRelocationType reloc32, reloc64; + + switch ((ElfArch)_objectFile.Arch) + { + case ElfArch.X86_64: + reloc32 = ElfRelocationType.R_X86_64_32; + reloc64 = ElfRelocationType.R_X86_64_64; + break; + case ElfArch.AARCH64: + reloc32 = ElfRelocationType.R_AARCH64_ABS32; + reloc64 = ElfRelocationType.R_AARCH64_ABS64; + break; + default: + throw new NotSupportedException("Unsupported architecture"); + } + + CopyRelocations(dwarfFile.InfoSection, debugInfoRelocation); + CopyRelocations(dwarfFile.AddressRangeTable, debugAddressRangeRelocation); + CopyRelocations(dwarfFile.LineSection, debugLineRelocation); + CopyRelocations(dwarfFile.LocationSection, debugLocationRelocation); - void CopyRelocationsX64(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTable relocTable) + void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTable relocTable) { relocTable.Entries.Clear(); @@ -306,7 +388,7 @@ void CopyRelocationsX64(DwarfRelocatableSection dwarfRelocSection, ElfRelocation { if (reloc.Target != DwarfRelocationTarget.Code) { - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; switch (reloc.Target) { @@ -337,7 +419,7 @@ void CopyRelocationsX64(DwarfRelocatableSection dwarfRelocSection, ElfRelocation if (reloc.Target == DwarfRelocationTarget.Code && reloc.Addend >= elfSection.Offset && reloc.Addend < elfSection.Offset + elfSection.Size) { - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, symbolIndex, (long)(reloc.Addend - elfSection.Offset))); } } From ff0d3827ab36eab32c09c8e8bb6c8dda869d623d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 20 Oct 2022 15:54:28 +0200 Subject: [PATCH 010/144] Add ObjectWriter class and derive UnixObjectWriter from it --- .../Compiler/ObjectWriter/ObjectWriter.cs | 328 +++++++++++++++++ .../Compiler/ObjectWriter/UnixObjectWriter.cs | 337 +++--------------- .../ILCompiler.Compiler.csproj | 1 + 3 files changed, 378 insertions(+), 288 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs new file mode 100644 index 00000000000000..4e2561a56f7d38 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -0,0 +1,328 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Linq; +using System.Numerics; +using System.Buffers; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +namespace ILCompiler.ObjectWriter +{ + public abstract class ObjectWriter : IDisposable + { + protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0); + protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); + + protected NodeFactory _nodeFactory; + protected ObjectWritingOptions _options; + + private byte _insPaddingByte; + + // Standard sections + private Dictionary _sectionNameToSectionIndex = new(); + private List _sectionIndexToStream = new(); + private List> _sectionIndexToRelocations = new(); + + // Symbol table + private Dictionary _definedSymbols = new(); + + // Debugging + private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; + + protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) + { + _nodeFactory = factory; + _options = options; + + // Padding byte for code sections (NOP for x86/x64) + _insPaddingByte = factory.Target.Architecture switch + { + TargetArchitecture.X86 => 0x90, + TargetArchitecture.X64 => 0x90, + _ => 0 + }; + } + + public void Dispose() + { + // Close all the streams + foreach (var sectionStream in _sectionIndexToStream) + { + sectionStream.Close(); + } + } + + protected abstract void CreateSection(ObjectNodeSection section, out Stream sectionStream); + + protected abstract void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable); + + protected int GetOrCreateSection( + ObjectNodeSection section, + out Stream sectionStream, + out List relocationList) + { + int sectionIndex; + + if (!_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) + { + CreateSection(section, out sectionStream); + sectionIndex = _sectionNameToSectionIndex.Count; + _sectionNameToSectionIndex[section.Name] = sectionIndex; + _sectionIndexToStream.Add(sectionStream); + _sectionIndexToRelocations.Add(relocationList = new()); + } + else + { + sectionStream = _sectionIndexToStream[sectionIndex]; + relocationList = _sectionIndexToRelocations[sectionIndex]; + } + + return sectionIndex; + } + + protected void GetSection( + int sectionIndex, + out Stream sectionStream, + out List relocationList) + { + sectionStream = _sectionIndexToStream[sectionIndex]; + relocationList = _sectionIndexToRelocations[sectionIndex]; + } + + protected abstract void EmitRelocation( + int sectionIndex, + List relocationList, + int offset, + Span data, + RelocType relocType, + string symbolName, + int addend); + + /// + /// Emit symbolic definitions into object file symbols. + /// + protected abstract void EmitSymbolTable(); + + /// + /// Emit symbolic relocations into object file as format specific + /// relocations. + /// + /// + /// This methods is guaranteed to run after . + /// + protected abstract void EmitRelocations(int sectionIndex, List relocationList); + + protected virtual string ExternCName(string name) => name; + + protected void EmitSymbolDefinition(string name, SymbolDefinition definition) + { + _definedSymbols.Add(name, definition); + } + + protected abstract void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo); + + protected void EmitAlignment(int sectionIndex, Stream sectionStream, int alignment) + { + UpdateSectionAlignment(sectionIndex, alignment, out bool isExecutable); + + int padding = (int)(((sectionStream.Position + alignment - 1) & ~(alignment - 1)) - sectionStream.Position); + Span buffer = stackalloc byte[padding]; + byte paddingByte = isExecutable ? _insPaddingByte : (byte)0; + buffer.Fill(paddingByte); + sectionStream.Write(buffer); + } + + protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) + { + uint typeIndex; + try + { + if (isStateMachineMoveNextMethod && debugVar.DebugVarInfo.VarNumber == 0) + { + typeIndex = _userDefinedTypeDescriptor.GetStateMachineThisVariableTypeIndex(debugVar.Type); + // FIXME + // varName = "locals"; + } + else + { + typeIndex = _userDefinedTypeDescriptor.GetVariableTypeIndex(debugVar.Type); + } + } + catch (TypeSystemException) + { + typeIndex = 0; // T_NOTYPE + // FIXME + // Debug.Fail(); + } + return typeIndex; + } + + protected abstract void EmitSectionsAndLayout(); + + protected abstract void EmitObjectFile(string objectFilePath); + + protected abstract void CreateEhSections(); + + protected IDictionary GetDefinedSymbols() => _definedSymbols; + + protected ISet GetUndefinedSymbols() + { + HashSet undefinedSymbolSet = new HashSet(); + foreach (var relocationList in _sectionIndexToRelocations) + foreach (var symbolicRelocation in relocationList) + { + if (!_definedSymbols.ContainsKey(symbolicRelocation.SymbolName)) + { + undefinedSymbolSet.Add(symbolicRelocation.SymbolName); + } + } + return undefinedSymbolSet; + } + + protected abstract ITypesDebugInfoWriter CreateDebugInfoBuilder(); + + protected virtual ulong GetSectionVirtualAddress(int sectionIndex) => 0; + + protected abstract void EmitDebugFunctionInfo( + uint methodTypeIndex, + string methodName, + SymbolDefinition methodSymbol, + INodeWithDebugInfo debugNode); + + protected abstract void EmitDebugSections(); + + protected abstract void EmitDebugStaticVars(); + + protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) + { + // Pre-create some of the sections + GetOrCreateSection(ObjectNodeSection.TextSection, out _, out _); + GetOrCreateSection(ObjectNodeSection.ManagedCodeUnixContentSection, out _, out _); + + // Create sections for exception handling + CreateEhSections(); + + // Debugging + if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) + { + _userDefinedTypeDescriptor = new UserDefinedTypeDescriptor(CreateDebugInfoBuilder(), _nodeFactory); + } + + foreach (DependencyNode depNode in nodes) + { + ObjectNode node = depNode as ObjectNode; + if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) + { + continue; + } + + ObjectData nodeContents = node.GetData(_nodeFactory); + + Stream sectionStream; + List relocationList; + int sectionIndex = GetOrCreateSection(node.Section, out sectionStream, out relocationList); + + EmitAlignment(sectionIndex, sectionStream, nodeContents.Alignment); + + long methodStart = sectionStream.Position; + + foreach (ISymbolDefinitionNode n in nodeContents.DefinedSymbols) + { + var symbolDefinition = new SymbolDefinition( + sectionIndex, + methodStart + n.Offset, + n.Offset == 0 ? nodeContents.Data.Length : 0); + EmitSymbolDefinition(ExternCName(n.GetMangledName(_nodeFactory.NameMangler)), symbolDefinition); + if (_nodeFactory.GetSymbolAlternateName(n) is string alternateName) + { + EmitSymbolDefinition(ExternCName(alternateName), symbolDefinition); + } + } + + if (nodeContents.Relocs != null) + { + foreach (var reloc in nodeContents.Relocs) + { + EmitRelocation( + sectionIndex, + relocationList, + (int)(methodStart + reloc.Offset), + nodeContents.Data.AsSpan(reloc.Offset), + reloc.RelocType, + ExternCName(reloc.Target.GetMangledName(_nodeFactory.NameMangler)), + reloc.Target.Offset); + } + } + + sectionStream.Write(nodeContents.Data); + + // Emit unwinding frames and LSDA + if (node is INodeWithCodeInfo nodeWithCodeInfo) + { + EmitUnwindInfo(sectionIndex, methodStart, nodeWithCodeInfo); + } + } + + EmitSectionsAndLayout(); + + if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) + { + foreach (DependencyNode depNode in nodes) + { + ObjectNode node = depNode as ObjectNode; + if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) + { + continue; + } + + // Emit debug type information + if (node is ConstructedEETypeNode methodTable) + { + _userDefinedTypeDescriptor.GetTypeIndex(methodTable.Type, needsCompleteType: true); + } + + if (node is IMethodNode methodNode) + { + uint methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method); + string methodName = ExternCName(methodNode.GetMangledName(_nodeFactory.NameMangler)); + + if (node is INodeWithDebugInfo debugNode && + _definedSymbols.TryGetValue(methodName, out var methodSymbol)) + { + EmitDebugFunctionInfo(methodTypeIndex, methodName, methodSymbol, debugNode); + } + } + } + + EmitDebugStaticVars(); + + EmitDebugSections(); + } + + EmitSymbolTable(); + + int relocSectionIndex = 0; + foreach (var relocationList in _sectionIndexToRelocations) + { + EmitRelocations(relocSectionIndex, relocationList); + relocSectionIndex++; + } + + EmitObjectFile(objectFilePath); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 51d36c2c5ca7ae..6317d1309cc9eb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -26,24 +26,10 @@ namespace ILCompiler.ObjectWriter { - public abstract class UnixObjectWriter : IDisposable + public abstract class UnixObjectWriter : ObjectWriter { - protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0); - protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); - - private NodeFactory _nodeFactory; - private ObjectWritingOptions _options; - // Debugging private DwarfBuilder _dwarfBuilder; - private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; - - private byte _insPaddingByte; - - // Standard sections - private Dictionary _sectionNameToSectionIndex = new(); - private List _sectionIndexToStream = new(); - private List> _sectionIndexToRelocations = new(); // Exception handling sections private int _lsdaSectionIndex; @@ -51,104 +37,28 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy private DwarfCie _dwarfCie; private DwarfEhFrame _dwarfEhFrame; - // Symbol table - private Dictionary _definedSymbols = new(); - protected int EhFrameSectionIndex => _ehFrameSectionIndex; protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) + : base(factory, options) { - _nodeFactory = factory; - _options = options; - - // Padding byte for code sections (NOP for x86/x64) - _insPaddingByte = factory.Target.Architecture switch - { - TargetArchitecture.X86 => 0x90, - TargetArchitecture.X64 => 0x90, - _ => 0 - }; - } - - public void Dispose() - { - // Close all the streams - foreach (var sectionStream in _sectionIndexToStream) - { - sectionStream.Close(); - } - } - - protected abstract void CreateSection(ObjectNodeSection section, out Stream sectionStream); - - protected abstract void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable); - - protected int GetOrCreateSection( - ObjectNodeSection section, - out Stream sectionStream, - out List relocationList) - { - int sectionIndex; - - if (!_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) - { - CreateSection(section, out sectionStream); - sectionIndex = _sectionNameToSectionIndex.Count; - _sectionNameToSectionIndex[section.Name] = sectionIndex; - _sectionIndexToStream.Add(sectionStream); - _sectionIndexToRelocations.Add(relocationList = new()); - } - else - { - sectionStream = _sectionIndexToStream[sectionIndex]; - relocationList = _sectionIndexToRelocations[sectionIndex]; - } - - return sectionIndex; - } - - protected abstract void EmitRelocation( - int sectionIndex, - List relocationList, - int offset, - Span data, - RelocType relocType, - string symbolName, - int addend); - - /// - /// Emit symbolic definitions into object file symbols. - /// - protected abstract void EmitSymbolTable(); - - /// - /// Emit symbolic relocations into object file as format specific - /// relocations. - /// - /// - /// This methods is guaranteed to run after . - /// - protected abstract void EmitRelocations(int sectionIndex, List relocationList); - - protected virtual string ExternCName(string name) => name; - - protected void EmitSymbolDefinition(string name, SymbolDefinition definition) - { - _definedSymbols.Add(name, definition); } protected virtual bool EmitCompactUnwinding(DwarfFde fde) => false; - private void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) + protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) { if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { - var lsdaStream = _sectionIndexToStream[_lsdaSectionIndex]; + Stream lsdaStream; + List lsdaRelocations; Span tempBuffer = stackalloc byte[4]; - long mainLsdaOffset = lsdaStream.Position; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); + GetSection(_lsdaSectionIndex, out lsdaStream, out lsdaRelocations); + long mainLsdaOffset = lsdaStream.Position; + for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; @@ -196,7 +106,7 @@ private void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInf tempBuffer.Clear(); EmitRelocation( _lsdaSectionIndex, - _sectionIndexToRelocations[_lsdaSectionIndex], + lsdaRelocations, (int)lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, @@ -211,7 +121,7 @@ private void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInf tempBuffer.Clear(); EmitRelocation( _lsdaSectionIndex, - _sectionIndexToRelocations[_lsdaSectionIndex], + lsdaRelocations, (int)lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, @@ -240,106 +150,45 @@ private void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInf } } - private void EmitAlignment(int sectionIndex, Stream sectionStream, int alignment) + protected override void EmitDebugFunctionInfo( + uint methodTypeIndex, + string methodName, + SymbolDefinition methodSymbol, + INodeWithDebugInfo debugNode) { - UpdateSectionAlignment(sectionIndex, alignment, out bool isExecutable); + var lowPC = GetSectionVirtualAddress(methodSymbol.SectionIndex) + (ulong)methodSymbol.Value; + DebugEHClauseInfo[] clauses = null; - int padding = (int)(((sectionStream.Position + alignment - 1) & ~(alignment - 1)) - sectionStream.Position); - Span buffer = stackalloc byte[padding]; - byte paddingByte = isExecutable ? _insPaddingByte : (byte)0; - buffer.Fill(paddingByte); - sectionStream.Write(buffer); - } - - private uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) - { - uint typeIndex; - try + if (debugNode is INodeWithCodeInfo nodeWithCodeInfo) { - if (isStateMachineMoveNextMethod && debugVar.DebugVarInfo.VarNumber == 0) - { - typeIndex = _userDefinedTypeDescriptor.GetStateMachineThisVariableTypeIndex(debugVar.Type); - // FIXME - // varName = "locals"; - } - else - { - typeIndex = _userDefinedTypeDescriptor.GetVariableTypeIndex(debugVar.Type); - } + clauses = nodeWithCodeInfo.DebugEHClauseInfos; } - catch (TypeSystemException) - { - typeIndex = 0; // T_NOTYPE - // FIXME - // Debug.Fail(); - } - return typeIndex; - } - protected virtual ulong GetSectionVirtualAddress(int sectionIndex) => 0; + _dwarfBuilder.EmitSubprogramInfo( + methodName, + lowPC, + methodSymbol.Size, + methodTypeIndex, + debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), + clauses ?? Array.Empty()); - private void EmitDebugFunctionInfo(ObjectNode node) - { - if (node is IMethodNode methodNode) - { - uint methodTypeIndex = _userDefinedTypeDescriptor.GetMethodFunctionIdTypeIndex(methodNode.Method); - string methodName = ExternCName(methodNode.GetMangledName(_nodeFactory.NameMangler)); - - if (node is INodeWithDebugInfo debugNode && - _definedSymbols.TryGetValue(methodName, out var methodSymbol)) - { - var lowPC = GetSectionVirtualAddress(methodSymbol.SectionIndex) + (ulong)methodSymbol.Value; - DebugEHClauseInfo[] clauses = null; - - if (node is INodeWithCodeInfo nodeWithCodeInfo) - { - clauses = nodeWithCodeInfo.DebugEHClauseInfos; - } - - _dwarfBuilder.EmitSubprogramInfo( - methodName, - lowPC, - methodSymbol.Size, - methodTypeIndex, - debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), - clauses ?? Array.Empty()); - - _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); - } - } + _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); } - protected abstract void EmitSectionsAndLayout(); - - protected abstract void EmitObjectFile(string objectFilePath); - protected abstract void EmitDebugSections(DwarfFile dwarfFile); - protected IDictionary GetDefinedSymbols() => _definedSymbols; - - protected ISet GetUndefinedSymbols() + protected override void EmitDebugSections() { - HashSet undefinedSymbolSet = new HashSet(); - foreach (var relocationList in _sectionIndexToRelocations) - foreach (var symbolicRelocation in relocationList) - { - if (!_definedSymbols.ContainsKey(symbolicRelocation.SymbolName)) - { - undefinedSymbolSet.Add(symbolicRelocation.SymbolName); - } - } - return undefinedSymbolSet; + EmitDebugSections(_dwarfBuilder.DwarfFile); } - protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) + protected override void CreateEhSections() { - // Pre-create some of the sections - GetOrCreateSection(ObjectNodeSection.TextSection, out _, out _); - GetOrCreateSection(ObjectNodeSection.ManagedCodeUnixContentSection, out _, out _); - // Create sections for exception handling _lsdaSectionIndex = GetOrCreateSection(new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null), out _, out _); - _ehFrameSectionIndex = GetOrCreateSection(new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), out _, out _); + _ehFrameSectionIndex = GetOrCreateSection( + new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), + out var ehFrameStream, out var ehFrameRelocations); UpdateSectionAlignment(_lsdaSectionIndex, 8, out _); UpdateSectionAlignment(_ehFrameSectionIndex, 8, out _); @@ -352,118 +201,30 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection EmitRelocation( - _ehFrameSectionIndex, _sectionIndexToRelocations[_ehFrameSectionIndex], + _ehFrameSectionIndex, ehFrameRelocations, offset, data, relocType, symbolName, 0), is64Bit); _dwarfEhFrame.AddCie(_dwarfCie); + } - // Debugging - if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) - { - _dwarfBuilder = new DwarfBuilder(_nodeFactory.NameMangler, _nodeFactory.Target.Architecture); - _userDefinedTypeDescriptor = new UserDefinedTypeDescriptor(_dwarfBuilder, _nodeFactory); - } - - foreach (DependencyNode depNode in nodes) - { - ObjectNode node = depNode as ObjectNode; - if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) - { - continue; - } - - ObjectData nodeContents = node.GetData(_nodeFactory); - - Stream sectionStream; - List relocationList; - int sectionIndex = GetOrCreateSection(node.Section, out sectionStream, out relocationList); - - EmitAlignment(sectionIndex, sectionStream, nodeContents.Alignment); - - long methodStart = sectionStream.Position; - - foreach (ISymbolDefinitionNode n in nodeContents.DefinedSymbols) - { - var symbolDefinition = new SymbolDefinition( - sectionIndex, - methodStart + n.Offset, - n.Offset == 0 ? nodeContents.Data.Length : 0); - EmitSymbolDefinition(ExternCName(n.GetMangledName(_nodeFactory.NameMangler)), symbolDefinition); - if (_nodeFactory.GetSymbolAlternateName(n) is string alternateName) - { - EmitSymbolDefinition(ExternCName(alternateName), symbolDefinition); - } - } - - if (nodeContents.Relocs != null) - { - foreach (var reloc in nodeContents.Relocs) - { - EmitRelocation( - sectionIndex, - relocationList, - (int)(methodStart + reloc.Offset), - nodeContents.Data.AsSpan(reloc.Offset), - reloc.RelocType, - ExternCName(reloc.Target.GetMangledName(_nodeFactory.NameMangler)), - reloc.Target.Offset); - } - } - - sectionStream.Write(nodeContents.Data); - - // Emit unwinding frames and LSDA - if (node is INodeWithCodeInfo nodeWithCodeInfo) - { - EmitUnwindInfo(sectionIndex, methodStart, nodeWithCodeInfo); - } - } - - EmitSectionsAndLayout(); + protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() + { + return _dwarfBuilder = new DwarfBuilder(_nodeFactory.NameMangler, _nodeFactory.Target.Architecture); + } - if (_options.HasFlag(ObjectWritingOptions.GenerateDebugInfo)) - { - foreach (DependencyNode depNode in nodes) + protected override void EmitDebugStaticVars() + { + var definedSymbols = GetDefinedSymbols(); + _dwarfBuilder.EmitStaticVars( + symbolName => { - ObjectNode node = depNode as ObjectNode; - if (node == null || node.ShouldSkipEmittingObjectNode(_nodeFactory)) - { - continue; - } - - // Emit debug type information - if (node is ConstructedEETypeNode methodTable) - { - _userDefinedTypeDescriptor.GetTypeIndex(methodTable.Type, needsCompleteType: true); - } - - EmitDebugFunctionInfo(node); + if (definedSymbols.TryGetValue(ExternCName(symbolName), out var symbolDef)) + return GetSectionVirtualAddress(symbolDef.SectionIndex) + (ulong)symbolDef.Value; + return 0; } - - _dwarfBuilder.EmitStaticVars( - symbolName => - { - if (_definedSymbols.TryGetValue(ExternCName(symbolName), out var symbolDef)) - return GetSectionVirtualAddress(symbolDef.SectionIndex) + (ulong)symbolDef.Value; - return 0; - } - ); - - EmitDebugSections(_dwarfBuilder.DwarfFile); - } - - EmitSymbolTable(); - - int relocSectionIndex = 0; - foreach (var relocationList in _sectionIndexToRelocations) - { - EmitRelocations(relocSectionIndex, relocationList); - relocSectionIndex++; - } - - EmitObjectFile(objectFilePath); + ); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index c2b2aab4e8b258..5e5e7f025af48a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -594,6 +594,7 @@ + From fc31d42894197af5e75ca0bd9e152eff854f745d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 21 Oct 2022 14:54:06 +0200 Subject: [PATCH 011/144] Add initial take on CoffObjectWriter --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 583 ++++++++++++++++++ .../Compiler/ObjectWriter/ObjectWriter.cs | 9 +- .../ILCompiler.Compiler.csproj | 1 + .../Compiler/RyuJitCompilation.cs | 2 + 4 files changed, 594 insertions(+), 1 deletion(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs new file mode 100644 index 00000000000000..8b7a6a74f8f10f --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -0,0 +1,583 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Numerics; +using System.Reflection.PortableExecutable; +using System.Runtime.InteropServices; +using System.Text; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +namespace ILCompiler.ObjectWriter +{ + public class CoffObjectWriter : ObjectWriter + { + private Machine _machine; + private List<(CoffSectionHeader Header, Stream Stream)> _sections = new(); + private List _symbols = new(); + private Dictionary _symbolNameToIndex = new(); + + private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); + + protected CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) + : base(factory, options) + { + _machine = factory.Target.Architecture switch + { + TargetArchitecture.X64 => Machine.Amd64, + TargetArchitecture.ARM64 => Machine.Arm64, + _ => throw new NotSupportedException("Unsupported architecture") + }; + } + + protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + { + var sectionHeader = new CoffSectionHeader + { + Name = section.Name.StartsWith(".") ? section.Name : "." + section.Name, + SectionCharacteristics = section.Type switch + { + SectionType.ReadOnly => + SectionCharacteristics.MemRead | SectionCharacteristics.ContainsInitializedData, + SectionType.Writeable => + SectionCharacteristics.MemRead | SectionCharacteristics.MemWrite | + SectionCharacteristics.ContainsInitializedData, + SectionType.Executable => + SectionCharacteristics.MemRead | SectionCharacteristics.MemExecute | + SectionCharacteristics.ContainsCode, + _ => 0 + } + }; + + if (section.Name == "bss") + { + sectionHeader.SectionCharacteristics = + SectionCharacteristics.MemRead | SectionCharacteristics.MemWrite | + SectionCharacteristics.ContainsUninitializedData; + } + + sectionStream = new MemoryStream(); + _sections.Add((sectionHeader, sectionStream)); + } + + protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) + { + Debug.Assert(alignment > 0 && BitOperations.IsPow2((uint)alignment)); + int minimumAlignment = BitOperations.Log2((uint)alignment) << 20; + int currentAlignment = (int)(_sections[sectionIndex].Header.SectionCharacteristics & SectionCharacteristics.AlignMask); + + if (currentAlignment < minimumAlignment) + { + _sections[sectionIndex].Header.SectionCharacteristics = + (_sections[sectionIndex].Header.SectionCharacteristics & ~SectionCharacteristics.AlignMask) | + (SectionCharacteristics)minimumAlignment; + } + + isExecutable = _sections[sectionIndex].Header.SectionCharacteristics.HasFlag(SectionCharacteristics.MemExecute); + } + + protected override void EmitRelocation( + int sectionIndex, + List relocationList, + int offset, + Span data, + RelocType relocType, + string symbolName, + int addend) + { + if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || + relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || + relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + { + Debug.Assert(addend == 0); + } + else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) + { + if (addend != 0) + { + BinaryPrimitives.WriteInt64LittleEndian( + data, + BinaryPrimitives.ReadInt64LittleEndian(data) + + addend); + } + } + else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) + { + addend += 4; + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + } + } + else if (relocType == RelocType.IMAGE_REL_BASED_REL32 || + relocType == RelocType.IMAGE_REL_BASED_ADDR32NB || + relocType == RelocType.IMAGE_REL_BASED_ABSOLUTE) + { + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + } + } + else + { + throw new NotSupportedException($"Unsupported relocation: {relocType}"); + } + + relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, 0)); + } + + protected override void EmitSymbolTable() + { + foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) + { + _symbolNameToIndex.Add(symbolName, _symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = symbolName, + Value = (int)symbolDefinition.Value, + SectionIndex = (short)(1 + symbolDefinition.SectionIndex), + StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + }); + } + + foreach (var symbolName in GetUndefinedSymbols()) + { + _symbolNameToIndex.Add(symbolName, _symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = symbolName, + StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + }); + } + } + + protected override void EmitRelocations(int sectionIndex, List relocationList) + { + // All relocations are emitted when writting final object file + } + + protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) + { + if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && + nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) + { + Span tempBuffer = stackalloc byte[4]; + string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); + + int xdataSectionIndex = GetOrCreateSection( + ObjectNodeSection.XDataSection, out var xdataStream, out var xdataRelocations); + int pdataSectionIndex = GetOrCreateSection( + PDataSection, out var pdataStream, out var pdataRelocations); + + for (int i = 0; i < frameInfos.Length; i++) + { + FrameInfo frameInfo = frameInfos[i]; + + int start = frameInfo.StartOffset; + int end = frameInfo.EndOffset; + byte[] blob = frameInfo.BlobData; + + // TODO: {_nodeFactory.NameMangler.CompilationUnitPrefix} ? + string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; + string framSymbolName = $"_fram{i}{currentSymbolName}"; + + UpdateSectionAlignment(xdataSectionIndex, 4, out _); + EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(xdataSectionIndex, xdataStream.Position)); + if (start != 0) + { + EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); + } + + xdataStream.Write(blob); + + FrameInfoFlags flags = frameInfo.Flags; + + if (i != 0) + { + xdataStream.WriteByte((byte)flags); + } + else + { + MethodExceptionHandlingInfoNode ehInfo = nodeWithCodeInfo.EHInfo; + ISymbolNode associatedDataNode = nodeWithCodeInfo.GetAssociatedDataNode(_nodeFactory) as ISymbolNode; + + flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; + flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; + + xdataStream.WriteByte((byte)flags); + + if (associatedDataNode != null) + { + string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); + tempBuffer.Clear(); + EmitRelocation( + xdataSectionIndex, + xdataRelocations, + (int)xdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + symbolName, + 0); + xdataStream.Write(tempBuffer); + } + + if (ehInfo != null) + { + string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); + tempBuffer.Clear(); + EmitRelocation( + xdataSectionIndex, + xdataRelocations, + (int)xdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + symbolName, + 0); + xdataStream.Write(tempBuffer); + } + + if (nodeWithCodeInfo.GCInfo != null) + { + xdataStream.Write(nodeWithCodeInfo.GCInfo); + } + } + + // Emit UNWIND_INFO + // TODO: Other architectures + + // Start + tempBuffer.Clear(); + EmitRelocation( + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + currentSymbolName, + start); + pdataStream.Write(tempBuffer); + + // End + tempBuffer.Clear(); + EmitRelocation( + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + currentSymbolName, + end); + pdataStream.Write(tempBuffer); + + // Unwind info pointer + tempBuffer.Clear(); + EmitRelocation( + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + unwindSymbolName, + 0); + pdataStream.Write(tempBuffer); + } + } + } + + protected override void EmitSectionsAndLayout() + { + } + + protected override void EmitObjectFile(string objectFilePath) + { + const int CoffHeaderSize = + sizeof(short) + // Machine + sizeof(short) + // NumberOfSections + sizeof(int) + // TimeDateStamp + sizeof(int) + // PointerToSymbolTable + sizeof(int) + // NumberOfSymbols + sizeof(short) + // SizeOfOptionalHeader + sizeof(ushort); // Characteristics + const int CoffSectionHeaderSize = + 8 + // Name size + sizeof(int) + // VirtualSize + sizeof(int) + // VirtualAddress + sizeof(int) + // SizeOfRawData + sizeof(int) + // PointerToRawData + sizeof(int) + // PointerToRelocations + sizeof(int) + // PointerToLineNumbers + sizeof(short) + // NumberOfRelocations + sizeof(short) + // NumberOfLineNumbers + sizeof(int); // SectionCharacteristics + const int CoffRelocationSize = + sizeof(int) + // Address + sizeof(int) + // Symbol index + sizeof(short); // Type + const int CoffSymbolSize = + 8 + // Name size + sizeof(int) + // Value + sizeof(short) + // Section index + sizeof(short) + // Type + sizeof(byte) + // Storage class + sizeof(byte); // Auxiliary symbol count + + using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); + using var binaryWriter = new BinaryWriter(outputFileStream); // TODO: Big endian? + + var stringTable = new MemoryStream(); + + // Calculate size of section data + int sectionIndex = 0; + foreach ((CoffSectionHeader sectionHeader, Stream sectionStream) in _sections) + { + sectionHeader.SizeOfRawData = (int)sectionStream.Length; + GetSection(sectionIndex, out _, out var relocationList); + if (relocationList.Count <= ushort.MaxValue) + { + sectionHeader.NumberOfRelocations = (ushort)relocationList.Count; + } + else + { + sectionHeader.NumberOfRelocations = ushort.MaxValue; + sectionHeader.SectionCharacteristics |= SectionCharacteristics.LinkerNRelocOvfl; + } + sectionIndex++; + } + + // Assign offsets to section data + int dataOffset = CoffHeaderSize + _sections.Count * CoffSectionHeaderSize; + sectionIndex = 0; + foreach ((CoffSectionHeader sectionHeader, _) in _sections) + { + GetSection(sectionIndex, out _, out var relocationList); + + if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) + { + sectionHeader.PointerToRawData = 0; + } + else + { + sectionHeader.PointerToRawData = dataOffset; + dataOffset += sectionHeader.SizeOfRawData; + } + + sectionHeader.PointerToRelocations = relocationList.Count > 0 ? dataOffset : 0; + dataOffset += relocationList.Count * CoffRelocationSize; + if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerNRelocOvfl)) + { + dataOffset += CoffRelocationSize; + } + + sectionIndex++; + } + + int symbolTableOffset = dataOffset; + int stringTableOffset = + symbolTableOffset + _symbols.Count * CoffSymbolSize + + sizeof(int); // Count + + // Write COFF header + binaryWriter.Write((ushort)_machine); + binaryWriter.Write((ushort)_sections.Count); + binaryWriter.Write((uint)0u); // TimeDateStamp + binaryWriter.Write(symbolTableOffset); + binaryWriter.Write((uint)_symbols.Count); + binaryWriter.Write((ushort)0u); // SizeOfOptionalHeader + binaryWriter.Write((ushort)0u); // Characteristics + + // Write COFF section headers + foreach ((CoffSectionHeader sectionHeader, _) in _sections) + { + WritePaddedName(sectionHeader.Name, isSectionName: true); + binaryWriter.Write(sectionHeader.VirtualSize); + binaryWriter.Write(sectionHeader.VirtualAddress); + binaryWriter.Write(sectionHeader.SizeOfRawData); + binaryWriter.Write(sectionHeader.PointerToRawData); + binaryWriter.Write(sectionHeader.PointerToRelocations); + binaryWriter.Write(sectionHeader.PointerToLineNumbers); + binaryWriter.Write(sectionHeader.NumberOfRelocations); + binaryWriter.Write(sectionHeader.NumberOfLineNumbers); + binaryWriter.Write((int)sectionHeader.SectionCharacteristics); + + // Relocation code below assumes that addresses are 0-indexed + Debug.Assert(sectionHeader.VirtualAddress == 0); + } + + // Writer section content and relocations + sectionIndex = 0; + foreach ((CoffSectionHeader sectionHeader, Stream sectionStream) in _sections) + { + if (!sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) + { + Debug.Assert(outputFileStream.Position == sectionHeader.PointerToRawData); + sectionStream.Position = 0; + sectionStream.CopyTo(outputFileStream); + } + + GetSection(sectionIndex, out _, out var relocationList); + + if (relocationList.Count > 0) + { + Debug.Assert(outputFileStream.Position == sectionHeader.PointerToRelocations); + if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerNRelocOvfl)) + { + binaryWriter.Write((int)relocationList.Count); + binaryWriter.Write((int)0); + binaryWriter.Write((ushort)0u); + } + + foreach (var relocation in relocationList) + { + // Addends are emitted directly into code in EmitRelocation + Debug.Assert(relocation.Addend == 0); + + binaryWriter.Write((int)relocation.Offset); + binaryWriter.Write((int)_symbolNameToIndex[relocation.SymbolName]); + + // FIXME: Other architectures + var relocationType = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => 3u, + RelocType.IMAGE_REL_BASED_ADDR32NB => 3u, + RelocType.IMAGE_REL_BASED_HIGHLOW => 2u, + RelocType.IMAGE_REL_BASED_DIR64 => 1u, + RelocType.IMAGE_REL_BASED_REL32 => 4u, + RelocType.IMAGE_REL_BASED_RELPTR32 => 4u, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }; + + binaryWriter.Write((ushort)relocationType); + } + } + + sectionIndex++; + } + + // Write symbol table + Debug.Assert(outputFileStream.Position == symbolTableOffset); + foreach (var coffSymbol in _symbols) + { + WritePaddedName(coffSymbol.Name); + binaryWriter.Write(coffSymbol.Value); + binaryWriter.Write(coffSymbol.SectionIndex); + binaryWriter.Write(coffSymbol.Type); + binaryWriter.Write(coffSymbol.StorageClass); + binaryWriter.Write(coffSymbol.AuxiliaryCount); + } + + // Write string table + binaryWriter.Write((int)(stringTable.Length + 4)); + Debug.Assert(outputFileStream.Position == stringTableOffset); + stringTable.Position = 0; + stringTable.CopyTo(outputFileStream); + + void WritePaddedName(string name, bool isSectionName = false) + { + // TODO: Reuse buffer + var nameBytes = Encoding.UTF8.GetBytes(name); + if (nameBytes.Length <= 8) + { + binaryWriter.Write(nameBytes); + if (nameBytes.Length < 8) + { + binaryWriter.Write(stackalloc byte[8 - nameBytes.Length]); + } + } + else + { + if (!isSectionName) + { + binaryWriter.Write((uint)0u); + binaryWriter.Write((uint)(stringTable.Position + 4)); + } + else + { + string longName = $"/{stringTable.Position + 4}\0\0\0\0\0\0"; + for (int i = 0; i < 8; i++) + { + binaryWriter.Write((byte)longName[i]); + } + } + stringTable.Write(nameBytes); + stringTable.WriteByte(0); + } + } + } + + protected override void CreateEhSections() + { + // Create .xdata and .pdata + } + + protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() => null; + + protected override void EmitDebugFunctionInfo( + uint methodTypeIndex, + string methodName, + SymbolDefinition methodSymbol, + INodeWithDebugInfo debugNode) + { + } + + protected override void EmitDebugSections() + { + } + + protected override void EmitDebugStaticVars() + { + } + + public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) + { + // Not supported yet + options &= ~ObjectWritingOptions.GenerateDebugInfo; + + using CoffObjectWriter objectWriter = new CoffObjectWriter(factory, options); + objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); + } + + private sealed class CoffSectionHeader + { + public string Name { get; set; } + public int VirtualSize { get; set; } + public int VirtualAddress { get; set; } + public int SizeOfRawData { get; set; } + public int PointerToRawData { get; set; } + public int PointerToRelocations { get; set; } + public int PointerToLineNumbers { get; set; } + public ushort NumberOfRelocations { get; set; } + public ushort NumberOfLineNumbers { get; set; } + public SectionCharacteristics SectionCharacteristics { get; set; } + } + + private sealed class CoffSymbol + { + public string Name { get; set; } + public int Value { get; set; } + public short SectionIndex { get; set; } + public short Type { get; set; } + public byte StorageClass { get; set; } + public byte AuxiliaryCount { get; set; } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 4e2561a56f7d38..9bf355b6e332ae 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -211,7 +211,14 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection + diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 45c366bf435e9f..a649b43546353c 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -111,6 +111,8 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else if (NodeFactory.Target.OperatingSystem == TargetOS.OSX) MachObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + else if (NodeFactory.Target.OperatingSystem == TargetOS.Windows) + CoffObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else if (NodeFactory.Target.OperatingSystem == TargetOS.Linux) ElfObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else From bd13d558a64f18fe3c207db480c508fabc5d2f01 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 21 Oct 2022 16:15:21 +0200 Subject: [PATCH 012/144] Emit control flow guard information --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 29 +++++++++++++++++++ .../Compiler/ObjectWriter/ObjectWriter.cs | 3 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 8b7a6a74f8f10f..be2ecd164922ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -32,6 +32,7 @@ public class CoffObjectWriter : ObjectWriter private Dictionary _symbolNameToIndex = new(); private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); + private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); protected CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) @@ -169,6 +170,34 @@ protected override void EmitSymbolTable() StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL }); } + + if (_options.HasFlag(ObjectWritingOptions.ControlFlowGuard)) + { + // Create section with control flow guard symbols + GetOrCreateSection(GfidsSection, out var sectionStream, out _); + + Span tempBuffer = stackalloc byte[4]; + foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) + { + // For now consider all method symbols address taken. + // We could restrict this in the future to those that are referenced from + // reflection tables, EH tables, were actually address taken in code, or are referenced from vtables. + if (symbolDefinition.Size > 0) + { + BinaryPrimitives.WriteInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); + sectionStream.Write(tempBuffer); + } + } + + // Emit the feat.00 symbol that controls various linker behaviors + _symbols.Add(new CoffSymbol + { + Name = "@feat.00", + StorageClass = 3, // IMAGE_SYM_CLASS_STATIC + SectionIndex = -1, // IMAGE_SYM_ABSOLUTE + Value = 0x800, // cfGuardCF flags this object as control flow guard aware + }); + } } protected override void EmitRelocations(int sectionIndex, List relocationList) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 9bf355b6e332ae..b2b90e9b225f0e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -249,10 +249,11 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Sun, 23 Oct 2022 03:37:01 -0700 Subject: [PATCH 013/144] Add win-arm64 support --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 70 +++++++++++++------ 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index be2ecd164922ca..d208fa5e1bdf26 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -230,7 +230,7 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; - UpdateSectionAlignment(xdataSectionIndex, 4, out _); + EmitAlignment(xdataSectionIndex, xdataStream, 4); EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(xdataSectionIndex, xdataStream.Position)); if (start != 0) { @@ -306,17 +306,20 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode start); pdataStream.Write(tempBuffer); - // End - tempBuffer.Clear(); - EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - currentSymbolName, - end); - pdataStream.Write(tempBuffer); + if (_machine == Machine.Amd64) + { + // End + tempBuffer.Clear(); + EmitRelocation( + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, + tempBuffer, + RelocType.IMAGE_REL_BASED_ADDR32NB, + currentSymbolName, + end); + pdataStream.Write(tempBuffer); + } // Unwind info pointer tempBuffer.Clear(); @@ -484,16 +487,41 @@ protected override void EmitObjectFile(string objectFilePath) binaryWriter.Write((int)_symbolNameToIndex[relocation.SymbolName]); // FIXME: Other architectures - var relocationType = relocation.Type switch + uint relocationType; + + if (_machine == Machine.Amd64) + { + relocationType = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => 3u, + RelocType.IMAGE_REL_BASED_ADDR32NB => 3u, + RelocType.IMAGE_REL_BASED_HIGHLOW => 2u, + RelocType.IMAGE_REL_BASED_DIR64 => 1u, + RelocType.IMAGE_REL_BASED_REL32 => 4u, + RelocType.IMAGE_REL_BASED_RELPTR32 => 4u, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }; + } + else if (_machine == Machine.Arm64) + { + relocationType = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => 2u, + RelocType.IMAGE_REL_BASED_ADDR32NB => 2u, + RelocType.IMAGE_REL_BASED_HIGHLOW => 1u, + RelocType.IMAGE_REL_BASED_DIR64 => 14u, + RelocType.IMAGE_REL_BASED_REL32 => 17u, + RelocType.IMAGE_REL_BASED_RELPTR32 => 17u, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => 3u, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => 4u, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => 6u, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }; + } + else { - RelocType.IMAGE_REL_BASED_ABSOLUTE => 3u, - RelocType.IMAGE_REL_BASED_ADDR32NB => 3u, - RelocType.IMAGE_REL_BASED_HIGHLOW => 2u, - RelocType.IMAGE_REL_BASED_DIR64 => 1u, - RelocType.IMAGE_REL_BASED_REL32 => 4u, - RelocType.IMAGE_REL_BASED_RELPTR32 => 4u, - _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") - }; + throw new NotSupportedException("Unsupported architecture"); + } binaryWriter.Write((ushort)relocationType); } From efd0c571e5d5b870dbd7aaffbb817aefbe763856 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 24 Oct 2022 14:01:11 +0200 Subject: [PATCH 014/144] Misc cleanups of the COFF object writer --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 568 +++++++++++------- 1 file changed, 341 insertions(+), 227 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index d208fa5e1bdf26..69b0adc918a1a8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -27,9 +27,19 @@ namespace ILCompiler.ObjectWriter public class CoffObjectWriter : ObjectWriter { private Machine _machine; - private List<(CoffSectionHeader Header, Stream Stream)> _sections = new(); + private List<(CoffSectionHeader Header, Stream Stream, List Relocations)> _sections = new(); + + // Symbol table private List _symbols = new(); - private Dictionary _symbolNameToIndex = new(); + private Dictionary _symbolNameToIndex = new(); + + // Exception handling + private int _xdataSectionIndex; + private int _pdataSectionIndex; + private Stream _xdataStream; + private Stream _pdataStream; + private List _xdataRelocations; + private List _pdataRelocations; private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); @@ -72,7 +82,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect } sectionStream = new MemoryStream(); - _sections.Add((sectionHeader, sectionStream)); + _sections.Add((sectionHeader, sectionStream, new List())); } protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) @@ -151,7 +161,7 @@ protected override void EmitSymbolTable() { foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) { - _symbolNameToIndex.Add(symbolName, _symbols.Count); + _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol { Name = symbolName, @@ -163,7 +173,7 @@ protected override void EmitSymbolTable() foreach (var symbolName in GetUndefinedSymbols()) { - _symbolNameToIndex.Add(symbolName, _symbols.Count); + _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol { Name = symbolName, @@ -184,7 +194,7 @@ protected override void EmitSymbolTable() // reflection tables, EH tables, were actually address taken in code, or are referenced from vtables. if (symbolDefinition.Size > 0) { - BinaryPrimitives.WriteInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); sectionStream.Write(tempBuffer); } } @@ -202,7 +212,72 @@ protected override void EmitSymbolTable() protected override void EmitRelocations(int sectionIndex, List relocationList) { - // All relocations are emitted when writting final object file + CoffSectionHeader sectionHeader = _sections[sectionIndex].Header; + List coffRelocations = _sections[sectionIndex].Relocations; + if (relocationList.Count > 0) + { + if (relocationList.Count <= ushort.MaxValue) + { + sectionHeader.NumberOfRelocations = (ushort)relocationList.Count; + } + else + { + // Write an overflow relocation with the real count of relocations + sectionHeader.NumberOfRelocations = ushort.MaxValue; + sectionHeader.SectionCharacteristics |= SectionCharacteristics.LinkerNRelocOvfl; + coffRelocations.Add(new CoffRelocation { VirtualAddress = (uint)relocationList.Count }); + } + + if (_machine == Machine.Amd64) + { + foreach (var relocation in relocationList) + { + coffRelocations.Add(new CoffRelocation + { + VirtualAddress = (uint)relocation.Offset, + SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], + Type = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, + RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, + RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_AMD64_ADDR32, + RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_AMD64_ADDR64, + RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, + RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }, + }); + } + } + else if (_machine == Machine.Arm64) + { + foreach (var relocation in relocationList) + { + coffRelocations.Add(new CoffRelocation + { + VirtualAddress = (uint)relocation.Offset, + SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], + Type = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, + RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, + RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_ARM64_ADDR32, + RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_ARM64_ADDR64, + RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, + RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => CoffRelocationType.IMAGE_REL_ARM64_BRANCH26, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => CoffRelocationType.IMAGE_REL_ARM64_PAGEBASE_REL21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => CoffRelocationType.IMAGE_REL_ARM64_PAGEOFFSET_12A, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }, + }); + } + } + else + { + throw new NotSupportedException("Unsupported architecture"); + } + } } protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) @@ -213,11 +288,6 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode Span tempBuffer = stackalloc byte[4]; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); - int xdataSectionIndex = GetOrCreateSection( - ObjectNodeSection.XDataSection, out var xdataStream, out var xdataRelocations); - int pdataSectionIndex = GetOrCreateSection( - PDataSection, out var pdataStream, out var pdataRelocations); - for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; @@ -230,20 +300,25 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; - EmitAlignment(xdataSectionIndex, xdataStream, 4); - EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(xdataSectionIndex, xdataStream.Position)); + // Need to emit the UNWIND_INFO at 4-byte alignment to ensure that the + // pointer has the lower two bits in .pdata section set to zero. On ARM64 + // non-zero bits would mean a compact encoding. + EmitAlignment(_xdataSectionIndex, _xdataStream, 4); + + EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(_xdataSectionIndex, _xdataStream.Position)); if (start != 0) { EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); } - xdataStream.Write(blob); + // Emit UNWIND_INFO + _xdataStream.Write(blob); FrameInfoFlags flags = frameInfo.Flags; if (i != 0) { - xdataStream.WriteByte((byte)flags); + _xdataStream.WriteByte((byte)flags); } else { @@ -253,21 +328,21 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - xdataStream.WriteByte((byte)flags); + _xdataStream.WriteByte((byte)flags); if (associatedDataNode != null) { string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - xdataSectionIndex, - xdataRelocations, - (int)xdataStream.Position, + _xdataSectionIndex, + _xdataRelocations, + (int)_xdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); - xdataStream.Write(tempBuffer); + _xdataStream.Write(tempBuffer); } if (ehInfo != null) @@ -275,63 +350,63 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - xdataSectionIndex, - xdataRelocations, - (int)xdataStream.Position, + _xdataSectionIndex, + _xdataRelocations, + (int)_xdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); - xdataStream.Write(tempBuffer); + _xdataStream.Write(tempBuffer); } if (nodeWithCodeInfo.GCInfo != null) { - xdataStream.Write(nodeWithCodeInfo.GCInfo); + _xdataStream.Write(nodeWithCodeInfo.GCInfo); } } - // Emit UNWIND_INFO - // TODO: Other architectures + // Emit RUNTIME_FUNCTION // Start tempBuffer.Clear(); EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, + _pdataSectionIndex, + _pdataRelocations, + (int)_pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); - pdataStream.Write(tempBuffer); + _pdataStream.Write(tempBuffer); + // Only x64 has the End symbol if (_machine == Machine.Amd64) { // End tempBuffer.Clear(); EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, + _pdataSectionIndex, + _pdataRelocations, + (int)_pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, end); - pdataStream.Write(tempBuffer); + _pdataStream.Write(tempBuffer); } // Unwind info pointer tempBuffer.Clear(); EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, + _pdataSectionIndex, + _pdataRelocations, + (int)_pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, unwindSymbolName, 0); - pdataStream.Write(tempBuffer); + _pdataStream.Write(tempBuffer); } } } @@ -342,248 +417,98 @@ protected override void EmitSectionsAndLayout() protected override void EmitObjectFile(string objectFilePath) { - const int CoffHeaderSize = - sizeof(short) + // Machine - sizeof(short) + // NumberOfSections - sizeof(int) + // TimeDateStamp - sizeof(int) + // PointerToSymbolTable - sizeof(int) + // NumberOfSymbols - sizeof(short) + // SizeOfOptionalHeader - sizeof(ushort); // Characteristics - const int CoffSectionHeaderSize = - 8 + // Name size - sizeof(int) + // VirtualSize - sizeof(int) + // VirtualAddress - sizeof(int) + // SizeOfRawData - sizeof(int) + // PointerToRawData - sizeof(int) + // PointerToRelocations - sizeof(int) + // PointerToLineNumbers - sizeof(short) + // NumberOfRelocations - sizeof(short) + // NumberOfLineNumbers - sizeof(int); // SectionCharacteristics - const int CoffRelocationSize = - sizeof(int) + // Address - sizeof(int) + // Symbol index - sizeof(short); // Type - const int CoffSymbolSize = - 8 + // Name size - sizeof(int) + // Value - sizeof(short) + // Section index - sizeof(short) + // Type - sizeof(byte) + // Storage class - sizeof(byte); // Auxiliary symbol count - using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); - using var binaryWriter = new BinaryWriter(outputFileStream); // TODO: Big endian? - var stringTable = new MemoryStream(); - // Calculate size of section data + // Calculate size of section data and assign offsets + int dataOffset = CoffHeader.Size + _sections.Count * CoffSectionHeader.Size; int sectionIndex = 0; - foreach ((CoffSectionHeader sectionHeader, Stream sectionStream) in _sections) + foreach (var section in _sections) { - sectionHeader.SizeOfRawData = (int)sectionStream.Length; - GetSection(sectionIndex, out _, out var relocationList); - if (relocationList.Count <= ushort.MaxValue) - { - sectionHeader.NumberOfRelocations = (ushort)relocationList.Count; - } - else - { - sectionHeader.NumberOfRelocations = ushort.MaxValue; - sectionHeader.SectionCharacteristics |= SectionCharacteristics.LinkerNRelocOvfl; - } - sectionIndex++; - } + section.Header.SizeOfRawData = (int)section.Stream.Length; - // Assign offsets to section data - int dataOffset = CoffHeaderSize + _sections.Count * CoffSectionHeaderSize; - sectionIndex = 0; - foreach ((CoffSectionHeader sectionHeader, _) in _sections) - { - GetSection(sectionIndex, out _, out var relocationList); - - if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) + // Section content + if (section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) { - sectionHeader.PointerToRawData = 0; + section.Header.PointerToRawData = 0; } else { - sectionHeader.PointerToRawData = dataOffset; - dataOffset += sectionHeader.SizeOfRawData; + section.Header.PointerToRawData = dataOffset; + dataOffset += section.Header.SizeOfRawData; } - sectionHeader.PointerToRelocations = relocationList.Count > 0 ? dataOffset : 0; - dataOffset += relocationList.Count * CoffRelocationSize; - if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerNRelocOvfl)) - { - dataOffset += CoffRelocationSize; - } + // Section relocations + section.Header.PointerToRelocations = section.Relocations.Count > 0 ? dataOffset : 0; + dataOffset += section.Relocations.Count * CoffRelocation.Size; sectionIndex++; } int symbolTableOffset = dataOffset; int stringTableOffset = - symbolTableOffset + _symbols.Count * CoffSymbolSize + + symbolTableOffset + _symbols.Count * CoffSymbol.Size + sizeof(int); // Count // Write COFF header - binaryWriter.Write((ushort)_machine); - binaryWriter.Write((ushort)_sections.Count); - binaryWriter.Write((uint)0u); // TimeDateStamp - binaryWriter.Write(symbolTableOffset); - binaryWriter.Write((uint)_symbols.Count); - binaryWriter.Write((ushort)0u); // SizeOfOptionalHeader - binaryWriter.Write((ushort)0u); // Characteristics + var coffHeader = new CoffHeader + { + Machine = _machine, + NumberOfSections = (ushort)_sections.Count, + PointerToSymbolTable = (uint)symbolTableOffset, + NumberOfSymbols = (uint)_symbols.Count, + }; + coffHeader.Write(outputFileStream); // Write COFF section headers - foreach ((CoffSectionHeader sectionHeader, _) in _sections) + foreach ((CoffSectionHeader sectionHeader, _, _) in _sections) { - WritePaddedName(sectionHeader.Name, isSectionName: true); - binaryWriter.Write(sectionHeader.VirtualSize); - binaryWriter.Write(sectionHeader.VirtualAddress); - binaryWriter.Write(sectionHeader.SizeOfRawData); - binaryWriter.Write(sectionHeader.PointerToRawData); - binaryWriter.Write(sectionHeader.PointerToRelocations); - binaryWriter.Write(sectionHeader.PointerToLineNumbers); - binaryWriter.Write(sectionHeader.NumberOfRelocations); - binaryWriter.Write(sectionHeader.NumberOfLineNumbers); - binaryWriter.Write((int)sectionHeader.SectionCharacteristics); + sectionHeader.Write(outputFileStream, stringTable); // Relocation code below assumes that addresses are 0-indexed Debug.Assert(sectionHeader.VirtualAddress == 0); } // Writer section content and relocations - sectionIndex = 0; - foreach ((CoffSectionHeader sectionHeader, Stream sectionStream) in _sections) + foreach (var section in _sections) { - if (!sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) + if (!section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) { - Debug.Assert(outputFileStream.Position == sectionHeader.PointerToRawData); - sectionStream.Position = 0; - sectionStream.CopyTo(outputFileStream); + Debug.Assert(outputFileStream.Position == section.Header.PointerToRawData); + section.Stream.Position = 0; + section.Stream.CopyTo(outputFileStream); } - GetSection(sectionIndex, out _, out var relocationList); - - if (relocationList.Count > 0) + if (section.Relocations.Count > 0) { - Debug.Assert(outputFileStream.Position == sectionHeader.PointerToRelocations); - if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerNRelocOvfl)) + foreach (var relocation in section.Relocations) { - binaryWriter.Write((int)relocationList.Count); - binaryWriter.Write((int)0); - binaryWriter.Write((ushort)0u); - } - - foreach (var relocation in relocationList) - { - // Addends are emitted directly into code in EmitRelocation - Debug.Assert(relocation.Addend == 0); - - binaryWriter.Write((int)relocation.Offset); - binaryWriter.Write((int)_symbolNameToIndex[relocation.SymbolName]); - - // FIXME: Other architectures - uint relocationType; - - if (_machine == Machine.Amd64) - { - relocationType = relocation.Type switch - { - RelocType.IMAGE_REL_BASED_ABSOLUTE => 3u, - RelocType.IMAGE_REL_BASED_ADDR32NB => 3u, - RelocType.IMAGE_REL_BASED_HIGHLOW => 2u, - RelocType.IMAGE_REL_BASED_DIR64 => 1u, - RelocType.IMAGE_REL_BASED_REL32 => 4u, - RelocType.IMAGE_REL_BASED_RELPTR32 => 4u, - _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") - }; - } - else if (_machine == Machine.Arm64) - { - relocationType = relocation.Type switch - { - RelocType.IMAGE_REL_BASED_ABSOLUTE => 2u, - RelocType.IMAGE_REL_BASED_ADDR32NB => 2u, - RelocType.IMAGE_REL_BASED_HIGHLOW => 1u, - RelocType.IMAGE_REL_BASED_DIR64 => 14u, - RelocType.IMAGE_REL_BASED_REL32 => 17u, - RelocType.IMAGE_REL_BASED_RELPTR32 => 17u, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => 3u, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => 4u, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => 6u, - _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") - }; - } - else - { - throw new NotSupportedException("Unsupported architecture"); - } - - binaryWriter.Write((ushort)relocationType); + relocation.Write(outputFileStream); } } - - sectionIndex++; } // Write symbol table Debug.Assert(outputFileStream.Position == symbolTableOffset); foreach (var coffSymbol in _symbols) { - WritePaddedName(coffSymbol.Name); - binaryWriter.Write(coffSymbol.Value); - binaryWriter.Write(coffSymbol.SectionIndex); - binaryWriter.Write(coffSymbol.Type); - binaryWriter.Write(coffSymbol.StorageClass); - binaryWriter.Write(coffSymbol.AuxiliaryCount); + coffSymbol.Write(outputFileStream, stringTable); } // Write string table - binaryWriter.Write((int)(stringTable.Length + 4)); + Span stringTableSize = stackalloc byte[4]; + BinaryPrimitives.WriteInt32LittleEndian(stringTableSize, (int)(stringTable.Length + 4)); + outputFileStream.Write(stringTableSize); Debug.Assert(outputFileStream.Position == stringTableOffset); stringTable.Position = 0; stringTable.CopyTo(outputFileStream); - - void WritePaddedName(string name, bool isSectionName = false) - { - // TODO: Reuse buffer - var nameBytes = Encoding.UTF8.GetBytes(name); - if (nameBytes.Length <= 8) - { - binaryWriter.Write(nameBytes); - if (nameBytes.Length < 8) - { - binaryWriter.Write(stackalloc byte[8 - nameBytes.Length]); - } - } - else - { - if (!isSectionName) - { - binaryWriter.Write((uint)0u); - binaryWriter.Write((uint)(stringTable.Position + 4)); - } - else - { - string longName = $"/{stringTable.Position + 4}\0\0\0\0\0\0"; - for (int i = 0; i < 8; i++) - { - binaryWriter.Write((byte)longName[i]); - } - } - stringTable.Write(nameBytes); - stringTable.WriteByte(0); - } - } } protected override void CreateEhSections() { // Create .xdata and .pdata + _xdataSectionIndex = GetOrCreateSection(ObjectNodeSection.XDataSection, out _xdataStream, out _xdataRelocations); + _pdataSectionIndex = GetOrCreateSection(PDataSection, out _pdataStream, out _pdataRelocations); } protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() => null; @@ -613,6 +538,41 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection buffer = stackalloc byte[Size]; + + BinaryPrimitives.WriteInt16LittleEndian(buffer, (short)Machine); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), NumberOfSections); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), TimeDateStamp); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), PointerToSymbolTable); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12), NumberOfSymbols); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(16), SizeOfOptionalHeader); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(18), Characteristics); + + stream.Write(buffer); + } + } + private sealed class CoffSectionHeader { public string Name { get; set; } @@ -625,6 +585,120 @@ private sealed class CoffSectionHeader public ushort NumberOfRelocations { get; set; } public ushort NumberOfLineNumbers { get; set; } public SectionCharacteristics SectionCharacteristics { get; set; } + + private const int NameSize = 8; + + public const int Size = + NameSize + // Name size + sizeof(int) + // VirtualSize + sizeof(int) + // VirtualAddress + sizeof(int) + // SizeOfRawData + sizeof(int) + // PointerToRawData + sizeof(int) + // PointerToRelocations + sizeof(int) + // PointerToLineNumbers + sizeof(short) + // NumberOfRelocations + sizeof(short) + // NumberOfLineNumbers + sizeof(int); // SectionCharacteristics + + public void Write(Stream stream, Stream stringTableStream) + { + Span buffer = stackalloc byte[Size]; + + var nameBytes = Encoding.UTF8.GetBytes(Name); // TODO: Pool buffers + if (nameBytes.Length <= NameSize) + { + nameBytes.CopyTo(buffer); + if (nameBytes.Length < NameSize) + { + buffer.Slice(nameBytes.Length, 8 - nameBytes.Length).Clear(); + } + } + else + { + string longName = $"/{stringTableStream.Position + 4}\0\0\0\0\0\0"; + for (int i = 0; i < 8; i++) + { + buffer[i] = (byte)longName[i]; + } + stringTableStream.Write(nameBytes); + stringTableStream.WriteByte(0); + } + + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), VirtualSize); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 4), VirtualAddress); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 8), SizeOfRawData); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 12), PointerToRawData); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 16), PointerToRelocations); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 20), PointerToLineNumbers); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(NameSize + 24), NumberOfRelocations); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(NameSize + 26), NumberOfLineNumbers); + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 28), (int)SectionCharacteristics); + + stream.Write(buffer); + } + } + + private enum CoffRelocationType + { + IMAGE_REL_AMD64_ABSOLUTE = 0, + IMAGE_REL_AMD64_ADDR64 = 1, + IMAGE_REL_AMD64_ADDR32 = 2, + IMAGE_REL_AMD64_ADDR32NB = 3, + IMAGE_REL_AMD64_REL32 = 4, + IMAGE_REL_AMD64_REL32_1 = 5, + IMAGE_REL_AMD64_REL32_2 = 6, + IMAGE_REL_AMD64_REL32_3 = 7, + IMAGE_REL_AMD64_REL32_4 = 8, + IMAGE_REL_AMD64_REL32_5 = 9, + IMAGE_REL_AMD64_SECTION = 10, + IMAGE_REL_AMD64_SECREL = 11, + IMAGE_REL_AMD64_SECREL7 = 12, + IMAGE_REL_AMD64_TOKEN = 13, + IMAGE_REL_AMD64_SREL32 = 14, + IMAGE_REL_AMD64_PAIR = 15, + IMAGE_REL_AMD64_SSPAN32 = 16, + + IMAGE_REL_ARM64_ABSOLUTE = 0, + IMAGE_REL_ARM64_ADDR32 = 1, + IMAGE_REL_ARM64_ADDR32NB = 2, + IMAGE_REL_ARM64_BRANCH26 = 3, + IMAGE_REL_ARM64_PAGEBASE_REL21 = 4, + IMAGE_REL_ARM64_REL21 = 5, + IMAGE_REL_ARM64_PAGEOFFSET_12A = 6, + IMAGE_REL_ARM64_PAGEOFFSET_12L = 7, + IMAGE_REL_ARM64_SECREL = 8, + IMAGE_REL_ARM64_SECREL_LOW12A = 9, + IMAGE_REL_ARM64_SECREL_HIGH12A = 10, + IMAGE_REL_ARM64_SECREL_LOW12L = 11, + IMAGE_REL_ARM64_TOKEN = 12, + IMAGE_REL_ARM64_SECTION = 13, + IMAGE_REL_ARM64_ADDR64 = 14, + IMAGE_REL_ARM64_BRANCH19 = 15, + IMAGE_REL_ARM64_BRANCH14 = 16, + IMAGE_REL_ARM64_REL32 = 17, + } + + private sealed class CoffRelocation + { + public uint VirtualAddress { get; set; } + public uint SymbolTableIndex { get; set; } + public CoffRelocationType Type { get; set; } + + public const int Size = + sizeof(uint) + // VirtualAddress + sizeof(uint) + // SymbolTableIndex + sizeof(ushort); // Type + + public void Write(Stream stream) + { + Span buffer = stackalloc byte[Size]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer, VirtualAddress); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), SymbolTableIndex); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(8), (ushort)Type); + + stream.Write(buffer); + } } private sealed class CoffSymbol @@ -635,6 +709,46 @@ private sealed class CoffSymbol public short Type { get; set; } public byte StorageClass { get; set; } public byte AuxiliaryCount { get; set; } + + private const int NameSize = 8; + + public const int Size = + NameSize + // Name size + sizeof(int) + // Value + sizeof(short) + // Section index + sizeof(short) + // Type + sizeof(byte) + // Storage class + sizeof(byte); // Auxiliary symbol count + + public void Write(Stream stream, Stream stringTableStream) + { + Span buffer = stackalloc byte[Size]; + + var nameBytes = Encoding.UTF8.GetBytes(Name); // TODO: Pool buffers + if (nameBytes.Length <= NameSize) + { + nameBytes.CopyTo(buffer); + if (nameBytes.Length < NameSize) + { + buffer.Slice(nameBytes.Length, 8 - nameBytes.Length).Clear(); + } + } + else + { + BinaryPrimitives.WriteUInt32LittleEndian(buffer, 0); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)(stringTableStream.Position + 4)); + stringTableStream.Write(nameBytes); + stringTableStream.WriteByte(0); + } + + BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), Value); + BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 4), SectionIndex); + BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 6), Type); + buffer[NameSize + 8] = StorageClass; + buffer[NameSize + 9] = AuxiliaryCount; + + stream.Write(buffer); + } } } } From 14a475581d6f9fdf1d0595dbe75390f78fd69451 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 24 Oct 2022 20:48:09 +0200 Subject: [PATCH 015/144] Remove GetSection --- .../Compiler/ObjectWriter/ObjectWriter.cs | 9 ----- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 38 +++++++++---------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index b2b90e9b225f0e..9aff3e56057be1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -94,15 +94,6 @@ protected int GetOrCreateSection( return sectionIndex; } - protected void GetSection( - int sectionIndex, - out Stream sectionStream, - out List relocationList) - { - sectionStream = _sectionIndexToStream[sectionIndex]; - relocationList = _sectionIndexToRelocations[sectionIndex]; - } - protected abstract void EmitRelocation( int sectionIndex, List relocationList, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 6317d1309cc9eb..eda227ed48a9b7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -34,6 +34,8 @@ public abstract class UnixObjectWriter : ObjectWriter // Exception handling sections private int _lsdaSectionIndex; private int _ehFrameSectionIndex; + private Stream _lsdaStream; + private List _lsdaRelocations; private DwarfCie _dwarfCie; private DwarfEhFrame _dwarfEhFrame; @@ -51,13 +53,9 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { - Stream lsdaStream; - List lsdaRelocations; Span tempBuffer = stackalloc byte[4]; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); - - GetSection(_lsdaSectionIndex, out lsdaStream, out lsdaRelocations); - long mainLsdaOffset = lsdaStream.Position; + long mainLsdaOffset = _lsdaStream.Position; for (int i = 0; i < frameInfos.Length; i++) { @@ -71,7 +69,7 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string lsdaSymbolName = $"_lsda{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; - EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(_lsdaSectionIndex, lsdaStream.Position)); + EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(_lsdaSectionIndex, _lsdaStream.Position)); if (start != 0) { EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); @@ -81,14 +79,14 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode if (i != 0) { - lsdaStream.WriteByte((byte)flags); + _lsdaStream.WriteByte((byte)flags); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaStream.Position)); - lsdaStream.Write(tempBuffer); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - _lsdaStream.Position)); + _lsdaStream.Write(tempBuffer); // Emit relative offset from the main function BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(start - frameInfos[0].StartOffset)); - lsdaStream.Write(tempBuffer); + _lsdaStream.Write(tempBuffer); } else { @@ -98,7 +96,7 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - lsdaStream.WriteByte((byte)flags); + _lsdaStream.WriteByte((byte)flags); if (associatedDataNode != null) { @@ -106,13 +104,13 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode tempBuffer.Clear(); EmitRelocation( _lsdaSectionIndex, - lsdaRelocations, - (int)lsdaStream.Position, + _lsdaRelocations, + (int)_lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); - lsdaStream.Write(tempBuffer); + _lsdaStream.Write(tempBuffer); } if (ehInfo != null) @@ -121,18 +119,18 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode tempBuffer.Clear(); EmitRelocation( _lsdaSectionIndex, - lsdaRelocations, - (int)lsdaStream.Position, + _lsdaRelocations, + (int)_lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); - lsdaStream.Write(tempBuffer); + _lsdaStream.Write(tempBuffer); } if (nodeWithCodeInfo.GCInfo != null) { - lsdaStream.Write(nodeWithCodeInfo.GCInfo); + _lsdaStream.Write(nodeWithCodeInfo.GCInfo); } } @@ -185,7 +183,9 @@ protected override void EmitDebugSections() protected override void CreateEhSections() { // Create sections for exception handling - _lsdaSectionIndex = GetOrCreateSection(new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null), out _, out _); + _lsdaSectionIndex = GetOrCreateSection( + new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null), + out _lsdaStream, out _lsdaRelocations); _ehFrameSectionIndex = GetOrCreateSection( new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), out var ehFrameStream, out var ehFrameRelocations); From ef5ffb49888e24e965b02acd3c31fa8edd7ebe70 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 25 Oct 2022 15:34:30 +0200 Subject: [PATCH 016/144] Add COFF COMDAT support --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 383 ++++++++++++++---- .../Compiler/ObjectWriter/ObjectWriter.cs | 54 ++- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 54 ++- 3 files changed, 395 insertions(+), 96 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 69b0adc918a1a8..87d72756accb53 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -27,11 +27,12 @@ namespace ILCompiler.ObjectWriter public class CoffObjectWriter : ObjectWriter { private Machine _machine; - private List<(CoffSectionHeader Header, Stream Stream, List Relocations)> _sections = new(); + private List<(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName)> _sections = new(); // Symbol table - private List _symbols = new(); + private List _symbols = new(); private Dictionary _symbolNameToIndex = new(); + private Dictionary _sectionNumberToComdatAuxRecord = new(); // Exception handling private int _xdataSectionIndex; @@ -81,8 +82,14 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect SectionCharacteristics.ContainsUninitializedData; } + if (section.ComdatName != null) + { + sectionHeader.SectionCharacteristics |= + SectionCharacteristics.LinkerComdat; + } + sectionStream = new MemoryStream(); - _sections.Add((sectionHeader, sectionStream, new List())); + _sections.Add((sectionHeader, sectionStream, new List(), section.ComdatName)); } protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) @@ -159,16 +166,68 @@ protected override void EmitRelocation( protected override void EmitSymbolTable() { - foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) + var definedSymbols = GetDefinedSymbols(); + + int sectionIndex = 0; + foreach (var (sectionHeader, _, _, comdatName) in _sections) { - _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); - _symbols.Add(new CoffSymbol + if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerComdat)) { - Name = symbolName, - Value = (int)symbolDefinition.Value, - SectionIndex = (short)(1 + symbolDefinition.SectionIndex), - StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL - }); + // We find the defining section of the COMDAT symbol. That one is marked + // as "ANY" selection type. All the other ones are marked as associated. + SymbolDefinition definingSymbol = definedSymbols[comdatName]; + int definingSectionIndex = definingSymbol.SectionIndex; + + var auxRecord = new CoffSectionSymbol + { + // SizeOfRawData, NumberOfRelocations, NumberOfLineNumbers + // CheckSum will be filled later in EmitObjectFile + + Number = (ushort)(1 + definingSectionIndex), + Selection = definingSectionIndex == sectionIndex ? + CoffComdatSelect.IMAGE_COMDAT_SELECT_ANY : + CoffComdatSelect.IMAGE_COMDAT_SELECT_ASSOCIATIVE, + }; + + _sectionNumberToComdatAuxRecord[sectionIndex] = auxRecord; + _symbols.Add(new CoffSymbol + { + Name = sectionHeader.Name, + Value = 0, + SectionIndex = (short)(1 + sectionIndex), + StorageClass = 3, // IMAGE_SYM_CLASS_STATIC + NumberOfAuxiliaryRecords = 1 + }); + _symbols.Add(auxRecord); + + if (definingSectionIndex == sectionIndex) + { + _symbolNameToIndex.Add(comdatName, (uint)_symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = comdatName, + Value = (int)definingSymbol.Value, + SectionIndex = (short)(1 + definingSymbol.SectionIndex), + StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + }); + } + } + sectionIndex++; + } + + foreach (var (symbolName, symbolDefinition) in definedSymbols) + { + if (!_symbolNameToIndex.ContainsKey(symbolName)) + { + _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = symbolName, + Value = (int)symbolDefinition.Value, + SectionIndex = (short)(1 + symbolDefinition.SectionIndex), + StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + }); + } } foreach (var symbolName in GetUndefinedSymbols()) @@ -285,8 +344,30 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { - Span tempBuffer = stackalloc byte[4]; + int xdataSectionIndex, pdataSectionIndex; + Stream xdataStream, pdataStream; + List xdataRelocations, pdataRelocations; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); + Span tempBuffer = stackalloc byte[4]; + + if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) + { + xdataSectionIndex = GetOrCreateSection( + GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName), + out xdataStream, out xdataRelocations); + pdataSectionIndex = GetOrCreateSection( + GetSharedSection(PDataSection, currentSymbolName), + out pdataStream, out pdataRelocations); + } + else + { + xdataSectionIndex = _xdataSectionIndex; + xdataStream = _xdataStream; + xdataRelocations = _xdataRelocations; + pdataSectionIndex = _pdataSectionIndex; + pdataStream = _pdataStream; + pdataRelocations = _pdataRelocations; + } for (int i = 0; i < frameInfos.Length; i++) { @@ -296,29 +377,28 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode int end = frameInfo.EndOffset; byte[] blob = frameInfo.BlobData; - // TODO: {_nodeFactory.NameMangler.CompilationUnitPrefix} ? string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; // Need to emit the UNWIND_INFO at 4-byte alignment to ensure that the // pointer has the lower two bits in .pdata section set to zero. On ARM64 // non-zero bits would mean a compact encoding. - EmitAlignment(_xdataSectionIndex, _xdataStream, 4); + EmitAlignment(xdataSectionIndex, xdataStream, 4); - EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(_xdataSectionIndex, _xdataStream.Position)); + EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(xdataSectionIndex, xdataStream.Position)); if (start != 0) { EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); } // Emit UNWIND_INFO - _xdataStream.Write(blob); + xdataStream.Write(blob); FrameInfoFlags flags = frameInfo.Flags; if (i != 0) { - _xdataStream.WriteByte((byte)flags); + xdataStream.WriteByte((byte)flags); } else { @@ -328,21 +408,21 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - _xdataStream.WriteByte((byte)flags); + xdataStream.WriteByte((byte)flags); if (associatedDataNode != null) { string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - _xdataSectionIndex, - _xdataRelocations, - (int)_xdataStream.Position, + xdataSectionIndex, + xdataRelocations, + (int)xdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); - _xdataStream.Write(tempBuffer); + xdataStream.Write(tempBuffer); } if (ehInfo != null) @@ -350,19 +430,19 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - _xdataSectionIndex, - _xdataRelocations, - (int)_xdataStream.Position, + xdataSectionIndex, + xdataRelocations, + (int)xdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); - _xdataStream.Write(tempBuffer); + xdataStream.Write(tempBuffer); } if (nodeWithCodeInfo.GCInfo != null) { - _xdataStream.Write(nodeWithCodeInfo.GCInfo); + xdataStream.Write(nodeWithCodeInfo.GCInfo); } } @@ -371,14 +451,14 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode // Start tempBuffer.Clear(); EmitRelocation( - _pdataSectionIndex, - _pdataRelocations, - (int)_pdataStream.Position, + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); - _pdataStream.Write(tempBuffer); + pdataStream.Write(tempBuffer); // Only x64 has the End symbol if (_machine == Machine.Amd64) @@ -386,27 +466,27 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode // End tempBuffer.Clear(); EmitRelocation( - _pdataSectionIndex, - _pdataRelocations, - (int)_pdataStream.Position, + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, end); - _pdataStream.Write(tempBuffer); + pdataStream.Write(tempBuffer); } // Unwind info pointer tempBuffer.Clear(); EmitRelocation( - _pdataSectionIndex, - _pdataRelocations, - (int)_pdataStream.Position, + pdataSectionIndex, + pdataRelocations, + (int)pdataStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_ADDR32NB, unwindSymbolName, 0); - _pdataStream.Write(tempBuffer); + pdataStream.Write(tempBuffer); } } } @@ -418,7 +498,7 @@ protected override void EmitSectionsAndLayout() protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); - var stringTable = new MemoryStream(); + var stringTable = new CoffStringTable(); // Calculate size of section data and assign offsets int dataOffset = CoffHeader.Size + _sections.Count * CoffSectionHeader.Size; @@ -446,9 +526,6 @@ protected override void EmitObjectFile(string objectFilePath) } int symbolTableOffset = dataOffset; - int stringTableOffset = - symbolTableOffset + _symbols.Count * CoffSymbol.Size + - sizeof(int); // Count // Write COFF header var coffHeader = new CoffHeader @@ -461,12 +538,30 @@ protected override void EmitObjectFile(string objectFilePath) coffHeader.Write(outputFileStream); // Write COFF section headers - foreach ((CoffSectionHeader sectionHeader, _, _) in _sections) + sectionIndex = 0; + foreach (var section in _sections) { - sectionHeader.Write(outputFileStream, stringTable); + section.Header.Write(outputFileStream, stringTable); // Relocation code below assumes that addresses are 0-indexed - Debug.Assert(sectionHeader.VirtualAddress == 0); + Debug.Assert(section.Header.VirtualAddress == 0); + + // Update COMDAT section symbol + if (_sectionNumberToComdatAuxRecord.TryGetValue(sectionIndex, out var auxRecord)) + { + auxRecord.SizeOfRawData = section.Header.SizeOfRawData; + auxRecord.NumberOfRelocations = section.Header.NumberOfRelocations; + auxRecord.NumberOfLineNumbers = section.Header.NumberOfLineNumbers; + + /*Crc32 crc = new Crc32(); + section.Stream.Position = 0; + crc.Append(section.Stream); + auxRecord.CheckSum = BinaryPrimitives.ReadUInt32LittleEndian(crc.GetCurrentHash());*/ + section.Stream.Position = 0; + auxRecord.CheckSum = JamCrc32.CalculateChecksum(section.Stream); + } + + sectionIndex++; } // Writer section content and relocations @@ -496,12 +591,7 @@ protected override void EmitObjectFile(string objectFilePath) } // Write string table - Span stringTableSize = stackalloc byte[4]; - BinaryPrimitives.WriteInt32LittleEndian(stringTableSize, (int)(stringTable.Length + 4)); - outputFileStream.Write(stringTableSize); - Debug.Assert(outputFileStream.Position == stringTableOffset); - stringTable.Position = 0; - stringTable.CopyTo(outputFileStream); + stringTable.Write(outputFileStream); } protected override void CreateEhSections() @@ -600,28 +690,26 @@ private sealed class CoffSectionHeader sizeof(short) + // NumberOfLineNumbers sizeof(int); // SectionCharacteristics - public void Write(Stream stream, Stream stringTableStream) + public void Write(Stream stream, CoffStringTable stringTable) { Span buffer = stackalloc byte[Size]; - var nameBytes = Encoding.UTF8.GetBytes(Name); // TODO: Pool buffers - if (nameBytes.Length <= NameSize) + var nameBytes = Encoding.UTF8.GetByteCount(Name); + if (nameBytes <= NameSize) { - nameBytes.CopyTo(buffer); - if (nameBytes.Length < NameSize) + Encoding.UTF8.GetBytes(Name, buffer); + if (nameBytes < NameSize) { - buffer.Slice(nameBytes.Length, 8 - nameBytes.Length).Clear(); + buffer.Slice(nameBytes, 8 - nameBytes).Clear(); } } else { - string longName = $"/{stringTableStream.Position + 4}\0\0\0\0\0\0"; + string longName = $"/{stringTable.GetStringOffset(Name)}\0\0\0\0\0\0"; for (int i = 0; i < 8; i++) { buffer[i] = (byte)longName[i]; } - stringTableStream.Write(nameBytes); - stringTableStream.WriteByte(0); } BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), VirtualSize); @@ -701,18 +789,23 @@ public void Write(Stream stream) } } - private sealed class CoffSymbol + private abstract class CoffSymbolRecord + { + public abstract void Write(Stream stream, CoffStringTable stringTable); + } + + private sealed class CoffSymbol : CoffSymbolRecord { public string Name { get; set; } public int Value { get; set; } public short SectionIndex { get; set; } public short Type { get; set; } public byte StorageClass { get; set; } - public byte AuxiliaryCount { get; set; } + public byte NumberOfAuxiliaryRecords { get; set; } private const int NameSize = 8; - public const int Size = + private const int Size = NameSize + // Name size sizeof(int) + // Value sizeof(short) + // Section index @@ -720,35 +813,177 @@ private sealed class CoffSymbol sizeof(byte) + // Storage class sizeof(byte); // Auxiliary symbol count - public void Write(Stream stream, Stream stringTableStream) + public override void Write(Stream stream, CoffStringTable stringTable) { Span buffer = stackalloc byte[Size]; - var nameBytes = Encoding.UTF8.GetBytes(Name); // TODO: Pool buffers - if (nameBytes.Length <= NameSize) + int nameBytes = Encoding.UTF8.GetByteCount(Name); + if (nameBytes <= NameSize) { - nameBytes.CopyTo(buffer); - if (nameBytes.Length < NameSize) + Encoding.UTF8.GetBytes(Name, buffer); + if (nameBytes < NameSize) { - buffer.Slice(nameBytes.Length, 8 - nameBytes.Length).Clear(); + buffer.Slice(nameBytes, 8 - nameBytes).Clear(); } } else { BinaryPrimitives.WriteUInt32LittleEndian(buffer, 0); - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)(stringTableStream.Position + 4)); - stringTableStream.Write(nameBytes); - stringTableStream.WriteByte(0); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), stringTable.GetStringOffset(Name)); } BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), Value); BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 4), SectionIndex); BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 6), Type); buffer[NameSize + 8] = StorageClass; - buffer[NameSize + 9] = AuxiliaryCount; + buffer[NameSize + 9] = NumberOfAuxiliaryRecords; stream.Write(buffer); } } + + private enum CoffComdatSelect + { + IMAGE_COMDAT_SELECT_NODUPLICATES = 1, + IMAGE_COMDAT_SELECT_ANY = 2, + IMAGE_COMDAT_SELECT_SAME_SIZE = 3, + IMAGE_COMDAT_SELECT_EXACT_MATCH = 4, + IMAGE_COMDAT_SELECT_ASSOCIATIVE = 5, + IMAGE_COMDAT_SELECT_LARGEST = 6, + } + + private sealed class CoffSectionSymbol : CoffSymbolRecord + { + public int SizeOfRawData { get; set; } + public ushort NumberOfRelocations { get; set; } + public ushort NumberOfLineNumbers { get; set; } + public uint CheckSum { get; set; } + public ushort Number { get; set; } + public CoffComdatSelect Selection { get; set; } + + private const int Size = + sizeof(uint) + // SizeOfRawData + sizeof(ushort) + // NumberOfRelocations + sizeof(ushort) + // NumberOfLineNumbers + sizeof(uint) + // CheckSum + sizeof(ushort) + // Number + sizeof(byte) + // Selection + 3; // Reserved + + public override void Write(Stream stream, CoffStringTable stringTable) + { + Span buffer = stackalloc byte[Size]; + + BinaryPrimitives.WriteInt32LittleEndian(buffer, SizeOfRawData); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(4), NumberOfRelocations); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), NumberOfLineNumbers); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), CheckSum); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(12), Number); + buffer[14] = (byte)Selection; + buffer[15] = 0; + buffer[16] = 0; + buffer[17] = 0; + + stream.Write(buffer); + } + } + + private sealed class CoffStringTable + { + private MemoryStream _stream = new(); + private Dictionary _stringToOffset = new(); + + public uint GetStringOffset(string str) + { + uint offset; + + if (_stringToOffset.TryGetValue(str, out offset)) + { + return offset; + } + + offset = (uint)(_stream.Position + 4); + var strBytes = Encoding.UTF8.GetBytes(str); // TODO: Pool buffers + _stream.Write(strBytes); + _stream.WriteByte(0); + _stringToOffset[str] = offset; + + return offset; + } + + public void Write(Stream stream) + { + Span stringTableSize = stackalloc byte[4]; + BinaryPrimitives.WriteInt32LittleEndian(stringTableSize, (int)(_stream.Length + 4)); + stream.Write(stringTableSize); + _stream.Position = 0; + _stream.CopyTo(stream); + } + } + + private static class JamCrc32 + { + private static uint[] Table = + { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + }; + + public static uint CalculateChecksum(Stream stream) + { + uint crc = 0; + Span buffer = stackalloc byte[4096]; + while (stream.Position < stream.Length) + { + int length = stream.Read(buffer); + for (int i = 0; i < length; i++) + { + crc = Table[(crc ^ buffer[i]) & 0xff] ^ (crc >> 8); + } + } + return crc; + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 9aff3e56057be1..c6efd10e1f001d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -29,11 +29,12 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy protected NodeFactory _nodeFactory; protected ObjectWritingOptions _options; + protected bool _isSingleFileCompilation; private byte _insPaddingByte; // Standard sections - private Dictionary _sectionNameToSectionIndex = new(); + private Dictionary<(string, string), int> _sectionNameToSectionIndex = new(); private List _sectionIndexToStream = new(); private List> _sectionIndexToRelocations = new(); @@ -47,6 +48,7 @@ protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) { _nodeFactory = factory; _options = options; + _isSingleFileCompilation = _nodeFactory.CompilationModuleGroup.IsSingleFileCompilation; // Padding byte for code sections (NOP for x86/x64) _insPaddingByte = factory.Target.Architecture switch @@ -77,11 +79,11 @@ protected int GetOrCreateSection( { int sectionIndex; - if (!_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) + if (!_sectionNameToSectionIndex.TryGetValue((section.Name, section.ComdatName), out sectionIndex)) { CreateSection(section, out sectionStream); sectionIndex = _sectionNameToSectionIndex.Count; - _sectionNameToSectionIndex[section.Name] = sectionIndex; + _sectionNameToSectionIndex.Add((section.Name, section.ComdatName), sectionIndex); _sectionIndexToStream.Add(sectionStream); _sectionIndexToRelocations.Add(relocationList = new()); } @@ -94,6 +96,42 @@ protected int GetOrCreateSection( return sectionIndex; } + protected bool ShouldShareSymbol(ObjectNode node) + { + // TODO: Not supported yet + if (_nodeFactory.Target.OperatingSystem == TargetOS.OSX || + _nodeFactory.Target.OperatingSystem == TargetOS.Linux) + return false; + + // Foldable sections are always COMDATs + ObjectNodeSection section = node.Section; + if (section == ObjectNodeSection.FoldableManagedCodeUnixContentSection || + section == ObjectNodeSection.FoldableManagedCodeWindowsContentSection || + section == ObjectNodeSection.FoldableReadOnlyDataSection) + return true; + + if (_isSingleFileCompilation) + return false; + + if (!(node is ISymbolNode)) + return false; + + // These intentionally clash with one another, but are merged with linker directives so should not be Comdat folded + if (node is ModulesSectionNode) + return false; + + return true; + } + + protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, string key) + { + string standardSectionPrefix = ""; + if (section.IsStandardSection) + standardSectionPrefix = "."; + + return new ObjectNodeSection(standardSectionPrefix + section.Name, section.Type, key); + } + protected abstract void EmitRelocation( int sectionIndex, List relocationList, @@ -230,9 +268,17 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection relocationList; - int sectionIndex = GetOrCreateSection(node.Section, out sectionStream, out relocationList); + int sectionIndex = GetOrCreateSection(section, out sectionStream, out relocationList); EmitAlignment(sectionIndex, sectionStream, nodeContents.Alignment); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index eda227ed48a9b7..ce9758f0076c14 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -41,6 +41,8 @@ public abstract class UnixObjectWriter : ObjectWriter protected int EhFrameSectionIndex => _ehFrameSectionIndex; + private static ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null); + protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { @@ -53,10 +55,26 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { - Span tempBuffer = stackalloc byte[4]; + int lsdaSectionIndex; + Stream lsdaStream; + List lsdaRelocations; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); - long mainLsdaOffset = _lsdaStream.Position; + Span tempBuffer = stackalloc byte[4]; + + if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) + { + lsdaSectionIndex = GetOrCreateSection( + GetSharedSection(LsdaSection, currentSymbolName), + out lsdaStream, out lsdaRelocations); + } + else + { + lsdaSectionIndex = _lsdaSectionIndex; + lsdaStream = _lsdaStream; + lsdaRelocations = _lsdaRelocations; + } + long mainLsdaOffset = lsdaStream.Position; for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; @@ -69,7 +87,7 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string lsdaSymbolName = $"_lsda{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; - EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(_lsdaSectionIndex, _lsdaStream.Position)); + EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(lsdaSectionIndex, lsdaStream.Position)); if (start != 0) { EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); @@ -79,14 +97,14 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode if (i != 0) { - _lsdaStream.WriteByte((byte)flags); + lsdaStream.WriteByte((byte)flags); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - _lsdaStream.Position)); - _lsdaStream.Write(tempBuffer); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaStream.Position)); + lsdaStream.Write(tempBuffer); // Emit relative offset from the main function BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(start - frameInfos[0].StartOffset)); - _lsdaStream.Write(tempBuffer); + lsdaStream.Write(tempBuffer); } else { @@ -96,21 +114,21 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - _lsdaStream.WriteByte((byte)flags); + lsdaStream.WriteByte((byte)flags); if (associatedDataNode != null) { string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - _lsdaSectionIndex, - _lsdaRelocations, - (int)_lsdaStream.Position, + lsdaSectionIndex, + lsdaRelocations, + (int)lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); - _lsdaStream.Write(tempBuffer); + lsdaStream.Write(tempBuffer); } if (ehInfo != null) @@ -118,19 +136,19 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); tempBuffer.Clear(); EmitRelocation( - _lsdaSectionIndex, - _lsdaRelocations, - (int)_lsdaStream.Position, + lsdaSectionIndex, + lsdaRelocations, + (int)lsdaStream.Position, tempBuffer, RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); - _lsdaStream.Write(tempBuffer); + lsdaStream.Write(tempBuffer); } if (nodeWithCodeInfo.GCInfo != null) { - _lsdaStream.Write(nodeWithCodeInfo.GCInfo); + lsdaStream.Write(nodeWithCodeInfo.GCInfo); } } @@ -184,7 +202,7 @@ protected override void CreateEhSections() { // Create sections for exception handling _lsdaSectionIndex = GetOrCreateSection( - new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null), + LsdaSection, out _lsdaStream, out _lsdaRelocations); _ehFrameSectionIndex = GetOrCreateSection( new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), From 19501ca9b37b90f45306196d654a6e5238aaa47d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 25 Oct 2022 16:15:03 +0200 Subject: [PATCH 017/144] Add support for writing extended COFF object files (> 65279 sections) --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 232 +++++++++++------- 1 file changed, 148 insertions(+), 84 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 87d72756accb53..ec5bb73676dbdf 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -194,7 +194,7 @@ protected override void EmitSymbolTable() { Name = sectionHeader.Name, Value = 0, - SectionIndex = (short)(1 + sectionIndex), + SectionIndex = (uint)(1 + sectionIndex), StorageClass = 3, // IMAGE_SYM_CLASS_STATIC NumberOfAuxiliaryRecords = 1 }); @@ -206,8 +206,8 @@ protected override void EmitSymbolTable() _symbols.Add(new CoffSymbol { Name = comdatName, - Value = (int)definingSymbol.Value, - SectionIndex = (short)(1 + definingSymbol.SectionIndex), + Value = (uint)definingSymbol.Value, + SectionIndex = (uint)(1 + definingSymbol.SectionIndex), StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL }); } @@ -223,8 +223,8 @@ protected override void EmitSymbolTable() _symbols.Add(new CoffSymbol { Name = symbolName, - Value = (int)symbolDefinition.Value, - SectionIndex = (short)(1 + symbolDefinition.SectionIndex), + Value = (uint)symbolDefinition.Value, + SectionIndex = (uint)(1 + symbolDefinition.SectionIndex), StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL }); } @@ -263,7 +263,7 @@ protected override void EmitSymbolTable() { Name = "@feat.00", StorageClass = 3, // IMAGE_SYM_CLASS_STATIC - SectionIndex = -1, // IMAGE_SYM_ABSOLUTE + SectionIndex = uint.MaxValue, // IMAGE_SYM_ABSOLUTE Value = 0x800, // cfGuardCF flags this object as control flow guard aware }); } @@ -499,13 +499,19 @@ protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); var stringTable = new CoffStringTable(); + var coffHeader = new CoffHeader + { + Machine = _machine, + NumberOfSections = (uint)_sections.Count, + NumberOfSymbols = (uint)_symbols.Count, + }; // Calculate size of section data and assign offsets - int dataOffset = CoffHeader.Size + _sections.Count * CoffSectionHeader.Size; + uint dataOffset = (uint)(coffHeader.Size + _sections.Count * CoffSectionHeader.Size); int sectionIndex = 0; foreach (var section in _sections) { - section.Header.SizeOfRawData = (int)section.Stream.Length; + section.Header.SizeOfRawData = (uint)section.Stream.Length; // Section content if (section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) @@ -520,21 +526,14 @@ protected override void EmitObjectFile(string objectFilePath) // Section relocations section.Header.PointerToRelocations = section.Relocations.Count > 0 ? dataOffset : 0; - dataOffset += section.Relocations.Count * CoffRelocation.Size; + dataOffset += (uint)(section.Relocations.Count * CoffRelocation.Size); sectionIndex++; } - int symbolTableOffset = dataOffset; + coffHeader.PointerToSymbolTable = dataOffset; // Write COFF header - var coffHeader = new CoffHeader - { - Machine = _machine, - NumberOfSections = (ushort)_sections.Count, - PointerToSymbolTable = (uint)symbolTableOffset, - NumberOfSymbols = (uint)_symbols.Count, - }; coffHeader.Write(outputFileStream); // Write COFF section headers @@ -553,10 +552,6 @@ protected override void EmitObjectFile(string objectFilePath) auxRecord.NumberOfRelocations = section.Header.NumberOfRelocations; auxRecord.NumberOfLineNumbers = section.Header.NumberOfLineNumbers; - /*Crc32 crc = new Crc32(); - section.Stream.Position = 0; - crc.Append(section.Stream); - auxRecord.CheckSum = BinaryPrimitives.ReadUInt32LittleEndian(crc.GetCurrentHash());*/ section.Stream.Position = 0; auxRecord.CheckSum = JamCrc32.CalculateChecksum(section.Stream); } @@ -584,10 +579,10 @@ protected override void EmitObjectFile(string objectFilePath) } // Write symbol table - Debug.Assert(outputFileStream.Position == symbolTableOffset); + Debug.Assert(outputFileStream.Position == coffHeader.PointerToSymbolTable); foreach (var coffSymbol in _symbols) { - coffSymbol.Write(outputFileStream, stringTable); + coffSymbol.Write(outputFileStream, stringTable, coffHeader.IsBigObj); } // Write string table @@ -631,14 +626,25 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection NumberOfSections > 65279; + + private static ReadOnlySpan BigObjMagic => new byte[] + { + 0xc7, 0xa1, 0xba, 0xd1, 0xee, 0xba, 0xa9, 0x4b, + 0xaf, 0x20, 0xfa, 0xf6, 0x6a, 0xa4, 0xdc, 0xb8, + }; + + private const int RegularSize = sizeof(ushort) + // Machine sizeof(ushort) + // NumberOfSections sizeof(uint) + // TimeDateStamp @@ -647,31 +653,70 @@ private sealed class CoffHeader sizeof(ushort) + // SizeOfOptionalHeader sizeof(ushort); // Characteristics + private const int BigObjSize = + sizeof(ushort) + // Signature 1 (Machine = Unknown) + sizeof(ushort) + // Signature 2 (NumberOfSections = 0xffff) + sizeof(ushort) + // Version (2) + sizeof(ushort) + // Machine + sizeof(uint) + // TimeDateStamp + 16 + // BigObjMagic + sizeof(uint) + // Reserved1 + sizeof(uint) + // Reserved2 + sizeof(uint) + // Reserved3 + sizeof(uint) + // Reserved4 + sizeof(uint) + // NumberOfSections + sizeof(uint) + // PointerToSymbolTable + sizeof(uint); // NumberOfSymbols + + public int Size => IsBigObj ? BigObjSize : RegularSize; + public void Write(Stream stream) { - Span buffer = stackalloc byte[Size]; + if (!IsBigObj) + { + Span buffer = stackalloc byte[RegularSize]; - BinaryPrimitives.WriteInt16LittleEndian(buffer, (short)Machine); - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), NumberOfSections); - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), TimeDateStamp); - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), PointerToSymbolTable); - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12), NumberOfSymbols); - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(16), SizeOfOptionalHeader); - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(18), Characteristics); + BinaryPrimitives.WriteInt16LittleEndian(buffer, (short)Machine); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), (ushort)NumberOfSections); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), TimeDateStamp); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), PointerToSymbolTable); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12), NumberOfSymbols); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(16), SizeOfOptionalHeader); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(18), Characteristics); - stream.Write(buffer); + stream.Write(buffer); + } + else + { + Span buffer = stackalloc byte[BigObjSize]; + + buffer.Clear(); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), 0xffff); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(4), 2); + BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(6), (short)Machine); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), TimeDateStamp); + BigObjMagic.CopyTo(buffer.Slice(12)); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(44), NumberOfSections); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(48), PointerToSymbolTable); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(52), NumberOfSymbols); + + Debug.Assert(SizeOfOptionalHeader == 0); + Debug.Assert(Characteristics == 0); + + stream.Write(buffer); + } } } private sealed class CoffSectionHeader { public string Name { get; set; } - public int VirtualSize { get; set; } - public int VirtualAddress { get; set; } - public int SizeOfRawData { get; set; } - public int PointerToRawData { get; set; } - public int PointerToRelocations { get; set; } - public int PointerToLineNumbers { get; set; } + public uint VirtualSize { get; set; } + public uint VirtualAddress { get; set; } + public uint SizeOfRawData { get; set; } + public uint PointerToRawData { get; set; } + public uint PointerToRelocations { get; set; } + public uint PointerToLineNumbers { get; set; } public ushort NumberOfRelocations { get; set; } public ushort NumberOfLineNumbers { get; set; } public SectionCharacteristics SectionCharacteristics { get; set; } @@ -679,16 +724,16 @@ private sealed class CoffSectionHeader private const int NameSize = 8; public const int Size = - NameSize + // Name size - sizeof(int) + // VirtualSize - sizeof(int) + // VirtualAddress - sizeof(int) + // SizeOfRawData - sizeof(int) + // PointerToRawData - sizeof(int) + // PointerToRelocations - sizeof(int) + // PointerToLineNumbers - sizeof(short) + // NumberOfRelocations - sizeof(short) + // NumberOfLineNumbers - sizeof(int); // SectionCharacteristics + NameSize + // Name size + sizeof(uint) + // VirtualSize + sizeof(uint) + // VirtualAddress + sizeof(uint) + // SizeOfRawData + sizeof(uint) + // PointerToRawData + sizeof(uint) + // PointerToRelocations + sizeof(uint) + // PointerToLineNumbers + sizeof(ushort) + // NumberOfRelocations + sizeof(ushort) + // NumberOfLineNumbers + sizeof(uint); // SectionCharacteristics public void Write(Stream stream, CoffStringTable stringTable) { @@ -712,15 +757,15 @@ public void Write(Stream stream, CoffStringTable stringTable) } } - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), VirtualSize); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 4), VirtualAddress); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 8), SizeOfRawData); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 12), PointerToRawData); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 16), PointerToRelocations); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 20), PointerToLineNumbers); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize), VirtualSize); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 4), VirtualAddress); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 8), SizeOfRawData); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 12), PointerToRawData); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 16), PointerToRelocations); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 20), PointerToLineNumbers); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(NameSize + 24), NumberOfRelocations); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(NameSize + 26), NumberOfLineNumbers); - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize + 28), (int)SectionCharacteristics); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 28), (uint)SectionCharacteristics); stream.Write(buffer); } @@ -791,31 +836,39 @@ public void Write(Stream stream) private abstract class CoffSymbolRecord { - public abstract void Write(Stream stream, CoffStringTable stringTable); + public abstract void Write(Stream stream, CoffStringTable stringTable, bool isBigObj); } private sealed class CoffSymbol : CoffSymbolRecord { public string Name { get; set; } - public int Value { get; set; } - public short SectionIndex { get; set; } - public short Type { get; set; } + public uint Value { get; set; } + public uint SectionIndex { get; set; } + public ushort Type { get; set; } public byte StorageClass { get; set; } public byte NumberOfAuxiliaryRecords { get; set; } private const int NameSize = 8; - private const int Size = - NameSize + // Name size - sizeof(int) + // Value - sizeof(short) + // Section index - sizeof(short) + // Type - sizeof(byte) + // Storage class - sizeof(byte); // Auxiliary symbol count - - public override void Write(Stream stream, CoffStringTable stringTable) + private const int RegularSize = + NameSize + // Name size + sizeof(uint) + // Value + sizeof(ushort) + // Section index + sizeof(ushort) + // Type + sizeof(byte) + // Storage class + sizeof(byte); // Auxiliary symbol count + + private const int BigObjSize = + NameSize + // Name size + sizeof(uint) + // Value + sizeof(uint) + // Section index + sizeof(ushort) + // Type + sizeof(byte) + // Storage class + sizeof(byte); // Auxiliary symbol count + + public override void Write(Stream stream, CoffStringTable stringTable, bool isBigObj) { - Span buffer = stackalloc byte[Size]; + Span buffer = stackalloc byte[isBigObj ? BigObjSize : RegularSize]; int nameBytes = Encoding.UTF8.GetByteCount(Name); if (nameBytes <= NameSize) @@ -832,11 +885,22 @@ public override void Write(Stream stream, CoffStringTable stringTable) BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), stringTable.GetStringOffset(Name)); } - BinaryPrimitives.WriteInt32LittleEndian(buffer.Slice(NameSize), Value); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 4), SectionIndex); - BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(NameSize + 6), Type); - buffer[NameSize + 8] = StorageClass; - buffer[NameSize + 9] = NumberOfAuxiliaryRecords; + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize), Value); + int sliceIndex; + if (isBigObj) + { + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(NameSize + 4), SectionIndex); + sliceIndex = NameSize + 8; + } + else + { + Debug.Assert(SectionIndex == uint.MaxValue || SectionIndex < ushort.MaxValue); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(NameSize + 4), (ushort)SectionIndex); + sliceIndex = NameSize + 6; + } + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(sliceIndex), Type); + buffer[sliceIndex + 2] = StorageClass; + buffer[sliceIndex + 3] = NumberOfAuxiliaryRecords; stream.Write(buffer); } @@ -854,14 +918,14 @@ private enum CoffComdatSelect private sealed class CoffSectionSymbol : CoffSymbolRecord { - public int SizeOfRawData { get; set; } + public uint SizeOfRawData { get; set; } public ushort NumberOfRelocations { get; set; } public ushort NumberOfLineNumbers { get; set; } public uint CheckSum { get; set; } public ushort Number { get; set; } public CoffComdatSelect Selection { get; set; } - private const int Size = + private const int RegularSize = sizeof(uint) + // SizeOfRawData sizeof(ushort) + // NumberOfRelocations sizeof(ushort) + // NumberOfLineNumbers @@ -870,19 +934,19 @@ private sealed class CoffSectionSymbol : CoffSymbolRecord sizeof(byte) + // Selection 3; // Reserved - public override void Write(Stream stream, CoffStringTable stringTable) + private const int BigObjSize = RegularSize + 2; + + public override void Write(Stream stream, CoffStringTable stringTable, bool isBigObj) { - Span buffer = stackalloc byte[Size]; + Span buffer = stackalloc byte[isBigObj ? BigObjSize : RegularSize]; - BinaryPrimitives.WriteInt32LittleEndian(buffer, SizeOfRawData); + buffer.Clear(); + BinaryPrimitives.WriteUInt32LittleEndian(buffer, SizeOfRawData); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(4), NumberOfRelocations); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), NumberOfLineNumbers); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), CheckSum); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(12), Number); buffer[14] = (byte)Selection; - buffer[15] = 0; - buffer[16] = 0; - buffer[17] = 0; stream.Write(buffer); } From 88e1002fc430310295563437c8b48294fbf88bf8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 25 Oct 2022 17:35:41 +0200 Subject: [PATCH 018/144] Wrap some logic in SectionWriter struct; clean up code --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 116 +++----------- .../Compiler/ObjectWriter/DwarfEhFrame.cs | 17 +- .../Compiler/ObjectWriter/ObjectWriter.cs | 147 +++++++++++++----- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 86 ++++------ 4 files changed, 167 insertions(+), 199 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index ec5bb73676dbdf..486628b4fe69ac 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -35,12 +35,8 @@ public class CoffObjectWriter : ObjectWriter private Dictionary _sectionNumberToComdatAuxRecord = new(); // Exception handling - private int _xdataSectionIndex; - private int _pdataSectionIndex; - private Stream _xdataStream; - private Stream _pdataStream; - private List _xdataRelocations; - private List _pdataRelocations; + private SectionWriter _xdataSectionWriter; + private SectionWriter _pdataSectionWriter; private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); @@ -243,7 +239,7 @@ protected override void EmitSymbolTable() if (_options.HasFlag(ObjectWritingOptions.ControlFlowGuard)) { // Create section with control flow guard symbols - GetOrCreateSection(GfidsSection, out var sectionStream, out _); + SectionWriter gfidsSectionWriter = GetOrCreateSection(GfidsSection); Span tempBuffer = stackalloc byte[4]; foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) @@ -254,7 +250,7 @@ protected override void EmitSymbolTable() if (symbolDefinition.Size > 0) { BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); - sectionStream.Write(tempBuffer); + gfidsSectionWriter.Stream.Write(tempBuffer); } } @@ -339,34 +335,25 @@ protected override void EmitRelocations(int sectionIndex, List xdataRelocations, pdataRelocations; + SectionWriter xdataSectionWriter; + SectionWriter pdataSectionWriter; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); Span tempBuffer = stackalloc byte[4]; if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) { - xdataSectionIndex = GetOrCreateSection( - GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName), - out xdataStream, out xdataRelocations); - pdataSectionIndex = GetOrCreateSection( - GetSharedSection(PDataSection, currentSymbolName), - out pdataStream, out pdataRelocations); + xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName)); + pdataSectionWriter = GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)); } else { - xdataSectionIndex = _xdataSectionIndex; - xdataStream = _xdataStream; - xdataRelocations = _xdataRelocations; - pdataSectionIndex = _pdataSectionIndex; - pdataStream = _pdataStream; - pdataRelocations = _pdataRelocations; + xdataSectionWriter = _xdataSectionWriter; + pdataSectionWriter = _pdataSectionWriter; } for (int i = 0; i < frameInfos.Length; i++) @@ -378,27 +365,22 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode byte[] blob = frameInfo.BlobData; string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; - string framSymbolName = $"_fram{i}{currentSymbolName}"; // Need to emit the UNWIND_INFO at 4-byte alignment to ensure that the // pointer has the lower two bits in .pdata section set to zero. On ARM64 // non-zero bits would mean a compact encoding. - EmitAlignment(xdataSectionIndex, xdataStream, 4); + xdataSectionWriter.EmitAlignment(4); - EmitSymbolDefinition(unwindSymbolName, new SymbolDefinition(xdataSectionIndex, xdataStream.Position)); - if (start != 0) - { - EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); - } + xdataSectionWriter.EmitSymbolDefinition(unwindSymbolName); // Emit UNWIND_INFO - xdataStream.Write(blob); + xdataSectionWriter.Stream.Write(blob); FrameInfoFlags flags = frameInfo.Flags; if (i != 0) { - xdataStream.WriteByte((byte)flags); + xdataSectionWriter.Stream.WriteByte((byte)flags); } else { @@ -408,85 +390,35 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - xdataStream.WriteByte((byte)flags); + xdataSectionWriter.Stream.WriteByte((byte)flags); if (associatedDataNode != null) { string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); - tempBuffer.Clear(); - EmitRelocation( - xdataSectionIndex, - xdataRelocations, - (int)xdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - symbolName, - 0); - xdataStream.Write(tempBuffer); + xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); } if (ehInfo != null) { string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); - tempBuffer.Clear(); - EmitRelocation( - xdataSectionIndex, - xdataRelocations, - (int)xdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - symbolName, - 0); - xdataStream.Write(tempBuffer); + xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); } if (nodeWithCodeInfo.GCInfo != null) { - xdataStream.Write(nodeWithCodeInfo.GCInfo); + xdataSectionWriter.Stream.Write(nodeWithCodeInfo.GCInfo); } } // Emit RUNTIME_FUNCTION - - // Start - tempBuffer.Clear(); - EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - currentSymbolName, - start); - pdataStream.Write(tempBuffer); - + pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); // Only x64 has the End symbol if (_machine == Machine.Amd64) { - // End - tempBuffer.Clear(); - EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - currentSymbolName, - end); - pdataStream.Write(tempBuffer); + pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, end); } - // Unwind info pointer - tempBuffer.Clear(); - EmitRelocation( - pdataSectionIndex, - pdataRelocations, - (int)pdataStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_ADDR32NB, - unwindSymbolName, - 0); - pdataStream.Write(tempBuffer); + pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, unwindSymbolName, 0); } } } @@ -592,8 +524,8 @@ protected override void EmitObjectFile(string objectFilePath) protected override void CreateEhSections() { // Create .xdata and .pdata - _xdataSectionIndex = GetOrCreateSection(ObjectNodeSection.XDataSection, out _xdataStream, out _xdataRelocations); - _pdataSectionIndex = GetOrCreateSection(PDataSection, out _pdataStream, out _pdataRelocations); + _xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection); + _pdataSectionWriter = GetOrCreateSection(PDataSection); } protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() => null; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs index e8e8a48af8e853..00cef64846276d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs @@ -18,17 +18,17 @@ namespace ILCompiler.ObjectWriter { public class DwarfEhFrame { - public delegate void EmitRelocationAction(int offset, Span data, RelocType relocationType, string symbolName); + public delegate void EmitSymbolReferenceAction(RelocType relocationType, string symbolName); private Stream _stream; - private EmitRelocationAction _emitRelocation; + private EmitSymbolReferenceAction _emitSymbolReference; private bool _is64Bit; private Dictionary _cieOffset; - public DwarfEhFrame(Stream stream, EmitRelocationAction emitRelocation, bool is64Bit) + public DwarfEhFrame(Stream stream, EmitSymbolReferenceAction emitSymbolReference, bool is64Bit) { _stream = stream; - _emitRelocation = emitRelocation; + _emitSymbolReference = emitSymbolReference; _is64Bit = is64Bit; _cieOffset = new Dictionary(); } @@ -180,7 +180,6 @@ private uint AddressSize(byte encoding) private void WriteAddress(byte encoding, string symbolName) { - Span address = stackalloc byte[(int)AddressSize(encoding)]; if (symbolName != null) { RelocType relocationType = encoding switch @@ -189,9 +188,13 @@ private void WriteAddress(byte encoding, string symbolName) DW_EH_PE_absptr => RelocType.IMAGE_REL_BASED_DIR64, _ => throw new NotSupportedException() }; - _emitRelocation((int)_stream.Position, address, relocationType, symbolName); + _emitSymbolReference(relocationType, symbolName); + } + else + { + Span address = stackalloc byte[(int)AddressSize(encoding)]; + _stream.Write(address); } - _stream.Write(address); } private void WriteSize(byte encoding, ulong size) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index c6efd10e1f001d..aecae9611bc69d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -72,12 +72,11 @@ public void Dispose() protected abstract void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable); - protected int GetOrCreateSection( - ObjectNodeSection section, - out Stream sectionStream, - out List relocationList) + protected SectionWriter GetOrCreateSection(ObjectNodeSection section) { int sectionIndex; + Stream sectionStream; + List relocationList; if (!_sectionNameToSectionIndex.TryGetValue((section.Name, section.ComdatName), out sectionIndex)) { @@ -93,7 +92,11 @@ protected int GetOrCreateSection( relocationList = _sectionIndexToRelocations[sectionIndex]; } - return sectionIndex; + return new SectionWriter( + this, + sectionIndex, + sectionStream, + relocationList); } protected bool ShouldShareSymbol(ObjectNode node) @@ -157,23 +160,7 @@ protected abstract void EmitRelocation( protected virtual string ExternCName(string name) => name; - protected void EmitSymbolDefinition(string name, SymbolDefinition definition) - { - _definedSymbols.Add(name, definition); - } - - protected abstract void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo); - - protected void EmitAlignment(int sectionIndex, Stream sectionStream, int alignment) - { - UpdateSectionAlignment(sectionIndex, alignment, out bool isExecutable); - - int padding = (int)(((sectionStream.Position + alignment - 1) & ~(alignment - 1)) - sectionStream.Position); - Span buffer = stackalloc byte[padding]; - byte paddingByte = isExecutable ? _insPaddingByte : (byte)0; - buffer.Fill(paddingByte); - sectionStream.Write(buffer); - } + protected abstract void EmitUnwindInfo(SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo); protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) { @@ -239,14 +226,14 @@ protected abstract void EmitDebugFunctionInfo( protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) { // Pre-create some of the sections - GetOrCreateSection(ObjectNodeSection.TextSection, out _, out _); + GetOrCreateSection(ObjectNodeSection.TextSection); if (_nodeFactory.Target.OperatingSystem == TargetOS.Windows) { - GetOrCreateSection(ObjectNodeSection.ManagedCodeWindowsContentSection, out _, out _); + GetOrCreateSection(ObjectNodeSection.ManagedCodeWindowsContentSection); } else { - GetOrCreateSection(ObjectNodeSection.ManagedCodeUnixContentSection, out _, out _); + GetOrCreateSection(ObjectNodeSection.ManagedCodeUnixContentSection); } // Create sections for exception handling @@ -276,25 +263,23 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection relocationList; - int sectionIndex = GetOrCreateSection(section, out sectionStream, out relocationList); - - EmitAlignment(sectionIndex, sectionStream, nodeContents.Alignment); + SectionWriter sectionWriter = GetOrCreateSection(section); - long methodStart = sectionStream.Position; + sectionWriter.EmitAlignment(nodeContents.Alignment); foreach (ISymbolDefinitionNode n in nodeContents.DefinedSymbols) { bool isMethod = n.Offset == 0 && node is IMethodNode or AssemblyStubNode; - var symbolDefinition = new SymbolDefinition( - sectionIndex, - methodStart + n.Offset, + sectionWriter.EmitSymbolDefinition( + ExternCName(n.GetMangledName(_nodeFactory.NameMangler)), + n.Offset, isMethod ? nodeContents.Data.Length : 0); - EmitSymbolDefinition(ExternCName(n.GetMangledName(_nodeFactory.NameMangler)), symbolDefinition); if (_nodeFactory.GetSymbolAlternateName(n) is string alternateName) { - EmitSymbolDefinition(ExternCName(alternateName), symbolDefinition); + sectionWriter.EmitSymbolDefinition( + ExternCName(alternateName), + n.Offset, + isMethod ? nodeContents.Data.Length : 0); } } @@ -302,10 +287,8 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Relocations { get; init; } + + public SectionWriter( + ObjectWriter objectWriter, + int sectionIndex, + Stream stream, + List relocations) + { + _objectWriter = objectWriter; + SectionIndex = sectionIndex; + Stream = stream; + Relocations = relocations; + } + + public void EmitAlignment(int alignment) + { + _objectWriter.UpdateSectionAlignment(SectionIndex, alignment, out bool isExecutable); + + int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); + Span buffer = stackalloc byte[padding]; + byte paddingByte = isExecutable ? _objectWriter._insPaddingByte : (byte)0; + buffer.Fill(paddingByte); + Stream.Write(buffer); + } + + public void EmitRelocation( + int relativeOffset, + Span data, + RelocType relocType, + string symbolName, + int addend) + { + _objectWriter.EmitRelocation( + SectionIndex, + Relocations, + (int)Stream.Position + relativeOffset, + data, + relocType, + symbolName, + addend); + } + + public void EmitSymbolDefinition( + string symbolName, + int relativeOffset = 0, + int size = 0) + { + var symbolDefinition = new SymbolDefinition(SectionIndex, Stream.Position + relativeOffset, size); + _objectWriter._definedSymbols.Add(symbolName, symbolDefinition); + } + + public void EmitSymbolReference( + RelocType relocType, + string symbolName, + int addend = 0) + { + Span buffer = stackalloc byte[relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint)]; + buffer.Clear(); + _objectWriter.EmitRelocation( + SectionIndex, + Relocations, + (int)Stream.Position, + buffer, + relocType, + symbolName, + addend); + Stream.Write(buffer); + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index ce9758f0076c14..d3f608f13ab3ba 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -32,10 +32,8 @@ public abstract class UnixObjectWriter : ObjectWriter private DwarfBuilder _dwarfBuilder; // Exception handling sections - private int _lsdaSectionIndex; + private SectionWriter _lsdaSectionWriter; private int _ehFrameSectionIndex; - private Stream _lsdaStream; - private List _lsdaRelocations; private DwarfCie _dwarfCie; private DwarfEhFrame _dwarfEhFrame; @@ -50,31 +48,25 @@ protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) protected virtual bool EmitCompactUnwinding(DwarfFde fde) => false; - protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INodeWithCodeInfo nodeWithCodeInfo) + protected override void EmitUnwindInfo(SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo) { if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { - int lsdaSectionIndex; - Stream lsdaStream; - List lsdaRelocations; + SectionWriter lsdaSectionWriter; string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); Span tempBuffer = stackalloc byte[4]; if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) { - lsdaSectionIndex = GetOrCreateSection( - GetSharedSection(LsdaSection, currentSymbolName), - out lsdaStream, out lsdaRelocations); + lsdaSectionWriter = GetOrCreateSection(GetSharedSection(LsdaSection, currentSymbolName)); } else { - lsdaSectionIndex = _lsdaSectionIndex; - lsdaStream = _lsdaStream; - lsdaRelocations = _lsdaRelocations; + lsdaSectionWriter = _lsdaSectionWriter; } - long mainLsdaOffset = lsdaStream.Position; + long mainLsdaOffset = lsdaSectionWriter.Stream.Position; for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; @@ -87,24 +79,24 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode string lsdaSymbolName = $"_lsda{i}{currentSymbolName}"; string framSymbolName = $"_fram{i}{currentSymbolName}"; - EmitSymbolDefinition(lsdaSymbolName, new SymbolDefinition(lsdaSectionIndex, lsdaStream.Position)); + lsdaSectionWriter.EmitSymbolDefinition(lsdaSymbolName); if (start != 0) { - EmitSymbolDefinition(framSymbolName, new SymbolDefinition(sectionIndex, methodStart + start, 0)); + sectionWriter.EmitSymbolDefinition(framSymbolName, start); } FrameInfoFlags flags = frameInfo.Flags; if (i != 0) { - lsdaStream.WriteByte((byte)flags); + lsdaSectionWriter.Stream.WriteByte((byte)flags); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaStream.Position)); - lsdaStream.Write(tempBuffer); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaSectionWriter.Stream.Position)); + lsdaSectionWriter.Stream.Write(tempBuffer); // Emit relative offset from the main function BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(start - frameInfos[0].StartOffset)); - lsdaStream.Write(tempBuffer); + lsdaSectionWriter.Stream.Write(tempBuffer); } else { @@ -114,41 +106,23 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - lsdaStream.WriteByte((byte)flags); + lsdaSectionWriter.Stream.WriteByte((byte)flags); if (associatedDataNode != null) { string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); - tempBuffer.Clear(); - EmitRelocation( - lsdaSectionIndex, - lsdaRelocations, - (int)lsdaStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_RELPTR32, - symbolName, - 0); - lsdaStream.Write(tempBuffer); + lsdaSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); } if (ehInfo != null) { string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); - tempBuffer.Clear(); - EmitRelocation( - lsdaSectionIndex, - lsdaRelocations, - (int)lsdaStream.Position, - tempBuffer, - RelocType.IMAGE_REL_BASED_RELPTR32, - symbolName, - 0); - lsdaStream.Write(tempBuffer); + lsdaSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); } if (nodeWithCodeInfo.GCInfo != null) { - lsdaStream.Write(nodeWithCodeInfo.GCInfo); + lsdaSectionWriter.Stream.Write(nodeWithCodeInfo.GCInfo); } } @@ -159,9 +133,10 @@ protected override void EmitUnwindInfo(int sectionIndex, long methodStart, INode LsdaSymbolName = lsdaSymbolName, }; - _dwarfEhFrame.AddFde(fde); - - EmitCompactUnwinding(fde); + if (!EmitCompactUnwinding(fde)) + { + _dwarfEhFrame.AddFde(fde); + } } } } @@ -200,15 +175,14 @@ protected override void EmitDebugSections() protected override void CreateEhSections() { + SectionWriter ehFrameSectionWriter; + // Create sections for exception handling - _lsdaSectionIndex = GetOrCreateSection( - LsdaSection, - out _lsdaStream, out _lsdaRelocations); - _ehFrameSectionIndex = GetOrCreateSection( - new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null), - out var ehFrameStream, out var ehFrameRelocations); - UpdateSectionAlignment(_lsdaSectionIndex, 8, out _); - UpdateSectionAlignment(_ehFrameSectionIndex, 8, out _); + _lsdaSectionWriter = GetOrCreateSection(LsdaSection); + ehFrameSectionWriter = GetOrCreateSection(new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null)); + UpdateSectionAlignment(_lsdaSectionWriter.SectionIndex, 8, out _); + UpdateSectionAlignment(ehFrameSectionWriter.SectionIndex, 8, out _); + _ehFrameSectionIndex = ehFrameSectionWriter.SectionIndex; // We always use the same CIE in DWARF EH frames, so create and emit it now bool is64Bit = _nodeFactory.Target.Architecture switch @@ -219,10 +193,8 @@ protected override void CreateEhSections() }; _dwarfCie = new DwarfCie(_nodeFactory.Target.Architecture); _dwarfEhFrame = new DwarfEhFrame( - ehFrameStream, - (offset, data, relocType, symbolName) => EmitRelocation( - _ehFrameSectionIndex, ehFrameRelocations, - offset, data, relocType, symbolName, 0), + ehFrameSectionWriter.Stream, + (relocType, symbolName) => ehFrameSectionWriter.EmitSymbolReference(relocType, symbolName), is64Bit); _dwarfEhFrame.AddCie(_dwarfCie); } From 6d2d4bdbf6e7b1bc3353d909cf134dc188501619 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 25 Oct 2022 19:36:35 +0200 Subject: [PATCH 019/144] Emit GNU-stack note in ELF --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 65b9aa0f4eb471..819c9ef09b5e3e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -438,6 +438,12 @@ protected override void EmitSectionsAndLayout() _sectionIndexToElfSection[_bssSectionIndex].Size = (ulong)_bssStream.Length; } + _objectFile.AddSection(new ElfBinarySection(Stream.Null) + { + Name = ".note.GNU-stack", + Type = ElfSectionType.ProgBits, + }); + var elfDiagnostics = new DiagnosticBag(); _objectFile.UpdateLayout(elfDiagnostics); Debug.Assert(!elfDiagnostics.HasErrors); From cdce467754b9d1bbb692d2c1138084288855e5e2 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 25 Oct 2022 19:45:17 +0200 Subject: [PATCH 020/144] Propagate DWARF5 option --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 5 +++-- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 1c7d932b4f53e2..15e29881c5e26c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -36,7 +36,7 @@ internal sealed class DwarfBuilder : ITypesDebugInfoWriter public DwarfFile DwarfFile => _dwarfFile; - public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture) + public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, bool useDwarf5) { _nameMangler = nameMangler; _architecture = targetArchitecture; @@ -73,7 +73,8 @@ public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitectu var compilationUnit = new DwarfCompilationUnit() { AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32, - Root = _rootDIE + Root = _rootDIE, + Version = (ushort)(useDwarf5 ? 5u : 4u), }; _dwarfFile.InfoSection.AddUnit(compilationUnit); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index d3f608f13ab3ba..e3e7520af6739a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -201,7 +201,10 @@ protected override void CreateEhSections() protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { - return _dwarfBuilder = new DwarfBuilder(_nodeFactory.NameMangler, _nodeFactory.Target.Architecture); + return _dwarfBuilder = new DwarfBuilder( + _nodeFactory.NameMangler, + _nodeFactory.Target.Architecture, + _options.HasFlag(ObjectWritingOptions.UseDwarf5)); } protected override void EmitDebugStaticVars() From f900b0d8bd63b629b4ea62e97b605ce8b5fc4e33 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 26 Oct 2022 16:12:37 +0200 Subject: [PATCH 021/144] Initial take on CodeView type section builder --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 24 +++++++++++++++---- .../ILCompiler.Compiler.csproj | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 486628b4fe69ac..38b9f1d66b4446 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -38,8 +38,14 @@ public class CoffObjectWriter : ObjectWriter private SectionWriter _xdataSectionWriter; private SectionWriter _pdataSectionWriter; + // Debugging + private SectionWriter _debugTypesSectionWriter; + //private SectionWriter _debugSymbolSectionWriter; + private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); + private ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); + //private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); protected CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) @@ -77,6 +83,12 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect SectionCharacteristics.MemRead | SectionCharacteristics.MemWrite | SectionCharacteristics.ContainsUninitializedData; } + else if (section == DebugTypesSection) + { + sectionHeader.SectionCharacteristics = + SectionCharacteristics.MemRead | SectionCharacteristics.ContainsInitializedData | + SectionCharacteristics.MemDiscardable; + } if (section.ComdatName != null) { @@ -528,7 +540,14 @@ protected override void CreateEhSections() _pdataSectionWriter = GetOrCreateSection(PDataSection); } - protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() => null; + protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() + { + _debugTypesSectionWriter = GetOrCreateSection(DebugTypesSection); + _debugTypesSectionWriter.EmitAlignment(4); + return new CodeViewTypesBuilder( + _nodeFactory.NameMangler, _nodeFactory.Target.Architecture, + _debugTypesSectionWriter.Stream); + } protected override void EmitDebugFunctionInfo( uint methodTypeIndex, @@ -548,9 +567,6 @@ protected override void EmitDebugStaticVars() public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { - // Not supported yet - options &= ~ObjectWritingOptions.GenerateDebugInfo; - using CoffObjectWriter objectWriter = new CoffObjectWriter(factory, options); objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index af6382754d0530..ca9ef564f36224 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -588,6 +588,8 @@ + + From 1f2473b506ddc7f6642fcc71c21a0b00dbf81ba9 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 27 Oct 2022 12:28:56 +0200 Subject: [PATCH 022/144] Move SectionWriter out of ObjectWriter so it can be used by other builder classes --- .../Compiler/ObjectWriter/CodeViewNative.cs | 651 ++++++++++++++++++ .../ObjectWriter/CodeViewSymbolsBuilder.cs | 169 +++++ .../ObjectWriter/CodeViewTypesBuilder.cs | 460 +++++++++++++ .../Compiler/ObjectWriter/CoffObjectWriter.cs | 12 +- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 23 +- .../Compiler/ObjectWriter/MachObjectWriter.cs | 27 +- .../Compiler/ObjectWriter/ObjectWriter.cs | 129 ++-- .../Compiler/ObjectWriter/SectionWriter.cs | 100 +++ .../Compiler/ObjectWriter/UnixObjectWriter.cs | 4 +- .../ILCompiler.Compiler.csproj | 1 + 10 files changed, 1458 insertions(+), 118 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs new file mode 100644 index 00000000000000..19d5ca6a6035d3 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs @@ -0,0 +1,651 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILCompiler.ObjectWriter +{ + internal static class CodeViewNative + { + public const uint T_NOTYPE = 0x0000; // uncharacterized type (no type) + public const uint T_ABS = 0x0001; // absolute symbol + public const uint T_SEGMENT = 0x0002; // segment type + public const uint T_VOID = 0x0003; // void + public const uint T_HRESULT = 0x0008; // OLE/COM HRESULT + public const uint T_32PHRESULT = 0x0408; // OLE/COM HRESULT __ptr32 * + public const uint T_64PHRESULT = 0x0608; // OLE/COM HRESULT __ptr64 * + + public const uint T_PVOID = 0x0103; // near pointer to void + public const uint T_PFVOID = 0x0203; // far pointer to void + public const uint T_PHVOID = 0x0303; // huge pointer to void + public const uint T_32PVOID = 0x0403; // 32 bit pointer to void + public const uint T_32PFVOID = 0x0503; // 16:32 pointer to void + public const uint T_64PVOID = 0x0603; // 64 bit pointer to void + public const uint T_CURRENCY = 0x0004; // BASIC 8 byte currency value + public const uint T_NBASICSTR = 0x0005; // Near BASIC string + public const uint T_FBASICSTR = 0x0006; // Far BASIC string + public const uint T_NOTTRANS = 0x0007; // type not translated by cvpack + public const uint T_BIT = 0x0060; // bit + public const uint T_PASCHAR = 0x0061; // Pascal CHAR + public const uint T_BOOL32FF = 0x0062; // 32-bit BOOL where true is 0xffffffff + + // Character types + public const uint T_CHAR = 0x0010; // 8 bit signed + public const uint T_PCHAR = 0x0110; // 16 bit pointer to 8 bit signed + public const uint T_PFCHAR = 0x0210; // 16:16 far pointer to 8 bit signed + public const uint T_PHCHAR = 0x0310; // 16:16 huge pointer to 8 bit signed + public const uint T_32PCHAR = 0x0410; // 32 bit pointer to 8 bit signed + public const uint T_32PFCHAR = 0x0510; // 16:32 pointer to 8 bit signed + public const uint T_64PCHAR = 0x0610; // 64 bit pointer to 8 bit signed + + public const uint T_UCHAR = 0x0020; // 8 bit unsigned + public const uint T_PUCHAR = 0x0120; // 16 bit pointer to 8 bit unsigned + public const uint T_PFUCHAR = 0x0220; // 16:16 far pointer to 8 bit unsigned + public const uint T_PHUCHAR = 0x0320; // 16:16 huge pointer to 8 bit unsigned + public const uint T_32PUCHAR = 0x0420; // 32 bit pointer to 8 bit unsigned + public const uint T_32PFUCHAR = 0x0520; // 16:32 pointer to 8 bit unsigned + public const uint T_64PUCHAR = 0x0620; // 64 bit pointer to 8 bit unsigned + + // Really a character types + public const uint T_RCHAR = 0x0070; // really a char + public const uint T_PRCHAR = 0x0170; // 16 bit pointer to a real char + public const uint T_PFRCHAR = 0x0270; // 16:16 far pointer to a real char + public const uint T_PHRCHAR = 0x0370; // 16:16 huge pointer to a real char + public const uint T_32PRCHAR = 0x0470; // 32 bit pointer to a real char + public const uint T_32PFRCHAR = 0x0570; // 16:32 pointer to a real char + public const uint T_64PRCHAR = 0x0670; // 64 bit pointer to a real char + + // really a wide character types + public const uint T_WCHAR = 0x0071; // wide char + public const uint T_PWCHAR = 0x0171; // 16 bit pointer to a wide char + public const uint T_PFWCHAR = 0x0271; // 16:16 far pointer to a wide char + public const uint T_PHWCHAR = 0x0371; // 16:16 huge pointer to a wide char + public const uint T_32PWCHAR = 0x0471; // 32 bit pointer to a wide char + public const uint T_32PFWCHAR = 0x0571; // 16:32 pointer to a wide char + public const uint T_64PWCHAR = 0x0671; // 64 bit pointer to a wide char + + // really a 16-bit unicode char + public const uint T_CHAR16 = 0x007a; // 16-bit unicode char + public const uint T_PCHAR16 = 0x017a; // 16 bit pointer to a 16-bit unicode char + public const uint T_PFCHAR16 = 0x027a; // 16:16 far pointer to a 16-bit unicode char + public const uint T_PHCHAR16 = 0x037a; // 16:16 huge pointer to a 16-bit unicode char + public const uint T_32PCHAR16 = 0x047a; // 32 bit pointer to a 16-bit unicode char + public const uint T_32PFCHAR16 = 0x057a; // 16:32 pointer to a 16-bit unicode char + public const uint T_64PCHAR16 = 0x067a; // 64 bit pointer to a 16-bit unicode char + + // really a 32-bit unicode char + public const uint T_CHAR32 = 0x007b; // 32-bit unicode char + public const uint T_PCHAR32 = 0x017b; // 16 bit pointer to a 32-bit unicode char + public const uint T_PFCHAR32 = 0x027b; // 16:16 far pointer to a 32-bit unicode char + public const uint T_PHCHAR32 = 0x037b; // 16:16 huge pointer to a 32-bit unicode char + public const uint T_32PCHAR32 = 0x047b; // 32 bit pointer to a 32-bit unicode char + public const uint T_32PFCHAR32 = 0x057b; // 16:32 pointer to a 32-bit unicode char + public const uint T_64PCHAR32 = 0x067b; // 64 bit pointer to a 32-bit unicode char + + // 8 bit int types + public const uint T_INT1 = 0x0068; // 8 bit signed int + public const uint T_PINT1 = 0x0168; // 16 bit pointer to 8 bit signed int + public const uint T_PFINT1 = 0x0268; // 16:16 far pointer to 8 bit signed int + public const uint T_PHINT1 = 0x0368; // 16:16 huge pointer to 8 bit signed int + public const uint T_32PINT1 = 0x0468; // 32 bit pointer to 8 bit signed int + public const uint T_32PFINT1 = 0x0568; // 16:32 pointer to 8 bit signed int + public const uint T_64PINT1 = 0x0668; // 64 bit pointer to 8 bit signed int + + public const uint T_UINT1 = 0x0069; // 8 bit unsigned int + public const uint T_PUINT1 = 0x0169; // 16 bit pointer to 8 bit unsigned int + public const uint T_PFUINT1 = 0x0269; // 16:16 far pointer to 8 bit unsigned int + public const uint T_PHUINT1 = 0x0369; // 16:16 huge pointer to 8 bit unsigned int + public const uint T_32PUINT1 = 0x0469; // 32 bit pointer to 8 bit unsigned int + public const uint T_32PFUINT1 = 0x0569; // 16:32 pointer to 8 bit unsigned int + public const uint T_64PUINT1 = 0x0669; // 64 bit pointer to 8 bit unsigned int + + // 16 bit short types + public const uint T_SHORT = 0x0011; // 16 bit signed + public const uint T_PSHORT = 0x0111; // 16 bit pointer to 16 bit signed + public const uint T_PFSHORT = 0x0211; // 16:16 far pointer to 16 bit signed + public const uint T_PHSHORT = 0x0311; // 16:16 huge pointer to 16 bit signed + public const uint T_32PSHORT = 0x0411; // 32 bit pointer to 16 bit signed + public const uint T_32PFSHORT = 0x0511; // 16:32 pointer to 16 bit signed + public const uint T_64PSHORT = 0x0611; // 64 bit pointer to 16 bit signed + + public const uint T_USHORT = 0x0021; // 16 bit unsigned + public const uint T_PUSHORT = 0x0121; // 16 bit pointer to 16 bit unsigned + public const uint T_PFUSHORT = 0x0221; // 16:16 far pointer to 16 bit unsigned + public const uint T_PHUSHORT = 0x0321; // 16:16 huge pointer to 16 bit unsigned + public const uint T_32PUSHORT = 0x0421; // 32 bit pointer to 16 bit unsigned + public const uint T_32PFUSHORT = 0x0521; // 16:32 pointer to 16 bit unsigned + public const uint T_64PUSHORT = 0x0621; // 64 bit pointer to 16 bit unsigned + + // 16 bit int types + public const uint T_INT2 = 0x0072; // 16 bit signed int + public const uint T_PINT2 = 0x0172; // 16 bit pointer to 16 bit signed int + public const uint T_PFINT2 = 0x0272; // 16:16 far pointer to 16 bit signed int + public const uint T_PHINT2 = 0x0372; // 16:16 huge pointer to 16 bit signed int + public const uint T_32PINT2 = 0x0472; // 32 bit pointer to 16 bit signed int + public const uint T_32PFINT2 = 0x0572; // 16:32 pointer to 16 bit signed int + public const uint T_64PINT2 = 0x0672; // 64 bit pointer to 16 bit signed int + + public const uint T_UINT2 = 0x0073; // 16 bit unsigned int + public const uint T_PUINT2 = 0x0173; // 16 bit pointer to 16 bit unsigned int + public const uint T_PFUINT2 = 0x0273; // 16:16 far pointer to 16 bit unsigned int + public const uint T_PHUINT2 = 0x0373; // 16:16 huge pointer to 16 bit unsigned int + public const uint T_32PUINT2 = 0x0473; // 32 bit pointer to 16 bit unsigned int + public const uint T_32PFUINT2 = 0x0573; // 16:32 pointer to 16 bit unsigned int + public const uint T_64PUINT2 = 0x0673; // 64 bit pointer to 16 bit unsigned int + + // 32 bit long types + public const uint T_LONG = 0x0012; // 32 bit signed + public const uint T_ULONG = 0x0022; // 32 bit unsigned + public const uint T_PLONG = 0x0112; // 16 bit pointer to 32 bit signed + public const uint T_PULONG = 0x0122; // 16 bit pointer to 32 bit unsigned + public const uint T_PFLONG = 0x0212; // 16:16 far pointer to 32 bit signed + public const uint T_PFULONG = 0x0222; // 16:16 far pointer to 32 bit unsigned + public const uint T_PHLONG = 0x0312; // 16:16 huge pointer to 32 bit signed + public const uint T_PHULONG = 0x0322; // 16:16 huge pointer to 32 bit unsigned + + public const uint T_32PLONG = 0x0412; // 32 bit pointer to 32 bit signed + public const uint T_32PULONG = 0x0422; // 32 bit pointer to 32 bit unsigned + public const uint T_32PFLONG = 0x0512; // 16:32 pointer to 32 bit signed + public const uint T_32PFULONG = 0x0522; // 16:32 pointer to 32 bit unsigned + public const uint T_64PLONG = 0x0612; // 64 bit pointer to 32 bit signed + public const uint T_64PULONG = 0x0622; // 64 bit pointer to 32 bit unsigned + + // 32 bit int types + public const uint T_INT4 = 0x0074; // 32 bit signed int + public const uint T_PINT4 = 0x0174; // 16 bit pointer to 32 bit signed int + public const uint T_PFINT4 = 0x0274; // 16:16 far pointer to 32 bit signed int + public const uint T_PHINT4 = 0x0374; // 16:16 huge pointer to 32 bit signed int + public const uint T_32PINT4 = 0x0474; // 32 bit pointer to 32 bit signed int + public const uint T_32PFINT4 = 0x0574; // 16:32 pointer to 32 bit signed int + public const uint T_64PINT4 = 0x0674; // 64 bit pointer to 32 bit signed int + + public const uint T_UINT4 = 0x0075; // 32 bit unsigned int + public const uint T_PUINT4 = 0x0175; // 16 bit pointer to 32 bit unsigned int + public const uint T_PFUINT4 = 0x0275; // 16:16 far pointer to 32 bit unsigned int + public const uint T_PHUINT4 = 0x0375; // 16:16 huge pointer to 32 bit unsigned int + public const uint T_32PUINT4 = 0x0475; // 32 bit pointer to 32 bit unsigned int + public const uint T_32PFUINT4 = 0x0575; // 16:32 pointer to 32 bit unsigned int + public const uint T_64PUINT4 = 0x0675; // 64 bit pointer to 32 bit unsigned int + + // 64 bit quad types + public const uint T_QUAD = 0x0013; // 64 bit signed + public const uint T_PQUAD = 0x0113; // 16 bit pointer to 64 bit signed + public const uint T_PFQUAD = 0x0213; // 16:16 far pointer to 64 bit signed + public const uint T_PHQUAD = 0x0313; // 16:16 huge pointer to 64 bit signed + public const uint T_32PQUAD = 0x0413; // 32 bit pointer to 64 bit signed + public const uint T_32PFQUAD = 0x0513; // 16:32 pointer to 64 bit signed + public const uint T_64PQUAD = 0x0613; // 64 bit pointer to 64 bit signed + + public const uint T_UQUAD = 0x0023; // 64 bit unsigned + public const uint T_PUQUAD = 0x0123; // 16 bit pointer to 64 bit unsigned + public const uint T_PFUQUAD = 0x0223; // 16:16 far pointer to 64 bit unsigned + public const uint T_PHUQUAD = 0x0323; // 16:16 huge pointer to 64 bit unsigned + public const uint T_32PUQUAD = 0x0423; // 32 bit pointer to 64 bit unsigned + public const uint T_32PFUQUAD = 0x0523; // 16:32 pointer to 64 bit unsigned + public const uint T_64PUQUAD = 0x0623; // 64 bit pointer to 64 bit unsigned + + // 64 bit int types + public const uint T_INT8 = 0x0076; // 64 bit signed int + public const uint T_PINT8 = 0x0176; // 16 bit pointer to 64 bit signed int + public const uint T_PFINT8 = 0x0276; // 16:16 far pointer to 64 bit signed int + public const uint T_PHINT8 = 0x0376; // 16:16 huge pointer to 64 bit signed int + public const uint T_32PINT8 = 0x0476; // 32 bit pointer to 64 bit signed int + public const uint T_32PFINT8 = 0x0576; // 16:32 pointer to 64 bit signed int + public const uint T_64PINT8 = 0x0676; // 64 bit pointer to 64 bit signed int + + public const uint T_UINT8 = 0x0077; // 64 bit unsigned int + public const uint T_PUINT8 = 0x0177; // 16 bit pointer to 64 bit unsigned int + public const uint T_PFUINT8 = 0x0277; // 16:16 far pointer to 64 bit unsigned int + public const uint T_PHUINT8 = 0x0377; // 16:16 huge pointer to 64 bit unsigned int + public const uint T_32PUINT8 = 0x0477; // 32 bit pointer to 64 bit unsigned int + public const uint T_32PFUINT8 = 0x0577; // 16:32 pointer to 64 bit unsigned int + public const uint T_64PUINT8 = 0x0677; // 64 bit pointer to 64 bit unsigned int + + // 128 bit octet types + public const uint T_OCT = 0x0014; // 128 bit signed + public const uint T_POCT = 0x0114; // 16 bit pointer to 128 bit signed + public const uint T_PFOCT = 0x0214; // 16:16 far pointer to 128 bit signed + public const uint T_PHOCT = 0x0314; // 16:16 huge pointer to 128 bit signed + public const uint T_32POCT = 0x0414; // 32 bit pointer to 128 bit signed + public const uint T_32PFOCT = 0x0514; // 16:32 pointer to 128 bit signed + public const uint T_64POCT = 0x0614; // 64 bit pointer to 128 bit signed + + public const uint T_UOCT = 0x0024; // 128 bit unsigned + public const uint T_PUOCT = 0x0124; // 16 bit pointer to 128 bit unsigned + public const uint T_PFUOCT = 0x0224; // 16:16 far pointer to 128 bit unsigned + public const uint T_PHUOCT = 0x0324; // 16:16 huge pointer to 128 bit unsigned + public const uint T_32PUOCT = 0x0424; // 32 bit pointer to 128 bit unsigned + public const uint T_32PFUOCT = 0x0524; // 16:32 pointer to 128 bit unsigned + public const uint T_64PUOCT = 0x0624; // 64 bit pointer to 128 bit unsigned + + // 128 bit int types + public const uint T_INT16 = 0x0078; // 128 bit signed int + public const uint T_PINT16 = 0x0178; // 16 bit pointer to 128 bit signed int + public const uint T_PFINT16 = 0x0278; // 16:16 far pointer to 128 bit signed int + public const uint T_PHINT16 = 0x0378; // 16:16 huge pointer to 128 bit signed int + public const uint T_32PINT16 = 0x0478; // 32 bit pointer to 128 bit signed int + public const uint T_32PFINT16 = 0x0578; // 16:32 pointer to 128 bit signed int + public const uint T_64PINT16 = 0x0678; // 64 bit pointer to 128 bit signed int + + public const uint T_UINT16 = 0x0079; // 128 bit unsigned int + public const uint T_PUINT16 = 0x0179; // 16 bit pointer to 128 bit unsigned int + public const uint T_PFUINT16 = 0x0279; // 16:16 far pointer to 128 bit unsigned int + public const uint T_PHUINT16 = 0x0379; // 16:16 huge pointer to 128 bit unsigned int + public const uint T_32PUINT16 = 0x0479; // 32 bit pointer to 128 bit unsigned int + public const uint T_32PFUINT16 = 0x0579; // 16:32 pointer to 128 bit unsigned int + public const uint T_64PUINT16 = 0x0679; // 64 bit pointer to 128 bit unsigned int + + // 16 bit real types + public const uint T_REAL16 = 0x0046; // 16 bit real + public const uint T_PREAL16 = 0x0146; // 16 bit pointer to 16 bit real + public const uint T_PFREAL16 = 0x0246; // 16:16 far pointer to 16 bit real + public const uint T_PHREAL16 = 0x0346; // 16:16 huge pointer to 16 bit real + public const uint T_32PREAL16 = 0x0446; // 32 bit pointer to 16 bit real + public const uint T_32PFREAL16 = 0x0546; // 16:32 pointer to 16 bit real + public const uint T_64PREAL16 = 0x0646; // 64 bit pointer to 16 bit real + + // 32 bit real types + public const uint T_REAL32 = 0x0040; // 32 bit real + public const uint T_PREAL32 = 0x0140; // 16 bit pointer to 32 bit real + public const uint T_PFREAL32 = 0x0240; // 16:16 far pointer to 32 bit real + public const uint T_PHREAL32 = 0x0340; // 16:16 huge pointer to 32 bit real + public const uint T_32PREAL32 = 0x0440; // 32 bit pointer to 32 bit real + public const uint T_32PFREAL32 = 0x0540; // 16:32 pointer to 32 bit real + public const uint T_64PREAL32 = 0x0640; // 64 bit pointer to 32 bit real + + // 32 bit partial-precision real types + public const uint T_REAL32PP = 0x0045; // 32 bit PP real + public const uint T_PREAL32PP = 0x0145; // 16 bit pointer to 32 bit PP real + public const uint T_PFREAL32PP = 0x0245; // 16:16 far pointer to 32 bit PP real + public const uint T_PHREAL32PP = 0x0345; // 16:16 huge pointer to 32 bit PP real + public const uint T_32PREAL32PP = 0x0445; // 32 bit pointer to 32 bit PP real + public const uint T_32PFREAL32PP = 0x0545; // 16:32 pointer to 32 bit PP real + public const uint T_64PREAL32PP = 0x0645; // 64 bit pointer to 32 bit PP real + + + // 48 bit real types + public const uint T_REAL48 = 0x0044; // 48 bit real + public const uint T_PREAL48 = 0x0144; // 16 bit pointer to 48 bit real + public const uint T_PFREAL48 = 0x0244; // 16:16 far pointer to 48 bit real + public const uint T_PHREAL48 = 0x0344; // 16:16 huge pointer to 48 bit real + public const uint T_32PREAL48 = 0x0444; // 32 bit pointer to 48 bit real + public const uint T_32PFREAL48 = 0x0544; // 16:32 pointer to 48 bit real + public const uint T_64PREAL48 = 0x0644; // 64 bit pointer to 48 bit real + + // 64 bit real types + public const uint T_REAL64 = 0x0041; // 64 bit real + public const uint T_PREAL64 = 0x0141; // 16 bit pointer to 64 bit real + public const uint T_PFREAL64 = 0x0241; // 16:16 far pointer to 64 bit real + public const uint T_PHREAL64 = 0x0341; // 16:16 huge pointer to 64 bit real + public const uint T_32PREAL64 = 0x0441; // 32 bit pointer to 64 bit real + public const uint T_32PFREAL64 = 0x0541; // 16:32 pointer to 64 bit real + public const uint T_64PREAL64 = 0x0641; // 64 bit pointer to 64 bit real + + // 80 bit real types + public const uint T_REAL80 = 0x0042; // 80 bit real + public const uint T_PREAL80 = 0x0142; // 16 bit pointer to 80 bit real + public const uint T_PFREAL80 = 0x0242; // 16:16 far pointer to 80 bit real + public const uint T_PHREAL80 = 0x0342; // 16:16 huge pointer to 80 bit real + public const uint T_32PREAL80 = 0x0442; // 32 bit pointer to 80 bit real + public const uint T_32PFREAL80 = 0x0542; // 16:32 pointer to 80 bit real + public const uint T_64PREAL80 = 0x0642; // 64 bit pointer to 80 bit real + + // 128 bit real types + public const uint T_REAL128 = 0x0043; // 128 bit real + public const uint T_PREAL128 = 0x0143; // 16 bit pointer to 128 bit real + public const uint T_PFREAL128 = 0x0243; // 16:16 far pointer to 128 bit real + public const uint T_PHREAL128 = 0x0343; // 16:16 huge pointer to 128 bit real + public const uint T_32PREAL128 = 0x0443; // 32 bit pointer to 128 bit real + public const uint T_32PFREAL128 = 0x0543; // 16:32 pointer to 128 bit real + public const uint T_64PREAL128 = 0x0643; // 64 bit pointer to 128 bit real + + // 32 bit complex types + public const uint T_CPLX32 = 0x0050; // 32 bit complex + public const uint T_PCPLX32 = 0x0150; // 16 bit pointer to 32 bit complex + public const uint T_PFCPLX32 = 0x0250; // 16:16 far pointer to 32 bit complex + public const uint T_PHCPLX32 = 0x0350; // 16:16 huge pointer to 32 bit complex + public const uint T_32PCPLX32 = 0x0450; // 32 bit pointer to 32 bit complex + public const uint T_32PFCPLX32 = 0x0550; // 16:32 pointer to 32 bit complex + public const uint T_64PCPLX32 = 0x0650; // 64 bit pointer to 32 bit complex + + // 64 bit complex types + public const uint T_CPLX64 = 0x0051; // 64 bit complex + public const uint T_PCPLX64 = 0x0151; // 16 bit pointer to 64 bit complex + public const uint T_PFCPLX64 = 0x0251; // 16:16 far pointer to 64 bit complex + public const uint T_PHCPLX64 = 0x0351; // 16:16 huge pointer to 64 bit complex + public const uint T_32PCPLX64 = 0x0451; // 32 bit pointer to 64 bit complex + public const uint T_32PFCPLX64 = 0x0551; // 16:32 pointer to 64 bit complex + public const uint T_64PCPLX64 = 0x0651; // 64 bit pointer to 64 bit complex + + // 80 bit complex types + public const uint T_CPLX80 = 0x0052; // 80 bit complex + public const uint T_PCPLX80 = 0x0152; // 16 bit pointer to 80 bit complex + public const uint T_PFCPLX80 = 0x0252; // 16:16 far pointer to 80 bit complex + public const uint T_PHCPLX80 = 0x0352; // 16:16 huge pointer to 80 bit complex + public const uint T_32PCPLX80 = 0x0452; // 32 bit pointer to 80 bit complex + public const uint T_32PFCPLX80 = 0x0552; // 16:32 pointer to 80 bit complex + public const uint T_64PCPLX80 = 0x0652; // 64 bit pointer to 80 bit complex + + // 128 bit complex types + public const uint T_CPLX128 = 0x0053; // 128 bit complex + public const uint T_PCPLX128 = 0x0153; // 16 bit pointer to 128 bit complex + public const uint T_PFCPLX128 = 0x0253; // 16:16 far pointer to 128 bit complex + public const uint T_PHCPLX128 = 0x0353; // 16:16 huge pointer to 128 bit real + public const uint T_32PCPLX128 = 0x0453; // 32 bit pointer to 128 bit complex + public const uint T_32PFCPLX128 = 0x0553; // 16:32 pointer to 128 bit complex + public const uint T_64PCPLX128 = 0x0653; // 64 bit pointer to 128 bit complex + + // Boolean types + public const uint T_BOOL08 = 0x0030; // 8 bit boolean + public const uint T_PBOOL08 = 0x0130; // 16 bit pointer to 8 bit boolean + public const uint T_PFBOOL08 = 0x0230; // 16:16 far pointer to 8 bit boolean + public const uint T_PHBOOL08 = 0x0330; // 16:16 huge pointer to 8 bit boolean + public const uint T_32PBOOL08 = 0x0430; // 32 bit pointer to 8 bit boolean + public const uint T_32PFBOOL08 = 0x0530; // 16:32 pointer to 8 bit boolean + public const uint T_64PBOOL08 = 0x0630; // 64 bit pointer to 8 bit boolean + + public const uint T_BOOL16 = 0x0031; // 16 bit boolean + public const uint T_PBOOL16 = 0x0131; // 16 bit pointer to 16 bit boolean + public const uint T_PFBOOL16 = 0x0231; // 16:16 far pointer to 16 bit boolean + public const uint T_PHBOOL16 = 0x0331; // 16:16 huge pointer to 16 bit boolean + public const uint T_32PBOOL16 = 0x0431; // 32 bit pointer to 18 bit boolean + public const uint T_32PFBOOL16 = 0x0531; // 16:32 pointer to 16 bit boolean + public const uint T_64PBOOL16 = 0x0631; // 64 bit pointer to 18 bit boolean + + public const uint T_BOOL32 = 0x0032; // 32 bit boolean + public const uint T_PBOOL32 = 0x0132; // 16 bit pointer to 32 bit boolean + public const uint T_PFBOOL32 = 0x0232; // 16:16 far pointer to 32 bit boolean + public const uint T_PHBOOL32 = 0x0332; // 16:16 huge pointer to 32 bit boolean + public const uint T_32PBOOL32 = 0x0432; // 32 bit pointer to 32 bit boolean + public const uint T_32PFBOOL32 = 0x0532; // 16:32 pointer to 32 bit boolean + public const uint T_64PBOOL32 = 0x0632; // 64 bit pointer to 32 bit boolean + + public const uint T_BOOL64 = 0x0033; // 64 bit boolean + public const uint T_PBOOL64 = 0x0133; // 16 bit pointer to 64 bit boolean + public const uint T_PFBOOL64 = 0x0233; // 16:16 far pointer to 64 bit boolean + public const uint T_PHBOOL64 = 0x0333; // 16:16 huge pointer to 64 bit boolean + public const uint T_32PBOOL64 = 0x0433; // 32 bit pointer to 64 bit boolean + public const uint T_32PFBOOL64 = 0x0533; // 16:32 pointer to 64 bit boolean + public const uint T_64PBOOL64 = 0x0633; // 64 bit pointer to 64 bit boolean + + // ??? + public const uint T_NCVPTR = 0x01f0; // CV Internal type for created near pointers + public const uint T_FCVPTR = 0x02f0; // CV Internal type for created far pointers + public const uint T_HCVPTR = 0x03f0; // CV Internal type for created huge pointers + public const uint T_32NCVPTR = 0x04f0; // CV Internal type for created near 32-bit pointers + public const uint T_32FCVPTR = 0x05f0; // CV Internal type for created far 32-bit pointers + public const uint T_64NCVPTR = 0x06f0; // CV Internal type for created near 64-bit pointers + + // Type enum for pointer records + // Pointers can be one of the following types + public const uint CV_PTR_NEAR = 0x00; // 16 bit pointer + public const uint CV_PTR_FAR = 0x01; // 16:16 far pointer + public const uint CV_PTR_HUGE = 0x02; // 16:16 huge pointer + public const uint CV_PTR_BASE_SEG = 0x03; // based on segment + public const uint CV_PTR_BASE_VAL = 0x04; // based on value of base + public const uint CV_PTR_BASE_SEGVAL = 0x05; // based on segment value of base + public const uint CV_PTR_BASE_ADDR = 0x06; // based on address of base + public const uint CV_PTR_BASE_SEGADDR = 0x07; // based on segment address of base + public const uint CV_PTR_BASE_TYPE = 0x08; // based on type + public const uint CV_PTR_BASE_SELF = 0x09; // based on self + public const uint CV_PTR_NEAR32 = 0x0a; // 32 bit pointer + public const uint CV_PTR_FAR32 = 0x0b; // 16:32 pointer + public const uint CV_PTR_64 = 0x0c; // 64 bit pointer + public const uint CV_PTR_UNUSEDPTR = 0x0d; // first unused pointer type + + public const uint CV_PTR_MODE_PTR = 0x00; // "normal" pointer + public const uint CV_PTR_MODE_REF = 0x01; // "old" reference + public const uint CV_PTR_MODE_LVREF = 0x01; // l-value reference + public const uint CV_PTR_MODE_PMEM = 0x02; // pointer to data member + public const uint CV_PTR_MODE_PMFUNC = 0x03; // pointer to member function + public const uint CV_PTR_MODE_RVREF = 0x04; // r-value reference + public const uint CV_PTR_MODE_RESERVED= 0x05; // first unused pointer mode + + public const ushort MOD_none = 0; + public const ushort MOD_const = 1; + public const ushort MOD_volatile = 2; + public const ushort MOD_unaligned = 4; + + // leaf indices starting records but referenced from symbol records + + public const ushort LF_MODIFIER_16t = 0x0001; + public const ushort LF_POINTER_16t = 0x0002; + public const ushort LF_ARRAY_16t = 0x0003; + public const ushort LF_CLASS_16t = 0x0004; + public const ushort LF_STRUCTURE_16t = 0x0005; + public const ushort LF_UNION_16t = 0x0006; + public const ushort LF_ENUM_16t = 0x0007; + public const ushort LF_PROCEDURE_16t = 0x0008; + public const ushort LF_MFUNCTION_16t = 0x0009; + public const ushort LF_VTSHAPE = 0x000a; + public const ushort LF_COBOL0_16t = 0x000b; + public const ushort LF_COBOL1 = 0x000c; + public const ushort LF_BARRAY_16t = 0x000d; + public const ushort LF_LABEL = 0x000e; + public const ushort LF_NULL = 0x000f; + public const ushort LF_NOTTRAN = 0x0010; + public const ushort LF_DIMARRAY_16t = 0x0011; + public const ushort LF_VFTPATH_16t = 0x0012; + public const ushort LF_PRECOMP_16t = 0x0013; // not referenced from symbol + public const ushort LF_ENDPRECOMP = 0x0014; // not referenced from symbol + public const ushort LF_OEM_16t = 0x0015; // oem definable type string + public const ushort LF_TYPESERVER_ST = 0x0016; // not referenced from symbol + + // leaf indices starting records but referenced only from type records + + public const ushort LF_SKIP_16t = 0x0200; + public const ushort LF_ARGLIST_16t = 0x0201; + public const ushort LF_DEFARG_16t = 0x0202; + public const ushort LF_LIST = 0x0203; + public const ushort LF_FIELDLIST_16t = 0x0204; + public const ushort LF_DERIVED_16t = 0x0205; + public const ushort LF_BITFIELD_16t = 0x0206; + public const ushort LF_METHODLIST_16t = 0x0207; + public const ushort LF_DIMCONU_16t = 0x0208; + public const ushort LF_DIMCONLU_16t = 0x0209; + public const ushort LF_DIMVARU_16t = 0x020a; + public const ushort LF_DIMVARLU_16t = 0x020b; + public const ushort LF_REFSYM = 0x020c; + + public const ushort LF_BCLASS_16t = 0x0400; + public const ushort LF_VBCLASS_16t = 0x0401; + public const ushort LF_IVBCLASS_16t = 0x0402; + public const ushort LF_ENUMERATE_ST = 0x0403; + public const ushort LF_FRIENDFCN_16t = 0x0404; + public const ushort LF_INDEX_16t = 0x0405; + public const ushort LF_MEMBER_16t = 0x0406; + public const ushort LF_STMEMBER_16t = 0x0407; + public const ushort LF_METHOD_16t = 0x0408; + public const ushort LF_NESTTYPE_16t = 0x0409; + public const ushort LF_VFUNCTAB_16t = 0x040a; + public const ushort LF_FRIENDCLS_16t = 0x040b; + public const ushort LF_ONEMETHOD_16t = 0x040c; + public const ushort LF_VFUNCOFF_16t = 0x040d; + +// 32-bit type index versions of leaves, all have the 0x1000 bit set +// + public const ushort LF_TI16_MAX = 0x1000; + + public const ushort LF_MODIFIER = 0x1001; + public const ushort LF_POINTER = 0x1002; + public const ushort LF_ARRAY_ST = 0x1003; + public const ushort LF_CLASS_ST = 0x1004; + public const ushort LF_STRUCTURE_ST = 0x1005; + public const ushort LF_UNION_ST = 0x1006; + public const ushort LF_ENUM_ST = 0x1007; + public const ushort LF_PROCEDURE = 0x1008; + public const ushort LF_MFUNCTION = 0x1009; + public const ushort LF_COBOL0 = 0x100a; + public const ushort LF_BARRAY = 0x100b; + public const ushort LF_DIMARRAY_ST = 0x100c; + public const ushort LF_VFTPATH = 0x100d; + public const ushort LF_PRECOMP_ST = 0x100e; // not referenced from symbol + public const ushort LF_OEM = 0x100f; // oem definable type string + public const ushort LF_ALIAS_ST = 0x1010; // alias (typedef) type + public const ushort LF_OEM2 = 0x1011; // oem definable type string + + // leaf indices starting records but referenced only from type records + + public const ushort LF_SKIP = 0x1200; + public const ushort LF_ARGLIST = 0x1201; + public const ushort LF_DEFARG_ST = 0x1202; + public const ushort LF_FIELDLIST = 0x1203; + public const ushort LF_DERIVED = 0x1204; + public const ushort LF_BITFIELD = 0x1205; + public const ushort LF_METHODLIST = 0x1206; + public const ushort LF_DIMCONU = 0x1207; + public const ushort LF_DIMCONLU = 0x1208; + public const ushort LF_DIMVARU = 0x1209; + public const ushort LF_DIMVARLU = 0x120a; + + public const ushort LF_BCLASS = 0x1400; + public const ushort LF_VBCLASS = 0x1401; + public const ushort LF_IVBCLASS = 0x1402; + public const ushort LF_FRIENDFCN_ST = 0x1403; + public const ushort LF_INDEX = 0x1404; + public const ushort LF_MEMBER_ST = 0x1405; + public const ushort LF_STMEMBER_ST = 0x1406; + public const ushort LF_METHOD_ST = 0x1407; + public const ushort LF_NESTTYPE_ST = 0x1408; + public const ushort LF_VFUNCTAB = 0x1409; + public const ushort LF_FRIENDCLS = 0x140a; + public const ushort LF_ONEMETHOD_ST = 0x140b; + public const ushort LF_VFUNCOFF = 0x140c; + public const ushort LF_NESTTYPEEX_ST = 0x140d; + public const ushort LF_MEMBERMODIFY_ST = 0x140e; + public const ushort LF_MANAGED_ST = 0x140f; + + // Types w/ SZ names + + public const ushort LF_ST_MAX = 0x1500; + + public const ushort LF_TYPESERVER = 0x1501; // not referenced from symbol + public const ushort LF_ENUMERATE = 0x1502; + public const ushort LF_ARRAY = 0x1503; + public const ushort LF_CLASS = 0x1504; + public const ushort LF_STRUCTURE = 0x1505; + public const ushort LF_UNION = 0x1506; + public const ushort LF_ENUM = 0x1507; + public const ushort LF_DIMARRAY = 0x1508; + public const ushort LF_PRECOMP = 0x1509; // not referenced from symbol + public const ushort LF_ALIAS = 0x150a; // alias (typedef) type + public const ushort LF_DEFARG = 0x150b; + public const ushort LF_FRIENDFCN = 0x150c; + public const ushort LF_MEMBER = 0x150d; + public const ushort LF_STMEMBER = 0x150e; + public const ushort LF_METHOD = 0x150f; + public const ushort LF_NESTTYPE = 0x1510; + public const ushort LF_ONEMETHOD = 0x1511; + public const ushort LF_NESTTYPEEX = 0x1512; + public const ushort LF_MEMBERMODIFY = 0x1513; + public const ushort LF_MANAGED = 0x1514; + public const ushort LF_TYPESERVER2 = 0x1515; + + public const ushort LF_STRIDED_ARRAY = 0x1516; // same as LF_ARRAY, but with stride between adjacent elements + public const ushort LF_HLSL = 0x1517; + public const ushort LF_MODIFIER_EX = 0x1518; + public const ushort LF_INTERFACE = 0x1519; + public const ushort LF_BINTERFACE = 0x151a; + public const ushort LF_VECTOR = 0x151b; + public const ushort LF_MATRIX = 0x151c; + + public const ushort LF_VFTABLE = 0x151d; // a virtual function table + public const ushort LF_ENDOFLEAFRECORD = LF_VFTABLE; + + //public const ushort LF_TYPE_LAST; // one greater than the last type record + //public const ushort LF_TYPE_MAX = LF_TYPE_LAST - 1; + + public const ushort LF_FUNC_ID = 0x1601; // global func ID + public const ushort LF_MFUNC_ID = 0x1602; // member func ID + public const ushort LF_BUILDINFO = 0x1603; // build info: tool, version, command line, src/pdb file + public const ushort LF_SUBSTR_LIST = 0x1604; // similar to LF_ARGLIST, for list of sub strings + public const ushort LF_STRING_ID = 0x1605; // string ID + + public const ushort LF_UDT_SRC_LINE = 0x1606; // source and line on where an UDT is defined + // only generated by compiler + + public const ushort LF_UDT_MOD_SRC_LINE = 0x1607; // module, source and line on where an UDT is defined + // only generated by linker + + //public const ushort LF_ID_LAST; // one greater than the last ID record + //public const ushort LF_ID_MAX = LF_ID_LAST - 1; + + public const ushort LF_NUMERIC = 0x8000; + public const ushort LF_CHAR = 0x8000; + public const ushort LF_SHORT = 0x8001; + public const ushort LF_USHORT = 0x8002; + public const ushort LF_LONG = 0x8003; + public const ushort LF_ULONG = 0x8004; + public const ushort LF_REAL32 = 0x8005; + public const ushort LF_REAL64 = 0x8006; + public const ushort LF_REAL80 = 0x8007; + public const ushort LF_REAL128 = 0x8008; + public const ushort LF_QUADWORD = 0x8009; + public const ushort LF_UQUADWORD = 0x800a; + public const ushort LF_REAL48 = 0x800b; + public const ushort LF_COMPLEX32 = 0x800c; + public const ushort LF_COMPLEX64 = 0x800d; + public const ushort LF_COMPLEX80 = 0x800e; + public const ushort LF_COMPLEX128 = 0x800f; + public const ushort LF_VARSTRING = 0x8010; + + public const ushort LF_OCTWORD = 0x8017; + public const ushort LF_UOCTWORD = 0x8018; + + public const ushort LF_DECIMAL = 0x8019; + public const ushort LF_DATE = 0x801a; + public const ushort LF_UTF8STRING = 0x801b; + + public const ushort LF_REAL16 = 0x801c; + + public const ushort LF_PAD0 = 0xf0; + public const ushort LF_PAD1 = 0xf1; + public const ushort LF_PAD2 = 0xf2; + public const ushort LF_PAD3 = 0xf3; + public const ushort LF_PAD4 = 0xf4; + public const ushort LF_PAD5 = 0xf5; + public const ushort LF_PAD6 = 0xf6; + public const ushort LF_PAD7 = 0xf7; + public const ushort LF_PAD8 = 0xf8; + public const ushort LF_PAD9 = 0xf9; + public const ushort LF_PAD10 = 0xfa; + public const ushort LF_PAD11 = 0xfb; + public const ushort LF_PAD12 = 0xfc; + public const ushort LF_PAD13 = 0xfd; + public const ushort LF_PAD14 = 0xfe; + public const ushort LF_PAD15 = 0xff; + + public const ushort CV_PROP_NONE = 0; + public const ushort CV_PROP_PACKED = 0x0001; + public const ushort CV_PROP_HAS_CONSTURUCTOR_OR_DESTRUCTOR = 0x0002; + public const ushort CV_PROP_HAS_OVERLOADED_OPERATOR = 0x0004; + public const ushort CV_PROP_NESTED = 0x0008; + public const ushort CV_PROP_CONTAINS_NESTED_CLASS = 0x0010; + public const ushort CV_PROP_HAS_OVERLOADED_ASSIGNMENT_OPERATOR = 0x0020; + public const ushort CV_PROP_HAS_CONVERSION_OPERATOR = 0x0040; + public const ushort CV_PROP_FORWARD_REFERENCE = 0x0080; + public const ushort CV_PROP_SCOPED = 0x0100; + public const ushort CV_PROP_HAS_UNIQUE_NAME = 0x0200; + public const ushort CV_PROP_SEALED = 0x0400; + public const ushort CV_PROP_INTRINSIC = 0x2000; + + public const ushort CV_REG_NONE = 0; + + public const ushort CV_AMD64_RAX = 328; + public const ushort CV_AMD64_RBX = 329; + public const ushort CV_AMD64_RCX = 330; + public const ushort CV_AMD64_RDX = 331; + public const ushort CV_AMD64_RSI = 332; + public const ushort CV_AMD64_RDI = 333; + public const ushort CV_AMD64_RBP = 334; + public const ushort CV_AMD64_RSP = 335; + + // 64-bit integer registers with 8-, 16-, and 32-bit forms (B, W, and D) + public const ushort CV_AMD64_R8 = 336; + public const ushort CV_AMD64_R9 = 337; + public const ushort CV_AMD64_R10 = 338; + public const ushort CV_AMD64_R11 = 339; + public const ushort CV_AMD64_R12 = 340; + public const ushort CV_AMD64_R13 = 341; + public const ushort CV_AMD64_R14 = 342; + public const ushort CV_AMD64_R15 = 343; + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs new file mode 100644 index 00000000000000..01b24e79ddfab3 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -0,0 +1,169 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +using ILCompiler.DependencyAnalysis; +using Internal.JitInterface; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; + +using static ILCompiler.ObjectWriter.CodeViewNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class CodeViewSymbolsBuilder + { + private TargetArchitecture _targetArchitecture; + + public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, Stream outputStream) + { + _targetArchitecture = targetArchitecture; + + // Write CodeView version header + Span versionBuffer = stackalloc byte[sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); + _outputStream.Write(versionBuffer); + } + + // Maps an ICorDebugInfo register number to the corresponding CodeView + // register number + private ushort GetCVRegNum(uint regNum) + { + switch (_targetArchitecture) + { + case TargetArchitecture.X64: + return regNum switch + { + 0u => CV_AMD64_RAX, + 1u => CV_AMD64_RCX, + 2u => CV_AMD64_RDX, + 3u => CV_AMD64_RBX, + 4u => CV_AMD64_RSP, + 5u => CV_AMD64_RBP, + 6u => CV_AMD64_RSI, + 7u => CV_AMD64_RDI, + 8u => CV_AMD64_R8, + 9u => CV_AMD64_R9, + 10u => CV_AMD64_R10, + 11u => CV_AMD64_R11, + 12u => CV_AMD64_R12, + 13u => CV_AMD64_R13, + 14u => CV_AMD64_R14, + 15u => CV_AMD64_R15, + _ => CV_REG_NONE, + }; + + //case TargetArchitecture.ARM64: + // ... + default: + return CV_REG_NONE; + } + } + + private static + + + /*private ref struct SubsectionWriter + { + + }*/ + + /*private ref struct LeafRecordWriter + { + private ArrayBufferWriter _bufferWriter; + private Stream _outputStream; + + public LeafRecordWriter(ArrayBufferWriter bufferWriter, Stream outputStream) + { + _bufferWriter = bufferWriter; + _outputStream = outputStream; + } + + public void Dispose() + { + int length = sizeof(ushort) + _bufferWriter.WrittenCount; + int padding = ((length + 3) & ~3) - length; + Span lengthBuffer = stackalloc byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); + _outputStream.Write(lengthBuffer); + _outputStream.Write(_bufferWriter.WrittenSpan); + _outputStream.Write(stackalloc byte[padding]); + _bufferWriter.Clear(); + + // TODO: LF_INDEX for long records + } + + public void Write(byte value) + { + _bufferWriter.GetSpan(1)[0] = value; + _bufferWriter.Advance(1); + } + + public void Write(ushort value) + { + BinaryPrimitives.WriteUInt16LittleEndian(_bufferWriter.GetSpan(sizeof(ushort)), value); + _bufferWriter.Advance(sizeof(ushort)); + } + + public void Write(uint value) + { + BinaryPrimitives.WriteUInt32LittleEndian(_bufferWriter.GetSpan(sizeof(uint)), value); + _bufferWriter.Advance(sizeof(uint)); + } + + public void Write(ulong value) + { + BinaryPrimitives.WriteUInt64LittleEndian(_bufferWriter.GetSpan(sizeof(ulong)), value); + _bufferWriter.Advance(sizeof(ulong)); + } + + public void Write(string value) + { + int byteCount = Encoding.UTF8.GetByteCount(value) + 1; + Encoding.UTF8.GetBytes(value, _bufferWriter.GetSpan(byteCount)); + _bufferWriter.Advance(byteCount); + } + + public void WriteEncodedInteger(ulong value) + { + if (value < LF_NUMERIC) + { + Write((ushort)value); + } + else if (value <= ushort.MaxValue) + { + Write(LF_USHORT); + Write((ushort)value); + } + else if (value <= uint.MaxValue) + { + Write(LF_ULONG); + Write((uint)value); + } + else + { + Write(LF_UQUADWORD); + Write(value); + } + } + + public void WritePadding() + { + int paddingLength = ((_bufferWriter.WrittenCount - 2 + 3) & ~3) - (_bufferWriter.WrittenCount - 2); + Span padding = _bufferWriter.GetSpan(paddingLength); + for (int i = 0; i < paddingLength; i++) + { + padding[i] = (byte)(LF_PAD0 + paddingLength - i); + } + _bufferWriter.Advance(paddingLength); + } + }*/ + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs new file mode 100644 index 00000000000000..b761382148a2e7 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -0,0 +1,460 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +using ILCompiler.DependencyAnalysis; +using Internal.JitInterface; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; + +using static ILCompiler.ObjectWriter.CodeViewNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter + { + private NameMangler _nameMangler; + private TargetArchitecture _architecture; + private Stream _outputStream; + private int _targetPointerSize; + + private uint _classVTableTypeIndex; + private uint _vfuncTabTypeIndex; + + private uint _nextTypeIndex = 0x1000; + private ArrayBufferWriter _bufferWriter = new(); + + public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, Stream outputStream) + { + _nameMangler = nameMangler; + _architecture = targetArchitecture; + _outputStream = outputStream; + _targetPointerSize = targetArchitecture switch + { + TargetArchitecture.ARM => 4, + TargetArchitecture.X86 => 4, + _ => 8, + }; + + // Write CodeView version header + Span versionBuffer = stackalloc byte[sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); + _outputStream.Write(versionBuffer); + + // We pretend that the MethodTable pointer in System.Object is VTable shape. + // We use the same "Vtable" for all types because the vtable shape debug + // record is not expressive enough to capture our vtable shape (where the + // vtable slots don't start at the beginning of the vtable). + using (var record = StartLeafRecord(LF_VTSHAPE)) + { + record.Write((ushort)0); // Number of entries in vfunctable + } + _classVTableTypeIndex = _nextTypeIndex++; + + using (var record = StartLeafRecord(LF_POINTER)) + { + record.Write(_classVTableTypeIndex); + record.Write((uint)((_targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | (CV_PTR_MODE_LVREF << 5))); + } + _vfuncTabTypeIndex = _nextTypeIndex++; + } + + private LeafRecordWriter StartLeafRecord(ushort leafRecordType) + { + LeafRecordWriter writer = new LeafRecordWriter(_bufferWriter, _outputStream); + writer.Write(leafRecordType); + return writer; + } + + public uint GetPrimitiveTypeIndex(TypeDesc type) + { + Debug.Assert(type.IsPrimitive, "it is not a primitive type"); + return GetPrimitiveTypeIndex(type.Category); + } + + private uint GetPrimitiveTypeIndex(TypeFlags typeFlags) + { + // CodeView uses predefined codes for simple types + return typeFlags switch + { + TypeFlags.Boolean => T_BOOL08, + TypeFlags.Char => T_WCHAR, + TypeFlags.SByte => T_INT1, + TypeFlags.Byte => T_UINT1, + TypeFlags.Int16 => T_INT2, + TypeFlags.UInt16 => T_UINT2, + TypeFlags.Int32 => T_INT4, + TypeFlags.UInt32 => T_UINT4, + TypeFlags.Int64 => T_INT8, + TypeFlags.UInt64 => T_UINT8, + TypeFlags.IntPtr => _targetPointerSize == 8 ? T_INT8 : T_INT4, + TypeFlags.UIntPtr => _targetPointerSize == 8 ? T_UINT8 : T_UINT4, + TypeFlags.Single => T_REAL32, + TypeFlags.Double => T_REAL64, + _ => T_NOTYPE, + }; + } + + public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) + { + uint elementType = pointerDescriptor.ElementType; + uint pointerKind = pointerDescriptor.Is64Bit == 1 ? CV_PTR_64 : CV_PTR_NEAR32; + uint pointerMode = pointerDescriptor.IsReference == 1 ? CV_PTR_MODE_LVREF : CV_PTR_MODE_PTR; + //ushort pointerOptions = pointerDescriptor.IsConst ? MOD_const : MOD_none; + + using (var record = StartLeafRecord(LF_POINTER)) + { + record.Write(elementType); + record.Write((uint)(pointerKind | (pointerMode << 5))); // TODO: pointerOptions + } + + return _nextTypeIndex++; + } + + public uint GetArrayTypeIndex( + ClassTypeDescriptor classDescriptor, + ArrayTypeDescriptor arrayDescriptor) + { + uint memberCount = 0; + uint offset = 0; + + using (var arrayRecord = StartLeafRecord(LF_ARRAY)) + { + arrayRecord.Write(arrayDescriptor.ElementType); + arrayRecord.Write(T_INT4); + arrayRecord.Write(arrayDescriptor.Size); + arrayRecord.Write(""); + } + + uint arrayRecordTypeIndex = _nextTypeIndex++; + + using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + { + if (classDescriptor.BaseClassId != 0) + { + fieldListRecord.Write(LF_BCLASS); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(classDescriptor.BaseClassId); + fieldListRecord.WriteEncodedInteger(0); // Offset + fieldListRecord.WritePadding(); + memberCount++; + offset += (uint)_targetPointerSize; + } + + fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(T_INT4); + fieldListRecord.WriteEncodedInteger(offset); + fieldListRecord.Write("count"); + fieldListRecord.WritePadding(); + memberCount++; + offset += (uint)_targetPointerSize; + + if (arrayDescriptor.IsMultiDimensional == 1) + { + for (uint i = 0; i < arrayDescriptor.Rank; ++i) + { + fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(T_INT4); + fieldListRecord.WriteEncodedInteger(offset); + fieldListRecord.Write($"length{i}"); + fieldListRecord.WritePadding(); + memberCount++; + offset += 4; + } + + for (uint i = 0; i < arrayDescriptor.Rank; ++i) + { + fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(T_INT4); + fieldListRecord.WriteEncodedInteger(offset); + fieldListRecord.Write($"bounds{i}"); + fieldListRecord.WritePadding(); + memberCount++; + offset += 4; + } + } + + fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(arrayRecordTypeIndex); + fieldListRecord.WriteEncodedInteger(offset); + fieldListRecord.Write("values"); + fieldListRecord.WritePadding(); + memberCount++; + } + + uint fieldListTypeIndex = _nextTypeIndex++; + + Debug.Assert(classDescriptor.IsStruct == 0); + using (var record = StartLeafRecord(LF_CLASS)) + { + record.Write((ushort)memberCount); // Number of elements in class + record.Write((ushort)0); // TODO: Options + record.Write(fieldListTypeIndex); // Field descriptor index + record.Write((uint)0); // Derived-from descriptor index + record.Write((uint)0); // Vtshape descriptor index + record.Write((ushort)arrayDescriptor.Size); // Size + record.Write(classDescriptor.Name); + } + + return _nextTypeIndex++; + } + + public uint GetEnumTypeIndex( + EnumTypeDescriptor typeDescriptor, + EnumRecordTypeDescriptor[] typeRecords) + { + using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + { + foreach (EnumRecordTypeDescriptor record in typeRecords) + { + fieldListRecord.Write(LF_ENUMERATE); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.WriteEncodedInteger(record.Value); + fieldListRecord.Write(record.Name); + fieldListRecord.WritePadding(); + } + } + + uint fieldListTypeIndex = _nextTypeIndex++; + + using (var record = StartLeafRecord(LF_ENUM)) + { + record.Write((ushort)typeRecords.Length); // Number of elements in class + record.Write((ushort)0); // TODO: Attributes + record.Write(typeDescriptor.ElementType); + record.Write(fieldListTypeIndex); + record.Write(typeDescriptor.Name); + } + + return _nextTypeIndex++; + } + + public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) + { + using (var record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) + { + record.Write((ushort)0); // Number of elements in class + record.Write((ushort)CV_PROP_FORWARD_REFERENCE); + record.Write((uint)0); // Field descriptor index + record.Write((uint)0); // Derived-from descriptor index + record.Write((uint)0); // Vtshape descriptor index + record.Write((ushort)0); // Size + record.Write(classDescriptor.Name); + } + + return _nextTypeIndex++; + } + + public uint GetCompleteClassTypeIndex( + ClassTypeDescriptor classTypeDescriptor, + ClassFieldsTypeDescriptor classFieldsTypeDescriptor, + DataFieldDescriptor[] fields, + StaticDataFieldDescriptor[] statics) + { + uint memberCount = 0; + + using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + { + if (classTypeDescriptor.BaseClassId != 0) + { + fieldListRecord.Write(LF_BCLASS); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(classTypeDescriptor.BaseClassId); + fieldListRecord.WriteEncodedInteger(0); // Offset + fieldListRecord.WritePadding(); + memberCount++; + } + else if (classTypeDescriptor.IsStruct == 0) + { + fieldListRecord.Write(LF_VFUNCTAB); + fieldListRecord.Write((ushort)0); // Padding + fieldListRecord.Write(_vfuncTabTypeIndex); + fieldListRecord.WritePadding(); + memberCount++; + } + + foreach (DataFieldDescriptor desc in fields) + { + if (desc.Offset == 0xFFFFFFFF) + { + fieldListRecord.Write(LF_STMEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(desc.Name); + } + else + { + fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(desc.FieldTypeIndex); + fieldListRecord.WriteEncodedInteger(desc.Offset); + fieldListRecord.Write(desc.Name); + } + fieldListRecord.WritePadding(); + memberCount++; + } + } + + uint fieldListTypeIndex = _nextTypeIndex++; + + using (var record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) + { + record.Write((ushort)memberCount); // Number of elements in class + record.Write((ushort)0); // TODO: Options + record.Write(fieldListTypeIndex); // Field descriptor index + record.Write((uint)0); // Derived-from descriptor index + record.Write((uint)0); // Vtshape descriptor index + record.Write((ushort)classFieldsTypeDescriptor.Size); // Size + record.Write(classTypeDescriptor.Name); + } + + return _nextTypeIndex++; + } + + public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) + { + using (var fieldListRecord = StartLeafRecord(LF_ARGLIST)) + { + fieldListRecord.Write((uint)argumentTypes.Length); + foreach (uint argumentType in argumentTypes) + { + fieldListRecord.Write(argumentType); + } + } + + uint argumentListTypeIndex = _nextTypeIndex++; + + using (var record = StartLeafRecord(LF_MFUNCTION)) + { + record.Write(memberDescriptor.ReturnType); + record.Write(memberDescriptor.ContainingClass); + record.Write(memberDescriptor.TypeIndexOfThisPointer); + record.Write((byte)memberDescriptor.CallingConvention); + record.Write((byte)0); // TODO: Attributes + record.Write((ushort)memberDescriptor.NumberOfArguments); + record.Write(argumentListTypeIndex); + record.Write((uint)memberDescriptor.ThisAdjust); + } + + return _nextTypeIndex++; + } + + public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor) + { + using (var record = StartLeafRecord(LF_MFUNC_ID)) + { + record.Write(memberIdDescriptor.ParentClass); + record.Write(memberIdDescriptor.MemberFunction); + record.Write(memberIdDescriptor.Name); + } + + return _nextTypeIndex++; + } + + public string GetMangledName(TypeDesc type) + { + return _nameMangler.GetMangledTypeName(type); + } + + private ref struct LeafRecordWriter + { + private ArrayBufferWriter _bufferWriter; + private Stream _outputStream; + + public LeafRecordWriter(ArrayBufferWriter bufferWriter, Stream outputStream) + { + _bufferWriter = bufferWriter; + _outputStream = outputStream; + } + + public void Dispose() + { + int length = sizeof(ushort) + _bufferWriter.WrittenCount; + int padding = ((length + 3) & ~3) - length; + Span lengthBuffer = stackalloc byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); + _outputStream.Write(lengthBuffer); + _outputStream.Write(_bufferWriter.WrittenSpan); + _outputStream.Write(stackalloc byte[padding]); + _bufferWriter.Clear(); + + // TODO: LF_INDEX for long records + } + + public void Write(byte value) + { + _bufferWriter.GetSpan(1)[0] = value; + _bufferWriter.Advance(1); + } + + public void Write(ushort value) + { + BinaryPrimitives.WriteUInt16LittleEndian(_bufferWriter.GetSpan(sizeof(ushort)), value); + _bufferWriter.Advance(sizeof(ushort)); + } + + public void Write(uint value) + { + BinaryPrimitives.WriteUInt32LittleEndian(_bufferWriter.GetSpan(sizeof(uint)), value); + _bufferWriter.Advance(sizeof(uint)); + } + + public void Write(ulong value) + { + BinaryPrimitives.WriteUInt64LittleEndian(_bufferWriter.GetSpan(sizeof(ulong)), value); + _bufferWriter.Advance(sizeof(ulong)); + } + + public void Write(string value) + { + int byteCount = Encoding.UTF8.GetByteCount(value) + 1; + Encoding.UTF8.GetBytes(value, _bufferWriter.GetSpan(byteCount)); + _bufferWriter.Advance(byteCount); + } + + public void WriteEncodedInteger(ulong value) + { + if (value < LF_NUMERIC) + { + Write((ushort)value); + } + else if (value <= ushort.MaxValue) + { + Write(LF_USHORT); + Write((ushort)value); + } + else if (value <= uint.MaxValue) + { + Write(LF_ULONG); + Write((uint)value); + } + else + { + Write(LF_UQUADWORD); + Write(value); + } + } + + public void WritePadding() + { + int paddingLength = ((_bufferWriter.WrittenCount - 2 + 3) & ~3) - (_bufferWriter.WrittenCount - 2); + Span padding = _bufferWriter.GetSpan(paddingLength); + for (int i = 0; i < paddingLength; i++) + { + padding[i] = (byte)(LF_PAD0 + paddingLength - i); + } + _bufferWriter.Advance(paddingLength); + } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 38b9f1d66b4446..a561ba1e0a5108 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -100,7 +100,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect _sections.Add((sectionHeader, sectionStream, new List(), section.ComdatName)); } - protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) + protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { Debug.Assert(alignment > 0 && BitOperations.IsPow2((uint)alignment)); int minimumAlignment = BitOperations.Log2((uint)alignment) << 20; @@ -112,13 +112,10 @@ protected override void UpdateSectionAlignment(int sectionIndex, int alignment, (_sections[sectionIndex].Header.SectionCharacteristics & ~SectionCharacteristics.AlignMask) | (SectionCharacteristics)minimumAlignment; } - - isExecutable = _sections[sectionIndex].Header.SectionCharacteristics.HasFlag(SectionCharacteristics.MemExecute); } - protected override void EmitRelocation( + protected internal override void EmitRelocation( int sectionIndex, - List relocationList, int offset, Span data, RelocType relocType, @@ -139,6 +136,7 @@ protected override void EmitRelocation( data, BinaryPrimitives.ReadInt64LittleEndian(data) + addend); + addend = 0; } } else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) @@ -150,6 +148,7 @@ protected override void EmitRelocation( data, BinaryPrimitives.ReadInt32LittleEndian(data) + addend); + addend = 0; } } else if (relocType == RelocType.IMAGE_REL_BASED_REL32 || @@ -162,6 +161,7 @@ protected override void EmitRelocation( data, BinaryPrimitives.ReadInt32LittleEndian(data) + addend); + addend = 0; } } else @@ -169,7 +169,7 @@ protected override void EmitRelocation( throw new NotSupportedException($"Unsupported relocation: {relocType}"); } - relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, 0)); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } protected override void EmitSymbolTable() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 819c9ef09b5e3e..0676b96494d42c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -108,15 +108,24 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect } } - protected override void EmitRelocation( + protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) + { + var elfSection = _sectionIndexToElfSection[sectionIndex]; + elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); + } + + protected internal override void EmitRelocation( int sectionIndex, - List relocationList, int offset, Span data, RelocType relocType, string symbolName, int addend) { + // We read the addend from the data and clear it. This is necessary + // to produce correct addends in the `.rela` sections which override + // the destination with the addend from relocation table. + if (relocType == RelocType.IMAGE_REL_BASED_REL32 || relocType == RelocType.IMAGE_REL_BASED_RELPTR32) { @@ -140,7 +149,8 @@ protected override void EmitRelocation( { throw new NotSupportedException($"Unsupported relocation: {relocType}"); } - relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } protected override void EmitSymbolTable() @@ -270,13 +280,6 @@ private void EmitRelocationsX64(int sectionIndex, List reloc } } - protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) - { - var elfSection = _sectionIndexToElfSection[sectionIndex]; - elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); - isExecutable = elfSection.Flags.HasFlag(ElfSectionFlags.Executable); - } - protected override ulong GetSectionVirtualAddress(int sectionIndex) { // Use file offset diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 8f2f2373bf76a4..5769880c26e31f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -160,15 +160,25 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect _segment.Sections.Add(machSection); } - protected override void EmitRelocation( + protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) + { + var machSection = _segment.Sections[sectionIndex]; + Debug.Assert(BitOperations.IsPow2(alignment)); + machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); + } + + protected internal override void EmitRelocation( int sectionIndex, - List relocationList, int offset, Span data, RelocType relocType, string symbolName, int addend) { + // For most relocations we write the addend directly into the + // data. The exceptions are IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 + // and IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A. + if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) { Debug.Assert(_objectFile.CpuType == MachCpuType.Arm64); @@ -182,6 +192,7 @@ protected override void EmitRelocation( data, BinaryPrimitives.ReadInt64LittleEndian(data) + addend); + addend = 0; } } else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) @@ -215,6 +226,7 @@ protected override void EmitRelocation( addend); } } + addend = 0; } else if (relocType == RelocType.IMAGE_REL_BASED_REL32) { @@ -225,10 +237,11 @@ protected override void EmitRelocation( data, BinaryPrimitives.ReadInt32LittleEndian(data) + addend); + addend = 0; } } - relocationList.Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } protected override void EmitSymbolTable() @@ -543,14 +556,6 @@ protected override bool EmitCompactUnwinding(DwarfFde fde) return false; } - protected override void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable) - { - var machSection = _segment.Sections[sectionIndex]; - Debug.Assert(BitOperations.IsPow2(alignment)); - machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); - isExecutable = machSection.Attributes.HasFlag(MachSectionAttributes.SomeInstructions); - } - protected override ulong GetSectionVirtualAddress(int sectionIndex) { var machSection = _segment.Sections[sectionIndex]; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index aecae9611bc69d..d62ff4aeaf169e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -70,13 +70,12 @@ public void Dispose() protected abstract void CreateSection(ObjectNodeSection section, out Stream sectionStream); - protected abstract void UpdateSectionAlignment(int sectionIndex, int alignment, out bool isExecutable); + protected internal abstract void UpdateSectionAlignment(int sectionIndex, int alignment); protected SectionWriter GetOrCreateSection(ObjectNodeSection section) { int sectionIndex; Stream sectionStream; - List relocationList; if (!_sectionNameToSectionIndex.TryGetValue((section.Name, section.ComdatName), out sectionIndex)) { @@ -84,19 +83,18 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) sectionIndex = _sectionNameToSectionIndex.Count; _sectionNameToSectionIndex.Add((section.Name, section.ComdatName), sectionIndex); _sectionIndexToStream.Add(sectionStream); - _sectionIndexToRelocations.Add(relocationList = new()); + _sectionIndexToRelocations.Add(new()); } else { sectionStream = _sectionIndexToStream[sectionIndex]; - relocationList = _sectionIndexToRelocations[sectionIndex]; } return new SectionWriter( this, sectionIndex, sectionStream, - relocationList); + section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); } protected bool ShouldShareSymbol(ObjectNode node) @@ -135,19 +133,23 @@ protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, s return new ObjectNodeSection(standardSectionPrefix + section.Name, section.Type, key); } - protected abstract void EmitRelocation( + /// + /// Emits a single relocation into a given section. + /// + /// + /// The relocation is not resolved until is called + /// later when symbol table is already generated. + /// + protected internal virtual void EmitRelocation( int sectionIndex, - List relocationList, int offset, Span data, RelocType relocType, string symbolName, - int addend); - - /// - /// Emit symbolic definitions into object file symbols. - /// - protected abstract void EmitSymbolTable(); + int addend) + { + _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + } /// /// Emit symbolic relocations into object file as format specific @@ -158,6 +160,31 @@ protected abstract void EmitRelocation( /// protected abstract void EmitRelocations(int sectionIndex, List relocationList); + /// + /// Emit new symbol definition at specified location in a given section. + /// + /// + /// The symbols are emitted into the object file representation later by + /// . Various formats have restrictions on + /// the order of the symbols so any necessary sorting is done when the + /// symbol table is created. + /// + protected internal void EmitSymbolDefinition( + int sectionIndex, + string symbolName, + int offset = 0, + int size = 0) + { + _definedSymbols.Add( + symbolName, + new SymbolDefinition(sectionIndex, offset, size)); + } + + /// + /// Emit symbolic definitions into object file symbols. + /// + protected abstract void EmitSymbolTable(); + protected virtual string ExternCName(string name) => name; protected abstract void EmitUnwindInfo(SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo); @@ -354,81 +381,5 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Relocations { get; init; } - - public SectionWriter( - ObjectWriter objectWriter, - int sectionIndex, - Stream stream, - List relocations) - { - _objectWriter = objectWriter; - SectionIndex = sectionIndex; - Stream = stream; - Relocations = relocations; - } - - public void EmitAlignment(int alignment) - { - _objectWriter.UpdateSectionAlignment(SectionIndex, alignment, out bool isExecutable); - - int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); - Span buffer = stackalloc byte[padding]; - byte paddingByte = isExecutable ? _objectWriter._insPaddingByte : (byte)0; - buffer.Fill(paddingByte); - Stream.Write(buffer); - } - - public void EmitRelocation( - int relativeOffset, - Span data, - RelocType relocType, - string symbolName, - int addend) - { - _objectWriter.EmitRelocation( - SectionIndex, - Relocations, - (int)Stream.Position + relativeOffset, - data, - relocType, - symbolName, - addend); - } - - public void EmitSymbolDefinition( - string symbolName, - int relativeOffset = 0, - int size = 0) - { - var symbolDefinition = new SymbolDefinition(SectionIndex, Stream.Position + relativeOffset, size); - _objectWriter._definedSymbols.Add(symbolName, symbolDefinition); - } - - public void EmitSymbolReference( - RelocType relocType, - string symbolName, - int addend = 0) - { - Span buffer = stackalloc byte[relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint)]; - buffer.Clear(); - _objectWriter.EmitRelocation( - SectionIndex, - Relocations, - (int)Stream.Position, - buffer, - relocType, - symbolName, - addend); - Stream.Write(buffer); - } - } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs new file mode 100644 index 00000000000000..d3335f6e43725e --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Linq; +using System.Numerics; +using System.Buffers; +using System.Buffers.Binary; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; + +using Internal.Text; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using Internal.JitInterface; +using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; + +namespace ILCompiler.ObjectWriter +{ + public struct SectionWriter + { + private ObjectWriter _objectWriter; + private byte _paddingByte; + + public int SectionIndex { get; init; } + public Stream Stream { get; init; } + + internal SectionWriter( + ObjectWriter objectWriter, + int sectionIndex, + Stream stream, + byte paddingByte) + { + _objectWriter = objectWriter; + _paddingByte = paddingByte; + SectionIndex = sectionIndex; + Stream = stream; + } + + public void EmitAlignment(int alignment) + { + _objectWriter.UpdateSectionAlignment(SectionIndex, alignment); + + int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); + Span buffer = stackalloc byte[padding]; + buffer.Fill(_paddingByte); + Stream.Write(buffer); + } + + public void EmitRelocation( + int relativeOffset, + Span data, + RelocType relocType, + string symbolName, + int addend) + { + _objectWriter.EmitRelocation( + SectionIndex, + (int)Stream.Position + relativeOffset, + data, + relocType, + symbolName, + addend); + } + + public void EmitSymbolDefinition( + string symbolName, + int relativeOffset = 0, + int size = 0) + { + _objectWriter.EmitSymbolDefinition( + SectionIndex, + symbolName, + (int)Stream.Position + relativeOffset, + size); + } + + public void EmitSymbolReference( + RelocType relocType, + string symbolName, + int addend = 0) + { + Span buffer = stackalloc byte[relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint)]; + buffer.Clear(); + _objectWriter.EmitRelocation( + SectionIndex, + (int)Stream.Position, + buffer, + relocType, + symbolName, + addend); + Stream.Write(buffer); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index e3e7520af6739a..127f668e8191ab 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -180,8 +180,8 @@ protected override void CreateEhSections() // Create sections for exception handling _lsdaSectionWriter = GetOrCreateSection(LsdaSection); ehFrameSectionWriter = GetOrCreateSection(new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null)); - UpdateSectionAlignment(_lsdaSectionWriter.SectionIndex, 8, out _); - UpdateSectionAlignment(ehFrameSectionWriter.SectionIndex, 8, out _); + _lsdaSectionWriter.EmitAlignment(8); + ehFrameSectionWriter.EmitAlignment(8); _ehFrameSectionIndex = ehFrameSectionWriter.SectionIndex; // We always use the same CIE in DWARF EH frames, so create and emit it now diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index ca9ef564f36224..ed039f983f86a5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -602,6 +602,7 @@ + From 00d86ffdd28525ae37d0ecf29c3b98fbee7808e7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 27 Oct 2022 12:40:29 +0200 Subject: [PATCH 023/144] Switch DwarfEhFrame to use UnixObjectWriter --- .../Compiler/ObjectWriter/DwarfEhFrame.cs | 56 +++++++++---------- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 5 +- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs index 00cef64846276d..758f6dcb547b21 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs @@ -18,24 +18,20 @@ namespace ILCompiler.ObjectWriter { public class DwarfEhFrame { - public delegate void EmitSymbolReferenceAction(RelocType relocationType, string symbolName); - - private Stream _stream; - private EmitSymbolReferenceAction _emitSymbolReference; + private SectionWriter _sectionWriter; private bool _is64Bit; private Dictionary _cieOffset; - public DwarfEhFrame(Stream stream, EmitSymbolReferenceAction emitSymbolReference, bool is64Bit) + public DwarfEhFrame(SectionWriter sectionWriter, bool is64Bit) { - _stream = stream; - _emitSymbolReference = emitSymbolReference; + _sectionWriter = sectionWriter; _is64Bit = is64Bit; _cieOffset = new Dictionary(); } public void AddCie(DwarfCie cie) { - _cieOffset.Add(cie, (uint)_stream.Position); + _cieOffset.Add(cie, (uint)_sectionWriter.Stream.Position); WriteCie(cie); } @@ -57,6 +53,7 @@ private void WriteCie(DwarfCie cie) Utf8StringBuilder augmentationString = new Utf8StringBuilder(); uint augmentationLength = 0; Span tempBuffer = stackalloc byte[8]; + var stream = _sectionWriter.Stream; if (cie.FdesHaveAugmentationData) { @@ -95,38 +92,39 @@ private void WriteCie(DwarfCie cie) uint padding = ((length + 7u) & ~7u) - length; BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - _stream.Write(tempBuffer); + stream.Write(tempBuffer); - _stream.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version - _stream.Write(augmentationString.UnderlyingArray); + stream.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version + stream.Write(augmentationString.UnderlyingArray); - _stream.WriteULEB128(cie.CodeAlignFactor); - _stream.WriteILEB128(cie.DataAlignFactor); - _stream.WriteULEB128(cie.ReturnAddressRegister); + stream.WriteULEB128(cie.CodeAlignFactor); + stream.WriteILEB128(cie.DataAlignFactor); + stream.WriteULEB128(cie.ReturnAddressRegister); - _stream.WriteULEB128(augmentationLength); + stream.WriteULEB128(augmentationLength); if (cie.PersonalitySymbolName != null) { - _stream.WriteByte(cie.PersonalityEncoding); + stream.WriteByte(cie.PersonalityEncoding); WriteAddress(cie.PersonalityEncoding, cie.PersonalitySymbolName); } if (cie.LsdaEncoding != 0) { - _stream.WriteByte(cie.LsdaEncoding); + stream.WriteByte(cie.LsdaEncoding); } if (cie.PointerEncoding != 0) { - _stream.WriteByte(cie.PointerEncoding); + stream.WriteByte(cie.PointerEncoding); } - _stream.Write(cie.Instructions); + stream.Write(cie.Instructions); - _stream.Write(stackalloc byte[(int)padding]); + stream.Write(stackalloc byte[(int)padding]); } private void WriteFde(DwarfFde fde, uint cieOffset) { Span tempBuffer = stackalloc byte[8]; + var stream = _sectionWriter.Stream; uint augmentationLength = fde.Cie.FdesHaveAugmentationData ? @@ -144,15 +142,15 @@ private void WriteFde(DwarfFde fde, uint cieOffset) uint padding = ((length + 7u) & ~7u) - length; BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - _stream.Write(tempBuffer.Slice(0, 4)); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(_stream.Position - cieOffset)); - _stream.Write(tempBuffer.Slice(0, 4)); + stream.Write(tempBuffer.Slice(0, 4)); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(stream.Position - cieOffset)); + stream.Write(tempBuffer.Slice(0, 4)); WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName); WriteSize(fde.Cie.PointerEncoding, fde.PcLength); if (fde.Cie.FdesHaveAugmentationData) { - _stream.WriteByte((byte)(augmentationLength - 1)); + stream.WriteByte((byte)(augmentationLength - 1)); if (fde.Cie.PersonalityEncoding != 0) { WriteAddress(fde.Cie.PersonalityEncoding, fde.PersonalitySymbolName); @@ -163,8 +161,8 @@ private void WriteFde(DwarfFde fde, uint cieOffset) } } - _stream.Write(fde.Instructions); - _stream.Write(stackalloc byte[(int)padding]); + stream.Write(fde.Instructions); + stream.Write(stackalloc byte[(int)padding]); } private uint AddressSize(byte encoding) @@ -188,12 +186,12 @@ private void WriteAddress(byte encoding, string symbolName) DW_EH_PE_absptr => RelocType.IMAGE_REL_BASED_DIR64, _ => throw new NotSupportedException() }; - _emitSymbolReference(relocationType, symbolName); + _sectionWriter.EmitSymbolReference(relocationType, symbolName); } else { Span address = stackalloc byte[(int)AddressSize(encoding)]; - _stream.Write(address); + _sectionWriter.Stream.Write(address); } } @@ -208,7 +206,7 @@ private void WriteSize(byte encoding, ulong size) { BinaryPrimitives.WriteUInt64LittleEndian(buffer, size); } - _stream.Write(buffer); + _sectionWriter.Stream.Write(buffer); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 127f668e8191ab..cf6233e4743796 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -192,10 +192,7 @@ protected override void CreateEhSections() _ => true }; _dwarfCie = new DwarfCie(_nodeFactory.Target.Architecture); - _dwarfEhFrame = new DwarfEhFrame( - ehFrameSectionWriter.Stream, - (relocType, symbolName) => ehFrameSectionWriter.EmitSymbolReference(relocType, symbolName), - is64Bit); + _dwarfEhFrame = new DwarfEhFrame(ehFrameSectionWriter, is64Bit); _dwarfEhFrame.AddCie(_dwarfCie); } From b770f786cbcbae0b00fef1dc97eb3ef6fd90d572 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 27 Oct 2022 21:01:53 +0200 Subject: [PATCH 024/144] WIP: CodeView debugging information --- .../Compiler/DependencyAnalysis/Relocation.cs | 1 + .../ObjectWriter/CodeViewSymbolsBuilder.cs | 259 ++++++++++++++---- .../ObjectWriter/CodeViewTypesBuilder.cs | 19 +- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 124 +++++---- .../Compiler/ObjectWriter/ObjectWriter.cs | 11 +- .../ILCompiler.Compiler.csproj | 1 + 6 files changed, 308 insertions(+), 107 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs index b833c909ff5b79..6c12dbbd1e607e 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs @@ -23,6 +23,7 @@ public enum RelocType // This is a special NGEN-specific relocation type // for relative pointer (used to make NGen relocation // section smaller) + IMAGE_REL_SECTION = 0x79, // 16 bit section index containing target IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 = 0x81, // ADRP IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A = 0x82, // ADD/ADDS (immediate) with zero shift, for page offset diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index 01b24e79ddfab3..2809d8aff4744b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -21,15 +21,11 @@ namespace ILCompiler.ObjectWriter internal sealed class CodeViewSymbolsBuilder { private TargetArchitecture _targetArchitecture; + private Dictionary _subsectionWriters = new(); - public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, Stream outputStream) + public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture) { _targetArchitecture = targetArchitecture; - - // Write CodeView version header - Span versionBuffer = stackalloc byte[sizeof(uint)]; - BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); - _outputStream.Write(versionBuffer); } // Maps an ICorDebugInfo register number to the corresponding CodeView @@ -67,37 +63,208 @@ private ushort GetCVRegNum(uint regNum) } } - private static + public void EmitSubprogramInfo( + string methodName, + int methodPCLength, + uint methodTypeIndex, + IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, + IEnumerable debugEHClauseInfos) + { + var symbolSubsection = GetSubsection(0xf1); + + using (var recordWriter = symbolSubsection.StartRecord(0x1147 /* S_GPROC32_ID */)) + { + recordWriter.Write((uint)0); // pointer to the parent + recordWriter.Write((uint)0); // pointer to this blocks end + recordWriter.Write((uint)0); // pointer to next symbol + recordWriter.Write((uint)methodPCLength); + recordWriter.Write((uint)0); // Debug start offset + recordWriter.Write((uint)methodPCLength); // Debug end offset + recordWriter.Write((uint)0); // Type index or ID + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); + recordWriter.Write((byte)0); // Proc flags + recordWriter.Write(methodName); + } + + foreach (var (debugVar, typeIndex) in debugVars) + { + using (var recordWriter = symbolSubsection.StartRecord(0x113e /* S_LOCAL */)) + { + recordWriter.Write(typeIndex); + recordWriter.Write((ushort)(debugVar.IsParameter ? 1 : 0)); // TODO: Flags + recordWriter.Write(debugVar.Name); // TODO: Names (this, etc.) + } + + foreach (var range in debugVar.DebugVarInfo.Ranges) + { + switch (range.VarLoc.LocationType) + { + case VarLocType.VLT_REG: + case VarLocType.VLT_REG_FP: + var cvRegNum = GetCVRegNum((uint)range.VarLoc.B); + if (cvRegNum != CV_REG_NONE) + { + using (var recordWriter = symbolSubsection.StartRecord(0x1141 /* S_DEFRANGE_REGISTER */)) + { + recordWriter.Write((ushort)cvRegNum); + recordWriter.Write((ushort)0); // TODO: Attributes + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName, (int)range.StartOffset); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); + recordWriter.Write((ushort)(range.EndOffset - range.StartOffset)); + } + } + break; + + case VarLocType.VLT_STK: + // FIXME: REGNUM_AMBIENT_SP + cvRegNum = GetCVRegNum((uint)range.VarLoc.B); + if (cvRegNum != CV_REG_NONE) + { + using (var recordWriter = symbolSubsection.StartRecord(0x1145 /* S_DEFRANGE_REGISTER_REL */)) + { + recordWriter.Write((ushort)cvRegNum); + // TODO: Flags, CV_OFFSET_PARENT_LENGTH_LIMIT + recordWriter.Write((ushort)0); + recordWriter.Write((uint)range.VarLoc.C); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName, (int)range.StartOffset); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); + recordWriter.Write((ushort)(range.EndOffset - range.StartOffset)); + } + } + break; + + case VarLocType.VLT_REG_BYREF: + case VarLocType.VLT_STK_BYREF: + case VarLocType.VLT_REG_REG: + case VarLocType.VLT_REG_STK: + case VarLocType.VLT_STK_REG: + case VarLocType.VLT_STK2: + case VarLocType.VLT_FPSTK: + case VarLocType.VLT_FIXED_VA: + break; + + default: + Debug.Fail("Unknown variable location type"); + break; + } + } + } + + using (var recordWriter = symbolSubsection.StartRecord(0x114f /* S_PROC_ID_END */)) + { + } + +/* + // We have an assembler directive that takes care of the whole line table. + // We also increase function id for the next function. + Streamer->emitCVLinetableDirective(FuncId++, Fn, FnEnd); +*/ + } + + public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) + { + var symbolSubsection = GetSubsection(0xf1); + foreach (var (name, typeIndex) in userDefinedTypes) + { + using (var recordWriter = symbolSubsection.StartRecord(0x1108 /* S_UDT */)) + { + recordWriter.Write(typeIndex); + recordWriter.Write(name); + } + } + } + + private SubsectionWriter GetSubsection(uint subsectionKind) + { + if (_subsectionWriters.TryGetValue(subsectionKind, out var subsectionWriter)) + { + return subsectionWriter; + } + else + { + subsectionWriter = new SubsectionWriter(); + _subsectionWriters.Add(subsectionKind, subsectionWriter); + return subsectionWriter; + } + } + + public void Write(SectionWriter sectionWriter) + { + // Write CodeView version header + Span versionBuffer = stackalloc byte[sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); + sectionWriter.Stream.Write(versionBuffer); + + Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; + foreach (var (subsectionKind, subsectionWriter) in _subsectionWriters) + { + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, subsectionWriter._size); + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, subsectionKind); + sectionWriter.Stream.Write(subsectionHeader); + foreach (var (offset, relocType, symbolName) in subsectionWriter._relocations) + { + sectionWriter.EmitRelocation( + (int)offset, + default, // NOTE: We know the data are unused for the relocation types used in debug section + relocType, + symbolName, + 0); + } - /*private ref struct SubsectionWriter + foreach (byte[] data in subsectionWriter._data) + { + sectionWriter.Stream.Write(data); + } + + sectionWriter.EmitAlignment(4); + } + } + + private sealed class SubsectionWriter { + internal uint _size; + internal List _data = new(); + internal List<(uint, RelocType, string)> _relocations = new(); + private ArrayBufferWriter _bufferWriter = new(); + + public RecordWriter StartRecord(ushort recordType) + { + RecordWriter writer = new RecordWriter(this, _bufferWriter); + writer.Write(recordType); + return writer; + } - }*/ + internal void CommitRecord() + { + byte[] lengthBuffer = new byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(_bufferWriter.WrittenCount)); + _data.Add(lengthBuffer); + _size += sizeof(ushort); + + // Add data + _data.Add(_bufferWriter.WrittenSpan.ToArray()); + _size += (uint)_bufferWriter.WrittenCount; + + _bufferWriter.Clear(); + } + } - /*private ref struct LeafRecordWriter + private ref struct RecordWriter { + private SubsectionWriter _subsectionWriter; private ArrayBufferWriter _bufferWriter; - private Stream _outputStream; - public LeafRecordWriter(ArrayBufferWriter bufferWriter, Stream outputStream) + public RecordWriter(SubsectionWriter subsectionWriter, ArrayBufferWriter bufferWriter) { + _subsectionWriter = subsectionWriter; _bufferWriter = bufferWriter; - _outputStream = outputStream; } public void Dispose() { - int length = sizeof(ushort) + _bufferWriter.WrittenCount; - int padding = ((length + 3) & ~3) - length; - Span lengthBuffer = stackalloc byte[sizeof(ushort)]; - BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); - _outputStream.Write(lengthBuffer); - _outputStream.Write(_bufferWriter.WrittenSpan); - _outputStream.Write(stackalloc byte[padding]); - _bufferWriter.Clear(); - - // TODO: LF_INDEX for long records + _subsectionWriter.CommitRecord(); } public void Write(byte value) @@ -131,39 +298,27 @@ public void Write(string value) _bufferWriter.Advance(byteCount); } - public void WriteEncodedInteger(ulong value) + public void EmitSymbolReference( + RelocType relocType, + string symbolName, + int addend = 0) { - if (value < LF_NUMERIC) - { - Write((ushort)value); - } - else if (value <= ushort.MaxValue) - { - Write(LF_USHORT); - Write((ushort)value); - } - else if (value <= uint.MaxValue) - { - Write(LF_ULONG); - Write((uint)value); - } - else - { - Write(LF_UQUADWORD); - Write(value); - } - } + _subsectionWriter._relocations.Add(( + _subsectionWriter._size + sizeof(ushort) + (uint)_bufferWriter.WrittenCount, + relocType, symbolName)); - public void WritePadding() - { - int paddingLength = ((_bufferWriter.WrittenCount - 2 + 3) & ~3) - (_bufferWriter.WrittenCount - 2); - Span padding = _bufferWriter.GetSpan(paddingLength); - for (int i = 0; i < paddingLength; i++) + switch (relocType) { - padding[i] = (byte)(LF_PAD0 + paddingLength - i); + case RelocType.IMAGE_REL_SECTION: + Write((ushort)0); + break; + case RelocType.IMAGE_REL_SECREL: + Write((uint)addend); + break; + default: + throw new NotSupportedException("Unsupported relocation"); } - _bufferWriter.Advance(paddingLength); } - }*/ + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index b761382148a2e7..1bfed3a44d48e7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -27,10 +27,13 @@ internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter private uint _classVTableTypeIndex; private uint _vfuncTabTypeIndex; + private List<(string, uint)> _userDefinedTypes = new(); private uint _nextTypeIndex = 0x1000; private ArrayBufferWriter _bufferWriter = new(); + public IList<(string, uint)> UserDefinedTypes => _userDefinedTypes; + public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, Stream outputStream) { _nameMangler = nameMangler; @@ -207,7 +210,10 @@ public uint GetArrayTypeIndex( record.Write(classDescriptor.Name); } - return _nextTypeIndex++; + uint typeIndex = _nextTypeIndex++; + _userDefinedTypes.Add((classDescriptor.Name, typeIndex)); + + return typeIndex; } public uint GetEnumTypeIndex( @@ -237,7 +243,10 @@ public uint GetEnumTypeIndex( record.Write(typeDescriptor.Name); } - return _nextTypeIndex++; + uint typeIndex = _nextTypeIndex++; + _userDefinedTypes.Add((typeDescriptor.Name, typeIndex)); + + return typeIndex; } public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) @@ -290,6 +299,7 @@ public uint GetCompleteClassTypeIndex( { fieldListRecord.Write(LF_STMEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.Write(desc.Name); } else @@ -318,7 +328,10 @@ public uint GetCompleteClassTypeIndex( record.Write(classTypeDescriptor.Name); } - return _nextTypeIndex++; + uint typeIndex = _nextTypeIndex++; + _userDefinedTypes.Add((classTypeDescriptor.Name, typeIndex)); + + return typeIndex; } public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index a561ba1e0a5108..75450bff9baff3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -40,12 +40,14 @@ public class CoffObjectWriter : ObjectWriter // Debugging private SectionWriter _debugTypesSectionWriter; - //private SectionWriter _debugSymbolSectionWriter; + private SectionWriter _debugSymbolSectionWriter; + private CodeViewSymbolsBuilder _debugSymbolsBuilder; + private CodeViewTypesBuilder _debugTypesBuilder; private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); private ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); - //private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); + private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); protected CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) @@ -122,51 +124,54 @@ protected internal override void EmitRelocation( string symbolName, int addend) { - if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || - relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || - relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + switch (relocType) { - Debug.Assert(addend == 0); - } - else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) - { - if (addend != 0) - { - BinaryPrimitives.WriteInt64LittleEndian( - data, - BinaryPrimitives.ReadInt64LittleEndian(data) + - addend); - addend = 0; - } - } - else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) - { - addend += 4; - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); - addend = 0; - } - } - else if (relocType == RelocType.IMAGE_REL_BASED_REL32 || - relocType == RelocType.IMAGE_REL_BASED_ADDR32NB || - relocType == RelocType.IMAGE_REL_BASED_ABSOLUTE) - { - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); - addend = 0; - } - } - else - { - throw new NotSupportedException($"Unsupported relocation: {relocType}"); + case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: + case RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: + case RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: + case RelocType.IMAGE_REL_SECREL: + case RelocType.IMAGE_REL_SECTION: + Debug.Assert(addend == 0); + break; + + case RelocType.IMAGE_REL_BASED_DIR64: + if (addend != 0) + { + BinaryPrimitives.WriteInt64LittleEndian( + data, + BinaryPrimitives.ReadInt64LittleEndian(data) + + addend); + addend = 0; + } + break; + + case RelocType.IMAGE_REL_BASED_RELPTR32: + addend += 4; + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + addend = 0; + } + break; + + case RelocType.IMAGE_REL_BASED_REL32: + case RelocType.IMAGE_REL_BASED_ADDR32NB: + case RelocType.IMAGE_REL_BASED_ABSOLUTE: + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + addend); + addend = 0; + } + break; + + default: + throw new NotSupportedException($"Unsupported relocation: {relocType}"); } base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); @@ -311,6 +316,8 @@ protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_AMD64_ADDR64, RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, + RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_AMD64_SECREL, + RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_AMD64_SECTION, _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") }, }); @@ -335,6 +342,8 @@ protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_ARM64_BRANCH26, RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => CoffRelocationType.IMAGE_REL_ARM64_PAGEBASE_REL21, RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => CoffRelocationType.IMAGE_REL_ARM64_PAGEOFFSET_12A, + RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_ARM64_SECREL, + RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_ARM64_SECTION, _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") }, }); @@ -542,11 +551,15 @@ protected override void CreateEhSections() protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { + _debugSymbolSectionWriter = GetOrCreateSection(DebugSymbolSection); + _debugSymbolSectionWriter.EmitAlignment(4); + _debugSymbolsBuilder = new CodeViewSymbolsBuilder(_nodeFactory.Target.Architecture); _debugTypesSectionWriter = GetOrCreateSection(DebugTypesSection); _debugTypesSectionWriter.EmitAlignment(4); - return new CodeViewTypesBuilder( + _debugTypesBuilder = new CodeViewTypesBuilder( _nodeFactory.NameMangler, _nodeFactory.Target.Architecture, _debugTypesSectionWriter.Stream); + return _debugTypesBuilder; } protected override void EmitDebugFunctionInfo( @@ -555,10 +568,27 @@ protected override void EmitDebugFunctionInfo( SymbolDefinition methodSymbol, INodeWithDebugInfo debugNode) { + DebugEHClauseInfo[] clauses = null; + + if (debugNode is INodeWithCodeInfo nodeWithCodeInfo) + { + clauses = nodeWithCodeInfo.DebugEHClauseInfos; + } + + _debugSymbolsBuilder.EmitSubprogramInfo( + methodName, + methodSymbol.Size, + methodTypeIndex, + debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), + clauses ?? Array.Empty()); + + //_debugSymbolsBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); } protected override void EmitDebugSections() { + _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); + _debugSymbolsBuilder.Write(_debugSymbolSectionWriter); } protected override void EmitDebugStaticVars() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index d62ff4aeaf169e..e63a687b895aea 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -352,13 +352,14 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection + From 65d59f0f82c0d7dc39ca97c4b7e4a86874516cb4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 28 Oct 2022 23:48:19 +0200 Subject: [PATCH 025/144] WIP: CodeView line mapping --- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 219 ++++++++++++++---- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 9 +- 2 files changed, 174 insertions(+), 54 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index 2809d8aff4744b..aece97b98b20a1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -21,11 +21,20 @@ namespace ILCompiler.ObjectWriter internal sealed class CodeViewSymbolsBuilder { private TargetArchitecture _targetArchitecture; - private Dictionary _subsectionWriters = new(); + private SectionWriter _sectionWriter; + private SubsectionWriter _stringTableWriter; + private SubsectionWriter _fileTableWriter; + private Dictionary _fileNameToIndex = new(); - public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture) + public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, SectionWriter sectionWriter) { _targetArchitecture = targetArchitecture; + _sectionWriter = sectionWriter; + + // Write CodeView version header + Span versionBuffer = stackalloc byte[sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); + sectionWriter.Stream.Write(versionBuffer); } // Maps an ICorDebugInfo register number to the corresponding CodeView @@ -53,6 +62,7 @@ private ushort GetCVRegNum(uint regNum) 13u => CV_AMD64_R13, 14u => CV_AMD64_R14, 15u => CV_AMD64_R15, + // TODO: Floating point _ => CV_REG_NONE, }; @@ -70,7 +80,7 @@ public void EmitSubprogramInfo( IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, IEnumerable debugEHClauseInfos) { - var symbolSubsection = GetSubsection(0xf1); + using var symbolSubsection = GetSubsection(0xf1); using (var recordWriter = symbolSubsection.StartRecord(0x1147 /* S_GPROC32_ID */)) { @@ -154,94 +164,174 @@ public void EmitSubprogramInfo( using (var recordWriter = symbolSubsection.StartRecord(0x114f /* S_PROC_ID_END */)) { } - -/* - // We have an assembler directive that takes care of the whole line table. - // We also increase function id for the next function. - Streamer->emitCVLinetableDirective(FuncId++, Fn, FnEnd); -*/ } - public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) + private uint GetFileIndex(string fileName) { - var symbolSubsection = GetSubsection(0xf1); - foreach (var (name, typeIndex) in userDefinedTypes) + if (fileName == "") { - using (var recordWriter = symbolSubsection.StartRecord(0x1108 /* S_UDT */)) - { - recordWriter.Write(typeIndex); - recordWriter.Write(name); - } + fileName = ""; } - } - private SubsectionWriter GetSubsection(uint subsectionKind) - { - if (_subsectionWriters.TryGetValue(subsectionKind, out var subsectionWriter)) + if (_fileNameToIndex.TryGetValue(fileName, out uint fileIndex)) { - return subsectionWriter; + return fileIndex; } else { - subsectionWriter = new SubsectionWriter(); - _subsectionWriters.Add(subsectionKind, subsectionWriter); - return subsectionWriter; + _stringTableWriter ??= GetSubsection(0xf3); + + uint stringTableIndex = _stringTableWriter._size; + using (var stringRecord = _stringTableWriter.StartRecord()) + { + if (stringTableIndex == 0) + { + // Start the table with non-zero indexs + stringRecord.Write((ushort)0); + stringTableIndex += sizeof(ushort); + } + stringRecord.Write(fileName); + } + + _fileTableWriter ??= GetSubsection(0xf4); + uint fileTableIndex = _fileTableWriter._size; + using (var fileRecord = _fileTableWriter.StartRecord()) + { + fileRecord.Write(stringTableIndex); + fileRecord.Write((uint)0); + } + + _fileNameToIndex.Add(fileName, fileTableIndex); + + return fileTableIndex; } } - public void Write(SectionWriter sectionWriter) + public void EmitLineInfo( + string methodName, + int methodPCLength, + IEnumerable sequencePoints) { - // Write CodeView version header - Span versionBuffer = stackalloc byte[sizeof(uint)]; - BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); - sectionWriter.Stream.Write(versionBuffer); + using var lineSubsection = GetSubsection(0xf2); - Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; - foreach (var (subsectionKind, subsectionWriter) in _subsectionWriters) + using (var recordWriter = lineSubsection.StartRecord()) { - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, subsectionWriter._size); - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, subsectionKind); - sectionWriter.Stream.Write(subsectionHeader); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName); + recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); + recordWriter.Write((ushort)0); // TODO: Flags (eg. have columns) + recordWriter.Write((uint)methodPCLength); - foreach (var (offset, relocType, symbolName) in subsectionWriter._relocations) + string lastFileName = null; + uint fileIndex = 0; + List codes = new(); + + foreach (var sequencePoint in sequencePoints) { - sectionWriter.EmitRelocation( - (int)offset, - default, // NOTE: We know the data are unused for the relocation types used in debug section - relocType, - symbolName, - 0); + if (lastFileName == null || lastFileName != sequencePoint.FileName) + { + if (codes.Count > 0) + { + recordWriter.Write(fileIndex); + recordWriter.Write((uint)(codes.Count / 2)); + recordWriter.Write((uint)(12 + 4 * codes.Count)); + foreach (uint code in codes) + { + recordWriter.Write((uint)code); + } + codes.Clear(); + } + + fileIndex = GetFileIndex(sequencePoint.FileName); + lastFileName = sequencePoint.FileName; + } + + codes.Add((uint)sequencePoint.NativeOffset); + codes.Add(0x80000000 | (uint)sequencePoint.LineNumber); } - foreach (byte[] data in subsectionWriter._data) + if (codes.Count > 0) { - sectionWriter.Stream.Write(data); + recordWriter.Write(fileIndex); + recordWriter.Write((uint)(codes.Count / 2)); + recordWriter.Write((uint)(12 + 4 * codes.Count)); + foreach (uint code in codes) + { + recordWriter.Write((uint)code); + } } + } + } - sectionWriter.EmitAlignment(4); + public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) + { + using var symbolSubsection = GetSubsection(0xf1); + foreach (var (name, typeIndex) in userDefinedTypes) + { + using (var recordWriter = symbolSubsection.StartRecord(0x1108 /* S_UDT */)) + { + recordWriter.Write(typeIndex); + recordWriter.Write(name); + } } } - private sealed class SubsectionWriter + private SubsectionWriter GetSubsection(uint subsectionKind) + { + return new SubsectionWriter(subsectionKind, _sectionWriter); + } + + public void Write() + { + _fileTableWriter?.Dispose(); + _stringTableWriter?.Dispose(); + _fileTableWriter = null; + _stringTableWriter = null; + } + + private sealed class SubsectionWriter : IDisposable { + private uint _kind; + private SectionWriter _sectionWriter; internal uint _size; internal List _data = new(); internal List<(uint, RelocType, string)> _relocations = new(); private ArrayBufferWriter _bufferWriter = new(); + internal bool _needLengthPrefix; + + public SubsectionWriter(uint kind, SectionWriter sectionWriter) + { + _kind = kind; + _sectionWriter = sectionWriter; + } + + public void Dispose() + { + Write(_sectionWriter); + } + + public RecordWriter StartRecord() + { + _needLengthPrefix = false; + return new RecordWriter(this, _bufferWriter); + } public RecordWriter StartRecord(ushort recordType) { RecordWriter writer = new RecordWriter(this, _bufferWriter); writer.Write(recordType); + _needLengthPrefix = true; return writer; } internal void CommitRecord() { - byte[] lengthBuffer = new byte[sizeof(ushort)]; - BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(_bufferWriter.WrittenCount)); - _data.Add(lengthBuffer); - _size += sizeof(ushort); + if (_needLengthPrefix) + { + byte[] lengthBuffer = new byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(_bufferWriter.WrittenCount)); + _data.Add(lengthBuffer); + _size += sizeof(ushort); + } // Add data _data.Add(_bufferWriter.WrittenSpan.ToArray()); @@ -249,6 +339,31 @@ internal void CommitRecord() _bufferWriter.Clear(); } + + internal void Write(SectionWriter sectionWriter) + { + Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), _size); + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, _kind); + sectionWriter.Stream.Write(subsectionHeader); + + foreach (var (offset, relocType, symbolName) in _relocations) + { + sectionWriter.EmitRelocation( + (int)offset, + default, // NOTE: We know the data are unused for the relocation types used in debug section + relocType, + symbolName, + 0); + } + + foreach (byte[] data in _data) + { + sectionWriter.Stream.Write(data); + } + + sectionWriter.EmitAlignment(4); + } } private ref struct RecordWriter @@ -304,7 +419,9 @@ public void EmitSymbolReference( int addend = 0) { _subsectionWriter._relocations.Add(( - _subsectionWriter._size + sizeof(ushort) + (uint)_bufferWriter.WrittenCount, + _subsectionWriter._size + + (uint)(_subsectionWriter._needLengthPrefix ? sizeof(ushort) : 0) + + (uint)_bufferWriter.WrittenCount, relocType, symbolName)); switch (relocType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 75450bff9baff3..7460abb8f5295d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -553,7 +553,9 @@ protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { _debugSymbolSectionWriter = GetOrCreateSection(DebugSymbolSection); _debugSymbolSectionWriter.EmitAlignment(4); - _debugSymbolsBuilder = new CodeViewSymbolsBuilder(_nodeFactory.Target.Architecture); + _debugSymbolsBuilder = new CodeViewSymbolsBuilder( + _nodeFactory.Target.Architecture, + _debugSymbolSectionWriter); _debugTypesSectionWriter = GetOrCreateSection(DebugTypesSection); _debugTypesSectionWriter.EmitAlignment(4); _debugTypesBuilder = new CodeViewTypesBuilder( @@ -582,13 +584,14 @@ protected override void EmitDebugFunctionInfo( debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? Array.Empty()); - //_debugSymbolsBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); + _debugSymbolsBuilder.EmitLineInfo( + methodName, methodSymbol.Size, debugNode.GetNativeSequencePoints()); } protected override void EmitDebugSections() { _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); - _debugSymbolsBuilder.Write(_debugSymbolSectionWriter); + _debugSymbolsBuilder.Write(); } protected override void EmitDebugStaticVars() From bc8b8d5e97110a17d983ff80a87e8c2c868842ab Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 29 Oct 2022 09:59:22 +0200 Subject: [PATCH 026/144] WIP: CodeView restructuring --- .../ObjectWriter/CodeViewFileTableBuilder.cs | 74 ++++ .../Compiler/ObjectWriter/CodeViewNative.cs | 382 ++++++++---------- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 114 ++---- .../ObjectWriter/CodeViewTypesBuilder.cs | 74 ++-- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 11 +- .../ILCompiler.Compiler.csproj | 1 + 6 files changed, 323 insertions(+), 333 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs new file mode 100644 index 00000000000000..af84e8743fde89 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +using static ILCompiler.ObjectWriter.CodeViewNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class CodeViewFileTableBuilder + { + private MemoryStream _stringTableWriter = new(); + private MemoryStream _fileTableWriter = new(); + private Dictionary _fileNameToIndex = new(); + + public CodeViewFileTableBuilder() + { + // Insert empty entry at the beginning of string table + _stringTableWriter.Write(stackalloc byte[2]); + } + + public uint GetFileIndex(string fileName) + { + if (fileName == "") + { + fileName = ""; + } + + if (_fileNameToIndex.TryGetValue(fileName, out uint fileIndex)) + { + return fileIndex; + } + else + { + uint stringTableIndex = (uint)_stringTableWriter.Position; + _stringTableWriter.Write(Encoding.UTF8.GetBytes(fileName)); + _stringTableWriter.WriteByte(0); + + uint fileTableIndex = (uint)_fileTableWriter.Position; + Span fileTableEntry = stackalloc byte[sizeof(uint) + sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(fileTableEntry, stringTableIndex); + BinaryPrimitives.WriteUInt32LittleEndian(fileTableEntry.Slice(4), 0); + _fileTableWriter.Write(fileTableEntry); + + _fileNameToIndex.Add(fileName, fileTableIndex); + + return fileTableIndex; + } + } + + public void Write(Stream sectionStream) + { + Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; + + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)DebugSymbolsSubsectionType.FileChecksums); + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), (uint)_fileTableWriter.Length); + sectionStream.Write(subsectionHeader); + _fileTableWriter.Position = 0; + _fileTableWriter.CopyTo(sectionStream); + + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)DebugSymbolsSubsectionType.StringTable); + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), (uint)_stringTableWriter.Length); + sectionStream.Write(subsectionHeader); + _stringTableWriter.Position = 0; + _stringTableWriter.CopyTo(sectionStream); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs index 19d5ca6a6035d3..86d73e18419ca6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; + namespace ILCompiler.ObjectWriter { internal static class CodeViewNative @@ -404,215 +406,6 @@ internal static class CodeViewNative public const ushort MOD_volatile = 2; public const ushort MOD_unaligned = 4; - // leaf indices starting records but referenced from symbol records - - public const ushort LF_MODIFIER_16t = 0x0001; - public const ushort LF_POINTER_16t = 0x0002; - public const ushort LF_ARRAY_16t = 0x0003; - public const ushort LF_CLASS_16t = 0x0004; - public const ushort LF_STRUCTURE_16t = 0x0005; - public const ushort LF_UNION_16t = 0x0006; - public const ushort LF_ENUM_16t = 0x0007; - public const ushort LF_PROCEDURE_16t = 0x0008; - public const ushort LF_MFUNCTION_16t = 0x0009; - public const ushort LF_VTSHAPE = 0x000a; - public const ushort LF_COBOL0_16t = 0x000b; - public const ushort LF_COBOL1 = 0x000c; - public const ushort LF_BARRAY_16t = 0x000d; - public const ushort LF_LABEL = 0x000e; - public const ushort LF_NULL = 0x000f; - public const ushort LF_NOTTRAN = 0x0010; - public const ushort LF_DIMARRAY_16t = 0x0011; - public const ushort LF_VFTPATH_16t = 0x0012; - public const ushort LF_PRECOMP_16t = 0x0013; // not referenced from symbol - public const ushort LF_ENDPRECOMP = 0x0014; // not referenced from symbol - public const ushort LF_OEM_16t = 0x0015; // oem definable type string - public const ushort LF_TYPESERVER_ST = 0x0016; // not referenced from symbol - - // leaf indices starting records but referenced only from type records - - public const ushort LF_SKIP_16t = 0x0200; - public const ushort LF_ARGLIST_16t = 0x0201; - public const ushort LF_DEFARG_16t = 0x0202; - public const ushort LF_LIST = 0x0203; - public const ushort LF_FIELDLIST_16t = 0x0204; - public const ushort LF_DERIVED_16t = 0x0205; - public const ushort LF_BITFIELD_16t = 0x0206; - public const ushort LF_METHODLIST_16t = 0x0207; - public const ushort LF_DIMCONU_16t = 0x0208; - public const ushort LF_DIMCONLU_16t = 0x0209; - public const ushort LF_DIMVARU_16t = 0x020a; - public const ushort LF_DIMVARLU_16t = 0x020b; - public const ushort LF_REFSYM = 0x020c; - - public const ushort LF_BCLASS_16t = 0x0400; - public const ushort LF_VBCLASS_16t = 0x0401; - public const ushort LF_IVBCLASS_16t = 0x0402; - public const ushort LF_ENUMERATE_ST = 0x0403; - public const ushort LF_FRIENDFCN_16t = 0x0404; - public const ushort LF_INDEX_16t = 0x0405; - public const ushort LF_MEMBER_16t = 0x0406; - public const ushort LF_STMEMBER_16t = 0x0407; - public const ushort LF_METHOD_16t = 0x0408; - public const ushort LF_NESTTYPE_16t = 0x0409; - public const ushort LF_VFUNCTAB_16t = 0x040a; - public const ushort LF_FRIENDCLS_16t = 0x040b; - public const ushort LF_ONEMETHOD_16t = 0x040c; - public const ushort LF_VFUNCOFF_16t = 0x040d; - -// 32-bit type index versions of leaves, all have the 0x1000 bit set -// - public const ushort LF_TI16_MAX = 0x1000; - - public const ushort LF_MODIFIER = 0x1001; - public const ushort LF_POINTER = 0x1002; - public const ushort LF_ARRAY_ST = 0x1003; - public const ushort LF_CLASS_ST = 0x1004; - public const ushort LF_STRUCTURE_ST = 0x1005; - public const ushort LF_UNION_ST = 0x1006; - public const ushort LF_ENUM_ST = 0x1007; - public const ushort LF_PROCEDURE = 0x1008; - public const ushort LF_MFUNCTION = 0x1009; - public const ushort LF_COBOL0 = 0x100a; - public const ushort LF_BARRAY = 0x100b; - public const ushort LF_DIMARRAY_ST = 0x100c; - public const ushort LF_VFTPATH = 0x100d; - public const ushort LF_PRECOMP_ST = 0x100e; // not referenced from symbol - public const ushort LF_OEM = 0x100f; // oem definable type string - public const ushort LF_ALIAS_ST = 0x1010; // alias (typedef) type - public const ushort LF_OEM2 = 0x1011; // oem definable type string - - // leaf indices starting records but referenced only from type records - - public const ushort LF_SKIP = 0x1200; - public const ushort LF_ARGLIST = 0x1201; - public const ushort LF_DEFARG_ST = 0x1202; - public const ushort LF_FIELDLIST = 0x1203; - public const ushort LF_DERIVED = 0x1204; - public const ushort LF_BITFIELD = 0x1205; - public const ushort LF_METHODLIST = 0x1206; - public const ushort LF_DIMCONU = 0x1207; - public const ushort LF_DIMCONLU = 0x1208; - public const ushort LF_DIMVARU = 0x1209; - public const ushort LF_DIMVARLU = 0x120a; - - public const ushort LF_BCLASS = 0x1400; - public const ushort LF_VBCLASS = 0x1401; - public const ushort LF_IVBCLASS = 0x1402; - public const ushort LF_FRIENDFCN_ST = 0x1403; - public const ushort LF_INDEX = 0x1404; - public const ushort LF_MEMBER_ST = 0x1405; - public const ushort LF_STMEMBER_ST = 0x1406; - public const ushort LF_METHOD_ST = 0x1407; - public const ushort LF_NESTTYPE_ST = 0x1408; - public const ushort LF_VFUNCTAB = 0x1409; - public const ushort LF_FRIENDCLS = 0x140a; - public const ushort LF_ONEMETHOD_ST = 0x140b; - public const ushort LF_VFUNCOFF = 0x140c; - public const ushort LF_NESTTYPEEX_ST = 0x140d; - public const ushort LF_MEMBERMODIFY_ST = 0x140e; - public const ushort LF_MANAGED_ST = 0x140f; - - // Types w/ SZ names - - public const ushort LF_ST_MAX = 0x1500; - - public const ushort LF_TYPESERVER = 0x1501; // not referenced from symbol - public const ushort LF_ENUMERATE = 0x1502; - public const ushort LF_ARRAY = 0x1503; - public const ushort LF_CLASS = 0x1504; - public const ushort LF_STRUCTURE = 0x1505; - public const ushort LF_UNION = 0x1506; - public const ushort LF_ENUM = 0x1507; - public const ushort LF_DIMARRAY = 0x1508; - public const ushort LF_PRECOMP = 0x1509; // not referenced from symbol - public const ushort LF_ALIAS = 0x150a; // alias (typedef) type - public const ushort LF_DEFARG = 0x150b; - public const ushort LF_FRIENDFCN = 0x150c; - public const ushort LF_MEMBER = 0x150d; - public const ushort LF_STMEMBER = 0x150e; - public const ushort LF_METHOD = 0x150f; - public const ushort LF_NESTTYPE = 0x1510; - public const ushort LF_ONEMETHOD = 0x1511; - public const ushort LF_NESTTYPEEX = 0x1512; - public const ushort LF_MEMBERMODIFY = 0x1513; - public const ushort LF_MANAGED = 0x1514; - public const ushort LF_TYPESERVER2 = 0x1515; - - public const ushort LF_STRIDED_ARRAY = 0x1516; // same as LF_ARRAY, but with stride between adjacent elements - public const ushort LF_HLSL = 0x1517; - public const ushort LF_MODIFIER_EX = 0x1518; - public const ushort LF_INTERFACE = 0x1519; - public const ushort LF_BINTERFACE = 0x151a; - public const ushort LF_VECTOR = 0x151b; - public const ushort LF_MATRIX = 0x151c; - - public const ushort LF_VFTABLE = 0x151d; // a virtual function table - public const ushort LF_ENDOFLEAFRECORD = LF_VFTABLE; - - //public const ushort LF_TYPE_LAST; // one greater than the last type record - //public const ushort LF_TYPE_MAX = LF_TYPE_LAST - 1; - - public const ushort LF_FUNC_ID = 0x1601; // global func ID - public const ushort LF_MFUNC_ID = 0x1602; // member func ID - public const ushort LF_BUILDINFO = 0x1603; // build info: tool, version, command line, src/pdb file - public const ushort LF_SUBSTR_LIST = 0x1604; // similar to LF_ARGLIST, for list of sub strings - public const ushort LF_STRING_ID = 0x1605; // string ID - - public const ushort LF_UDT_SRC_LINE = 0x1606; // source and line on where an UDT is defined - // only generated by compiler - - public const ushort LF_UDT_MOD_SRC_LINE = 0x1607; // module, source and line on where an UDT is defined - // only generated by linker - - //public const ushort LF_ID_LAST; // one greater than the last ID record - //public const ushort LF_ID_MAX = LF_ID_LAST - 1; - - public const ushort LF_NUMERIC = 0x8000; - public const ushort LF_CHAR = 0x8000; - public const ushort LF_SHORT = 0x8001; - public const ushort LF_USHORT = 0x8002; - public const ushort LF_LONG = 0x8003; - public const ushort LF_ULONG = 0x8004; - public const ushort LF_REAL32 = 0x8005; - public const ushort LF_REAL64 = 0x8006; - public const ushort LF_REAL80 = 0x8007; - public const ushort LF_REAL128 = 0x8008; - public const ushort LF_QUADWORD = 0x8009; - public const ushort LF_UQUADWORD = 0x800a; - public const ushort LF_REAL48 = 0x800b; - public const ushort LF_COMPLEX32 = 0x800c; - public const ushort LF_COMPLEX64 = 0x800d; - public const ushort LF_COMPLEX80 = 0x800e; - public const ushort LF_COMPLEX128 = 0x800f; - public const ushort LF_VARSTRING = 0x8010; - - public const ushort LF_OCTWORD = 0x8017; - public const ushort LF_UOCTWORD = 0x8018; - - public const ushort LF_DECIMAL = 0x8019; - public const ushort LF_DATE = 0x801a; - public const ushort LF_UTF8STRING = 0x801b; - - public const ushort LF_REAL16 = 0x801c; - - public const ushort LF_PAD0 = 0xf0; - public const ushort LF_PAD1 = 0xf1; - public const ushort LF_PAD2 = 0xf2; - public const ushort LF_PAD3 = 0xf3; - public const ushort LF_PAD4 = 0xf4; - public const ushort LF_PAD5 = 0xf5; - public const ushort LF_PAD6 = 0xf6; - public const ushort LF_PAD7 = 0xf7; - public const ushort LF_PAD8 = 0xf8; - public const ushort LF_PAD9 = 0xf9; - public const ushort LF_PAD10 = 0xfa; - public const ushort LF_PAD11 = 0xfb; - public const ushort LF_PAD12 = 0xfc; - public const ushort LF_PAD13 = 0xfd; - public const ushort LF_PAD14 = 0xfe; - public const ushort LF_PAD15 = 0xff; - public const ushort CV_PROP_NONE = 0; public const ushort CV_PROP_PACKED = 0x0001; public const ushort CV_PROP_HAS_CONSTURUCTOR_OR_DESTRUCTOR = 0x0002; @@ -647,5 +440,176 @@ internal static class CodeViewNative public const ushort CV_AMD64_R13 = 341; public const ushort CV_AMD64_R14 = 342; public const ushort CV_AMD64_R15 = 343; + + // Matches DEBUG_S_SUBSECTION_TYPE in cvinfo.h + public enum DebugSymbolsSubsectionType : uint + { + Symbols = 0xf1, + Lines, + StringTable, + FileChecksums, + FrameData, + InlineeLines, + CrossScopeImports, + CrossScopeExports, + + ILLines, + FunctionMDTokenMap, + TypeMDTokenMap, + MergedAssemblyInput, + + CoffSymbolRva, + } + + // Matches LEAF_ENUM_e in cvinfo.h + // 32-bit type index versions of leaves have the 0x1000 bit set; most 16-bit + // leaves are omitted since they are unused + public enum LeafRecordType + { + // Leaf indices starting records referenced from symbol records + VTShape = 0x000a, + Label = 0x000e, + Null = 0x000f, + NotTran = 0x0010, + EndPrecomp = 0x0014, // not referenced from symbol + TypeServerST = 0x0016, // not referenced from symbol + Modifier = 0x1001, + Pointer = 0x1002, + ArrayST = 0x1003, + ClassST = 0x1004, + StructureST = 0x1005, + UnionST = 0x1006, + EnumST = 0x1007, + Procedure = 0x1008, + MemberFunction = 0x1009, + Cobol0 = 0x100a, + BArray = 0x100b, + DimArrayST = 0x100c, + VFTPath = 0x100d, + PrecompST = 0x100e, // not referenced from symbol + Oem = 0x100f, // oem definable type string + AliasST = 0x1010, // alias (typedef) type + Oem2 = 0x1011, // oem definable type string + + // Leaf indices starting records but referenced only from type records + RefSym = 0x020c, + EnumerateST = 0x0403, + + Skip = 0x1200, + ArgList = 0x1201, + DefArgST = 0x1202, + FieldList = 0x1203, + Derived = 0x1204, + BitField = 0x1205, + MethodList = 0x1206, + DimConU = 0x1207, + DimConLU = 0x1208, + DimVatU = 0x1209, + DimVarLU = 0x120a, + + BaseClass = 0x1400, + VBaseClass = 0x1401, + IVBaseClass = 0x1402, + FriendFunctionST = 0x1403, + Index = 0x1404, + MemberST = 0x1405, + StaticMemberST = 0x1406, + MethodST = 0x1407, + NestTypeST = 0x1408, + VFunctionTable = 0x1409, + FriendClass = 0x140a, + OneMethodST = 0x140b, + VFunctionOffset = 0x140c, + NestTypeExST = 0x140d, + MemberModifyST = 0x140e, + ManagedST = 0x140f, + + // Types w/ SZ names + TypeServer = 0x1501, // not referenced from symbol + Enumerate = 0x1502, + Array = 0x1503, + Class = 0x1504, + Structure = 0x1505, + Union = 0x1506, + Enum = 0x1507, + DimArray = 0x1508, + Precomp = 0x1509, // not referenced from symbol + Alias = 0x150a, // alias (typedef) type + DefArg = 0x150b, + FriendFunction = 0x150c, + Member = 0x150d, + StaticMember = 0x150e, + Method = 0x150f, + NestType = 0x1510, + OneMethod = 0x1511, + NestTypeEx = 0x1512, + MemberModify = 0x1513, + Managed = 0x1514, + TypeServer2 = 0x1515, + + StridedArray = 0x1516, // same as Array, but with stride between adjacent elements + HLSL = 0x1517, + ModifierEx = 0x1518, + Interface = 0x1519, + BInterface = 0x151a, + Vector = 0x151b, + Matrix = 0x151c, + + VFTable = 0x151d, + + FunctionId = 0x1601, + MemberFunctionId = 0x1602, + BuildInfo = 0x1603, + SubstringList = 0x1604, + StringId = 0x1605, + + UdtSrcLine = 0x1606, // source and line on where an UDT is defined (only generated by compiler) + UdtModSrcLine = 0x1607, // module, source and line on where an UDT is defined (only generated by linker) + + // Size prefixes + Numeric = 0x8000, + Char = 0x8000, + Short = 0x8001, + UShort = 0x8002, + Long = 0x8003, + ULong = 0x8004, + Real32 = 0x8005, + Real64 = 0x8006, + Real80 = 0x8007, + Real128 = 0x8008, + QuadWord = 0x8009, + UQuadWord = 0x800a, + Real48 = 0x800b, + Complex32 = 0x800c, + Complex64 = 0x800d, + Complex80 = 0x800e, + Complex128 = 0x800f, + VarString = 0x8010, + + OctWord = 0x8017, + UOctWord = 0x8018, + Decimal = 0x8019, + Date = 0x801a, + Utf8String = 0x801b, + Real = 0x801c, + + // List padding + Pad0 = 0xf0, + Pad1 = 0xf1, + Pad2 = 0xf2, + Pad3 = 0xf3, + Pad4 = 0xf4, + Pad5 = 0xf5, + Pad6 = 0xf6, + Pad7 = 0xf7, + Pad8 = 0xf8, + Pad9 = 0xf9, + Pad10 = 0xfa, + Pad11 = 0xfb, + Pad12 = 0xfc, + Pad13 = 0xfd, + Pad14 = 0xfe, + Pad15 = 0xff, + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index aece97b98b20a1..e605391d7b3771 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -22,9 +22,6 @@ internal sealed class CodeViewSymbolsBuilder { private TargetArchitecture _targetArchitecture; private SectionWriter _sectionWriter; - private SubsectionWriter _stringTableWriter; - private SubsectionWriter _fileTableWriter; - private Dictionary _fileNameToIndex = new(); public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, SectionWriter sectionWriter) { @@ -80,7 +77,7 @@ public void EmitSubprogramInfo( IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, IEnumerable debugEHClauseInfos) { - using var symbolSubsection = GetSubsection(0xf1); + using var symbolSubsection = GetSubsection(DebugSymbolsSubsectionType.Symbols); using (var recordWriter = symbolSubsection.StartRecord(0x1147 /* S_GPROC32_ID */)) { @@ -166,53 +163,13 @@ public void EmitSubprogramInfo( } } - private uint GetFileIndex(string fileName) - { - if (fileName == "") - { - fileName = ""; - } - - if (_fileNameToIndex.TryGetValue(fileName, out uint fileIndex)) - { - return fileIndex; - } - else - { - _stringTableWriter ??= GetSubsection(0xf3); - - uint stringTableIndex = _stringTableWriter._size; - using (var stringRecord = _stringTableWriter.StartRecord()) - { - if (stringTableIndex == 0) - { - // Start the table with non-zero indexs - stringRecord.Write((ushort)0); - stringTableIndex += sizeof(ushort); - } - stringRecord.Write(fileName); - } - - _fileTableWriter ??= GetSubsection(0xf4); - uint fileTableIndex = _fileTableWriter._size; - using (var fileRecord = _fileTableWriter.StartRecord()) - { - fileRecord.Write(stringTableIndex); - fileRecord.Write((uint)0); - } - - _fileNameToIndex.Add(fileName, fileTableIndex); - - return fileTableIndex; - } - } - public void EmitLineInfo( + CodeViewFileTableBuilder fileTableBuilder, string methodName, int methodPCLength, IEnumerable sequencePoints) { - using var lineSubsection = GetSubsection(0xf2); + using var lineSubsection = GetSubsection(DebugSymbolsSubsectionType.Lines); using (var recordWriter = lineSubsection.StartRecord()) { @@ -241,7 +198,7 @@ public void EmitLineInfo( codes.Clear(); } - fileIndex = GetFileIndex(sequencePoint.FileName); + fileIndex = fileTableBuilder.GetFileIndex(sequencePoint.FileName); lastFileName = sequencePoint.FileName; } @@ -264,7 +221,7 @@ public void EmitLineInfo( public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) { - using var symbolSubsection = GetSubsection(0xf1); + using var symbolSubsection = GetSubsection(DebugSymbolsSubsectionType.Symbols); foreach (var (name, typeIndex) in userDefinedTypes) { using (var recordWriter = symbolSubsection.StartRecord(0x1108 /* S_UDT */)) @@ -275,22 +232,14 @@ public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) } } - private SubsectionWriter GetSubsection(uint subsectionKind) + private SubsectionWriter GetSubsection(DebugSymbolsSubsectionType subsectionKind) { return new SubsectionWriter(subsectionKind, _sectionWriter); } - public void Write() - { - _fileTableWriter?.Dispose(); - _stringTableWriter?.Dispose(); - _fileTableWriter = null; - _stringTableWriter = null; - } - private sealed class SubsectionWriter : IDisposable { - private uint _kind; + private DebugSymbolsSubsectionType _kind; private SectionWriter _sectionWriter; internal uint _size; internal List _data = new(); @@ -298,7 +247,7 @@ private sealed class SubsectionWriter : IDisposable private ArrayBufferWriter _bufferWriter = new(); internal bool _needLengthPrefix; - public SubsectionWriter(uint kind, SectionWriter sectionWriter) + public SubsectionWriter(DebugSymbolsSubsectionType kind, SectionWriter sectionWriter) { _kind = kind; _sectionWriter = sectionWriter; @@ -306,7 +255,27 @@ public SubsectionWriter(uint kind, SectionWriter sectionWriter) public void Dispose() { - Write(_sectionWriter); + Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)_kind); + BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), _size); + _sectionWriter.Stream.Write(subsectionHeader); + + foreach (var (offset, relocType, symbolName) in _relocations) + { + _sectionWriter.EmitRelocation( + (int)offset, + default, // NOTE: We know the data are unused for the relocation types used in debug section + relocType, + symbolName, + 0); + } + + foreach (byte[] data in _data) + { + _sectionWriter.Stream.Write(data); + } + + _sectionWriter.EmitAlignment(4); } public RecordWriter StartRecord() @@ -339,31 +308,6 @@ internal void CommitRecord() _bufferWriter.Clear(); } - - internal void Write(SectionWriter sectionWriter) - { - Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), _size); - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, _kind); - sectionWriter.Stream.Write(subsectionHeader); - - foreach (var (offset, relocType, symbolName) in _relocations) - { - sectionWriter.EmitRelocation( - (int)offset, - default, // NOTE: We know the data are unused for the relocation types used in debug section - relocType, - symbolName, - 0); - } - - foreach (byte[] data in _data) - { - sectionWriter.Stream.Write(data); - } - - sectionWriter.EmitAlignment(4); - } } private ref struct RecordWriter diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index 1bfed3a44d48e7..942b19b7648afc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -55,13 +55,13 @@ public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetAr // We use the same "Vtable" for all types because the vtable shape debug // record is not expressive enough to capture our vtable shape (where the // vtable slots don't start at the beginning of the vtable). - using (var record = StartLeafRecord(LF_VTSHAPE)) + using (var record = StartLeafRecord(LeafRecordType.VTShape)) { record.Write((ushort)0); // Number of entries in vfunctable } _classVTableTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LF_POINTER)) + using (var record = StartLeafRecord(LeafRecordType.Pointer)) { record.Write(_classVTableTypeIndex); record.Write((uint)((_targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | (CV_PTR_MODE_LVREF << 5))); @@ -69,13 +69,6 @@ public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetAr _vfuncTabTypeIndex = _nextTypeIndex++; } - private LeafRecordWriter StartLeafRecord(ushort leafRecordType) - { - LeafRecordWriter writer = new LeafRecordWriter(_bufferWriter, _outputStream); - writer.Write(leafRecordType); - return writer; - } - public uint GetPrimitiveTypeIndex(TypeDesc type) { Debug.Assert(type.IsPrimitive, "it is not a primitive type"); @@ -112,7 +105,7 @@ public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) uint pointerMode = pointerDescriptor.IsReference == 1 ? CV_PTR_MODE_LVREF : CV_PTR_MODE_PTR; //ushort pointerOptions = pointerDescriptor.IsConst ? MOD_const : MOD_none; - using (var record = StartLeafRecord(LF_POINTER)) + using (var record = StartLeafRecord(LeafRecordType.Pointer)) { record.Write(elementType); record.Write((uint)(pointerKind | (pointerMode << 5))); // TODO: pointerOptions @@ -128,7 +121,7 @@ public uint GetArrayTypeIndex( uint memberCount = 0; uint offset = 0; - using (var arrayRecord = StartLeafRecord(LF_ARRAY)) + using (var arrayRecord = StartLeafRecord(LeafRecordType.Array)) { arrayRecord.Write(arrayDescriptor.ElementType); arrayRecord.Write(T_INT4); @@ -138,11 +131,11 @@ public uint GetArrayTypeIndex( uint arrayRecordTypeIndex = _nextTypeIndex++; - using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) { if (classDescriptor.BaseClassId != 0) { - fieldListRecord.Write(LF_BCLASS); + fieldListRecord.Write((ushort)LeafRecordType.BaseClass); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset @@ -151,7 +144,7 @@ public uint GetArrayTypeIndex( offset += (uint)_targetPointerSize; } - fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)LeafRecordType.Member); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -164,7 +157,7 @@ public uint GetArrayTypeIndex( { for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)LeafRecordType.Member); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -176,7 +169,7 @@ public uint GetArrayTypeIndex( for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)LeafRecordType.Member); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -187,7 +180,7 @@ public uint GetArrayTypeIndex( } } - fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)LeafRecordType.Member); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(arrayRecordTypeIndex); fieldListRecord.WriteEncodedInteger(offset); @@ -199,7 +192,7 @@ public uint GetArrayTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; Debug.Assert(classDescriptor.IsStruct == 0); - using (var record = StartLeafRecord(LF_CLASS)) + using (var record = StartLeafRecord(LeafRecordType.Class)) { record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options @@ -220,11 +213,11 @@ public uint GetEnumTypeIndex( EnumTypeDescriptor typeDescriptor, EnumRecordTypeDescriptor[] typeRecords) { - using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) { foreach (EnumRecordTypeDescriptor record in typeRecords) { - fieldListRecord.Write(LF_ENUMERATE); + fieldListRecord.Write((ushort)LeafRecordType.Enumerate); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.WriteEncodedInteger(record.Value); fieldListRecord.Write(record.Name); @@ -234,7 +227,7 @@ public uint GetEnumTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LF_ENUM)) + using (var record = StartLeafRecord(LeafRecordType.Enum)) { record.Write((ushort)typeRecords.Length); // Number of elements in class record.Write((ushort)0); // TODO: Attributes @@ -251,7 +244,7 @@ public uint GetEnumTypeIndex( public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) { - using (var record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) + using (var record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LeafRecordType.Structure : LeafRecordType.Class)) { record.Write((ushort)0); // Number of elements in class record.Write((ushort)CV_PROP_FORWARD_REFERENCE); @@ -273,11 +266,11 @@ public uint GetCompleteClassTypeIndex( { uint memberCount = 0; - using (var fieldListRecord = StartLeafRecord(LF_FIELDLIST)) + using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) { if (classTypeDescriptor.BaseClassId != 0) { - fieldListRecord.Write(LF_BCLASS); + fieldListRecord.Write((ushort)LeafRecordType.BaseClass); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classTypeDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset @@ -286,7 +279,7 @@ public uint GetCompleteClassTypeIndex( } else if (classTypeDescriptor.IsStruct == 0) { - fieldListRecord.Write(LF_VFUNCTAB); + fieldListRecord.Write((ushort)LeafRecordType.VFunctionTable); fieldListRecord.Write((ushort)0); // Padding fieldListRecord.Write(_vfuncTabTypeIndex); fieldListRecord.WritePadding(); @@ -297,14 +290,14 @@ public uint GetCompleteClassTypeIndex( { if (desc.Offset == 0xFFFFFFFF) { - fieldListRecord.Write(LF_STMEMBER); + fieldListRecord.Write((ushort)LeafRecordType.StaticMember); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.Write(desc.Name); } else { - fieldListRecord.Write(LF_MEMBER); + fieldListRecord.Write((ushort)LeafRecordType.Member); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.WriteEncodedInteger(desc.Offset); @@ -317,7 +310,7 @@ public uint GetCompleteClassTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) + using (var record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LeafRecordType.Structure : LeafRecordType.Class)) { record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options @@ -336,7 +329,7 @@ public uint GetCompleteClassTypeIndex( public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) { - using (var fieldListRecord = StartLeafRecord(LF_ARGLIST)) + using (var fieldListRecord = StartLeafRecord(LeafRecordType.ArgList)) { fieldListRecord.Write((uint)argumentTypes.Length); foreach (uint argumentType in argumentTypes) @@ -347,7 +340,7 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri uint argumentListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LF_MFUNCTION)) + using (var record = StartLeafRecord(LeafRecordType.MemberFunction)) { record.Write(memberDescriptor.ReturnType); record.Write(memberDescriptor.ContainingClass); @@ -364,7 +357,7 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor) { - using (var record = StartLeafRecord(LF_MFUNC_ID)) + using (var record = StartLeafRecord(LeafRecordType.MemberFunctionId)) { record.Write(memberIdDescriptor.ParentClass); record.Write(memberIdDescriptor.MemberFunction); @@ -379,6 +372,13 @@ public string GetMangledName(TypeDesc type) return _nameMangler.GetMangledTypeName(type); } + private LeafRecordWriter StartLeafRecord(LeafRecordType leafRecordType) + { + LeafRecordWriter writer = new LeafRecordWriter(_bufferWriter, _outputStream); + writer.Write((ushort)leafRecordType); + return writer; + } + private ref struct LeafRecordWriter { private ArrayBufferWriter _bufferWriter; @@ -401,7 +401,7 @@ public void Dispose() _outputStream.Write(stackalloc byte[padding]); _bufferWriter.Clear(); - // TODO: LF_INDEX for long records + // TODO: LeafRecordType.Index for long records } public void Write(byte value) @@ -437,23 +437,23 @@ public void Write(string value) public void WriteEncodedInteger(ulong value) { - if (value < LF_NUMERIC) + if (value < (ushort)LeafRecordType.Numeric) { Write((ushort)value); } else if (value <= ushort.MaxValue) { - Write(LF_USHORT); + Write((ushort)LeafRecordType.UShort); Write((ushort)value); } else if (value <= uint.MaxValue) { - Write(LF_ULONG); + Write((ushort)LeafRecordType.ULong); Write((uint)value); } else { - Write(LF_UQUADWORD); + Write((ushort)LeafRecordType.UQuadWord); Write(value); } } @@ -464,7 +464,7 @@ public void WritePadding() Span padding = _bufferWriter.GetSpan(paddingLength); for (int i = 0; i < paddingLength; i++) { - padding[i] = (byte)(LF_PAD0 + paddingLength - i); + padding[i] = (byte)(LeafRecordType.Pad0 + paddingLength - i); } _bufferWriter.Advance(paddingLength); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 7460abb8f5295d..873264a6440250 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -41,6 +41,7 @@ public class CoffObjectWriter : ObjectWriter // Debugging private SectionWriter _debugTypesSectionWriter; private SectionWriter _debugSymbolSectionWriter; + private CodeViewFileTableBuilder _debugFileTableBuilder; private CodeViewSymbolsBuilder _debugSymbolsBuilder; private CodeViewTypesBuilder _debugTypesBuilder; @@ -551,11 +552,14 @@ protected override void CreateEhSections() protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { + _debugFileTableBuilder = new CodeViewFileTableBuilder(); + _debugSymbolSectionWriter = GetOrCreateSection(DebugSymbolSection); _debugSymbolSectionWriter.EmitAlignment(4); _debugSymbolsBuilder = new CodeViewSymbolsBuilder( _nodeFactory.Target.Architecture, _debugSymbolSectionWriter); + _debugTypesSectionWriter = GetOrCreateSection(DebugTypesSection); _debugTypesSectionWriter.EmitAlignment(4); _debugTypesBuilder = new CodeViewTypesBuilder( @@ -585,13 +589,16 @@ protected override void EmitDebugFunctionInfo( clauses ?? Array.Empty()); _debugSymbolsBuilder.EmitLineInfo( - methodName, methodSymbol.Size, debugNode.GetNativeSequencePoints()); + _debugFileTableBuilder, + methodName, + methodSymbol.Size, + debugNode.GetNativeSequencePoints()); } protected override void EmitDebugSections() { _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); - _debugSymbolsBuilder.Write(); + _debugFileTableBuilder.Write(_debugSymbolSectionWriter.Stream); } protected override void EmitDebugStaticVars() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 73a7cc9500152b..231587b200bee5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -588,6 +588,7 @@ + From 22ae5a6561f35eb1f8907cd625423f5b77761fdd Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 31 Oct 2022 12:17:36 +0100 Subject: [PATCH 027/144] CodeView cleanup --- .../Compiler/ObjectWriter/CodeViewNative.cs | 2878 +++++++++++++---- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 69 +- .../ObjectWriter/CodeViewTypesBuilder.cs | 99 +- 3 files changed, 2385 insertions(+), 661 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs index 86d73e18419ca6..82bc4bca2f10ba 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs @@ -7,439 +7,433 @@ namespace ILCompiler.ObjectWriter { internal static class CodeViewNative { - public const uint T_NOTYPE = 0x0000; // uncharacterized type (no type) - public const uint T_ABS = 0x0001; // absolute symbol - public const uint T_SEGMENT = 0x0002; // segment type - public const uint T_VOID = 0x0003; // void - public const uint T_HRESULT = 0x0008; // OLE/COM HRESULT - public const uint T_32PHRESULT = 0x0408; // OLE/COM HRESULT __ptr32 * - public const uint T_64PHRESULT = 0x0608; // OLE/COM HRESULT __ptr64 * - - public const uint T_PVOID = 0x0103; // near pointer to void - public const uint T_PFVOID = 0x0203; // far pointer to void - public const uint T_PHVOID = 0x0303; // huge pointer to void - public const uint T_32PVOID = 0x0403; // 32 bit pointer to void - public const uint T_32PFVOID = 0x0503; // 16:32 pointer to void - public const uint T_64PVOID = 0x0603; // 64 bit pointer to void - public const uint T_CURRENCY = 0x0004; // BASIC 8 byte currency value - public const uint T_NBASICSTR = 0x0005; // Near BASIC string - public const uint T_FBASICSTR = 0x0006; // Far BASIC string - public const uint T_NOTTRANS = 0x0007; // type not translated by cvpack - public const uint T_BIT = 0x0060; // bit - public const uint T_PASCHAR = 0x0061; // Pascal CHAR - public const uint T_BOOL32FF = 0x0062; // 32-bit BOOL where true is 0xffffffff - - // Character types - public const uint T_CHAR = 0x0010; // 8 bit signed - public const uint T_PCHAR = 0x0110; // 16 bit pointer to 8 bit signed - public const uint T_PFCHAR = 0x0210; // 16:16 far pointer to 8 bit signed - public const uint T_PHCHAR = 0x0310; // 16:16 huge pointer to 8 bit signed - public const uint T_32PCHAR = 0x0410; // 32 bit pointer to 8 bit signed - public const uint T_32PFCHAR = 0x0510; // 16:32 pointer to 8 bit signed - public const uint T_64PCHAR = 0x0610; // 64 bit pointer to 8 bit signed - - public const uint T_UCHAR = 0x0020; // 8 bit unsigned - public const uint T_PUCHAR = 0x0120; // 16 bit pointer to 8 bit unsigned - public const uint T_PFUCHAR = 0x0220; // 16:16 far pointer to 8 bit unsigned - public const uint T_PHUCHAR = 0x0320; // 16:16 huge pointer to 8 bit unsigned - public const uint T_32PUCHAR = 0x0420; // 32 bit pointer to 8 bit unsigned - public const uint T_32PFUCHAR = 0x0520; // 16:32 pointer to 8 bit unsigned - public const uint T_64PUCHAR = 0x0620; // 64 bit pointer to 8 bit unsigned - - // Really a character types - public const uint T_RCHAR = 0x0070; // really a char - public const uint T_PRCHAR = 0x0170; // 16 bit pointer to a real char - public const uint T_PFRCHAR = 0x0270; // 16:16 far pointer to a real char - public const uint T_PHRCHAR = 0x0370; // 16:16 huge pointer to a real char - public const uint T_32PRCHAR = 0x0470; // 32 bit pointer to a real char - public const uint T_32PFRCHAR = 0x0570; // 16:32 pointer to a real char - public const uint T_64PRCHAR = 0x0670; // 64 bit pointer to a real char - - // really a wide character types - public const uint T_WCHAR = 0x0071; // wide char - public const uint T_PWCHAR = 0x0171; // 16 bit pointer to a wide char - public const uint T_PFWCHAR = 0x0271; // 16:16 far pointer to a wide char - public const uint T_PHWCHAR = 0x0371; // 16:16 huge pointer to a wide char - public const uint T_32PWCHAR = 0x0471; // 32 bit pointer to a wide char - public const uint T_32PFWCHAR = 0x0571; // 16:32 pointer to a wide char - public const uint T_64PWCHAR = 0x0671; // 64 bit pointer to a wide char - - // really a 16-bit unicode char - public const uint T_CHAR16 = 0x007a; // 16-bit unicode char - public const uint T_PCHAR16 = 0x017a; // 16 bit pointer to a 16-bit unicode char - public const uint T_PFCHAR16 = 0x027a; // 16:16 far pointer to a 16-bit unicode char - public const uint T_PHCHAR16 = 0x037a; // 16:16 huge pointer to a 16-bit unicode char - public const uint T_32PCHAR16 = 0x047a; // 32 bit pointer to a 16-bit unicode char - public const uint T_32PFCHAR16 = 0x057a; // 16:32 pointer to a 16-bit unicode char - public const uint T_64PCHAR16 = 0x067a; // 64 bit pointer to a 16-bit unicode char - - // really a 32-bit unicode char - public const uint T_CHAR32 = 0x007b; // 32-bit unicode char - public const uint T_PCHAR32 = 0x017b; // 16 bit pointer to a 32-bit unicode char - public const uint T_PFCHAR32 = 0x027b; // 16:16 far pointer to a 32-bit unicode char - public const uint T_PHCHAR32 = 0x037b; // 16:16 huge pointer to a 32-bit unicode char - public const uint T_32PCHAR32 = 0x047b; // 32 bit pointer to a 32-bit unicode char - public const uint T_32PFCHAR32 = 0x057b; // 16:32 pointer to a 32-bit unicode char - public const uint T_64PCHAR32 = 0x067b; // 64 bit pointer to a 32-bit unicode char - - // 8 bit int types - public const uint T_INT1 = 0x0068; // 8 bit signed int - public const uint T_PINT1 = 0x0168; // 16 bit pointer to 8 bit signed int - public const uint T_PFINT1 = 0x0268; // 16:16 far pointer to 8 bit signed int - public const uint T_PHINT1 = 0x0368; // 16:16 huge pointer to 8 bit signed int - public const uint T_32PINT1 = 0x0468; // 32 bit pointer to 8 bit signed int - public const uint T_32PFINT1 = 0x0568; // 16:32 pointer to 8 bit signed int - public const uint T_64PINT1 = 0x0668; // 64 bit pointer to 8 bit signed int - - public const uint T_UINT1 = 0x0069; // 8 bit unsigned int - public const uint T_PUINT1 = 0x0169; // 16 bit pointer to 8 bit unsigned int - public const uint T_PFUINT1 = 0x0269; // 16:16 far pointer to 8 bit unsigned int - public const uint T_PHUINT1 = 0x0369; // 16:16 huge pointer to 8 bit unsigned int - public const uint T_32PUINT1 = 0x0469; // 32 bit pointer to 8 bit unsigned int - public const uint T_32PFUINT1 = 0x0569; // 16:32 pointer to 8 bit unsigned int - public const uint T_64PUINT1 = 0x0669; // 64 bit pointer to 8 bit unsigned int - - // 16 bit short types - public const uint T_SHORT = 0x0011; // 16 bit signed - public const uint T_PSHORT = 0x0111; // 16 bit pointer to 16 bit signed - public const uint T_PFSHORT = 0x0211; // 16:16 far pointer to 16 bit signed - public const uint T_PHSHORT = 0x0311; // 16:16 huge pointer to 16 bit signed - public const uint T_32PSHORT = 0x0411; // 32 bit pointer to 16 bit signed - public const uint T_32PFSHORT = 0x0511; // 16:32 pointer to 16 bit signed - public const uint T_64PSHORT = 0x0611; // 64 bit pointer to 16 bit signed - - public const uint T_USHORT = 0x0021; // 16 bit unsigned - public const uint T_PUSHORT = 0x0121; // 16 bit pointer to 16 bit unsigned - public const uint T_PFUSHORT = 0x0221; // 16:16 far pointer to 16 bit unsigned - public const uint T_PHUSHORT = 0x0321; // 16:16 huge pointer to 16 bit unsigned - public const uint T_32PUSHORT = 0x0421; // 32 bit pointer to 16 bit unsigned - public const uint T_32PFUSHORT = 0x0521; // 16:32 pointer to 16 bit unsigned - public const uint T_64PUSHORT = 0x0621; // 64 bit pointer to 16 bit unsigned - - // 16 bit int types - public const uint T_INT2 = 0x0072; // 16 bit signed int - public const uint T_PINT2 = 0x0172; // 16 bit pointer to 16 bit signed int - public const uint T_PFINT2 = 0x0272; // 16:16 far pointer to 16 bit signed int - public const uint T_PHINT2 = 0x0372; // 16:16 huge pointer to 16 bit signed int - public const uint T_32PINT2 = 0x0472; // 32 bit pointer to 16 bit signed int - public const uint T_32PFINT2 = 0x0572; // 16:32 pointer to 16 bit signed int - public const uint T_64PINT2 = 0x0672; // 64 bit pointer to 16 bit signed int - - public const uint T_UINT2 = 0x0073; // 16 bit unsigned int - public const uint T_PUINT2 = 0x0173; // 16 bit pointer to 16 bit unsigned int - public const uint T_PFUINT2 = 0x0273; // 16:16 far pointer to 16 bit unsigned int - public const uint T_PHUINT2 = 0x0373; // 16:16 huge pointer to 16 bit unsigned int - public const uint T_32PUINT2 = 0x0473; // 32 bit pointer to 16 bit unsigned int - public const uint T_32PFUINT2 = 0x0573; // 16:32 pointer to 16 bit unsigned int - public const uint T_64PUINT2 = 0x0673; // 64 bit pointer to 16 bit unsigned int - - // 32 bit long types - public const uint T_LONG = 0x0012; // 32 bit signed - public const uint T_ULONG = 0x0022; // 32 bit unsigned - public const uint T_PLONG = 0x0112; // 16 bit pointer to 32 bit signed - public const uint T_PULONG = 0x0122; // 16 bit pointer to 32 bit unsigned - public const uint T_PFLONG = 0x0212; // 16:16 far pointer to 32 bit signed - public const uint T_PFULONG = 0x0222; // 16:16 far pointer to 32 bit unsigned - public const uint T_PHLONG = 0x0312; // 16:16 huge pointer to 32 bit signed - public const uint T_PHULONG = 0x0322; // 16:16 huge pointer to 32 bit unsigned - - public const uint T_32PLONG = 0x0412; // 32 bit pointer to 32 bit signed - public const uint T_32PULONG = 0x0422; // 32 bit pointer to 32 bit unsigned - public const uint T_32PFLONG = 0x0512; // 16:32 pointer to 32 bit signed - public const uint T_32PFULONG = 0x0522; // 16:32 pointer to 32 bit unsigned - public const uint T_64PLONG = 0x0612; // 64 bit pointer to 32 bit signed - public const uint T_64PULONG = 0x0622; // 64 bit pointer to 32 bit unsigned - - // 32 bit int types - public const uint T_INT4 = 0x0074; // 32 bit signed int - public const uint T_PINT4 = 0x0174; // 16 bit pointer to 32 bit signed int - public const uint T_PFINT4 = 0x0274; // 16:16 far pointer to 32 bit signed int - public const uint T_PHINT4 = 0x0374; // 16:16 huge pointer to 32 bit signed int - public const uint T_32PINT4 = 0x0474; // 32 bit pointer to 32 bit signed int - public const uint T_32PFINT4 = 0x0574; // 16:32 pointer to 32 bit signed int - public const uint T_64PINT4 = 0x0674; // 64 bit pointer to 32 bit signed int - - public const uint T_UINT4 = 0x0075; // 32 bit unsigned int - public const uint T_PUINT4 = 0x0175; // 16 bit pointer to 32 bit unsigned int - public const uint T_PFUINT4 = 0x0275; // 16:16 far pointer to 32 bit unsigned int - public const uint T_PHUINT4 = 0x0375; // 16:16 huge pointer to 32 bit unsigned int - public const uint T_32PUINT4 = 0x0475; // 32 bit pointer to 32 bit unsigned int - public const uint T_32PFUINT4 = 0x0575; // 16:32 pointer to 32 bit unsigned int - public const uint T_64PUINT4 = 0x0675; // 64 bit pointer to 32 bit unsigned int - - // 64 bit quad types - public const uint T_QUAD = 0x0013; // 64 bit signed - public const uint T_PQUAD = 0x0113; // 16 bit pointer to 64 bit signed - public const uint T_PFQUAD = 0x0213; // 16:16 far pointer to 64 bit signed - public const uint T_PHQUAD = 0x0313; // 16:16 huge pointer to 64 bit signed - public const uint T_32PQUAD = 0x0413; // 32 bit pointer to 64 bit signed - public const uint T_32PFQUAD = 0x0513; // 16:32 pointer to 64 bit signed - public const uint T_64PQUAD = 0x0613; // 64 bit pointer to 64 bit signed - - public const uint T_UQUAD = 0x0023; // 64 bit unsigned - public const uint T_PUQUAD = 0x0123; // 16 bit pointer to 64 bit unsigned - public const uint T_PFUQUAD = 0x0223; // 16:16 far pointer to 64 bit unsigned - public const uint T_PHUQUAD = 0x0323; // 16:16 huge pointer to 64 bit unsigned - public const uint T_32PUQUAD = 0x0423; // 32 bit pointer to 64 bit unsigned - public const uint T_32PFUQUAD = 0x0523; // 16:32 pointer to 64 bit unsigned - public const uint T_64PUQUAD = 0x0623; // 64 bit pointer to 64 bit unsigned - - // 64 bit int types - public const uint T_INT8 = 0x0076; // 64 bit signed int - public const uint T_PINT8 = 0x0176; // 16 bit pointer to 64 bit signed int - public const uint T_PFINT8 = 0x0276; // 16:16 far pointer to 64 bit signed int - public const uint T_PHINT8 = 0x0376; // 16:16 huge pointer to 64 bit signed int - public const uint T_32PINT8 = 0x0476; // 32 bit pointer to 64 bit signed int - public const uint T_32PFINT8 = 0x0576; // 16:32 pointer to 64 bit signed int - public const uint T_64PINT8 = 0x0676; // 64 bit pointer to 64 bit signed int - - public const uint T_UINT8 = 0x0077; // 64 bit unsigned int - public const uint T_PUINT8 = 0x0177; // 16 bit pointer to 64 bit unsigned int - public const uint T_PFUINT8 = 0x0277; // 16:16 far pointer to 64 bit unsigned int - public const uint T_PHUINT8 = 0x0377; // 16:16 huge pointer to 64 bit unsigned int - public const uint T_32PUINT8 = 0x0477; // 32 bit pointer to 64 bit unsigned int - public const uint T_32PFUINT8 = 0x0577; // 16:32 pointer to 64 bit unsigned int - public const uint T_64PUINT8 = 0x0677; // 64 bit pointer to 64 bit unsigned int - - // 128 bit octet types - public const uint T_OCT = 0x0014; // 128 bit signed - public const uint T_POCT = 0x0114; // 16 bit pointer to 128 bit signed - public const uint T_PFOCT = 0x0214; // 16:16 far pointer to 128 bit signed - public const uint T_PHOCT = 0x0314; // 16:16 huge pointer to 128 bit signed - public const uint T_32POCT = 0x0414; // 32 bit pointer to 128 bit signed - public const uint T_32PFOCT = 0x0514; // 16:32 pointer to 128 bit signed - public const uint T_64POCT = 0x0614; // 64 bit pointer to 128 bit signed - - public const uint T_UOCT = 0x0024; // 128 bit unsigned - public const uint T_PUOCT = 0x0124; // 16 bit pointer to 128 bit unsigned - public const uint T_PFUOCT = 0x0224; // 16:16 far pointer to 128 bit unsigned - public const uint T_PHUOCT = 0x0324; // 16:16 huge pointer to 128 bit unsigned - public const uint T_32PUOCT = 0x0424; // 32 bit pointer to 128 bit unsigned - public const uint T_32PFUOCT = 0x0524; // 16:32 pointer to 128 bit unsigned - public const uint T_64PUOCT = 0x0624; // 64 bit pointer to 128 bit unsigned - - // 128 bit int types - public const uint T_INT16 = 0x0078; // 128 bit signed int - public const uint T_PINT16 = 0x0178; // 16 bit pointer to 128 bit signed int - public const uint T_PFINT16 = 0x0278; // 16:16 far pointer to 128 bit signed int - public const uint T_PHINT16 = 0x0378; // 16:16 huge pointer to 128 bit signed int - public const uint T_32PINT16 = 0x0478; // 32 bit pointer to 128 bit signed int - public const uint T_32PFINT16 = 0x0578; // 16:32 pointer to 128 bit signed int - public const uint T_64PINT16 = 0x0678; // 64 bit pointer to 128 bit signed int - - public const uint T_UINT16 = 0x0079; // 128 bit unsigned int - public const uint T_PUINT16 = 0x0179; // 16 bit pointer to 128 bit unsigned int - public const uint T_PFUINT16 = 0x0279; // 16:16 far pointer to 128 bit unsigned int - public const uint T_PHUINT16 = 0x0379; // 16:16 huge pointer to 128 bit unsigned int - public const uint T_32PUINT16 = 0x0479; // 32 bit pointer to 128 bit unsigned int - public const uint T_32PFUINT16 = 0x0579; // 16:32 pointer to 128 bit unsigned int - public const uint T_64PUINT16 = 0x0679; // 64 bit pointer to 128 bit unsigned int - - // 16 bit real types - public const uint T_REAL16 = 0x0046; // 16 bit real - public const uint T_PREAL16 = 0x0146; // 16 bit pointer to 16 bit real - public const uint T_PFREAL16 = 0x0246; // 16:16 far pointer to 16 bit real - public const uint T_PHREAL16 = 0x0346; // 16:16 huge pointer to 16 bit real - public const uint T_32PREAL16 = 0x0446; // 32 bit pointer to 16 bit real - public const uint T_32PFREAL16 = 0x0546; // 16:32 pointer to 16 bit real - public const uint T_64PREAL16 = 0x0646; // 64 bit pointer to 16 bit real - - // 32 bit real types - public const uint T_REAL32 = 0x0040; // 32 bit real - public const uint T_PREAL32 = 0x0140; // 16 bit pointer to 32 bit real - public const uint T_PFREAL32 = 0x0240; // 16:16 far pointer to 32 bit real - public const uint T_PHREAL32 = 0x0340; // 16:16 huge pointer to 32 bit real - public const uint T_32PREAL32 = 0x0440; // 32 bit pointer to 32 bit real - public const uint T_32PFREAL32 = 0x0540; // 16:32 pointer to 32 bit real - public const uint T_64PREAL32 = 0x0640; // 64 bit pointer to 32 bit real - - // 32 bit partial-precision real types - public const uint T_REAL32PP = 0x0045; // 32 bit PP real - public const uint T_PREAL32PP = 0x0145; // 16 bit pointer to 32 bit PP real - public const uint T_PFREAL32PP = 0x0245; // 16:16 far pointer to 32 bit PP real - public const uint T_PHREAL32PP = 0x0345; // 16:16 huge pointer to 32 bit PP real - public const uint T_32PREAL32PP = 0x0445; // 32 bit pointer to 32 bit PP real - public const uint T_32PFREAL32PP = 0x0545; // 16:32 pointer to 32 bit PP real - public const uint T_64PREAL32PP = 0x0645; // 64 bit pointer to 32 bit PP real - - - // 48 bit real types - public const uint T_REAL48 = 0x0044; // 48 bit real - public const uint T_PREAL48 = 0x0144; // 16 bit pointer to 48 bit real - public const uint T_PFREAL48 = 0x0244; // 16:16 far pointer to 48 bit real - public const uint T_PHREAL48 = 0x0344; // 16:16 huge pointer to 48 bit real - public const uint T_32PREAL48 = 0x0444; // 32 bit pointer to 48 bit real - public const uint T_32PFREAL48 = 0x0544; // 16:32 pointer to 48 bit real - public const uint T_64PREAL48 = 0x0644; // 64 bit pointer to 48 bit real - - // 64 bit real types - public const uint T_REAL64 = 0x0041; // 64 bit real - public const uint T_PREAL64 = 0x0141; // 16 bit pointer to 64 bit real - public const uint T_PFREAL64 = 0x0241; // 16:16 far pointer to 64 bit real - public const uint T_PHREAL64 = 0x0341; // 16:16 huge pointer to 64 bit real - public const uint T_32PREAL64 = 0x0441; // 32 bit pointer to 64 bit real - public const uint T_32PFREAL64 = 0x0541; // 16:32 pointer to 64 bit real - public const uint T_64PREAL64 = 0x0641; // 64 bit pointer to 64 bit real - - // 80 bit real types - public const uint T_REAL80 = 0x0042; // 80 bit real - public const uint T_PREAL80 = 0x0142; // 16 bit pointer to 80 bit real - public const uint T_PFREAL80 = 0x0242; // 16:16 far pointer to 80 bit real - public const uint T_PHREAL80 = 0x0342; // 16:16 huge pointer to 80 bit real - public const uint T_32PREAL80 = 0x0442; // 32 bit pointer to 80 bit real - public const uint T_32PFREAL80 = 0x0542; // 16:32 pointer to 80 bit real - public const uint T_64PREAL80 = 0x0642; // 64 bit pointer to 80 bit real - - // 128 bit real types - public const uint T_REAL128 = 0x0043; // 128 bit real - public const uint T_PREAL128 = 0x0143; // 16 bit pointer to 128 bit real - public const uint T_PFREAL128 = 0x0243; // 16:16 far pointer to 128 bit real - public const uint T_PHREAL128 = 0x0343; // 16:16 huge pointer to 128 bit real - public const uint T_32PREAL128 = 0x0443; // 32 bit pointer to 128 bit real - public const uint T_32PFREAL128 = 0x0543; // 16:32 pointer to 128 bit real - public const uint T_64PREAL128 = 0x0643; // 64 bit pointer to 128 bit real - - // 32 bit complex types - public const uint T_CPLX32 = 0x0050; // 32 bit complex - public const uint T_PCPLX32 = 0x0150; // 16 bit pointer to 32 bit complex - public const uint T_PFCPLX32 = 0x0250; // 16:16 far pointer to 32 bit complex - public const uint T_PHCPLX32 = 0x0350; // 16:16 huge pointer to 32 bit complex - public const uint T_32PCPLX32 = 0x0450; // 32 bit pointer to 32 bit complex - public const uint T_32PFCPLX32 = 0x0550; // 16:32 pointer to 32 bit complex - public const uint T_64PCPLX32 = 0x0650; // 64 bit pointer to 32 bit complex - - // 64 bit complex types - public const uint T_CPLX64 = 0x0051; // 64 bit complex - public const uint T_PCPLX64 = 0x0151; // 16 bit pointer to 64 bit complex - public const uint T_PFCPLX64 = 0x0251; // 16:16 far pointer to 64 bit complex - public const uint T_PHCPLX64 = 0x0351; // 16:16 huge pointer to 64 bit complex - public const uint T_32PCPLX64 = 0x0451; // 32 bit pointer to 64 bit complex - public const uint T_32PFCPLX64 = 0x0551; // 16:32 pointer to 64 bit complex - public const uint T_64PCPLX64 = 0x0651; // 64 bit pointer to 64 bit complex - - // 80 bit complex types - public const uint T_CPLX80 = 0x0052; // 80 bit complex - public const uint T_PCPLX80 = 0x0152; // 16 bit pointer to 80 bit complex - public const uint T_PFCPLX80 = 0x0252; // 16:16 far pointer to 80 bit complex - public const uint T_PHCPLX80 = 0x0352; // 16:16 huge pointer to 80 bit complex - public const uint T_32PCPLX80 = 0x0452; // 32 bit pointer to 80 bit complex - public const uint T_32PFCPLX80 = 0x0552; // 16:32 pointer to 80 bit complex - public const uint T_64PCPLX80 = 0x0652; // 64 bit pointer to 80 bit complex - - // 128 bit complex types - public const uint T_CPLX128 = 0x0053; // 128 bit complex - public const uint T_PCPLX128 = 0x0153; // 16 bit pointer to 128 bit complex - public const uint T_PFCPLX128 = 0x0253; // 16:16 far pointer to 128 bit complex - public const uint T_PHCPLX128 = 0x0353; // 16:16 huge pointer to 128 bit real - public const uint T_32PCPLX128 = 0x0453; // 32 bit pointer to 128 bit complex - public const uint T_32PFCPLX128 = 0x0553; // 16:32 pointer to 128 bit complex - public const uint T_64PCPLX128 = 0x0653; // 64 bit pointer to 128 bit complex - - // Boolean types - public const uint T_BOOL08 = 0x0030; // 8 bit boolean - public const uint T_PBOOL08 = 0x0130; // 16 bit pointer to 8 bit boolean - public const uint T_PFBOOL08 = 0x0230; // 16:16 far pointer to 8 bit boolean - public const uint T_PHBOOL08 = 0x0330; // 16:16 huge pointer to 8 bit boolean - public const uint T_32PBOOL08 = 0x0430; // 32 bit pointer to 8 bit boolean - public const uint T_32PFBOOL08 = 0x0530; // 16:32 pointer to 8 bit boolean - public const uint T_64PBOOL08 = 0x0630; // 64 bit pointer to 8 bit boolean - - public const uint T_BOOL16 = 0x0031; // 16 bit boolean - public const uint T_PBOOL16 = 0x0131; // 16 bit pointer to 16 bit boolean - public const uint T_PFBOOL16 = 0x0231; // 16:16 far pointer to 16 bit boolean - public const uint T_PHBOOL16 = 0x0331; // 16:16 huge pointer to 16 bit boolean - public const uint T_32PBOOL16 = 0x0431; // 32 bit pointer to 18 bit boolean - public const uint T_32PFBOOL16 = 0x0531; // 16:32 pointer to 16 bit boolean - public const uint T_64PBOOL16 = 0x0631; // 64 bit pointer to 18 bit boolean - - public const uint T_BOOL32 = 0x0032; // 32 bit boolean - public const uint T_PBOOL32 = 0x0132; // 16 bit pointer to 32 bit boolean - public const uint T_PFBOOL32 = 0x0232; // 16:16 far pointer to 32 bit boolean - public const uint T_PHBOOL32 = 0x0332; // 16:16 huge pointer to 32 bit boolean - public const uint T_32PBOOL32 = 0x0432; // 32 bit pointer to 32 bit boolean - public const uint T_32PFBOOL32 = 0x0532; // 16:32 pointer to 32 bit boolean - public const uint T_64PBOOL32 = 0x0632; // 64 bit pointer to 32 bit boolean - - public const uint T_BOOL64 = 0x0033; // 64 bit boolean - public const uint T_PBOOL64 = 0x0133; // 16 bit pointer to 64 bit boolean - public const uint T_PFBOOL64 = 0x0233; // 16:16 far pointer to 64 bit boolean - public const uint T_PHBOOL64 = 0x0333; // 16:16 huge pointer to 64 bit boolean - public const uint T_32PBOOL64 = 0x0433; // 32 bit pointer to 64 bit boolean - public const uint T_32PFBOOL64 = 0x0533; // 16:32 pointer to 64 bit boolean - public const uint T_64PBOOL64 = 0x0633; // 64 bit pointer to 64 bit boolean - - // ??? - public const uint T_NCVPTR = 0x01f0; // CV Internal type for created near pointers - public const uint T_FCVPTR = 0x02f0; // CV Internal type for created far pointers - public const uint T_HCVPTR = 0x03f0; // CV Internal type for created huge pointers - public const uint T_32NCVPTR = 0x04f0; // CV Internal type for created near 32-bit pointers - public const uint T_32FCVPTR = 0x05f0; // CV Internal type for created far 32-bit pointers - public const uint T_64NCVPTR = 0x06f0; // CV Internal type for created near 64-bit pointers - - // Type enum for pointer records - // Pointers can be one of the following types - public const uint CV_PTR_NEAR = 0x00; // 16 bit pointer - public const uint CV_PTR_FAR = 0x01; // 16:16 far pointer - public const uint CV_PTR_HUGE = 0x02; // 16:16 huge pointer - public const uint CV_PTR_BASE_SEG = 0x03; // based on segment - public const uint CV_PTR_BASE_VAL = 0x04; // based on value of base - public const uint CV_PTR_BASE_SEGVAL = 0x05; // based on segment value of base - public const uint CV_PTR_BASE_ADDR = 0x06; // based on address of base - public const uint CV_PTR_BASE_SEGADDR = 0x07; // based on segment address of base - public const uint CV_PTR_BASE_TYPE = 0x08; // based on type - public const uint CV_PTR_BASE_SELF = 0x09; // based on self - public const uint CV_PTR_NEAR32 = 0x0a; // 32 bit pointer - public const uint CV_PTR_FAR32 = 0x0b; // 16:32 pointer - public const uint CV_PTR_64 = 0x0c; // 64 bit pointer - public const uint CV_PTR_UNUSEDPTR = 0x0d; // first unused pointer type - - public const uint CV_PTR_MODE_PTR = 0x00; // "normal" pointer - public const uint CV_PTR_MODE_REF = 0x01; // "old" reference - public const uint CV_PTR_MODE_LVREF = 0x01; // l-value reference - public const uint CV_PTR_MODE_PMEM = 0x02; // pointer to data member - public const uint CV_PTR_MODE_PMFUNC = 0x03; // pointer to member function - public const uint CV_PTR_MODE_RVREF = 0x04; // r-value reference - public const uint CV_PTR_MODE_RESERVED= 0x05; // first unused pointer mode - - public const ushort MOD_none = 0; - public const ushort MOD_const = 1; - public const ushort MOD_volatile = 2; - public const ushort MOD_unaligned = 4; - - public const ushort CV_PROP_NONE = 0; - public const ushort CV_PROP_PACKED = 0x0001; - public const ushort CV_PROP_HAS_CONSTURUCTOR_OR_DESTRUCTOR = 0x0002; - public const ushort CV_PROP_HAS_OVERLOADED_OPERATOR = 0x0004; - public const ushort CV_PROP_NESTED = 0x0008; - public const ushort CV_PROP_CONTAINS_NESTED_CLASS = 0x0010; - public const ushort CV_PROP_HAS_OVERLOADED_ASSIGNMENT_OPERATOR = 0x0020; - public const ushort CV_PROP_HAS_CONVERSION_OPERATOR = 0x0040; - public const ushort CV_PROP_FORWARD_REFERENCE = 0x0080; - public const ushort CV_PROP_SCOPED = 0x0100; - public const ushort CV_PROP_HAS_UNIQUE_NAME = 0x0200; - public const ushort CV_PROP_SEALED = 0x0400; - public const ushort CV_PROP_INTRINSIC = 0x2000; - - public const ushort CV_REG_NONE = 0; - - public const ushort CV_AMD64_RAX = 328; - public const ushort CV_AMD64_RBX = 329; - public const ushort CV_AMD64_RCX = 330; - public const ushort CV_AMD64_RDX = 331; - public const ushort CV_AMD64_RSI = 332; - public const ushort CV_AMD64_RDI = 333; - public const ushort CV_AMD64_RBP = 334; - public const ushort CV_AMD64_RSP = 335; - - // 64-bit integer registers with 8-, 16-, and 32-bit forms (B, W, and D) - public const ushort CV_AMD64_R8 = 336; - public const ushort CV_AMD64_R9 = 337; - public const ushort CV_AMD64_R10 = 338; - public const ushort CV_AMD64_R11 = 339; - public const ushort CV_AMD64_R12 = 340; - public const ushort CV_AMD64_R13 = 341; - public const ushort CV_AMD64_R14 = 342; - public const ushort CV_AMD64_R15 = 343; + // Matches TYPE_ENUM_e in cvinfo.h + public enum CodeViewType : ushort + { + // Special Types + T_NOTYPE = 0x0000, // uncharacterized type (no type) + T_ABS = 0x0001, // absolute symbol + T_SEGMENT = 0x0002, // segment type + T_VOID = 0x0003, // void + T_HRESULT = 0x0008, // OLE/COM HRESULT + T_32PHRESULT = 0x0408, // OLE/COM HRESULT __ptr32 * + T_64PHRESULT = 0x0608, // OLE/COM HRESULT __ptr64 * + + T_PVOID = 0x0103, // near pointer to void + T_PFVOID = 0x0203, // far pointer to void + T_PHVOID = 0x0303, // huge pointer to void + T_32PVOID = 0x0403, // 32 bit pointer to void + T_32PFVOID = 0x0503, // 16:32 pointer to void + T_64PVOID = 0x0603, // 64 bit pointer to void + T_CURRENCY = 0x0004, // BASIC 8 byte currency value + T_NBASICSTR = 0x0005, // Near BASIC string + T_FBASICSTR = 0x0006, // Far BASIC string + T_NOTTRANS = 0x0007, // type not translated by cvpack + T_BIT = 0x0060, // bit + T_PASCHAR = 0x0061, // Pascal CHAR + T_BOOL32FF = 0x0062, // 32-bit BOOL where true is 0xffffffff + + // Character types + T_CHAR = 0x0010, // 8 bit signed + T_PCHAR = 0x0110, // 16 bit pointer to 8 bit signed + T_PFCHAR = 0x0210, // 16:16 far pointer to 8 bit signed + T_PHCHAR = 0x0310, // 16:16 huge pointer to 8 bit signed + T_32PCHAR = 0x0410, // 32 bit pointer to 8 bit signed + T_32PFCHAR = 0x0510, // 16:32 pointer to 8 bit signed + T_64PCHAR = 0x0610, // 64 bit pointer to 8 bit signed + + T_UCHAR = 0x0020, // 8 bit unsigned + T_PUCHAR = 0x0120, // 16 bit pointer to 8 bit unsigned + T_PFUCHAR = 0x0220, // 16:16 far pointer to 8 bit unsigned + T_PHUCHAR = 0x0320, // 16:16 huge pointer to 8 bit unsigned + T_32PUCHAR = 0x0420, // 32 bit pointer to 8 bit unsigned + T_32PFUCHAR = 0x0520, // 16:32 pointer to 8 bit unsigned + T_64PUCHAR = 0x0620, // 64 bit pointer to 8 bit unsigned + + // Really a character types + T_RCHAR = 0x0070, // really a char + T_PRCHAR = 0x0170, // 16 bit pointer to a real char + T_PFRCHAR = 0x0270, // 16:16 far pointer to a real char + T_PHRCHAR = 0x0370, // 16:16 huge pointer to a real char + T_32PRCHAR = 0x0470, // 32 bit pointer to a real char + T_32PFRCHAR = 0x0570, // 16:32 pointer to a real char + T_64PRCHAR = 0x0670, // 64 bit pointer to a real char + + // Really a wide character types + T_WCHAR = 0x0071, // wide char + T_PWCHAR = 0x0171, // 16 bit pointer to a wide char + T_PFWCHAR = 0x0271, // 16:16 far pointer to a wide char + T_PHWCHAR = 0x0371, // 16:16 huge pointer to a wide char + T_32PWCHAR = 0x0471, // 32 bit pointer to a wide char + T_32PFWCHAR = 0x0571, // 16:32 pointer to a wide char + T_64PWCHAR = 0x0671, // 64 bit pointer to a wide char + + // Really a 16-bit unicode char + T_CHAR16 = 0x007a, // 16-bit unicode char + T_PCHAR16 = 0x017a, // 16 bit pointer to a 16-bit unicode char + T_PFCHAR16 = 0x027a, // 16:16 far pointer to a 16-bit unicode char + T_PHCHAR16 = 0x037a, // 16:16 huge pointer to a 16-bit unicode char + T_32PCHAR16 = 0x047a, // 32 bit pointer to a 16-bit unicode char + T_32PFCHAR16 = 0x057a, // 16:32 pointer to a 16-bit unicode char + T_64PCHAR16 = 0x067a, // 64 bit pointer to a 16-bit unicode char + + // Really a 32-bit unicode char + T_CHAR32 = 0x007b, // 32-bit unicode char + T_PCHAR32 = 0x017b, // 16 bit pointer to a 32-bit unicode char + T_PFCHAR32 = 0x027b, // 16:16 far pointer to a 32-bit unicode char + T_PHCHAR32 = 0x037b, // 16:16 huge pointer to a 32-bit unicode char + T_32PCHAR32 = 0x047b, // 32 bit pointer to a 32-bit unicode char + T_32PFCHAR32 = 0x057b, // 16:32 pointer to a 32-bit unicode char + T_64PCHAR32 = 0x067b, // 64 bit pointer to a 32-bit unicode char + + // 8-bit int types + T_INT1 = 0x0068, // 8 bit signed int + T_PINT1 = 0x0168, // 16 bit pointer to 8 bit signed int + T_PFINT1 = 0x0268, // 16:16 far pointer to 8 bit signed int + T_PHINT1 = 0x0368, // 16:16 huge pointer to 8 bit signed int + T_32PINT1 = 0x0468, // 32 bit pointer to 8 bit signed int + T_32PFINT1 = 0x0568, // 16:32 pointer to 8 bit signed int + T_64PINT1 = 0x0668, // 64 bit pointer to 8 bit signed int + + T_UINT1 = 0x0069, // 8 bit unsigned int + T_PUINT1 = 0x0169, // 16 bit pointer to 8 bit unsigned int + T_PFUINT1 = 0x0269, // 16:16 far pointer to 8 bit unsigned int + T_PHUINT1 = 0x0369, // 16:16 huge pointer to 8 bit unsigned int + T_32PUINT1 = 0x0469, // 32 bit pointer to 8 bit unsigned int + T_32PFUINT1 = 0x0569, // 16:32 pointer to 8 bit unsigned int + T_64PUINT1 = 0x0669, // 64 bit pointer to 8 bit unsigned int + + // 16-bit short types + T_SHORT = 0x0011, // 16 bit signed + T_PSHORT = 0x0111, // 16 bit pointer to 16 bit signed + T_PFSHORT = 0x0211, // 16:16 far pointer to 16 bit signed + T_PHSHORT = 0x0311, // 16:16 huge pointer to 16 bit signed + T_32PSHORT = 0x0411, // 32 bit pointer to 16 bit signed + T_32PFSHORT = 0x0511, // 16:32 pointer to 16 bit signed + T_64PSHORT = 0x0611, // 64 bit pointer to 16 bit signed + + T_USHORT = 0x0021, // 16 bit unsigned + T_PUSHORT = 0x0121, // 16 bit pointer to 16 bit unsigned + T_PFUSHORT = 0x0221, // 16:16 far pointer to 16 bit unsigned + T_PHUSHORT = 0x0321, // 16:16 huge pointer to 16 bit unsigned + T_32PUSHORT = 0x0421, // 32 bit pointer to 16 bit unsigned + T_32PFUSHORT = 0x0521, // 16:32 pointer to 16 bit unsigned + T_64PUSHORT = 0x0621, // 64 bit pointer to 16 bit unsigned + + // 16-bit int types + T_INT2 = 0x0072, // 16 bit signed int + T_PINT2 = 0x0172, // 16 bit pointer to 16 bit signed int + T_PFINT2 = 0x0272, // 16:16 far pointer to 16 bit signed int + T_PHINT2 = 0x0372, // 16:16 huge pointer to 16 bit signed int + T_32PINT2 = 0x0472, // 32 bit pointer to 16 bit signed int + T_32PFINT2 = 0x0572, // 16:32 pointer to 16 bit signed int + T_64PINT2 = 0x0672, // 64 bit pointer to 16 bit signed int + + T_UINT2 = 0x0073, // 16 bit unsigned int + T_PUINT2 = 0x0173, // 16 bit pointer to 16 bit unsigned int + T_PFUINT2 = 0x0273, // 16:16 far pointer to 16 bit unsigned int + T_PHUINT2 = 0x0373, // 16:16 huge pointer to 16 bit unsigned int + T_32PUINT2 = 0x0473, // 32 bit pointer to 16 bit unsigned int + T_32PFUINT2 = 0x0573, // 16:32 pointer to 16 bit unsigned int + T_64PUINT2 = 0x0673, // 64 bit pointer to 16 bit unsigned int + + // 32-bit long types + T_LONG = 0x0012, // 32 bit signed + T_ULONG = 0x0022, // 32 bit unsigned + T_PLONG = 0x0112, // 16 bit pointer to 32 bit signed + T_PULONG = 0x0122, // 16 bit pointer to 32 bit unsigned + T_PFLONG = 0x0212, // 16:16 far pointer to 32 bit signed + T_PFULONG = 0x0222, // 16:16 far pointer to 32 bit unsigned + T_PHLONG = 0x0312, // 16:16 huge pointer to 32 bit signed + T_PHULONG = 0x0322, // 16:16 huge pointer to 32 bit unsigned + + T_32PLONG = 0x0412, // 32 bit pointer to 32 bit signed + T_32PULONG = 0x0422, // 32 bit pointer to 32 bit unsigned + T_32PFLONG = 0x0512, // 16:32 pointer to 32 bit signed + T_32PFULONG = 0x0522, // 16:32 pointer to 32 bit unsigned + T_64PLONG = 0x0612, // 64 bit pointer to 32 bit signed + T_64PULONG = 0x0622, // 64 bit pointer to 32 bit unsigned + + // 32-bit int types + T_INT4 = 0x0074, // 32 bit signed int + T_PINT4 = 0x0174, // 16 bit pointer to 32 bit signed int + T_PFINT4 = 0x0274, // 16:16 far pointer to 32 bit signed int + T_PHINT4 = 0x0374, // 16:16 huge pointer to 32 bit signed int + T_32PINT4 = 0x0474, // 32 bit pointer to 32 bit signed int + T_32PFINT4 = 0x0574, // 16:32 pointer to 32 bit signed int + T_64PINT4 = 0x0674, // 64 bit pointer to 32 bit signed int + + T_UINT4 = 0x0075, // 32 bit unsigned int + T_PUINT4 = 0x0175, // 16 bit pointer to 32 bit unsigned int + T_PFUINT4 = 0x0275, // 16:16 far pointer to 32 bit unsigned int + T_PHUINT4 = 0x0375, // 16:16 huge pointer to 32 bit unsigned int + T_32PUINT4 = 0x0475, // 32 bit pointer to 32 bit unsigned int + T_32PFUINT4 = 0x0575, // 16:32 pointer to 32 bit unsigned int + T_64PUINT4 = 0x0675, // 64 bit pointer to 32 bit unsigned int + + // 64-bit quad types + T_QUAD = 0x0013, // 64 bit signed + T_PQUAD = 0x0113, // 16 bit pointer to 64 bit signed + T_PFQUAD = 0x0213, // 16:16 far pointer to 64 bit signed + T_PHQUAD = 0x0313, // 16:16 huge pointer to 64 bit signed + T_32PQUAD = 0x0413, // 32 bit pointer to 64 bit signed + T_32PFQUAD = 0x0513, // 16:32 pointer to 64 bit signed + T_64PQUAD = 0x0613, // 64 bit pointer to 64 bit signed + + T_UQUAD = 0x0023, // 64 bit unsigned + T_PUQUAD = 0x0123, // 16 bit pointer to 64 bit unsigned + T_PFUQUAD = 0x0223, // 16:16 far pointer to 64 bit unsigned + T_PHUQUAD = 0x0323, // 16:16 huge pointer to 64 bit unsigned + T_32PUQUAD = 0x0423, // 32 bit pointer to 64 bit unsigned + T_32PFUQUAD = 0x0523, // 16:32 pointer to 64 bit unsigned + T_64PUQUAD = 0x0623, // 64 bit pointer to 64 bit unsigned + + // 64-bit int types + T_INT8 = 0x0076, // 64 bit signed int + T_PINT8 = 0x0176, // 16 bit pointer to 64 bit signed int + T_PFINT8 = 0x0276, // 16:16 far pointer to 64 bit signed int + T_PHINT8 = 0x0376, // 16:16 huge pointer to 64 bit signed int + T_32PINT8 = 0x0476, // 32 bit pointer to 64 bit signed int + T_32PFINT8 = 0x0576, // 16:32 pointer to 64 bit signed int + T_64PINT8 = 0x0676, // 64 bit pointer to 64 bit signed int + + T_UINT8 = 0x0077, // 64 bit unsigned int + T_PUINT8 = 0x0177, // 16 bit pointer to 64 bit unsigned int + T_PFUINT8 = 0x0277, // 16:16 far pointer to 64 bit unsigned int + T_PHUINT8 = 0x0377, // 16:16 huge pointer to 64 bit unsigned int + T_32PUINT8 = 0x0477, // 32 bit pointer to 64 bit unsigned int + T_32PFUINT8 = 0x0577, // 16:32 pointer to 64 bit unsigned int + T_64PUINT8 = 0x0677, // 64 bit pointer to 64 bit unsigned int + + // 128-bit octet types + T_OCT = 0x0014, // 128 bit signed + T_POCT = 0x0114, // 16 bit pointer to 128 bit signed + T_PFOCT = 0x0214, // 16:16 far pointer to 128 bit signed + T_PHOCT = 0x0314, // 16:16 huge pointer to 128 bit signed + T_32POCT = 0x0414, // 32 bit pointer to 128 bit signed + T_32PFOCT = 0x0514, // 16:32 pointer to 128 bit signed + T_64POCT = 0x0614, // 64 bit pointer to 128 bit signed + + T_UOCT = 0x0024, // 128 bit unsigned + T_PUOCT = 0x0124, // 16 bit pointer to 128 bit unsigned + T_PFUOCT = 0x0224, // 16:16 far pointer to 128 bit unsigned + T_PHUOCT = 0x0324, // 16:16 huge pointer to 128 bit unsigned + T_32PUOCT = 0x0424, // 32 bit pointer to 128 bit unsigned + T_32PFUOCT = 0x0524, // 16:32 pointer to 128 bit unsigned + T_64PUOCT = 0x0624, // 64 bit pointer to 128 bit unsigned + + // 128-bit int types + T_INT16 = 0x0078, // 128 bit signed int + T_PINT16 = 0x0178, // 16 bit pointer to 128 bit signed int + T_PFINT16 = 0x0278, // 16:16 far pointer to 128 bit signed int + T_PHINT16 = 0x0378, // 16:16 huge pointer to 128 bit signed int + T_32PINT16 = 0x0478, // 32 bit pointer to 128 bit signed int + T_32PFINT16 = 0x0578, // 16:32 pointer to 128 bit signed int + T_64PINT16 = 0x0678, // 64 bit pointer to 128 bit signed int + + T_UINT16 = 0x0079, // 128 bit unsigned int + T_PUINT16 = 0x0179, // 16 bit pointer to 128 bit unsigned int + T_PFUINT16 = 0x0279, // 16:16 far pointer to 128 bit unsigned int + T_PHUINT16 = 0x0379, // 16:16 huge pointer to 128 bit unsigned int + T_32PUINT16 = 0x0479, // 32 bit pointer to 128 bit unsigned int + T_32PFUINT16 = 0x0579, // 16:32 pointer to 128 bit unsigned int + T_64PUINT16 = 0x0679, // 64 bit pointer to 128 bit unsigned int + + // 16-bit real types + T_REAL16 = 0x0046, // 16 bit real + T_PREAL16 = 0x0146, // 16 bit pointer to 16 bit real + T_PFREAL16 = 0x0246, // 16:16 far pointer to 16 bit real + T_PHREAL16 = 0x0346, // 16:16 huge pointer to 16 bit real + T_32PREAL16 = 0x0446, // 32 bit pointer to 16 bit real + T_32PFREAL16 = 0x0546, // 16:32 pointer to 16 bit real + T_64PREAL16 = 0x0646, // 64 bit pointer to 16 bit real + + // 32-bit real types + T_REAL32 = 0x0040, // 32 bit real + T_PREAL32 = 0x0140, // 16 bit pointer to 32 bit real + T_PFREAL32 = 0x0240, // 16:16 far pointer to 32 bit real + T_PHREAL32 = 0x0340, // 16:16 huge pointer to 32 bit real + T_32PREAL32 = 0x0440, // 32 bit pointer to 32 bit real + T_32PFREAL32 = 0x0540, // 16:32 pointer to 32 bit real + T_64PREAL32 = 0x0640, // 64 bit pointer to 32 bit real + + // 32-bit partial-precision real types + T_REAL32PP = 0x0045, // 32 bit PP real + T_PREAL32PP = 0x0145, // 16 bit pointer to 32 bit PP real + T_PFREAL32PP = 0x0245, // 16:16 far pointer to 32 bit PP real + T_PHREAL32PP = 0x0345, // 16:16 huge pointer to 32 bit PP real + T_32PREAL32PP = 0x0445, // 32 bit pointer to 32 bit PP real + T_32PFREAL32PP = 0x0545, // 16:32 pointer to 32 bit PP real + T_64PREAL32PP = 0x0645, // 64 bit pointer to 32 bit PP real + + // 48-bit real types + T_REAL48 = 0x0044, // 48 bit real + T_PREAL48 = 0x0144, // 16 bit pointer to 48 bit real + T_PFREAL48 = 0x0244, // 16:16 far pointer to 48 bit real + T_PHREAL48 = 0x0344, // 16:16 huge pointer to 48 bit real + T_32PREAL48 = 0x0444, // 32 bit pointer to 48 bit real + T_32PFREAL48 = 0x0544, // 16:32 pointer to 48 bit real + T_64PREAL48 = 0x0644, // 64 bit pointer to 48 bit real + + // 64-bit real types + T_REAL64 = 0x0041, // 64 bit real + T_PREAL64 = 0x0141, // 16 bit pointer to 64 bit real + T_PFREAL64 = 0x0241, // 16:16 far pointer to 64 bit real + T_PHREAL64 = 0x0341, // 16:16 huge pointer to 64 bit real + T_32PREAL64 = 0x0441, // 32 bit pointer to 64 bit real + T_32PFREAL64 = 0x0541, // 16:32 pointer to 64 bit real + T_64PREAL64 = 0x0641, // 64 bit pointer to 64 bit real + + // 80-bit real types + T_REAL80 = 0x0042, // 80 bit real + T_PREAL80 = 0x0142, // 16 bit pointer to 80 bit real + T_PFREAL80 = 0x0242, // 16:16 far pointer to 80 bit real + T_PHREAL80 = 0x0342, // 16:16 huge pointer to 80 bit real + T_32PREAL80 = 0x0442, // 32 bit pointer to 80 bit real + T_32PFREAL80 = 0x0542, // 16:32 pointer to 80 bit real + T_64PREAL80 = 0x0642, // 64 bit pointer to 80 bit real + + // 128-bit real types + T_REAL128 = 0x0043, // 128 bit real + T_PREAL128 = 0x0143, // 16 bit pointer to 128 bit real + T_PFREAL128 = 0x0243, // 16:16 far pointer to 128 bit real + T_PHREAL128 = 0x0343, // 16:16 huge pointer to 128 bit real + T_32PREAL128 = 0x0443, // 32 bit pointer to 128 bit real + T_32PFREAL128 = 0x0543, // 16:32 pointer to 128 bit real + T_64PREAL128 = 0x0643, // 64 bit pointer to 128 bit real + + // 32-bit complex types + T_CPLX32 = 0x0050, // 32 bit complex + T_PCPLX32 = 0x0150, // 16 bit pointer to 32 bit complex + T_PFCPLX32 = 0x0250, // 16:16 far pointer to 32 bit complex + T_PHCPLX32 = 0x0350, // 16:16 huge pointer to 32 bit complex + T_32PCPLX32 = 0x0450, // 32 bit pointer to 32 bit complex + T_32PFCPLX32 = 0x0550, // 16:32 pointer to 32 bit complex + T_64PCPLX32 = 0x0650, // 64 bit pointer to 32 bit complex + + // 64-bit complex types + T_CPLX64 = 0x0051, // 64 bit complex + T_PCPLX64 = 0x0151, // 16 bit pointer to 64 bit complex + T_PFCPLX64 = 0x0251, // 16:16 far pointer to 64 bit complex + T_PHCPLX64 = 0x0351, // 16:16 huge pointer to 64 bit complex + T_32PCPLX64 = 0x0451, // 32 bit pointer to 64 bit complex + T_32PFCPLX64 = 0x0551, // 16:32 pointer to 64 bit complex + T_64PCPLX64 = 0x0651, // 64 bit pointer to 64 bit complex + + // 80-bit complex types + T_CPLX80 = 0x0052, // 80 bit complex + T_PCPLX80 = 0x0152, // 16 bit pointer to 80 bit complex + T_PFCPLX80 = 0x0252, // 16:16 far pointer to 80 bit complex + T_PHCPLX80 = 0x0352, // 16:16 huge pointer to 80 bit complex + T_32PCPLX80 = 0x0452, // 32 bit pointer to 80 bit complex + T_32PFCPLX80 = 0x0552, // 16:32 pointer to 80 bit complex + T_64PCPLX80 = 0x0652, // 64 bit pointer to 80 bit complex + + // 128-bit complex types + T_CPLX128 = 0x0053, // 128 bit complex + T_PCPLX128 = 0x0153, // 16 bit pointer to 128 bit complex + T_PFCPLX128 = 0x0253, // 16:16 far pointer to 128 bit complex + T_PHCPLX128 = 0x0353, // 16:16 huge pointer to 128 bit real + T_32PCPLX128 = 0x0453, // 32 bit pointer to 128 bit complex + T_32PFCPLX128 = 0x0553, // 16:32 pointer to 128 bit complex + T_64PCPLX128 = 0x0653, // 64 bit pointer to 128 bit complex + + // Boolean types + T_BOOL08 = 0x0030, // 8 bit boolean + T_PBOOL08 = 0x0130, // 16 bit pointer to 8 bit boolean + T_PFBOOL08 = 0x0230, // 16:16 far pointer to 8 bit boolean + T_PHBOOL08 = 0x0330, // 16:16 huge pointer to 8 bit boolean + T_32PBOOL08 = 0x0430, // 32 bit pointer to 8 bit boolean + T_32PFBOOL08 = 0x0530, // 16:32 pointer to 8 bit boolean + T_64PBOOL08 = 0x0630, // 64 bit pointer to 8 bit boolean + + T_BOOL16 = 0x0031, // 16 bit boolean + T_PBOOL16 = 0x0131, // 16 bit pointer to 16 bit boolean + T_PFBOOL16 = 0x0231, // 16:16 far pointer to 16 bit boolean + T_PHBOOL16 = 0x0331, // 16:16 huge pointer to 16 bit boolean + T_32PBOOL16 = 0x0431, // 32 bit pointer to 18 bit boolean + T_32PFBOOL16 = 0x0531, // 16:32 pointer to 16 bit boolean + T_64PBOOL16 = 0x0631, // 64 bit pointer to 18 bit boolean + + T_BOOL32 = 0x0032, // 32 bit boolean + T_PBOOL32 = 0x0132, // 16 bit pointer to 32 bit boolean + T_PFBOOL32 = 0x0232, // 16:16 far pointer to 32 bit boolean + T_PHBOOL32 = 0x0332, // 16:16 huge pointer to 32 bit boolean + T_32PBOOL32 = 0x0432, // 32 bit pointer to 32 bit boolean + T_32PFBOOL32 = 0x0532, // 16:32 pointer to 32 bit boolean + T_64PBOOL32 = 0x0632, // 64 bit pointer to 32 bit boolean + + T_BOOL64 = 0x0033, // 64 bit boolean + T_PBOOL64 = 0x0133, // 16 bit pointer to 64 bit boolean + T_PFBOOL64 = 0x0233, // 16:16 far pointer to 64 bit boolean + T_PHBOOL64 = 0x0333, // 16:16 huge pointer to 64 bit boolean + T_32PBOOL64 = 0x0433, // 32 bit pointer to 64 bit boolean + T_32PFBOOL64 = 0x0533, // 16:32 pointer to 64 bit boolean + T_64PBOOL64 = 0x0633, // 64 bit pointer to 64 bit boolean + + T_NCVPTR = 0x01f0, // CV Internal type for created near pointers + T_FCVPTR = 0x02f0, // CV Internal type for created far pointers + T_HCVPTR = 0x03f0, // CV Internal type for created huge pointers + T_32NCVPTR = 0x04f0, // CV Internal type for created near 32-bit pointers + T_32FCVPTR = 0x05f0, // CV Internal type for created far 32-bit pointers + T_64NCVPTR = 0x06f0, // CV Internal type for created near 64-bit pointers + } + + /// Type enum for pointer records + /// + /// CV_PTR_* matches CV_ptrtype_e in cvinfo.h. + /// CV_PTR_MODE_* matches CV_ptrmode_e in cvinfo.h shifted left by 5. + /// CV_PTR_IS_* matches bit fields in lfPointer in cvinfo.h. + /// + public enum CodeViewPointer : uint + { + CV_PTR_NEAR = 0x00, // 16 bit pointer + CV_PTR_FAR = 0x01, // 16:16 far pointer + CV_PTR_HUGE = 0x02, // 16:16 huge pointer + CV_PTR_BASE_SEG = 0x03, // based on segment + CV_PTR_BASE_VAL = 0x04, // based on value of base + CV_PTR_BASE_SEGVAL = 0x05, // based on segment value of base + CV_PTR_BASE_ADDR = 0x06, // based on address of base + CV_PTR_BASE_SEGADDR = 0x07, // based on segment address of base + CV_PTR_BASE_TYPE = 0x08, // based on type + CV_PTR_BASE_SELF = 0x09, // based on self + CV_PTR_NEAR32 = 0x0a, // 32 bit pointer + CV_PTR_FAR32 = 0x0b, // 16:32 pointer + CV_PTR_64 = 0x0c, // 64 bit pointer + CV_PTR_UNUSEDPTR = 0x0d, // first unused pointer type + + CV_PTR_MODE_PTR = 0x00 << 5, // "normal" pointer + CV_PTR_MODE_REF = 0x01 << 5, // "old" reference + CV_PTR_MODE_LVREF = 0x01 << 5, // l-value reference + CV_PTR_MODE_PMEM = 0x02 << 5, // pointer to data member + CV_PTR_MODE_PMFUNC = 0x03 << 5, // pointer to member function + CV_PTR_MODE_RVREF = 0x04 << 5, // r-value reference + CV_PTR_MODE_RESERVED = 0x05 << 5, // first unused pointer mode + + CV_PTR_IS_FLAT32 = 1 << 8, + CV_PTR_IS_VOLATILE = 1 << 9, + CV_PTR_IS_CONST = 1 << 10, + CV_PTR_IS_UNALIGNED = 1 << 11, + CV_PTR_IS_RESTRICTED = 1 << 12, + } + + // Matches bit fields in CV_prop_t in cvinfo.h + public enum CodeViewPropertyFlags : ushort + { + CV_PROP_NONE = 0, + CV_PROP_PACKED = 1, + CV_PROP_HAS_CONSTURUCTOR_OR_DESTRUCTOR = 2, + CV_PROP_HAS_OVERLOADED_OPERATOR = 4, + CV_PROP_NESTED = 8, + CV_PROP_CONTAINS_NESTED_CLASS = 16, + CV_PROP_HAS_OVERLOADED_ASSIGNMENT_OPERATOR = 32, + CV_PROP_HAS_CONVERSION_OPERATOR = 64, + CV_PROP_FORWARD_REFERENCE = 128, + CV_PROP_SCOPED = 256, + CV_PROP_HAS_UNIQUE_NAME = 512, + CV_PROP_SEALED = 1024, + CV_PROP_INTRINSIC = 2048, + } // Matches DEBUG_S_SUBSECTION_TYPE in cvinfo.h public enum DebugSymbolsSubsectionType : uint @@ -462,154 +456,1886 @@ public enum DebugSymbolsSubsectionType : uint } // Matches LEAF_ENUM_e in cvinfo.h - // 32-bit type index versions of leaves have the 0x1000 bit set; most 16-bit - // leaves are omitted since they are unused public enum LeafRecordType { // Leaf indices starting records referenced from symbol records - VTShape = 0x000a, - Label = 0x000e, - Null = 0x000f, - NotTran = 0x0010, - EndPrecomp = 0x0014, // not referenced from symbol - TypeServerST = 0x0016, // not referenced from symbol - Modifier = 0x1001, - Pointer = 0x1002, - ArrayST = 0x1003, - ClassST = 0x1004, - StructureST = 0x1005, - UnionST = 0x1006, - EnumST = 0x1007, - Procedure = 0x1008, - MemberFunction = 0x1009, - Cobol0 = 0x100a, - BArray = 0x100b, - DimArrayST = 0x100c, - VFTPath = 0x100d, - PrecompST = 0x100e, // not referenced from symbol - Oem = 0x100f, // oem definable type string - AliasST = 0x1010, // alias (typedef) type - Oem2 = 0x1011, // oem definable type string - - // Leaf indices starting records but referenced only from type records - RefSym = 0x020c, - EnumerateST = 0x0403, - - Skip = 0x1200, - ArgList = 0x1201, - DefArgST = 0x1202, - FieldList = 0x1203, - Derived = 0x1204, - BitField = 0x1205, - MethodList = 0x1206, - DimConU = 0x1207, - DimConLU = 0x1208, - DimVatU = 0x1209, - DimVarLU = 0x120a, - - BaseClass = 0x1400, - VBaseClass = 0x1401, - IVBaseClass = 0x1402, - FriendFunctionST = 0x1403, - Index = 0x1404, - MemberST = 0x1405, - StaticMemberST = 0x1406, - MethodST = 0x1407, - NestTypeST = 0x1408, - VFunctionTable = 0x1409, - FriendClass = 0x140a, - OneMethodST = 0x140b, - VFunctionOffset = 0x140c, - NestTypeExST = 0x140d, - MemberModifyST = 0x140e, - ManagedST = 0x140f, + LF_MODIFIER_16t = 0x0001, + LF_POINTER_16t = 0x0002, + LF_ARRAY_16t = 0x0003, + LF_CLASS_16t = 0x0004, + LF_STRUCTURE_16t = 0x0005, + LF_UNION_16t = 0x0006, + LF_ENUM_16t = 0x0007, + LF_PROCEDURE_16t = 0x0008, + LF_MFUNCTION_16t = 0x0009, + LF_VTSHAPE = 0x000a, + LF_COBOL0_16t = 0x000b, + LF_COBOL1 = 0x000c, + LF_BARRAY_16t = 0x000d, + LF_LABEL = 0x000e, + LF_NULL = 0x000f, + LF_NOTTRAN = 0x0010, + LF_DIMARRAY_16t = 0x0011, + LF_VFTPATH_16t = 0x0012, + LF_PRECOMP_16t = 0x0013, // not referenced from symbol + LF_ENDPRECOMP = 0x0014, // not referenced from symbol + LF_OEM_16t = 0x0015, // oem definable type string + LF_TYPESERVER_ST = 0x0016, // not referenced from symbol + + // leaf indices starting records referenced only from type records + LF_SKIP_16t = 0x0200, + LF_ARGLIST_16t = 0x0201, + LF_DEFARG_16t = 0x0202, + LF_LIST = 0x0203, + LF_FIELDLIST_16t = 0x0204, + LF_DERIVED_16t = 0x0205, + LF_BITFIELD_16t = 0x0206, + LF_METHODLIST_16t = 0x0207, + LF_DIMCONU_16t = 0x0208, + LF_DIMCONLU_16t = 0x0209, + LF_DIMVARU_16t = 0x020a, + LF_DIMVARLU_16t = 0x020b, + LF_REFSYM = 0x020c, + + LF_BCLASS_16t = 0x0400, + LF_VBCLASS_16t = 0x0401, + LF_IVBCLASS_16t = 0x0402, + LF_ENUMERATE_ST = 0x0403, + LF_FRIENDFCN_16t = 0x0404, + LF_INDEX_16t = 0x0405, + LF_MEMBER_16t = 0x0406, + LF_STMEMBER_16t = 0x0407, + LF_METHOD_16t = 0x0408, + LF_NESTTYPE_16t = 0x0409, + LF_VFUNCTAB_16t = 0x040a, + LF_FRIENDCLS_16t = 0x040b, + LF_ONEMETHOD_16t = 0x040c, + LF_VFUNCOFF_16t = 0x040d, + + // 32-bit type index versions of leaves, all have the 0x1000 bit set + LF_TI16_MAX = 0x1000, + + LF_MODIFIER = 0x1001, + LF_POINTER = 0x1002, + LF_ARRAY_ST = 0x1003, + LF_CLASS_ST = 0x1004, + LF_STRUCTURE_ST = 0x1005, + LF_UNION_ST = 0x1006, + LF_ENUM_ST = 0x1007, + LF_PROCEDURE = 0x1008, + LF_MFUNCTION = 0x1009, + LF_COBOL0 = 0x100a, + LF_BARRAY = 0x100b, + LF_DIMARRAY_ST = 0x100c, + LF_VFTPATH = 0x100d, + LF_PRECOMP_ST = 0x100e, // not referenced from symbol + LF_OEM = 0x100f, // oem definable type string + LF_ALIAS_ST = 0x1010, // alias (typedef) type + LF_OEM2 = 0x1011, // oem definable type string + + // leaf indices starting records but referenced only from type records + LF_SKIP = 0x1200, + LF_ARGLIST = 0x1201, + LF_DEFARG_ST = 0x1202, + LF_FIELDLIST = 0x1203, + LF_DERIVED = 0x1204, + LF_BITFIELD = 0x1205, + LF_METHODLIST = 0x1206, + LF_DIMCONU = 0x1207, + LF_DIMCONLU = 0x1208, + LF_DIMVARU = 0x1209, + LF_DIMVARLU = 0x120a, + + LF_BCLASS = 0x1400, + LF_VBCLASS = 0x1401, + LF_IVBCLASS = 0x1402, + LF_FRIENDFCN_ST = 0x1403, + LF_INDEX = 0x1404, + LF_MEMBER_ST = 0x1405, + LF_STMEMBER_ST = 0x1406, + LF_METHOD_ST = 0x1407, + LF_NESTTYPE_ST = 0x1408, + LF_VFUNCTAB = 0x1409, + LF_FRIENDCLS = 0x140a, + LF_ONEMETHOD_ST = 0x140b, + LF_VFUNCOFF = 0x140c, + LF_NESTTYPEEX_ST = 0x140d, + LF_MEMBERMODIFY_ST = 0x140e, + LF_MANAGED_ST = 0x140f, // Types w/ SZ names - TypeServer = 0x1501, // not referenced from symbol - Enumerate = 0x1502, - Array = 0x1503, - Class = 0x1504, - Structure = 0x1505, - Union = 0x1506, - Enum = 0x1507, - DimArray = 0x1508, - Precomp = 0x1509, // not referenced from symbol - Alias = 0x150a, // alias (typedef) type - DefArg = 0x150b, - FriendFunction = 0x150c, - Member = 0x150d, - StaticMember = 0x150e, - Method = 0x150f, - NestType = 0x1510, - OneMethod = 0x1511, - NestTypeEx = 0x1512, - MemberModify = 0x1513, - Managed = 0x1514, - TypeServer2 = 0x1515, - - StridedArray = 0x1516, // same as Array, but with stride between adjacent elements - HLSL = 0x1517, - ModifierEx = 0x1518, - Interface = 0x1519, - BInterface = 0x151a, - Vector = 0x151b, - Matrix = 0x151c, - - VFTable = 0x151d, - - FunctionId = 0x1601, - MemberFunctionId = 0x1602, - BuildInfo = 0x1603, - SubstringList = 0x1604, - StringId = 0x1605, - - UdtSrcLine = 0x1606, // source and line on where an UDT is defined (only generated by compiler) - UdtModSrcLine = 0x1607, // module, source and line on where an UDT is defined (only generated by linker) - - // Size prefixes - Numeric = 0x8000, - Char = 0x8000, - Short = 0x8001, - UShort = 0x8002, - Long = 0x8003, - ULong = 0x8004, - Real32 = 0x8005, - Real64 = 0x8006, - Real80 = 0x8007, - Real128 = 0x8008, - QuadWord = 0x8009, - UQuadWord = 0x800a, - Real48 = 0x800b, - Complex32 = 0x800c, - Complex64 = 0x800d, - Complex80 = 0x800e, - Complex128 = 0x800f, - VarString = 0x8010, - - OctWord = 0x8017, - UOctWord = 0x8018, - Decimal = 0x8019, - Date = 0x801a, - Utf8String = 0x801b, - Real = 0x801c, - - // List padding - Pad0 = 0xf0, - Pad1 = 0xf1, - Pad2 = 0xf2, - Pad3 = 0xf3, - Pad4 = 0xf4, - Pad5 = 0xf5, - Pad6 = 0xf6, - Pad7 = 0xf7, - Pad8 = 0xf8, - Pad9 = 0xf9, - Pad10 = 0xfa, - Pad11 = 0xfb, - Pad12 = 0xfc, - Pad13 = 0xfd, - Pad14 = 0xfe, - Pad15 = 0xff, + LF_ST_MAX = 0x1500, + + LF_TYPESERVER = 0x1501, // not referenced from symbol + LF_ENUMERATE = 0x1502, + LF_ARRAY = 0x1503, + LF_CLASS = 0x1504, + LF_STRUCTURE = 0x1505, + LF_UNION = 0x1506, + LF_ENUM = 0x1507, + LF_DIMARRAY = 0x1508, + LF_PRECOMP = 0x1509, // not referenced from symbol + LF_ALIAS = 0x150a, // alias (typedef) type + LF_DEFARG = 0x150b, + LF_FRIENDFCN = 0x150c, + LF_MEMBER = 0x150d, + LF_STMEMBER = 0x150e, + LF_METHOD = 0x150f, + LF_NESTTYPE = 0x1510, + LF_ONEMETHOD = 0x1511, + LF_NESTTYPEEX = 0x1512, + LF_MEMBERMODIFY = 0x1513, + LF_MANAGED = 0x1514, + LF_TYPESERVER2 = 0x1515, + + LF_STRIDED_ARRAY = 0x1516, // same as LF_ARRAY, but with stride between adjacent elements + LF_HLSL = 0x1517, + LF_MODIFIER_EX = 0x1518, + LF_INTERFACE = 0x1519, + LF_BINTERFACE = 0x151a, + LF_VECTOR = 0x151b, + LF_MATRIX = 0x151c, + + LF_VFTABLE = 0x151d, // a virtual function table + LF_ENDOFLEAFRECORD = LF_VFTABLE, + + LF_TYPE_LAST, // one greater than the last type record + LF_TYPE_MAX = LF_TYPE_LAST - 1, + + LF_FUNC_ID = 0x1601, // global func ID + LF_MFUNC_ID = 0x1602, // member func ID + LF_BUILDINFO = 0x1603, // build info: tool, version, command line, src/pdb file + LF_SUBSTR_LIST = 0x1604, // similar to LF_ARGLIST, for list of sub strings + LF_STRING_ID = 0x1605, // string ID + + LF_UDT_SRC_LINE = 0x1606, // source and line on where an UDT is defined (only generated by compiler) + + LF_UDT_MOD_SRC_LINE = 0x1607, // module, source and line on where an UDT is defined (only generated by linker) + + LF_ID_LAST, // one greater than the last ID record + LF_ID_MAX = LF_ID_LAST - 1, + + LF_NUMERIC = 0x8000, + LF_CHAR = 0x8000, + LF_SHORT = 0x8001, + LF_USHORT = 0x8002, + LF_LONG = 0x8003, + LF_ULONG = 0x8004, + LF_REAL32 = 0x8005, + LF_REAL64 = 0x8006, + LF_REAL80 = 0x8007, + LF_REAL128 = 0x8008, + LF_QUADWORD = 0x8009, + LF_UQUADWORD = 0x800a, + LF_REAL48 = 0x800b, + LF_COMPLEX32 = 0x800c, + LF_COMPLEX64 = 0x800d, + LF_COMPLEX80 = 0x800e, + LF_COMPLEX128 = 0x800f, + LF_VARSTRING = 0x8010, + + LF_OCTWORD = 0x8017, + LF_UOCTWORD = 0x8018, + + LF_DECIMAL = 0x8019, + LF_DATE = 0x801a, + LF_UTF8STRING = 0x801b, + + LF_REAL16 = 0x801c, + + LF_PAD0 = 0xf0, + LF_PAD1 = 0xf1, + LF_PAD2 = 0xf2, + LF_PAD3 = 0xf3, + LF_PAD4 = 0xf4, + LF_PAD5 = 0xf5, + LF_PAD6 = 0xf6, + LF_PAD7 = 0xf7, + LF_PAD8 = 0xf8, + LF_PAD9 = 0xf9, + LF_PAD10 = 0xfa, + LF_PAD11 = 0xfb, + LF_PAD12 = 0xfc, + LF_PAD13 = 0xfd, + LF_PAD14 = 0xfe, + LF_PAD15 = 0xff, + } + + // Matches CV_HREG_e in cvinfo.h + public enum CodeViewRegister : ushort + { + // Register subset shared by all processor types, + // must not overlap with any of the ranges below, hence the high values + CV_ALLREG_ERR = 30000, + CV_ALLREG_TEB = 30001, + CV_ALLREG_TIMER = 30002, + CV_ALLREG_EFAD1 = 30003, + CV_ALLREG_EFAD2 = 30004, + CV_ALLREG_EFAD3 = 30005, + CV_ALLREG_VFRAME = 30006, + CV_ALLREG_HANDLE = 30007, + CV_ALLREG_PARAMS = 30008, + CV_ALLREG_LOCALS = 30009, + CV_ALLREG_TID = 30010, + CV_ALLREG_ENV = 30011, + CV_ALLREG_CMDLN = 30012, + + // Register set for the Intel 80x86 and ix86 processor series + // (plus PCODE registers) + CV_REG_NONE = 0, + CV_REG_AL = 1, + CV_REG_CL = 2, + CV_REG_DL = 3, + CV_REG_BL = 4, + CV_REG_AH = 5, + CV_REG_CH = 6, + CV_REG_DH = 7, + CV_REG_BH = 8, + CV_REG_AX = 9, + CV_REG_CX = 10, + CV_REG_DX = 11, + CV_REG_BX = 12, + CV_REG_SP = 13, + CV_REG_BP = 14, + CV_REG_SI = 15, + CV_REG_DI = 16, + CV_REG_EAX = 17, + CV_REG_ECX = 18, + CV_REG_EDX = 19, + CV_REG_EBX = 20, + CV_REG_ESP = 21, + CV_REG_EBP = 22, + CV_REG_ESI = 23, + CV_REG_EDI = 24, + CV_REG_ES = 25, + CV_REG_CS = 26, + CV_REG_SS = 27, + CV_REG_DS = 28, + CV_REG_FS = 29, + CV_REG_GS = 30, + CV_REG_IP = 31, + CV_REG_FLAGS = 32, + CV_REG_EIP = 33, + CV_REG_EFLAGS = 34, + CV_REG_TEMP = 40, // PCODE Temp + CV_REG_TEMPH = 41, // PCODE TempH + CV_REG_QUOTE = 42, // PCODE Quote + CV_REG_PCDR3 = 43, // PCODE reserved + CV_REG_PCDR4 = 44, // PCODE reserved + CV_REG_PCDR5 = 45, // PCODE reserved + CV_REG_PCDR6 = 46, // PCODE reserved + CV_REG_PCDR7 = 47, // PCODE reserved + CV_REG_CR0 = 80, // CR0 -- control registers + CV_REG_CR1 = 81, + CV_REG_CR2 = 82, + CV_REG_CR3 = 83, + CV_REG_CR4 = 84, // Pentium + CV_REG_DR0 = 90, // Debug register + CV_REG_DR1 = 91, + CV_REG_DR2 = 92, + CV_REG_DR3 = 93, + CV_REG_DR4 = 94, + CV_REG_DR5 = 95, + CV_REG_DR6 = 96, + CV_REG_DR7 = 97, + CV_REG_GDTR = 110, + CV_REG_GDTL = 111, + CV_REG_IDTR = 112, + CV_REG_IDTL = 113, + CV_REG_LDTR = 114, + CV_REG_TR = 115, + + CV_REG_PSEUDO1 = 116, + CV_REG_PSEUDO2 = 117, + CV_REG_PSEUDO3 = 118, + CV_REG_PSEUDO4 = 119, + CV_REG_PSEUDO5 = 120, + CV_REG_PSEUDO6 = 121, + CV_REG_PSEUDO7 = 122, + CV_REG_PSEUDO8 = 123, + CV_REG_PSEUDO9 = 124, + + CV_REG_ST0 = 128, + CV_REG_ST1 = 129, + CV_REG_ST2 = 130, + CV_REG_ST3 = 131, + CV_REG_ST4 = 132, + CV_REG_ST5 = 133, + CV_REG_ST6 = 134, + CV_REG_ST7 = 135, + CV_REG_CTRL = 136, + CV_REG_STAT = 137, + CV_REG_TAG = 138, + CV_REG_FPIP = 139, + CV_REG_FPCS = 140, + CV_REG_FPDO = 141, + CV_REG_FPDS = 142, + CV_REG_ISEM = 143, + CV_REG_FPEIP = 144, + CV_REG_FPEDO = 145, + + CV_REG_MM0 = 146, + CV_REG_MM1 = 147, + CV_REG_MM2 = 148, + CV_REG_MM3 = 149, + CV_REG_MM4 = 150, + CV_REG_MM5 = 151, + CV_REG_MM6 = 152, + CV_REG_MM7 = 153, + + // KATMAI registers + CV_REG_XMM0 = 154, + CV_REG_XMM1 = 155, + CV_REG_XMM2 = 156, + CV_REG_XMM3 = 157, + CV_REG_XMM4 = 158, + CV_REG_XMM5 = 159, + CV_REG_XMM6 = 160, + CV_REG_XMM7 = 161, + + // KATMAI sub-registers + CV_REG_XMM00 = 162, + CV_REG_XMM01 = 163, + CV_REG_XMM02 = 164, + CV_REG_XMM03 = 165, + CV_REG_XMM10 = 166, + CV_REG_XMM11 = 167, + CV_REG_XMM12 = 168, + CV_REG_XMM13 = 169, + CV_REG_XMM20 = 170, + CV_REG_XMM21 = 171, + CV_REG_XMM22 = 172, + CV_REG_XMM23 = 173, + CV_REG_XMM30 = 174, + CV_REG_XMM31 = 175, + CV_REG_XMM32 = 176, + CV_REG_XMM33 = 177, + CV_REG_XMM40 = 178, + CV_REG_XMM41 = 179, + CV_REG_XMM42 = 180, + CV_REG_XMM43 = 181, + CV_REG_XMM50 = 182, + CV_REG_XMM51 = 183, + CV_REG_XMM52 = 184, + CV_REG_XMM53 = 185, + CV_REG_XMM60 = 186, + CV_REG_XMM61 = 187, + CV_REG_XMM62 = 188, + CV_REG_XMM63 = 189, + CV_REG_XMM70 = 190, + CV_REG_XMM71 = 191, + CV_REG_XMM72 = 192, + CV_REG_XMM73 = 193, + + CV_REG_XMM0L = 194, + CV_REG_XMM1L = 195, + CV_REG_XMM2L = 196, + CV_REG_XMM3L = 197, + CV_REG_XMM4L = 198, + CV_REG_XMM5L = 199, + CV_REG_XMM6L = 200, + CV_REG_XMM7L = 201, + + CV_REG_XMM0H = 202, + CV_REG_XMM1H = 203, + CV_REG_XMM2H = 204, + CV_REG_XMM3H = 205, + CV_REG_XMM4H = 206, + CV_REG_XMM5H = 207, + CV_REG_XMM6H = 208, + CV_REG_XMM7H = 209, + + // XMM status register + CV_REG_MXCSR = 211, + + // EDX:EAX pair + CV_REG_EDXEAX = 212, + + // XMM sub-registers (WNI integer) + CV_REG_EMM0L = 220, + CV_REG_EMM1L = 221, + CV_REG_EMM2L = 222, + CV_REG_EMM3L = 223, + CV_REG_EMM4L = 224, + CV_REG_EMM5L = 225, + CV_REG_EMM6L = 226, + CV_REG_EMM7L = 227, + + CV_REG_EMM0H = 228, + CV_REG_EMM1H = 229, + CV_REG_EMM2H = 230, + CV_REG_EMM3H = 231, + CV_REG_EMM4H = 232, + CV_REG_EMM5H = 233, + CV_REG_EMM6H = 234, + CV_REG_EMM7H = 235, + + // Do not change the order of these regs, first one must be even too + CV_REG_MM00 = 236, + CV_REG_MM01 = 237, + CV_REG_MM10 = 238, + CV_REG_MM11 = 239, + CV_REG_MM20 = 240, + CV_REG_MM21 = 241, + CV_REG_MM30 = 242, + CV_REG_MM31 = 243, + CV_REG_MM40 = 244, + CV_REG_MM41 = 245, + CV_REG_MM50 = 246, + CV_REG_MM51 = 247, + CV_REG_MM60 = 248, + CV_REG_MM61 = 249, + CV_REG_MM70 = 250, + CV_REG_MM71 = 251, + + // AVX registers + CV_REG_YMM0 = 252, + CV_REG_YMM1 = 253, + CV_REG_YMM2 = 254, + CV_REG_YMM3 = 255, + CV_REG_YMM4 = 256, + CV_REG_YMM5 = 257, + CV_REG_YMM6 = 258, + CV_REG_YMM7 = 259, + + CV_REG_YMM0H = 260, + CV_REG_YMM1H = 261, + CV_REG_YMM2H = 262, + CV_REG_YMM3H = 263, + CV_REG_YMM4H = 264, + CV_REG_YMM5H = 265, + CV_REG_YMM6H = 266, + CV_REG_YMM7H = 267, + + // AVX integer registers + CV_REG_YMM0I0 = 268, + CV_REG_YMM0I1 = 269, + CV_REG_YMM0I2 = 270, + CV_REG_YMM0I3 = 271, + CV_REG_YMM1I0 = 272, + CV_REG_YMM1I1 = 273, + CV_REG_YMM1I2 = 274, + CV_REG_YMM1I3 = 275, + CV_REG_YMM2I0 = 276, + CV_REG_YMM2I1 = 277, + CV_REG_YMM2I2 = 278, + CV_REG_YMM2I3 = 279, + CV_REG_YMM3I0 = 280, + CV_REG_YMM3I1 = 281, + CV_REG_YMM3I2 = 282, + CV_REG_YMM3I3 = 283, + CV_REG_YMM4I0 = 284, + CV_REG_YMM4I1 = 285, + CV_REG_YMM4I2 = 286, + CV_REG_YMM4I3 = 287, + CV_REG_YMM5I0 = 288, + CV_REG_YMM5I1 = 289, + CV_REG_YMM5I2 = 290, + CV_REG_YMM5I3 = 291, + CV_REG_YMM6I0 = 292, + CV_REG_YMM6I1 = 293, + CV_REG_YMM6I2 = 294, + CV_REG_YMM6I3 = 295, + CV_REG_YMM7I0 = 296, + CV_REG_YMM7I1 = 297, + CV_REG_YMM7I2 = 298, + CV_REG_YMM7I3 = 299, + + // AVX floating-point single precise registers + CV_REG_YMM0F0 = 300, + CV_REG_YMM0F1 = 301, + CV_REG_YMM0F2 = 302, + CV_REG_YMM0F3 = 303, + CV_REG_YMM0F4 = 304, + CV_REG_YMM0F5 = 305, + CV_REG_YMM0F6 = 306, + CV_REG_YMM0F7 = 307, + CV_REG_YMM1F0 = 308, + CV_REG_YMM1F1 = 309, + CV_REG_YMM1F2 = 310, + CV_REG_YMM1F3 = 311, + CV_REG_YMM1F4 = 312, + CV_REG_YMM1F5 = 313, + CV_REG_YMM1F6 = 314, + CV_REG_YMM1F7 = 315, + CV_REG_YMM2F0 = 316, + CV_REG_YMM2F1 = 317, + CV_REG_YMM2F2 = 318, + CV_REG_YMM2F3 = 319, + CV_REG_YMM2F4 = 320, + CV_REG_YMM2F5 = 321, + CV_REG_YMM2F6 = 322, + CV_REG_YMM2F7 = 323, + CV_REG_YMM3F0 = 324, + CV_REG_YMM3F1 = 325, + CV_REG_YMM3F2 = 326, + CV_REG_YMM3F3 = 327, + CV_REG_YMM3F4 = 328, + CV_REG_YMM3F5 = 329, + CV_REG_YMM3F6 = 330, + CV_REG_YMM3F7 = 331, + CV_REG_YMM4F0 = 332, + CV_REG_YMM4F1 = 333, + CV_REG_YMM4F2 = 334, + CV_REG_YMM4F3 = 335, + CV_REG_YMM4F4 = 336, + CV_REG_YMM4F5 = 337, + CV_REG_YMM4F6 = 338, + CV_REG_YMM4F7 = 339, + CV_REG_YMM5F0 = 340, + CV_REG_YMM5F1 = 341, + CV_REG_YMM5F2 = 342, + CV_REG_YMM5F3 = 343, + CV_REG_YMM5F4 = 344, + CV_REG_YMM5F5 = 345, + CV_REG_YMM5F6 = 346, + CV_REG_YMM5F7 = 347, + CV_REG_YMM6F0 = 348, + CV_REG_YMM6F1 = 349, + CV_REG_YMM6F2 = 350, + CV_REG_YMM6F3 = 351, + CV_REG_YMM6F4 = 352, + CV_REG_YMM6F5 = 353, + CV_REG_YMM6F6 = 354, + CV_REG_YMM6F7 = 355, + CV_REG_YMM7F0 = 356, + CV_REG_YMM7F1 = 357, + CV_REG_YMM7F2 = 358, + CV_REG_YMM7F3 = 359, + CV_REG_YMM7F4 = 360, + CV_REG_YMM7F5 = 361, + CV_REG_YMM7F6 = 362, + CV_REG_YMM7F7 = 363, + + // AVX floating-point double precise registers + CV_REG_YMM0D0 = 364, + CV_REG_YMM0D1 = 365, + CV_REG_YMM0D2 = 366, + CV_REG_YMM0D3 = 367, + CV_REG_YMM1D0 = 368, + CV_REG_YMM1D1 = 369, + CV_REG_YMM1D2 = 370, + CV_REG_YMM1D3 = 371, + CV_REG_YMM2D0 = 372, + CV_REG_YMM2D1 = 373, + CV_REG_YMM2D2 = 374, + CV_REG_YMM2D3 = 375, + CV_REG_YMM3D0 = 376, + CV_REG_YMM3D1 = 377, + CV_REG_YMM3D2 = 378, + CV_REG_YMM3D3 = 379, + CV_REG_YMM4D0 = 380, + CV_REG_YMM4D1 = 381, + CV_REG_YMM4D2 = 382, + CV_REG_YMM4D3 = 383, + CV_REG_YMM5D0 = 384, + CV_REG_YMM5D1 = 385, + CV_REG_YMM5D2 = 386, + CV_REG_YMM5D3 = 387, + CV_REG_YMM6D0 = 388, + CV_REG_YMM6D1 = 389, + CV_REG_YMM6D2 = 390, + CV_REG_YMM6D3 = 391, + CV_REG_YMM7D0 = 392, + CV_REG_YMM7D1 = 393, + CV_REG_YMM7D2 = 394, + CV_REG_YMM7D3 = 395, + + CV_REG_BND0 = 396, + CV_REG_BND1 = 397, + CV_REG_BND2 = 398, + CV_REG_BND3 = 399, + + // Register set for the ARM processor. + CV_ARM_NOREG = CV_REG_NONE, + + CV_ARM_R0 = 10, + CV_ARM_R1 = 11, + CV_ARM_R2 = 12, + CV_ARM_R3 = 13, + CV_ARM_R4 = 14, + CV_ARM_R5 = 15, + CV_ARM_R6 = 16, + CV_ARM_R7 = 17, + CV_ARM_R8 = 18, + CV_ARM_R9 = 19, + CV_ARM_R10 = 20, + CV_ARM_R11 = 21, // Frame pointer, if allocated + CV_ARM_R12 = 22, + CV_ARM_SP = 23, // Stack pointer + CV_ARM_LR = 24, // Link Register + CV_ARM_PC = 25, // Program counter + CV_ARM_CPSR = 26, // Current program status register + + CV_ARM_ACC0 = 27, // DSP co-processor 0 40 bit accumulator + + // Registers for ARM VFP10 support + CV_ARM_FPSCR = 40, + CV_ARM_FPEXC = 41, + + CV_ARM_FS0 = 50, + CV_ARM_FS1 = 51, + CV_ARM_FS2 = 52, + CV_ARM_FS3 = 53, + CV_ARM_FS4 = 54, + CV_ARM_FS5 = 55, + CV_ARM_FS6 = 56, + CV_ARM_FS7 = 57, + CV_ARM_FS8 = 58, + CV_ARM_FS9 = 59, + CV_ARM_FS10 = 60, + CV_ARM_FS11 = 61, + CV_ARM_FS12 = 62, + CV_ARM_FS13 = 63, + CV_ARM_FS14 = 64, + CV_ARM_FS15 = 65, + CV_ARM_FS16 = 66, + CV_ARM_FS17 = 67, + CV_ARM_FS18 = 68, + CV_ARM_FS19 = 69, + CV_ARM_FS20 = 70, + CV_ARM_FS21 = 71, + CV_ARM_FS22 = 72, + CV_ARM_FS23 = 73, + CV_ARM_FS24 = 74, + CV_ARM_FS25 = 75, + CV_ARM_FS26 = 76, + CV_ARM_FS27 = 77, + CV_ARM_FS28 = 78, + CV_ARM_FS29 = 79, + CV_ARM_FS30 = 80, + CV_ARM_FS31 = 81, + + // ARM VFP Floating Point Extra control registers + CV_ARM_FPEXTRA0 = 90, + CV_ARM_FPEXTRA1 = 91, + CV_ARM_FPEXTRA2 = 92, + CV_ARM_FPEXTRA3 = 93, + CV_ARM_FPEXTRA4 = 94, + CV_ARM_FPEXTRA5 = 95, + CV_ARM_FPEXTRA6 = 96, + CV_ARM_FPEXTRA7 = 97, + + // XSCALE Concan co-processor registers + CV_ARM_WR0 = 128, + CV_ARM_WR1 = 129, + CV_ARM_WR2 = 130, + CV_ARM_WR3 = 131, + CV_ARM_WR4 = 132, + CV_ARM_WR5 = 133, + CV_ARM_WR6 = 134, + CV_ARM_WR7 = 135, + CV_ARM_WR8 = 136, + CV_ARM_WR9 = 137, + CV_ARM_WR10 = 138, + CV_ARM_WR11 = 139, + CV_ARM_WR12 = 140, + CV_ARM_WR13 = 141, + CV_ARM_WR14 = 142, + CV_ARM_WR15 = 143, + + // XSCALE Concan co-processor control registers + CV_ARM_WCID = 144, + CV_ARM_WCON = 145, + CV_ARM_WCSSF = 146, + CV_ARM_WCASF = 147, + CV_ARM_WC4 = 148, + CV_ARM_WC5 = 149, + CV_ARM_WC6 = 150, + CV_ARM_WC7 = 151, + CV_ARM_WCGR0 = 152, + CV_ARM_WCGR1 = 153, + CV_ARM_WCGR2 = 154, + CV_ARM_WCGR3 = 155, + CV_ARM_WC12 = 156, + CV_ARM_WC13 = 157, + CV_ARM_WC14 = 158, + CV_ARM_WC15 = 159, + + // ARM VFPv3/Neon extended floating Point + CV_ARM_FS32 = 200, + CV_ARM_FS33 = 201, + CV_ARM_FS34 = 202, + CV_ARM_FS35 = 203, + CV_ARM_FS36 = 204, + CV_ARM_FS37 = 205, + CV_ARM_FS38 = 206, + CV_ARM_FS39 = 207, + CV_ARM_FS40 = 208, + CV_ARM_FS41 = 209, + CV_ARM_FS42 = 210, + CV_ARM_FS43 = 211, + CV_ARM_FS44 = 212, + CV_ARM_FS45 = 213, + CV_ARM_FS46 = 214, + CV_ARM_FS47 = 215, + CV_ARM_FS48 = 216, + CV_ARM_FS49 = 217, + CV_ARM_FS50 = 218, + CV_ARM_FS51 = 219, + CV_ARM_FS52 = 220, + CV_ARM_FS53 = 221, + CV_ARM_FS54 = 222, + CV_ARM_FS55 = 223, + CV_ARM_FS56 = 224, + CV_ARM_FS57 = 225, + CV_ARM_FS58 = 226, + CV_ARM_FS59 = 227, + CV_ARM_FS60 = 228, + CV_ARM_FS61 = 229, + CV_ARM_FS62 = 230, + CV_ARM_FS63 = 231, + + // ARM double-precision floating point + CV_ARM_ND0 = 300, + CV_ARM_ND1 = 301, + CV_ARM_ND2 = 302, + CV_ARM_ND3 = 303, + CV_ARM_ND4 = 304, + CV_ARM_ND5 = 305, + CV_ARM_ND6 = 306, + CV_ARM_ND7 = 307, + CV_ARM_ND8 = 308, + CV_ARM_ND9 = 309, + CV_ARM_ND10 = 310, + CV_ARM_ND11 = 311, + CV_ARM_ND12 = 312, + CV_ARM_ND13 = 313, + CV_ARM_ND14 = 314, + CV_ARM_ND15 = 315, + CV_ARM_ND16 = 316, + CV_ARM_ND17 = 317, + CV_ARM_ND18 = 318, + CV_ARM_ND19 = 319, + CV_ARM_ND20 = 320, + CV_ARM_ND21 = 321, + CV_ARM_ND22 = 322, + CV_ARM_ND23 = 323, + CV_ARM_ND24 = 324, + CV_ARM_ND25 = 325, + CV_ARM_ND26 = 326, + CV_ARM_ND27 = 327, + CV_ARM_ND28 = 328, + CV_ARM_ND29 = 329, + CV_ARM_ND30 = 330, + CV_ARM_ND31 = 331, + + // ARM extended precision floating point + CV_ARM_NQ0 = 400, + CV_ARM_NQ1 = 401, + CV_ARM_NQ2 = 402, + CV_ARM_NQ3 = 403, + CV_ARM_NQ4 = 404, + CV_ARM_NQ5 = 405, + CV_ARM_NQ6 = 406, + CV_ARM_NQ7 = 407, + CV_ARM_NQ8 = 408, + CV_ARM_NQ9 = 409, + CV_ARM_NQ10 = 410, + CV_ARM_NQ11 = 411, + CV_ARM_NQ12 = 412, + CV_ARM_NQ13 = 413, + CV_ARM_NQ14 = 414, + CV_ARM_NQ15 = 415, + + // Register set for ARM64 + CV_ARM64_NOREG = CV_REG_NONE, + + // General purpose 32-bit integer registers + CV_ARM64_W0 = 10, + CV_ARM64_W1 = 11, + CV_ARM64_W2 = 12, + CV_ARM64_W3 = 13, + CV_ARM64_W4 = 14, + CV_ARM64_W5 = 15, + CV_ARM64_W6 = 16, + CV_ARM64_W7 = 17, + CV_ARM64_W8 = 18, + CV_ARM64_W9 = 19, + CV_ARM64_W10 = 20, + CV_ARM64_W11 = 21, + CV_ARM64_W12 = 22, + CV_ARM64_W13 = 23, + CV_ARM64_W14 = 24, + CV_ARM64_W15 = 25, + CV_ARM64_W16 = 26, + CV_ARM64_W17 = 27, + CV_ARM64_W18 = 28, + CV_ARM64_W19 = 29, + CV_ARM64_W20 = 30, + CV_ARM64_W21 = 31, + CV_ARM64_W22 = 32, + CV_ARM64_W23 = 33, + CV_ARM64_W24 = 34, + CV_ARM64_W25 = 35, + CV_ARM64_W26 = 36, + CV_ARM64_W27 = 37, + CV_ARM64_W28 = 38, + CV_ARM64_W29 = 39, + CV_ARM64_W30 = 40, + CV_ARM64_WZR = 41, + + // General purpose 64-bit integer registers + CV_ARM64_X0 = 50, + CV_ARM64_X1 = 51, + CV_ARM64_X2 = 52, + CV_ARM64_X3 = 53, + CV_ARM64_X4 = 54, + CV_ARM64_X5 = 55, + CV_ARM64_X6 = 56, + CV_ARM64_X7 = 57, + CV_ARM64_X8 = 58, + CV_ARM64_X9 = 59, + CV_ARM64_X10 = 60, + CV_ARM64_X11 = 61, + CV_ARM64_X12 = 62, + CV_ARM64_X13 = 63, + CV_ARM64_X14 = 64, + CV_ARM64_X15 = 65, + CV_ARM64_IP0 = 66, + CV_ARM64_IP1 = 67, + CV_ARM64_X18 = 68, + CV_ARM64_X19 = 69, + CV_ARM64_X20 = 70, + CV_ARM64_X21 = 71, + CV_ARM64_X22 = 72, + CV_ARM64_X23 = 73, + CV_ARM64_X24 = 74, + CV_ARM64_X25 = 75, + CV_ARM64_X26 = 76, + CV_ARM64_X27 = 77, + CV_ARM64_X28 = 78, + CV_ARM64_FP = 79, + CV_ARM64_LR = 80, + CV_ARM64_SP = 81, + CV_ARM64_ZR = 82, + CV_ARM64_PC = 83, + + // status registers + CV_ARM64_NZCV = 90, + CV_ARM64_CPSR = 91, + + // 32-bit floating point registers + CV_ARM64_S0 = 100, + CV_ARM64_S1 = 101, + CV_ARM64_S2 = 102, + CV_ARM64_S3 = 103, + CV_ARM64_S4 = 104, + CV_ARM64_S5 = 105, + CV_ARM64_S6 = 106, + CV_ARM64_S7 = 107, + CV_ARM64_S8 = 108, + CV_ARM64_S9 = 109, + CV_ARM64_S10 = 110, + CV_ARM64_S11 = 111, + CV_ARM64_S12 = 112, + CV_ARM64_S13 = 113, + CV_ARM64_S14 = 114, + CV_ARM64_S15 = 115, + CV_ARM64_S16 = 116, + CV_ARM64_S17 = 117, + CV_ARM64_S18 = 118, + CV_ARM64_S19 = 119, + CV_ARM64_S20 = 120, + CV_ARM64_S21 = 121, + CV_ARM64_S22 = 122, + CV_ARM64_S23 = 123, + CV_ARM64_S24 = 124, + CV_ARM64_S25 = 125, + CV_ARM64_S26 = 126, + CV_ARM64_S27 = 127, + CV_ARM64_S28 = 128, + CV_ARM64_S29 = 129, + CV_ARM64_S30 = 130, + CV_ARM64_S31 = 131, + + // 64-bit floating point registers + CV_ARM64_D0 = 140, + CV_ARM64_D1 = 141, + CV_ARM64_D2 = 142, + CV_ARM64_D3 = 143, + CV_ARM64_D4 = 144, + CV_ARM64_D5 = 145, + CV_ARM64_D6 = 146, + CV_ARM64_D7 = 147, + CV_ARM64_D8 = 148, + CV_ARM64_D9 = 149, + CV_ARM64_D10 = 150, + CV_ARM64_D11 = 151, + CV_ARM64_D12 = 152, + CV_ARM64_D13 = 153, + CV_ARM64_D14 = 154, + CV_ARM64_D15 = 155, + CV_ARM64_D16 = 156, + CV_ARM64_D17 = 157, + CV_ARM64_D18 = 158, + CV_ARM64_D19 = 159, + CV_ARM64_D20 = 160, + CV_ARM64_D21 = 161, + CV_ARM64_D22 = 162, + CV_ARM64_D23 = 163, + CV_ARM64_D24 = 164, + CV_ARM64_D25 = 165, + CV_ARM64_D26 = 166, + CV_ARM64_D27 = 167, + CV_ARM64_D28 = 168, + CV_ARM64_D29 = 169, + CV_ARM64_D30 = 170, + CV_ARM64_D31 = 171, + + // 128-bit SIMD registers + CV_ARM64_Q0 = 180, + CV_ARM64_Q1 = 181, + CV_ARM64_Q2 = 182, + CV_ARM64_Q3 = 183, + CV_ARM64_Q4 = 184, + CV_ARM64_Q5 = 185, + CV_ARM64_Q6 = 186, + CV_ARM64_Q7 = 187, + CV_ARM64_Q8 = 188, + CV_ARM64_Q9 = 189, + CV_ARM64_Q10 = 190, + CV_ARM64_Q11 = 191, + CV_ARM64_Q12 = 192, + CV_ARM64_Q13 = 193, + CV_ARM64_Q14 = 194, + CV_ARM64_Q15 = 195, + CV_ARM64_Q16 = 196, + CV_ARM64_Q17 = 197, + CV_ARM64_Q18 = 198, + CV_ARM64_Q19 = 199, + CV_ARM64_Q20 = 200, + CV_ARM64_Q21 = 201, + CV_ARM64_Q22 = 202, + CV_ARM64_Q23 = 203, + CV_ARM64_Q24 = 204, + CV_ARM64_Q25 = 205, + CV_ARM64_Q26 = 206, + CV_ARM64_Q27 = 207, + CV_ARM64_Q28 = 208, + CV_ARM64_Q29 = 209, + CV_ARM64_Q30 = 210, + CV_ARM64_Q31 = 211, + + // Floating point status register + CV_ARM64_FPSR = 220, + + // AMD64 registers + CV_AMD64_AL = 1, + CV_AMD64_CL = 2, + CV_AMD64_DL = 3, + CV_AMD64_BL = 4, + CV_AMD64_AH = 5, + CV_AMD64_CH = 6, + CV_AMD64_DH = 7, + CV_AMD64_BH = 8, + CV_AMD64_AX = 9, + CV_AMD64_CX = 10, + CV_AMD64_DX = 11, + CV_AMD64_BX = 12, + CV_AMD64_SP = 13, + CV_AMD64_BP = 14, + CV_AMD64_SI = 15, + CV_AMD64_DI = 16, + CV_AMD64_EAX = 17, + CV_AMD64_ECX = 18, + CV_AMD64_EDX = 19, + CV_AMD64_EBX = 20, + CV_AMD64_ESP = 21, + CV_AMD64_EBP = 22, + CV_AMD64_ESI = 23, + CV_AMD64_EDI = 24, + CV_AMD64_ES = 25, + CV_AMD64_CS = 26, + CV_AMD64_SS = 27, + CV_AMD64_DS = 28, + CV_AMD64_FS = 29, + CV_AMD64_GS = 30, + CV_AMD64_FLAGS = 32, + CV_AMD64_RIP = 33, + CV_AMD64_EFLAGS = 34, + + // Control registers + CV_AMD64_CR0 = 80, + CV_AMD64_CR1 = 81, + CV_AMD64_CR2 = 82, + CV_AMD64_CR3 = 83, + CV_AMD64_CR4 = 84, + CV_AMD64_CR8 = 88, + + // Debug registers + CV_AMD64_DR0 = 90, + CV_AMD64_DR1 = 91, + CV_AMD64_DR2 = 92, + CV_AMD64_DR3 = 93, + CV_AMD64_DR4 = 94, + CV_AMD64_DR5 = 95, + CV_AMD64_DR6 = 96, + CV_AMD64_DR7 = 97, + CV_AMD64_DR8 = 98, + CV_AMD64_DR9 = 99, + CV_AMD64_DR10 = 100, + CV_AMD64_DR11 = 101, + CV_AMD64_DR12 = 102, + CV_AMD64_DR13 = 103, + CV_AMD64_DR14 = 104, + CV_AMD64_DR15 = 105, + + CV_AMD64_GDTR = 110, + CV_AMD64_GDTL = 111, + CV_AMD64_IDTR = 112, + CV_AMD64_IDTL = 113, + CV_AMD64_LDTR = 114, + CV_AMD64_TR = 115, + + CV_AMD64_ST0 = 128, + CV_AMD64_ST1 = 129, + CV_AMD64_ST2 = 130, + CV_AMD64_ST3 = 131, + CV_AMD64_ST4 = 132, + CV_AMD64_ST5 = 133, + CV_AMD64_ST6 = 134, + CV_AMD64_ST7 = 135, + CV_AMD64_CTRL = 136, + CV_AMD64_STAT = 137, + CV_AMD64_TAG = 138, + CV_AMD64_FPIP = 139, + CV_AMD64_FPCS = 140, + CV_AMD64_FPDO = 141, + CV_AMD64_FPDS = 142, + CV_AMD64_ISEM = 143, + CV_AMD64_FPEIP = 144, + CV_AMD64_FPEDO = 145, + + CV_AMD64_MM0 = 146, + CV_AMD64_MM1 = 147, + CV_AMD64_MM2 = 148, + CV_AMD64_MM3 = 149, + CV_AMD64_MM4 = 150, + CV_AMD64_MM5 = 151, + CV_AMD64_MM6 = 152, + CV_AMD64_MM7 = 153, + + // KATMAI registers + CV_AMD64_XMM0 = 154, + CV_AMD64_XMM1 = 155, + CV_AMD64_XMM2 = 156, + CV_AMD64_XMM3 = 157, + CV_AMD64_XMM4 = 158, + CV_AMD64_XMM5 = 159, + CV_AMD64_XMM6 = 160, + CV_AMD64_XMM7 = 161, + + // KATMAI sub-registers + CV_AMD64_XMM0_0 = 162, + CV_AMD64_XMM0_1 = 163, + CV_AMD64_XMM0_2 = 164, + CV_AMD64_XMM0_3 = 165, + CV_AMD64_XMM1_0 = 166, + CV_AMD64_XMM1_1 = 167, + CV_AMD64_XMM1_2 = 168, + CV_AMD64_XMM1_3 = 169, + CV_AMD64_XMM2_0 = 170, + CV_AMD64_XMM2_1 = 171, + CV_AMD64_XMM2_2 = 172, + CV_AMD64_XMM2_3 = 173, + CV_AMD64_XMM3_0 = 174, + CV_AMD64_XMM3_1 = 175, + CV_AMD64_XMM3_2 = 176, + CV_AMD64_XMM3_3 = 177, + CV_AMD64_XMM4_0 = 178, + CV_AMD64_XMM4_1 = 179, + CV_AMD64_XMM4_2 = 180, + CV_AMD64_XMM4_3 = 181, + CV_AMD64_XMM5_0 = 182, + CV_AMD64_XMM5_1 = 183, + CV_AMD64_XMM5_2 = 184, + CV_AMD64_XMM5_3 = 185, + CV_AMD64_XMM6_0 = 186, + CV_AMD64_XMM6_1 = 187, + CV_AMD64_XMM6_2 = 188, + CV_AMD64_XMM6_3 = 189, + CV_AMD64_XMM7_0 = 190, + CV_AMD64_XMM7_1 = 191, + CV_AMD64_XMM7_2 = 192, + CV_AMD64_XMM7_3 = 193, + + CV_AMD64_XMM0L = 194, + CV_AMD64_XMM1L = 195, + CV_AMD64_XMM2L = 196, + CV_AMD64_XMM3L = 197, + CV_AMD64_XMM4L = 198, + CV_AMD64_XMM5L = 199, + CV_AMD64_XMM6L = 200, + CV_AMD64_XMM7L = 201, + + CV_AMD64_XMM0H = 202, + CV_AMD64_XMM1H = 203, + CV_AMD64_XMM2H = 204, + CV_AMD64_XMM3H = 205, + CV_AMD64_XMM4H = 206, + CV_AMD64_XMM5H = 207, + CV_AMD64_XMM6H = 208, + CV_AMD64_XMM7H = 209, + + // XMM status register + CV_AMD64_MXCSR = 211, + + // XMM sub-registers (WNI integer) + CV_AMD64_EMM0L = 220, + CV_AMD64_EMM1L = 221, + CV_AMD64_EMM2L = 222, + CV_AMD64_EMM3L = 223, + CV_AMD64_EMM4L = 224, + CV_AMD64_EMM5L = 225, + CV_AMD64_EMM6L = 226, + CV_AMD64_EMM7L = 227, + + CV_AMD64_EMM0H = 228, + CV_AMD64_EMM1H = 229, + CV_AMD64_EMM2H = 230, + CV_AMD64_EMM3H = 231, + CV_AMD64_EMM4H = 232, + CV_AMD64_EMM5H = 233, + CV_AMD64_EMM6H = 234, + CV_AMD64_EMM7H = 235, + + // Do not change the order of these regs, first one must be even too + CV_AMD64_MM00 = 236, + CV_AMD64_MM01 = 237, + CV_AMD64_MM10 = 238, + CV_AMD64_MM11 = 239, + CV_AMD64_MM20 = 240, + CV_AMD64_MM21 = 241, + CV_AMD64_MM30 = 242, + CV_AMD64_MM31 = 243, + CV_AMD64_MM40 = 244, + CV_AMD64_MM41 = 245, + CV_AMD64_MM50 = 246, + CV_AMD64_MM51 = 247, + CV_AMD64_MM60 = 248, + CV_AMD64_MM61 = 249, + CV_AMD64_MM70 = 250, + CV_AMD64_MM71 = 251, + + // Extended KATMAI registers + CV_AMD64_XMM8 = 252, + CV_AMD64_XMM9 = 253, + CV_AMD64_XMM10 = 254, + CV_AMD64_XMM11 = 255, + CV_AMD64_XMM12 = 256, + CV_AMD64_XMM13 = 257, + CV_AMD64_XMM14 = 258, + CV_AMD64_XMM15 = 259, + + // KATMAI sub-registers + CV_AMD64_XMM8_0 = 260, + CV_AMD64_XMM8_1 = 261, + CV_AMD64_XMM8_2 = 262, + CV_AMD64_XMM8_3 = 263, + CV_AMD64_XMM9_0 = 264, + CV_AMD64_XMM9_1 = 265, + CV_AMD64_XMM9_2 = 266, + CV_AMD64_XMM9_3 = 267, + CV_AMD64_XMM10_0 = 268, + CV_AMD64_XMM10_1 = 269, + CV_AMD64_XMM10_2 = 270, + CV_AMD64_XMM10_3 = 271, + CV_AMD64_XMM11_0 = 272, + CV_AMD64_XMM11_1 = 273, + CV_AMD64_XMM11_2 = 274, + CV_AMD64_XMM11_3 = 275, + CV_AMD64_XMM12_0 = 276, + CV_AMD64_XMM12_1 = 277, + CV_AMD64_XMM12_2 = 278, + CV_AMD64_XMM12_3 = 279, + CV_AMD64_XMM13_0 = 280, + CV_AMD64_XMM13_1 = 281, + CV_AMD64_XMM13_2 = 282, + CV_AMD64_XMM13_3 = 283, + CV_AMD64_XMM14_0 = 284, + CV_AMD64_XMM14_1 = 285, + CV_AMD64_XMM14_2 = 286, + CV_AMD64_XMM14_3 = 287, + CV_AMD64_XMM15_0 = 288, + CV_AMD64_XMM15_1 = 289, + CV_AMD64_XMM15_2 = 290, + CV_AMD64_XMM15_3 = 291, + + CV_AMD64_XMM8L = 292, + CV_AMD64_XMM9L = 293, + CV_AMD64_XMM10L = 294, + CV_AMD64_XMM11L = 295, + CV_AMD64_XMM12L = 296, + CV_AMD64_XMM13L = 297, + CV_AMD64_XMM14L = 298, + CV_AMD64_XMM15L = 299, + + CV_AMD64_XMM8H = 300, + CV_AMD64_XMM9H = 301, + CV_AMD64_XMM10H = 302, + CV_AMD64_XMM11H = 303, + CV_AMD64_XMM12H = 304, + CV_AMD64_XMM13H = 305, + CV_AMD64_XMM14H = 306, + CV_AMD64_XMM15H = 307, + + // XMM sub-registers (WNI integer) + CV_AMD64_EMM8L = 308, + CV_AMD64_EMM9L = 309, + CV_AMD64_EMM10L = 310, + CV_AMD64_EMM11L = 311, + CV_AMD64_EMM12L = 312, + CV_AMD64_EMM13L = 313, + CV_AMD64_EMM14L = 314, + CV_AMD64_EMM15L = 315, + + CV_AMD64_EMM8H = 316, + CV_AMD64_EMM9H = 317, + CV_AMD64_EMM10H = 318, + CV_AMD64_EMM11H = 319, + CV_AMD64_EMM12H = 320, + CV_AMD64_EMM13H = 321, + CV_AMD64_EMM14H = 322, + CV_AMD64_EMM15H = 323, + + // Low byte forms of some standard registers + CV_AMD64_SIL = 324, + CV_AMD64_DIL = 325, + CV_AMD64_BPL = 326, + CV_AMD64_SPL = 327, + + // 64-bit regular registers + CV_AMD64_RAX = 328, + CV_AMD64_RBX = 329, + CV_AMD64_RCX = 330, + CV_AMD64_RDX = 331, + CV_AMD64_RSI = 332, + CV_AMD64_RDI = 333, + CV_AMD64_RBP = 334, + CV_AMD64_RSP = 335, + + // 64-bit integer registers with 8-, 16-, and 32-bit forms (B, W, and D) + CV_AMD64_R8 = 336, + CV_AMD64_R9 = 337, + CV_AMD64_R10 = 338, + CV_AMD64_R11 = 339, + CV_AMD64_R12 = 340, + CV_AMD64_R13 = 341, + CV_AMD64_R14 = 342, + CV_AMD64_R15 = 343, + + CV_AMD64_R8B = 344, + CV_AMD64_R9B = 345, + CV_AMD64_R10B = 346, + CV_AMD64_R11B = 347, + CV_AMD64_R12B = 348, + CV_AMD64_R13B = 349, + CV_AMD64_R14B = 350, + CV_AMD64_R15B = 351, + + CV_AMD64_R8W = 352, + CV_AMD64_R9W = 353, + CV_AMD64_R10W = 354, + CV_AMD64_R11W = 355, + CV_AMD64_R12W = 356, + CV_AMD64_R13W = 357, + CV_AMD64_R14W = 358, + CV_AMD64_R15W = 359, + + CV_AMD64_R8D = 360, + CV_AMD64_R9D = 361, + CV_AMD64_R10D = 362, + CV_AMD64_R11D = 363, + CV_AMD64_R12D = 364, + CV_AMD64_R13D = 365, + CV_AMD64_R14D = 366, + CV_AMD64_R15D = 367, + + // AVX registers 256 bits + CV_AMD64_YMM0 = 368, + CV_AMD64_YMM1 = 369, + CV_AMD64_YMM2 = 370, + CV_AMD64_YMM3 = 371, + CV_AMD64_YMM4 = 372, + CV_AMD64_YMM5 = 373, + CV_AMD64_YMM6 = 374, + CV_AMD64_YMM7 = 375, + CV_AMD64_YMM8 = 376, + CV_AMD64_YMM9 = 377, + CV_AMD64_YMM10 = 378, + CV_AMD64_YMM11 = 379, + CV_AMD64_YMM12 = 380, + CV_AMD64_YMM13 = 381, + CV_AMD64_YMM14 = 382, + CV_AMD64_YMM15 = 383, + + // AVX registers upper 128 bits + CV_AMD64_YMM0H = 384, + CV_AMD64_YMM1H = 385, + CV_AMD64_YMM2H = 386, + CV_AMD64_YMM3H = 387, + CV_AMD64_YMM4H = 388, + CV_AMD64_YMM5H = 389, + CV_AMD64_YMM6H = 390, + CV_AMD64_YMM7H = 391, + CV_AMD64_YMM8H = 392, + CV_AMD64_YMM9H = 393, + CV_AMD64_YMM10H = 394, + CV_AMD64_YMM11H = 395, + CV_AMD64_YMM12H = 396, + CV_AMD64_YMM13H = 397, + CV_AMD64_YMM14H = 398, + CV_AMD64_YMM15H = 399, + + // Lower/upper 8 bytes of XMM registers. Unlike CV_AMD64_XMM, these + // values reprsesent the bit patterns of the registers as 64-bit integers, not + // the representation of these registers as a double. + CV_AMD64_XMM0IL = 400, + CV_AMD64_XMM1IL = 401, + CV_AMD64_XMM2IL = 402, + CV_AMD64_XMM3IL = 403, + CV_AMD64_XMM4IL = 404, + CV_AMD64_XMM5IL = 405, + CV_AMD64_XMM6IL = 406, + CV_AMD64_XMM7IL = 407, + CV_AMD64_XMM8IL = 408, + CV_AMD64_XMM9IL = 409, + CV_AMD64_XMM10IL = 410, + CV_AMD64_XMM11IL = 411, + CV_AMD64_XMM12IL = 412, + CV_AMD64_XMM13IL = 413, + CV_AMD64_XMM14IL = 414, + CV_AMD64_XMM15IL = 415, + + CV_AMD64_XMM0IH = 416, + CV_AMD64_XMM1IH = 417, + CV_AMD64_XMM2IH = 418, + CV_AMD64_XMM3IH = 419, + CV_AMD64_XMM4IH = 420, + CV_AMD64_XMM5IH = 421, + CV_AMD64_XMM6IH = 422, + CV_AMD64_XMM7IH = 423, + CV_AMD64_XMM8IH = 424, + CV_AMD64_XMM9IH = 425, + CV_AMD64_XMM10IH = 426, + CV_AMD64_XMM11IH = 427, + CV_AMD64_XMM12IH = 428, + CV_AMD64_XMM13IH = 429, + CV_AMD64_XMM14IH = 430, + CV_AMD64_XMM15IH = 431, + + // AVX integer registers + CV_AMD64_YMM0I0 = 432, + CV_AMD64_YMM0I1 = 433, + CV_AMD64_YMM0I2 = 434, + CV_AMD64_YMM0I3 = 435, + CV_AMD64_YMM1I0 = 436, + CV_AMD64_YMM1I1 = 437, + CV_AMD64_YMM1I2 = 438, + CV_AMD64_YMM1I3 = 439, + CV_AMD64_YMM2I0 = 440, + CV_AMD64_YMM2I1 = 441, + CV_AMD64_YMM2I2 = 442, + CV_AMD64_YMM2I3 = 443, + CV_AMD64_YMM3I0 = 444, + CV_AMD64_YMM3I1 = 445, + CV_AMD64_YMM3I2 = 446, + CV_AMD64_YMM3I3 = 447, + CV_AMD64_YMM4I0 = 448, + CV_AMD64_YMM4I1 = 449, + CV_AMD64_YMM4I2 = 450, + CV_AMD64_YMM4I3 = 451, + CV_AMD64_YMM5I0 = 452, + CV_AMD64_YMM5I1 = 453, + CV_AMD64_YMM5I2 = 454, + CV_AMD64_YMM5I3 = 455, + CV_AMD64_YMM6I0 = 456, + CV_AMD64_YMM6I1 = 457, + CV_AMD64_YMM6I2 = 458, + CV_AMD64_YMM6I3 = 459, + CV_AMD64_YMM7I0 = 460, + CV_AMD64_YMM7I1 = 461, + CV_AMD64_YMM7I2 = 462, + CV_AMD64_YMM7I3 = 463, + CV_AMD64_YMM8I0 = 464, + CV_AMD64_YMM8I1 = 465, + CV_AMD64_YMM8I2 = 466, + CV_AMD64_YMM8I3 = 467, + CV_AMD64_YMM9I0 = 468, + CV_AMD64_YMM9I1 = 469, + CV_AMD64_YMM9I2 = 470, + CV_AMD64_YMM9I3 = 471, + CV_AMD64_YMM10I0 = 472, + CV_AMD64_YMM10I1 = 473, + CV_AMD64_YMM10I2 = 474, + CV_AMD64_YMM10I3 = 475, + CV_AMD64_YMM11I0 = 476, + CV_AMD64_YMM11I1 = 477, + CV_AMD64_YMM11I2 = 478, + CV_AMD64_YMM11I3 = 479, + CV_AMD64_YMM12I0 = 480, + CV_AMD64_YMM12I1 = 481, + CV_AMD64_YMM12I2 = 482, + CV_AMD64_YMM12I3 = 483, + CV_AMD64_YMM13I0 = 484, + CV_AMD64_YMM13I1 = 485, + CV_AMD64_YMM13I2 = 486, + CV_AMD64_YMM13I3 = 487, + CV_AMD64_YMM14I0 = 488, + CV_AMD64_YMM14I1 = 489, + CV_AMD64_YMM14I2 = 490, + CV_AMD64_YMM14I3 = 491, + CV_AMD64_YMM15I0 = 492, + CV_AMD64_YMM15I1 = 493, + CV_AMD64_YMM15I2 = 494, + CV_AMD64_YMM15I3 = 495, + + // AVX floating-point single precise registers + CV_AMD64_YMM0F0 = 496, + CV_AMD64_YMM0F1 = 497, + CV_AMD64_YMM0F2 = 498, + CV_AMD64_YMM0F3 = 499, + CV_AMD64_YMM0F4 = 500, + CV_AMD64_YMM0F5 = 501, + CV_AMD64_YMM0F6 = 502, + CV_AMD64_YMM0F7 = 503, + CV_AMD64_YMM1F0 = 504, + CV_AMD64_YMM1F1 = 505, + CV_AMD64_YMM1F2 = 506, + CV_AMD64_YMM1F3 = 507, + CV_AMD64_YMM1F4 = 508, + CV_AMD64_YMM1F5 = 509, + CV_AMD64_YMM1F6 = 510, + CV_AMD64_YMM1F7 = 511, + CV_AMD64_YMM2F0 = 512, + CV_AMD64_YMM2F1 = 513, + CV_AMD64_YMM2F2 = 514, + CV_AMD64_YMM2F3 = 515, + CV_AMD64_YMM2F4 = 516, + CV_AMD64_YMM2F5 = 517, + CV_AMD64_YMM2F6 = 518, + CV_AMD64_YMM2F7 = 519, + CV_AMD64_YMM3F0 = 520, + CV_AMD64_YMM3F1 = 521, + CV_AMD64_YMM3F2 = 522, + CV_AMD64_YMM3F3 = 523, + CV_AMD64_YMM3F4 = 524, + CV_AMD64_YMM3F5 = 525, + CV_AMD64_YMM3F6 = 526, + CV_AMD64_YMM3F7 = 527, + CV_AMD64_YMM4F0 = 528, + CV_AMD64_YMM4F1 = 529, + CV_AMD64_YMM4F2 = 530, + CV_AMD64_YMM4F3 = 531, + CV_AMD64_YMM4F4 = 532, + CV_AMD64_YMM4F5 = 533, + CV_AMD64_YMM4F6 = 534, + CV_AMD64_YMM4F7 = 535, + CV_AMD64_YMM5F0 = 536, + CV_AMD64_YMM5F1 = 537, + CV_AMD64_YMM5F2 = 538, + CV_AMD64_YMM5F3 = 539, + CV_AMD64_YMM5F4 = 540, + CV_AMD64_YMM5F5 = 541, + CV_AMD64_YMM5F6 = 542, + CV_AMD64_YMM5F7 = 543, + CV_AMD64_YMM6F0 = 544, + CV_AMD64_YMM6F1 = 545, + CV_AMD64_YMM6F2 = 546, + CV_AMD64_YMM6F3 = 547, + CV_AMD64_YMM6F4 = 548, + CV_AMD64_YMM6F5 = 549, + CV_AMD64_YMM6F6 = 550, + CV_AMD64_YMM6F7 = 551, + CV_AMD64_YMM7F0 = 552, + CV_AMD64_YMM7F1 = 553, + CV_AMD64_YMM7F2 = 554, + CV_AMD64_YMM7F3 = 555, + CV_AMD64_YMM7F4 = 556, + CV_AMD64_YMM7F5 = 557, + CV_AMD64_YMM7F6 = 558, + CV_AMD64_YMM7F7 = 559, + CV_AMD64_YMM8F0 = 560, + CV_AMD64_YMM8F1 = 561, + CV_AMD64_YMM8F2 = 562, + CV_AMD64_YMM8F3 = 563, + CV_AMD64_YMM8F4 = 564, + CV_AMD64_YMM8F5 = 565, + CV_AMD64_YMM8F6 = 566, + CV_AMD64_YMM8F7 = 567, + CV_AMD64_YMM9F0 = 568, + CV_AMD64_YMM9F1 = 569, + CV_AMD64_YMM9F2 = 570, + CV_AMD64_YMM9F3 = 571, + CV_AMD64_YMM9F4 = 572, + CV_AMD64_YMM9F5 = 573, + CV_AMD64_YMM9F6 = 574, + CV_AMD64_YMM9F7 = 575, + CV_AMD64_YMM10F0 = 576, + CV_AMD64_YMM10F1 = 577, + CV_AMD64_YMM10F2 = 578, + CV_AMD64_YMM10F3 = 579, + CV_AMD64_YMM10F4 = 580, + CV_AMD64_YMM10F5 = 581, + CV_AMD64_YMM10F6 = 582, + CV_AMD64_YMM10F7 = 583, + CV_AMD64_YMM11F0 = 584, + CV_AMD64_YMM11F1 = 585, + CV_AMD64_YMM11F2 = 586, + CV_AMD64_YMM11F3 = 587, + CV_AMD64_YMM11F4 = 588, + CV_AMD64_YMM11F5 = 589, + CV_AMD64_YMM11F6 = 590, + CV_AMD64_YMM11F7 = 591, + CV_AMD64_YMM12F0 = 592, + CV_AMD64_YMM12F1 = 593, + CV_AMD64_YMM12F2 = 594, + CV_AMD64_YMM12F3 = 595, + CV_AMD64_YMM12F4 = 596, + CV_AMD64_YMM12F5 = 597, + CV_AMD64_YMM12F6 = 598, + CV_AMD64_YMM12F7 = 599, + CV_AMD64_YMM13F0 = 600, + CV_AMD64_YMM13F1 = 601, + CV_AMD64_YMM13F2 = 602, + CV_AMD64_YMM13F3 = 603, + CV_AMD64_YMM13F4 = 604, + CV_AMD64_YMM13F5 = 605, + CV_AMD64_YMM13F6 = 606, + CV_AMD64_YMM13F7 = 607, + CV_AMD64_YMM14F0 = 608, + CV_AMD64_YMM14F1 = 609, + CV_AMD64_YMM14F2 = 610, + CV_AMD64_YMM14F3 = 611, + CV_AMD64_YMM14F4 = 612, + CV_AMD64_YMM14F5 = 613, + CV_AMD64_YMM14F6 = 614, + CV_AMD64_YMM14F7 = 615, + CV_AMD64_YMM15F0 = 616, + CV_AMD64_YMM15F1 = 617, + CV_AMD64_YMM15F2 = 618, + CV_AMD64_YMM15F3 = 619, + CV_AMD64_YMM15F4 = 620, + CV_AMD64_YMM15F5 = 621, + CV_AMD64_YMM15F6 = 622, + CV_AMD64_YMM15F7 = 623, + + // AVX floating-point double precise registers + CV_AMD64_YMM0D0 = 624, + CV_AMD64_YMM0D1 = 625, + CV_AMD64_YMM0D2 = 626, + CV_AMD64_YMM0D3 = 627, + CV_AMD64_YMM1D0 = 628, + CV_AMD64_YMM1D1 = 629, + CV_AMD64_YMM1D2 = 630, + CV_AMD64_YMM1D3 = 631, + CV_AMD64_YMM2D0 = 632, + CV_AMD64_YMM2D1 = 633, + CV_AMD64_YMM2D2 = 634, + CV_AMD64_YMM2D3 = 635, + CV_AMD64_YMM3D0 = 636, + CV_AMD64_YMM3D1 = 637, + CV_AMD64_YMM3D2 = 638, + CV_AMD64_YMM3D3 = 639, + CV_AMD64_YMM4D0 = 640, + CV_AMD64_YMM4D1 = 641, + CV_AMD64_YMM4D2 = 642, + CV_AMD64_YMM4D3 = 643, + CV_AMD64_YMM5D0 = 644, + CV_AMD64_YMM5D1 = 645, + CV_AMD64_YMM5D2 = 646, + CV_AMD64_YMM5D3 = 647, + CV_AMD64_YMM6D0 = 648, + CV_AMD64_YMM6D1 = 649, + CV_AMD64_YMM6D2 = 650, + CV_AMD64_YMM6D3 = 651, + CV_AMD64_YMM7D0 = 652, + CV_AMD64_YMM7D1 = 653, + CV_AMD64_YMM7D2 = 654, + CV_AMD64_YMM7D3 = 655, + CV_AMD64_YMM8D0 = 656, + CV_AMD64_YMM8D1 = 657, + CV_AMD64_YMM8D2 = 658, + CV_AMD64_YMM8D3 = 659, + CV_AMD64_YMM9D0 = 660, + CV_AMD64_YMM9D1 = 661, + CV_AMD64_YMM9D2 = 662, + CV_AMD64_YMM9D3 = 663, + CV_AMD64_YMM10D0 = 664, + CV_AMD64_YMM10D1 = 665, + CV_AMD64_YMM10D2 = 666, + CV_AMD64_YMM10D3 = 667, + CV_AMD64_YMM11D0 = 668, + CV_AMD64_YMM11D1 = 669, + CV_AMD64_YMM11D2 = 670, + CV_AMD64_YMM11D3 = 671, + CV_AMD64_YMM12D0 = 672, + CV_AMD64_YMM12D1 = 673, + CV_AMD64_YMM12D2 = 674, + CV_AMD64_YMM12D3 = 675, + CV_AMD64_YMM13D0 = 676, + CV_AMD64_YMM13D1 = 677, + CV_AMD64_YMM13D2 = 678, + CV_AMD64_YMM13D3 = 679, + CV_AMD64_YMM14D0 = 680, + CV_AMD64_YMM14D1 = 681, + CV_AMD64_YMM14D2 = 682, + CV_AMD64_YMM14D3 = 683, + CV_AMD64_YMM15D0 = 684, + CV_AMD64_YMM15D1 = 685, + CV_AMD64_YMM15D2 = 686, + CV_AMD64_YMM15D3 = 687, + } + + public enum CodeViewSymbolDefinition : ushort + { + S_COMPILE = 0x0001, // Compile flags symbol + S_REGISTER_16t = 0x0002, // Register variable + S_CONSTANT_16t = 0x0003, // constant symbol + S_UDT_16t = 0x0004, // User defined type + S_SSEARCH = 0x0005, // Start Search + S_END = 0x0006, // Block, procedure, "with" or thunk end + S_SKIP = 0x0007, // Reserve symbol space in $$Symbols table + S_CVRESERVE = 0x0008, // Reserved symbol for CV internal use + S_OBJNAME_ST = 0x0009, // path to object file name + S_ENDARG = 0x000a, // end of argument/return list + S_COBOLUDT_16t = 0x000b, // special UDT for cobol that does not symbol pack + S_MANYREG_16t = 0x000c, // multiple register variable + S_RETURN = 0x000d, // return description symbol + S_ENTRYTHIS = 0x000e, // description of this pointer on entry + + S_BPREL16 = 0x0100, // BP-relative + S_LDATA16 = 0x0101, // Module-local symbol + S_GDATA16 = 0x0102, // Global data symbol + S_PUB16 = 0x0103, // a public symbol + S_LPROC16 = 0x0104, // Local procedure start + S_GPROC16 = 0x0105, // Global procedure start + S_THUNK16 = 0x0106, // Thunk Start + S_BLOCK16 = 0x0107, // block start + S_WITH16 = 0x0108, // with start + S_LABEL16 = 0x0109, // code label + S_CEXMODEL16 = 0x010a, // change execution model + S_VFTABLE16 = 0x010b, // address of virtual function table + S_REGREL16 = 0x010c, // register relative address + + S_BPREL32_16t = 0x0200, // BP-relative + S_LDATA32_16t = 0x0201, // Module-local symbol + S_GDATA32_16t = 0x0202, // Global data symbol + S_PUB32_16t = 0x0203, // a public symbol (CV internal reserved) + S_LPROC32_16t = 0x0204, // Local procedure start + S_GPROC32_16t = 0x0205, // Global procedure start + S_THUNK32_ST = 0x0206, // Thunk Start + S_BLOCK32_ST = 0x0207, // block start + S_WITH32_ST = 0x0208, // with start + S_LABEL32_ST = 0x0209, // code label + S_CEXMODEL32 = 0x020a, // change execution model + S_VFTABLE32_16t = 0x020b, // address of virtual function table + S_REGREL32_16t = 0x020c, // register relative address + S_LTHREAD32_16t = 0x020d, // local thread storage + S_GTHREAD32_16t = 0x020e, // global thread storage + S_SLINK32 = 0x020f, // static link for MIPS EH implementation + + S_LPROCMIPS_16t = 0x0300, // Local procedure start + S_GPROCMIPS_16t = 0x0301, // Global procedure start + + // if these ref symbols have names following then the names are in ST format + S_PROCREF_ST = 0x0400, // Reference to a procedure + S_DATAREF_ST = 0x0401, // Reference to data + S_ALIGN = 0x0402, // Used for page alignment of symbols + + S_LPROCREF_ST = 0x0403, // Local Reference to a procedure + S_OEM = 0x0404, // OEM defined symbol + + // sym records with 32-bit types embedded instead of 16-bit + // all have 0x1000 bit set for easy identification + // only do the 32-bit target versions since we don't really + // care about 16-bit ones anymore. + S_TI16_MAX = 0x1000, + + S_REGISTER_ST = 0x1001, // Register variable + S_CONSTANT_ST = 0x1002, // constant symbol + S_UDT_ST = 0x1003, // User defined type + S_COBOLUDT_ST = 0x1004, // special UDT for cobol that does not symbol pack + S_MANYREG_ST = 0x1005, // multiple register variable + S_BPREL32_ST = 0x1006, // BP-relative + S_LDATA32_ST = 0x1007, // Module-local symbol + S_GDATA32_ST = 0x1008, // Global data symbol + S_PUB32_ST = 0x1009, // a public symbol (CV internal reserved) + S_LPROC32_ST = 0x100a, // Local procedure start + S_GPROC32_ST = 0x100b, // Global procedure start + S_VFTABLE32 = 0x100c, // address of virtual function table + S_REGREL32_ST = 0x100d, // register relative address + S_LTHREAD32_ST = 0x100e, // local thread storage + S_GTHREAD32_ST = 0x100f, // global thread storage + + S_LPROCMIPS_ST = 0x1010, // Local procedure start + S_GPROCMIPS_ST = 0x1011, // Global procedure start + + S_FRAMEPROC = 0x1012, // extra frame and proc information + S_COMPILE2_ST = 0x1013, // extended compile flags and info + + // New symbols necessary for 16-bit enumerates of IA64 registers + // and IA64 specific symbols + S_MANYREG2_ST = 0x1014, // multiple register variable + S_LPROCIA64_ST = 0x1015, // Local procedure start (IA64) + S_GPROCIA64_ST = 0x1016, // Global procedure start (IA64) + + // Local symbols for IL + S_LOCALSLOT_ST = 0x1017, // local IL sym with field for local slot index + S_PARAMSLOT_ST = 0x1018, // local IL sym with field for parameter slot index + + S_ANNOTATION = 0x1019, // Annotation string literals + + // Symbols to support managed code debugging + S_GMANPROC_ST = 0x101a, // Global proc + S_LMANPROC_ST = 0x101b, // Local proc + S_RESERVED1 = 0x101c, // reserved + S_RESERVED2 = 0x101d, // reserved + S_RESERVED3 = 0x101e, // reserved + S_RESERVED4 = 0x101f, // reserved + S_LMANDATA_ST = 0x1020, + S_GMANDATA_ST = 0x1021, + S_MANFRAMEREL_ST = 0x1022, + S_MANREGISTER_ST = 0x1023, + S_MANSLOT_ST = 0x1024, + S_MANMANYREG_ST = 0x1025, + S_MANREGREL_ST = 0x1026, + S_MANMANYREG2_ST = 0x1027, + S_MANTYPREF = 0x1028, // Index for type referenced by name from metadata + S_UNAMESPACE_ST = 0x1029, // Using namespace + + // Symbols w/ SZ name fields. All name fields contain utf8 encoded strings. + S_ST_MAX = 0x1100, // starting point for SZ name symbols + + S_OBJNAME = 0x1101, // path to object file name + S_THUNK32 = 0x1102, // Thunk Start + S_BLOCK32 = 0x1103, // block start + S_WITH32 = 0x1104, // with start + S_LABEL32 = 0x1105, // code label + S_REGISTER = 0x1106, // Register variable + S_CONSTANT = 0x1107, // constant symbol + S_UDT = 0x1108, // User defined type + S_COBOLUDT = 0x1109, // special UDT for cobol that does not symbol pack + S_MANYREG = 0x110a, // multiple register variable + S_BPREL32 = 0x110b, // BP-relative + S_LDATA32 = 0x110c, // Module-local symbol + S_GDATA32 = 0x110d, // Global data symbol + S_PUB32 = 0x110e, // a public symbol (CV internal reserved) + S_LPROC32 = 0x110f, // Local procedure start + S_GPROC32 = 0x1110, // Global procedure start + S_REGREL32 = 0x1111, // register relative address + S_LTHREAD32 = 0x1112, // local thread storage + S_GTHREAD32 = 0x1113, // global thread storage + + S_LPROCMIPS = 0x1114, // Local procedure start + S_GPROCMIPS = 0x1115, // Global procedure start + S_COMPILE2 = 0x1116, // extended compile flags and info + S_MANYREG2 = 0x1117, // multiple register variable + S_LPROCIA64 = 0x1118, // Local procedure start (IA64) + S_GPROCIA64 = 0x1119, // Global procedure start (IA64) + S_LOCALSLOT = 0x111a, // local IL sym with field for local slot index + S_SLOT = S_LOCALSLOT, // alias for LOCALSLOT + S_PARAMSLOT = 0x111b, // local IL sym with field for parameter slot index + + // symbols to support managed code debugging + S_LMANDATA = 0x111c, + S_GMANDATA = 0x111d, + S_MANFRAMEREL = 0x111e, + S_MANREGISTER = 0x111f, + S_MANSLOT = 0x1120, + S_MANMANYREG = 0x1121, + S_MANREGREL = 0x1122, + S_MANMANYREG2 = 0x1123, + S_UNAMESPACE = 0x1124, // Using namespace + + // ref symbols with name fields + S_PROCREF = 0x1125, // Reference to a procedure + S_DATAREF = 0x1126, // Reference to data + S_LPROCREF = 0x1127, // Local Reference to a procedure + S_ANNOTATIONREF = 0x1128, // Reference to an S_ANNOTATION symbol + S_TOKENREF = 0x1129, // Reference to one of the many MANPROCSYM's + + // continuation of managed symbols + S_GMANPROC = 0x112a, // Global proc + S_LMANPROC = 0x112b, // Local proc + + // short, light-weight thunks + S_TRAMPOLINE = 0x112c, // trampoline thunks + S_MANCONSTANT = 0x112d, // constants with metadata type info + + // native attributed local/parms + S_ATTR_FRAMEREL = 0x112e, // relative to virtual frame ptr + S_ATTR_REGISTER = 0x112f, // stored in a register + S_ATTR_REGREL = 0x1130, // relative to register (alternate frame ptr) + S_ATTR_MANYREG = 0x1131, // stored in >1 register + + // Separated code (from the compiler) support + S_SEPCODE = 0x1132, + + S_LOCAL_2005 = 0x1133, // defines a local symbol in optimized code + S_DEFRANGE_2005 = 0x1134, // defines a single range of addresses in which symbol can be evaluated + S_DEFRANGE2_2005 = 0x1135, // defines ranges of addresses in which symbol can be evaluated + + S_SECTION = 0x1136, // A COFF section in a PE executable + S_COFFGROUP = 0x1137, // A COFF group + S_EXPORT = 0x1138, // A export + + S_CALLSITEINFO = 0x1139, // Indirect call site information + S_FRAMECOOKIE = 0x113a, // Security cookie information + + S_DISCARDED = 0x113b, // Discarded by LINK /OPT:REF (experimental, see richards) + + S_COMPILE3 = 0x113c, // Replacement for S_COMPILE2 + S_ENVBLOCK = 0x113d, // Environment block split off from S_COMPILE2 + + S_LOCAL = 0x113e, // defines a local symbol in optimized code + S_DEFRANGE = 0x113f, // defines a single range of addresses in which symbol can be evaluated + S_DEFRANGE_SUBFIELD = 0x1140, // ranges for a subfield + + S_DEFRANGE_REGISTER = 0x1141, // ranges for en-registered symbol + S_DEFRANGE_FRAMEPOINTER_REL = 0x1142, // range for stack symbol. + S_DEFRANGE_SUBFIELD_REGISTER = 0x1143, // ranges for en-registered field of symbol + S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144, // range for stack symbol span valid full scope of function body, gap might apply. + S_DEFRANGE_REGISTER_REL = 0x1145, // range for symbol address as register + offset. + + // S_PROC symbols that reference ID instead of type + S_LPROC32_ID = 0x1146, + S_GPROC32_ID = 0x1147, + S_LPROCMIPS_ID = 0x1148, + S_GPROCMIPS_ID = 0x1149, + S_LPROCIA64_ID = 0x114a, + S_GPROCIA64_ID = 0x114b, + + S_BUILDINFO = 0x114c, // build information. + S_INLINESITE = 0x114d, // inlined function callsite. + S_INLINESITE_END = 0x114e, + S_PROC_ID_END = 0x114f, + + S_DEFRANGE_HLSL = 0x1150, + S_GDATA_HLSL = 0x1151, + S_LDATA_HLSL = 0x1152, + + S_FILESTATIC = 0x1153, + + S_ARMSWITCHTABLE = 0x1159, + S_CALLEES = 0x115a, + S_CALLERS = 0x115b, + S_POGODATA = 0x115c, + S_INLINESITE2 = 0x115d, // extended inline site information + + S_HEAPALLOCSITE = 0x115e, // heap allocation site + + S_MOD_TYPEREF = 0x115f, // only generated at link time + + S_REF_MINIPDB = 0x1160, // only generated at link time for mini PDB + S_PDBMAP = 0x1161, // only generated at link time for mini PDB + + S_GDATA_HLSL32 = 0x1162, + S_LDATA_HLSL32 = 0x1163, + + S_GDATA_HLSL32_EX = 0x1164, + S_LDATA_HLSL32_EX = 0x1165, } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index e605391d7b3771..f1afb8f9488bc2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -15,6 +15,8 @@ using Internal.TypeSystem.TypesDebugInfo; using static ILCompiler.ObjectWriter.CodeViewNative; +using static ILCompiler.ObjectWriter.CodeViewNative.CodeViewRegister; +using static ILCompiler.ObjectWriter.CodeViewNative.CodeViewSymbolDefinition; namespace ILCompiler.ObjectWriter { @@ -36,7 +38,7 @@ public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, SectionWrit // Maps an ICorDebugInfo register number to the corresponding CodeView // register number - private ushort GetCVRegNum(uint regNum) + private CodeViewRegister GetCVRegNum(uint regNum) { switch (_targetArchitecture) { @@ -79,7 +81,7 @@ public void EmitSubprogramInfo( { using var symbolSubsection = GetSubsection(DebugSymbolsSubsectionType.Symbols); - using (var recordWriter = symbolSubsection.StartRecord(0x1147 /* S_GPROC32_ID */)) + using (var recordWriter = symbolSubsection.StartRecord(S_GPROC32_ID)) { recordWriter.Write((uint)0); // pointer to the parent recordWriter.Write((uint)0); // pointer to this blocks end @@ -96,7 +98,7 @@ public void EmitSubprogramInfo( foreach (var (debugVar, typeIndex) in debugVars) { - using (var recordWriter = symbolSubsection.StartRecord(0x113e /* S_LOCAL */)) + using (var recordWriter = symbolSubsection.StartRecord(S_LOCAL)) { recordWriter.Write(typeIndex); recordWriter.Write((ushort)(debugVar.IsParameter ? 1 : 0)); // TODO: Flags @@ -109,10 +111,10 @@ public void EmitSubprogramInfo( { case VarLocType.VLT_REG: case VarLocType.VLT_REG_FP: - var cvRegNum = GetCVRegNum((uint)range.VarLoc.B); + CodeViewRegister cvRegNum = GetCVRegNum((uint)range.VarLoc.B); if (cvRegNum != CV_REG_NONE) { - using (var recordWriter = symbolSubsection.StartRecord(0x1141 /* S_DEFRANGE_REGISTER */)) + using (var recordWriter = symbolSubsection.StartRecord(S_DEFRANGE_REGISTER)) { recordWriter.Write((ushort)cvRegNum); recordWriter.Write((ushort)0); // TODO: Attributes @@ -128,7 +130,7 @@ public void EmitSubprogramInfo( cvRegNum = GetCVRegNum((uint)range.VarLoc.B); if (cvRegNum != CV_REG_NONE) { - using (var recordWriter = symbolSubsection.StartRecord(0x1145 /* S_DEFRANGE_REGISTER_REL */)) + using (var recordWriter = symbolSubsection.StartRecord(S_DEFRANGE_REGISTER_REL)) { recordWriter.Write((ushort)cvRegNum); // TODO: Flags, CV_OFFSET_PARENT_LENGTH_LIMIT @@ -158,7 +160,7 @@ public void EmitSubprogramInfo( } } - using (var recordWriter = symbolSubsection.StartRecord(0x114f /* S_PROC_ID_END */)) + using (var recordWriter = symbolSubsection.StartRecord(S_PROC_ID_END)) { } } @@ -224,7 +226,7 @@ public void WriteUserDefinedTypes(IList<(string, uint)> userDefinedTypes) using var symbolSubsection = GetSubsection(DebugSymbolsSubsectionType.Symbols); foreach (var (name, typeIndex) in userDefinedTypes) { - using (var recordWriter = symbolSubsection.StartRecord(0x1108 /* S_UDT */)) + using (var recordWriter = symbolSubsection.StartRecord(S_UDT)) { recordWriter.Write(typeIndex); recordWriter.Write(name); @@ -244,8 +246,6 @@ private sealed class SubsectionWriter : IDisposable internal uint _size; internal List _data = new(); internal List<(uint, RelocType, string)> _relocations = new(); - private ArrayBufferWriter _bufferWriter = new(); - internal bool _needLengthPrefix; public SubsectionWriter(DebugSymbolsSubsectionType kind, SectionWriter sectionWriter) { @@ -280,50 +280,45 @@ public void Dispose() public RecordWriter StartRecord() { - _needLengthPrefix = false; - return new RecordWriter(this, _bufferWriter); + return new RecordWriter(this, false); } - public RecordWriter StartRecord(ushort recordType) + public RecordWriter StartRecord(CodeViewSymbolDefinition recordType) { - RecordWriter writer = new RecordWriter(this, _bufferWriter); - writer.Write(recordType); - _needLengthPrefix = true; + RecordWriter writer = new RecordWriter(this, true); + writer.Write((ushort)recordType); return writer; } - - internal void CommitRecord() - { - if (_needLengthPrefix) - { - byte[] lengthBuffer = new byte[sizeof(ushort)]; - BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(_bufferWriter.WrittenCount)); - _data.Add(lengthBuffer); - _size += sizeof(ushort); - } - - // Add data - _data.Add(_bufferWriter.WrittenSpan.ToArray()); - _size += (uint)_bufferWriter.WrittenCount; - - _bufferWriter.Clear(); - } } private ref struct RecordWriter { private SubsectionWriter _subsectionWriter; private ArrayBufferWriter _bufferWriter; + private bool _hasLengthPrefix; - public RecordWriter(SubsectionWriter subsectionWriter, ArrayBufferWriter bufferWriter) + public RecordWriter(SubsectionWriter subsectionWriter, bool hasLengthPrefix) { _subsectionWriter = subsectionWriter; - _bufferWriter = bufferWriter; + _bufferWriter = new(); + _hasLengthPrefix = hasLengthPrefix; } public void Dispose() { - _subsectionWriter.CommitRecord(); + if (_hasLengthPrefix) + { + byte[] lengthBuffer = new byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(_bufferWriter.WrittenCount)); + _subsectionWriter._data.Add(lengthBuffer); + _subsectionWriter._size += sizeof(ushort); + } + + // Add data + _subsectionWriter._data.Add(_bufferWriter.WrittenSpan.ToArray()); + _subsectionWriter._size += (uint)_bufferWriter.WrittenCount; + + _bufferWriter.Clear(); } public void Write(byte value) @@ -364,7 +359,7 @@ public void EmitSymbolReference( { _subsectionWriter._relocations.Add(( _subsectionWriter._size + - (uint)(_subsectionWriter._needLengthPrefix ? sizeof(ushort) : 0) + + (uint)(_hasLengthPrefix ? sizeof(ushort) : 0) + (uint)_bufferWriter.WrittenCount, relocType, symbolName)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index 942b19b7648afc..679ec08952a21a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -15,6 +15,10 @@ using Internal.TypeSystem.TypesDebugInfo; using static ILCompiler.ObjectWriter.CodeViewNative; +using static ILCompiler.ObjectWriter.CodeViewNative.CodeViewPointer; +using static ILCompiler.ObjectWriter.CodeViewNative.CodeViewPropertyFlags; +using static ILCompiler.ObjectWriter.CodeViewNative.CodeViewType; +using static ILCompiler.ObjectWriter.CodeViewNative.LeafRecordType; namespace ILCompiler.ObjectWriter { @@ -30,7 +34,6 @@ internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter private List<(string, uint)> _userDefinedTypes = new(); private uint _nextTypeIndex = 0x1000; - private ArrayBufferWriter _bufferWriter = new(); public IList<(string, uint)> UserDefinedTypes => _userDefinedTypes; @@ -55,16 +58,16 @@ public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetAr // We use the same "Vtable" for all types because the vtable shape debug // record is not expressive enough to capture our vtable shape (where the // vtable slots don't start at the beginning of the vtable). - using (var record = StartLeafRecord(LeafRecordType.VTShape)) + using (LeafRecordWriter record = StartLeafRecord(LF_VTSHAPE)) { record.Write((ushort)0); // Number of entries in vfunctable } _classVTableTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LeafRecordType.Pointer)) + using (LeafRecordWriter record = StartLeafRecord(LF_POINTER)) { record.Write(_classVTableTypeIndex); - record.Write((uint)((_targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | (CV_PTR_MODE_LVREF << 5))); + record.Write((uint)((_targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | CV_PTR_MODE_LVREF)); } _vfuncTabTypeIndex = _nextTypeIndex++; } @@ -78,7 +81,7 @@ public uint GetPrimitiveTypeIndex(TypeDesc type) private uint GetPrimitiveTypeIndex(TypeFlags typeFlags) { // CodeView uses predefined codes for simple types - return typeFlags switch + return (uint)(typeFlags switch { TypeFlags.Boolean => T_BOOL08, TypeFlags.Char => T_WCHAR, @@ -95,20 +98,18 @@ private uint GetPrimitiveTypeIndex(TypeFlags typeFlags) TypeFlags.Single => T_REAL32, TypeFlags.Double => T_REAL64, _ => T_NOTYPE, - }; + }); } public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) { - uint elementType = pointerDescriptor.ElementType; - uint pointerKind = pointerDescriptor.Is64Bit == 1 ? CV_PTR_64 : CV_PTR_NEAR32; - uint pointerMode = pointerDescriptor.IsReference == 1 ? CV_PTR_MODE_LVREF : CV_PTR_MODE_PTR; - //ushort pointerOptions = pointerDescriptor.IsConst ? MOD_const : MOD_none; - - using (var record = StartLeafRecord(LeafRecordType.Pointer)) + using (LeafRecordWriter record = StartLeafRecord(LF_POINTER)) { - record.Write(elementType); - record.Write((uint)(pointerKind | (pointerMode << 5))); // TODO: pointerOptions + record.Write(pointerDescriptor.ElementType); + record.Write((uint)( + (pointerDescriptor.Is64Bit == 1 ? CV_PTR_64 : CV_PTR_NEAR32) | + (pointerDescriptor.IsReference == 1 ? CV_PTR_MODE_LVREF : CV_PTR_MODE_PTR) | + (pointerDescriptor.IsConst == 1 ? CV_PTR_IS_CONST : 0))); } return _nextTypeIndex++; @@ -121,7 +122,7 @@ public uint GetArrayTypeIndex( uint memberCount = 0; uint offset = 0; - using (var arrayRecord = StartLeafRecord(LeafRecordType.Array)) + using (LeafRecordWriter arrayRecord = StartLeafRecord(LF_ARRAY)) { arrayRecord.Write(arrayDescriptor.ElementType); arrayRecord.Write(T_INT4); @@ -131,11 +132,11 @@ public uint GetArrayTypeIndex( uint arrayRecordTypeIndex = _nextTypeIndex++; - using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) + using (LeafRecordWriter fieldListRecord = StartLeafRecord(LF_FIELDLIST)) { if (classDescriptor.BaseClassId != 0) { - fieldListRecord.Write((ushort)LeafRecordType.BaseClass); + fieldListRecord.Write((ushort)LF_BCLASS); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset @@ -144,7 +145,7 @@ public uint GetArrayTypeIndex( offset += (uint)_targetPointerSize; } - fieldListRecord.Write((ushort)LeafRecordType.Member); + fieldListRecord.Write((ushort)LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -157,7 +158,7 @@ public uint GetArrayTypeIndex( { for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write((ushort)LeafRecordType.Member); + fieldListRecord.Write((ushort)LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -169,7 +170,7 @@ public uint GetArrayTypeIndex( for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write((ushort)LeafRecordType.Member); + fieldListRecord.Write((ushort)LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); @@ -180,7 +181,7 @@ public uint GetArrayTypeIndex( } } - fieldListRecord.Write((ushort)LeafRecordType.Member); + fieldListRecord.Write((ushort)LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(arrayRecordTypeIndex); fieldListRecord.WriteEncodedInteger(offset); @@ -192,7 +193,7 @@ public uint GetArrayTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; Debug.Assert(classDescriptor.IsStruct == 0); - using (var record = StartLeafRecord(LeafRecordType.Class)) + using (LeafRecordWriter record = StartLeafRecord(LF_CLASS)) { record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options @@ -213,11 +214,11 @@ public uint GetEnumTypeIndex( EnumTypeDescriptor typeDescriptor, EnumRecordTypeDescriptor[] typeRecords) { - using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) + using (LeafRecordWriter fieldListRecord = StartLeafRecord(LF_FIELDLIST)) { foreach (EnumRecordTypeDescriptor record in typeRecords) { - fieldListRecord.Write((ushort)LeafRecordType.Enumerate); + fieldListRecord.Write((ushort)LF_ENUMERATE); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.WriteEncodedInteger(record.Value); fieldListRecord.Write(record.Name); @@ -227,7 +228,7 @@ public uint GetEnumTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LeafRecordType.Enum)) + using (LeafRecordWriter record = StartLeafRecord(LF_ENUM)) { record.Write((ushort)typeRecords.Length); // Number of elements in class record.Write((ushort)0); // TODO: Attributes @@ -244,7 +245,7 @@ public uint GetEnumTypeIndex( public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) { - using (var record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LeafRecordType.Structure : LeafRecordType.Class)) + using (LeafRecordWriter record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) { record.Write((ushort)0); // Number of elements in class record.Write((ushort)CV_PROP_FORWARD_REFERENCE); @@ -266,11 +267,11 @@ public uint GetCompleteClassTypeIndex( { uint memberCount = 0; - using (var fieldListRecord = StartLeafRecord(LeafRecordType.FieldList)) + using (LeafRecordWriter fieldListRecord = StartLeafRecord(LF_FIELDLIST)) { if (classTypeDescriptor.BaseClassId != 0) { - fieldListRecord.Write((ushort)LeafRecordType.BaseClass); + fieldListRecord.Write((ushort)LF_BCLASS); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classTypeDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset @@ -279,7 +280,7 @@ public uint GetCompleteClassTypeIndex( } else if (classTypeDescriptor.IsStruct == 0) { - fieldListRecord.Write((ushort)LeafRecordType.VFunctionTable); + fieldListRecord.Write((ushort)LF_VFUNCTAB); fieldListRecord.Write((ushort)0); // Padding fieldListRecord.Write(_vfuncTabTypeIndex); fieldListRecord.WritePadding(); @@ -290,14 +291,14 @@ public uint GetCompleteClassTypeIndex( { if (desc.Offset == 0xFFFFFFFF) { - fieldListRecord.Write((ushort)LeafRecordType.StaticMember); + fieldListRecord.Write((ushort)LF_STMEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.Write(desc.Name); } else { - fieldListRecord.Write((ushort)LeafRecordType.Member); + fieldListRecord.Write((ushort)LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.WriteEncodedInteger(desc.Offset); @@ -310,7 +311,7 @@ public uint GetCompleteClassTypeIndex( uint fieldListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LeafRecordType.Structure : LeafRecordType.Class)) + using (LeafRecordWriter record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) { record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options @@ -329,7 +330,7 @@ public uint GetCompleteClassTypeIndex( public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) { - using (var fieldListRecord = StartLeafRecord(LeafRecordType.ArgList)) + using (LeafRecordWriter fieldListRecord = StartLeafRecord(LF_ARGLIST)) { fieldListRecord.Write((uint)argumentTypes.Length); foreach (uint argumentType in argumentTypes) @@ -340,7 +341,7 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri uint argumentListTypeIndex = _nextTypeIndex++; - using (var record = StartLeafRecord(LeafRecordType.MemberFunction)) + using (LeafRecordWriter record = StartLeafRecord(LF_MFUNCTION)) { record.Write(memberDescriptor.ReturnType); record.Write(memberDescriptor.ContainingClass); @@ -357,7 +358,7 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor) { - using (var record = StartLeafRecord(LeafRecordType.MemberFunctionId)) + using (LeafRecordWriter record = StartLeafRecord(LF_MFUNC_ID)) { record.Write(memberIdDescriptor.ParentClass); record.Write(memberIdDescriptor.MemberFunction); @@ -374,20 +375,20 @@ public string GetMangledName(TypeDesc type) private LeafRecordWriter StartLeafRecord(LeafRecordType leafRecordType) { - LeafRecordWriter writer = new LeafRecordWriter(_bufferWriter, _outputStream); + LeafRecordWriter writer = new LeafRecordWriter(this); writer.Write((ushort)leafRecordType); return writer; } private ref struct LeafRecordWriter { + private CodeViewTypesBuilder _debugTypesBuilder; private ArrayBufferWriter _bufferWriter; - private Stream _outputStream; - public LeafRecordWriter(ArrayBufferWriter bufferWriter, Stream outputStream) + public LeafRecordWriter(CodeViewTypesBuilder debugTypesBuilder) { - _bufferWriter = bufferWriter; - _outputStream = outputStream; + _debugTypesBuilder = debugTypesBuilder; + _bufferWriter = new(); } public void Dispose() @@ -396,9 +397,9 @@ public void Dispose() int padding = ((length + 3) & ~3) - length; Span lengthBuffer = stackalloc byte[sizeof(ushort)]; BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); - _outputStream.Write(lengthBuffer); - _outputStream.Write(_bufferWriter.WrittenSpan); - _outputStream.Write(stackalloc byte[padding]); + _debugTypesBuilder._outputStream.Write(lengthBuffer); + _debugTypesBuilder._outputStream.Write(_bufferWriter.WrittenSpan); + _debugTypesBuilder._outputStream.Write(stackalloc byte[padding]); _bufferWriter.Clear(); // TODO: LeafRecordType.Index for long records @@ -437,23 +438,23 @@ public void Write(string value) public void WriteEncodedInteger(ulong value) { - if (value < (ushort)LeafRecordType.Numeric) + if (value < (ushort)LF_NUMERIC) { Write((ushort)value); } else if (value <= ushort.MaxValue) { - Write((ushort)LeafRecordType.UShort); + Write((ushort)LF_USHORT); Write((ushort)value); } else if (value <= uint.MaxValue) { - Write((ushort)LeafRecordType.ULong); + Write((ushort)LF_ULONG); Write((uint)value); } else { - Write((ushort)LeafRecordType.UQuadWord); + Write((ushort)LF_UQUADWORD); Write(value); } } @@ -464,10 +465,12 @@ public void WritePadding() Span padding = _bufferWriter.GetSpan(paddingLength); for (int i = 0; i < paddingLength; i++) { - padding[i] = (byte)(LeafRecordType.Pad0 + paddingLength - i); + padding[i] = (byte)(LF_PAD0 + paddingLength - i); } _bufferWriter.Advance(paddingLength); } + + public void Write(CodeViewType value) => Write((uint)value); } } } From cd56a6cd6fc95b222e2e8435ace04aae6785ce54 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 1 Nov 2022 10:23:25 +0100 Subject: [PATCH 028/144] CodeView: Handle continuation records in lists --- .../ObjectWriter/CodeViewTypesBuilder.cs | 99 ++++++++++++++----- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index 679ec08952a21a..bdaffce7b03699 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -136,21 +136,21 @@ public uint GetArrayTypeIndex( { if (classDescriptor.BaseClassId != 0) { - fieldListRecord.Write((ushort)LF_BCLASS); + fieldListRecord.StartListEntry(LF_BCLASS); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; offset += (uint)_targetPointerSize; } - fieldListRecord.Write((ushort)LF_MEMBER); + fieldListRecord.StartListEntry(LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write("count"); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; offset += (uint)_targetPointerSize; @@ -158,35 +158,35 @@ public uint GetArrayTypeIndex( { for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write((ushort)LF_MEMBER); + fieldListRecord.StartListEntry(LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write($"length{i}"); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; offset += 4; } for (uint i = 0; i < arrayDescriptor.Rank; ++i) { - fieldListRecord.Write((ushort)LF_MEMBER); + fieldListRecord.StartListEntry(LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write($"bounds{i}"); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; offset += 4; } } - fieldListRecord.Write((ushort)LF_MEMBER); + fieldListRecord.StartListEntry(LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(arrayRecordTypeIndex); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write("values"); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; } @@ -218,11 +218,11 @@ public uint GetEnumTypeIndex( { foreach (EnumRecordTypeDescriptor record in typeRecords) { - fieldListRecord.Write((ushort)LF_ENUMERATE); + fieldListRecord.StartListEntry(LF_ENUMERATE); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.WriteEncodedInteger(record.Value); fieldListRecord.Write(record.Name); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); } } @@ -271,19 +271,19 @@ public uint GetCompleteClassTypeIndex( { if (classTypeDescriptor.BaseClassId != 0) { - fieldListRecord.Write((ushort)LF_BCLASS); + fieldListRecord.StartListEntry(LF_BCLASS); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(classTypeDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; } else if (classTypeDescriptor.IsStruct == 0) { - fieldListRecord.Write((ushort)LF_VFUNCTAB); + fieldListRecord.StartListEntry(LF_VFUNCTAB); fieldListRecord.Write((ushort)0); // Padding fieldListRecord.Write(_vfuncTabTypeIndex); - fieldListRecord.WritePadding(); + fieldListRecord.EndListEntry(); memberCount++; } @@ -291,20 +291,21 @@ public uint GetCompleteClassTypeIndex( { if (desc.Offset == 0xFFFFFFFF) { - fieldListRecord.Write((ushort)LF_STMEMBER); + fieldListRecord.StartListEntry(LF_STMEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.Write(desc.Name); + fieldListRecord.EndListEntry(); } else { - fieldListRecord.Write((ushort)LF_MEMBER); + fieldListRecord.StartListEntry(LF_MEMBER); fieldListRecord.Write((ushort)0); // TODO: Attributes fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.WriteEncodedInteger(desc.Offset); fieldListRecord.Write(desc.Name); + fieldListRecord.EndListEntry(); } - fieldListRecord.WritePadding(); memberCount++; } } @@ -375,20 +376,22 @@ public string GetMangledName(TypeDesc type) private LeafRecordWriter StartLeafRecord(LeafRecordType leafRecordType) { - LeafRecordWriter writer = new LeafRecordWriter(this); - writer.Write((ushort)leafRecordType); - return writer; + return new LeafRecordWriter(this, leafRecordType); } private ref struct LeafRecordWriter { private CodeViewTypesBuilder _debugTypesBuilder; + private LeafRecordType _leafRecordType; private ArrayBufferWriter _bufferWriter; + private int _lastListMemberStart; - public LeafRecordWriter(CodeViewTypesBuilder debugTypesBuilder) + public LeafRecordWriter(CodeViewTypesBuilder debugTypesBuilder, LeafRecordType leafRecordType) { _debugTypesBuilder = debugTypesBuilder; + _leafRecordType = leafRecordType; _bufferWriter = new(); + Write((ushort)_leafRecordType); } public void Dispose() @@ -401,8 +404,6 @@ public void Dispose() _debugTypesBuilder._outputStream.Write(_bufferWriter.WrittenSpan); _debugTypesBuilder._outputStream.Write(stackalloc byte[padding]); _bufferWriter.Clear(); - - // TODO: LeafRecordType.Index for long records } public void Write(byte value) @@ -459,7 +460,9 @@ public void WriteEncodedInteger(ulong value) } } - public void WritePadding() + public void Write(CodeViewType value) => Write((uint)value); + + private void WritePadding() { int paddingLength = ((_bufferWriter.WrittenCount - 2 + 3) & ~3) - (_bufferWriter.WrittenCount - 2); Span padding = _bufferWriter.GetSpan(paddingLength); @@ -470,7 +473,49 @@ public void WritePadding() _bufferWriter.Advance(paddingLength); } - public void Write(CodeViewType value) => Write((uint)value); + public void StartListEntry(LeafRecordType recordType) + { + Debug.Assert(_leafRecordType == LF_FIELDLIST || _leafRecordType == LF_METHODLIST); + + _lastListMemberStart = _bufferWriter.WrittenCount; + Write((ushort)recordType); + } + + public void EndListEntry() + { + Debug.Assert(_leafRecordType == LF_FIELDLIST || _leafRecordType == LF_METHODLIST); + Debug.Assert(_lastListMemberStart > 0); + + WritePadding(); + + // If the current list record overflows the maximum list length then emit a + // LF_FIELDLIST/LF_METHODLIST leaf record now and start a new one. The new one + // has LF_INDEX as the first element to chain the lists together. + if (_bufferWriter.WrittenCount > short.MaxValue - sizeof(ushort)) + { + // At least one record was already written in the current list. + Debug.Assert(_lastListMemberStart > sizeof(ushort)); + + // Flush the current record up to _lastListMemberStart and write LF_INDEX to reference it. + int length = sizeof(ushort) + _lastListMemberStart; + int padding = ((length + 3) & ~3) - length; + Span lengthBuffer = stackalloc byte[sizeof(ushort)]; + BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); + _debugTypesBuilder._outputStream.Write(lengthBuffer); + _debugTypesBuilder._outputStream.Write(_bufferWriter.WrittenSpan.Slice(0, _lastListMemberStart)); + _debugTypesBuilder._outputStream.Write(stackalloc byte[padding]); + byte[] overflow = _bufferWriter.WrittenSpan.Slice(_lastListMemberStart).ToArray(); + _bufferWriter.Clear(); + + Write((ushort)_leafRecordType); + Write((ushort)LF_INDEX); + Write((ushort)0); // Padding + Write((uint)_debugTypesBuilder._nextTypeIndex++); + overflow.CopyTo(_bufferWriter.GetSpan(overflow.Length)); + _bufferWriter.Advance(overflow.Length); + _lastListMemberStart = _bufferWriter.WrittenCount; + } + } } } } From 81210d1ac18e37836d133107e506ad5940925e0c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 1 Nov 2022 11:51:58 +0100 Subject: [PATCH 029/144] Add comments and asserts --- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 18 ++++++++++++++++ .../ObjectWriter/CodeViewTypesBuilder.cs | 21 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index f1afb8f9488bc2..170ecb3596bdb6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -20,6 +20,24 @@ namespace ILCompiler.ObjectWriter { + /// Builder for the CodeView .debug$S section. + /// + /// The .debug$S section in CodeView contains information about methods, + /// their parameters, stack layout, and line mapping. + /// + /// The section is divided into logical chunks known as subsections for + /// different kind of information (eg. Symbols, Lines). Unlike the type + /// section () this section does need + /// relocations. + /// + /// The builder emits the subsections linearly into the section writer as + /// the records are produced. Similarly to MSVC we output separate symbol + /// subsection and line subsection for each method. + /// + /// File table (and related string table) are constructed through and appended at the very end of + /// the section. + /// internal sealed class CodeViewSymbolsBuilder { private TargetArchitecture _targetArchitecture; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index bdaffce7b03699..ed6d52b652b460 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -22,6 +22,20 @@ namespace ILCompiler.ObjectWriter { + /// Builder for the CodeView .debug$T section. + /// + /// The .debug$T section in CodeView contains type (enum, struct, class) + /// descriptions. The section is composed of records that are prefixed + /// with their type and length. Each record is assigned a type index + /// representing its position in the stream. The type indexes start at + /// 0x1000 and increase by one for each record. Elementary types, such + /// as uint, short, or float, have preassigned indexes below 0x1000, + /// represented by the enumeration. + /// + /// The maximum record size is limited to sizeof(ushort) due to the + /// layout of the record header. List records (eg. field list) can + /// be split into multiple records that are chained together. + /// internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter { private NameMangler _nameMangler; @@ -195,6 +209,8 @@ public uint GetArrayTypeIndex( Debug.Assert(classDescriptor.IsStruct == 0); using (LeafRecordWriter record = StartLeafRecord(LF_CLASS)) { + Debug.Assert(memberCount <= ushort.MaxValue); + Debug.Assert(arrayDescriptor.Size <= ushort.MaxValue); record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options record.Write(fieldListTypeIndex); // Field descriptor index @@ -230,6 +246,7 @@ public uint GetEnumTypeIndex( using (LeafRecordWriter record = StartLeafRecord(LF_ENUM)) { + Debug.Assert(typeRecords.Length <= ushort.MaxValue); record.Write((ushort)typeRecords.Length); // Number of elements in class record.Write((ushort)0); // TODO: Attributes record.Write(typeDescriptor.ElementType); @@ -314,6 +331,8 @@ public uint GetCompleteClassTypeIndex( using (LeafRecordWriter record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) { + Debug.Assert(memberCount <= ushort.MaxValue); + Debug.Assert(classFieldsTypeDescriptor.Size <= ushort.MaxValue); record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options record.Write(fieldListTypeIndex); // Field descriptor index @@ -344,6 +363,7 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri using (LeafRecordWriter record = StartLeafRecord(LF_MFUNCTION)) { + Debug.Assert(memberDescriptor.NumberOfArguments <= ushort.MaxValue); record.Write(memberDescriptor.ReturnType); record.Write(memberDescriptor.ContainingClass); record.Write(memberDescriptor.TypeIndexOfThisPointer); @@ -398,6 +418,7 @@ public void Dispose() { int length = sizeof(ushort) + _bufferWriter.WrittenCount; int padding = ((length + 3) & ~3) - length; + Debug.Assert(length <= ushort.MaxValue); Span lengthBuffer = stackalloc byte[sizeof(ushort)]; BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); _debugTypesBuilder._outputStream.Write(lengthBuffer); From 249407cdebd6137eedc289d75976a79d93340e54 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 1 Nov 2022 12:31:15 +0100 Subject: [PATCH 030/144] Emit CodeView symbols correctly when COMDAT is used --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 873264a6440250..0d9e02eef3c04f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -575,20 +575,33 @@ protected override void EmitDebugFunctionInfo( INodeWithDebugInfo debugNode) { DebugEHClauseInfo[] clauses = null; + CodeViewSymbolsBuilder debugSymbolsBuilder; if (debugNode is INodeWithCodeInfo nodeWithCodeInfo) { clauses = nodeWithCodeInfo.DebugEHClauseInfos; } - _debugSymbolsBuilder.EmitSubprogramInfo( + if (ShouldShareSymbol((ObjectNode)debugNode)) + { + // If the method is emitted in COMDAT section then we need to create an + // associated COMDAT section for the debugging symbols. + var sectionWriter = GetOrCreateSection(GetSharedSection(DebugSymbolSection, methodName)); + debugSymbolsBuilder = new CodeViewSymbolsBuilder(_nodeFactory.Target.Architecture, sectionWriter); + } + else + { + debugSymbolsBuilder = _debugSymbolsBuilder; + } + + debugSymbolsBuilder.EmitSubprogramInfo( methodName, methodSymbol.Size, methodTypeIndex, debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? Array.Empty()); - _debugSymbolsBuilder.EmitLineInfo( + debugSymbolsBuilder.EmitLineInfo( _debugFileTableBuilder, methodName, methodSymbol.Size, From 904bec462062072dc5df5c7072aa91afc3e3d5d9 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 2 Nov 2022 10:15:44 +0100 Subject: [PATCH 031/144] Minor cleanup in CodeView, add ARM64 register mapping --- .../Compiler/ObjectWriter/CodeViewNative.cs | 3 +++ .../ObjectWriter/CodeViewSymbolsBuilder.cs | 25 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs index 82bc4bca2f10ba..5186df320a0826 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs @@ -5,6 +5,9 @@ namespace ILCompiler.ObjectWriter { + /// + /// Native constants and enumerations for CodeView binary format. + /// internal static class CodeViewNative { // Matches TYPE_ENUM_e in cvinfo.h diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index 170ecb3596bdb6..622e359a1c0827 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -83,8 +83,13 @@ private CodeViewRegister GetCVRegNum(uint regNum) _ => CV_REG_NONE, }; - //case TargetArchitecture.ARM64: - // ... + case TargetArchitecture.ARM64: + // X0-X28, FP, LR, SP have same order + if (regNum <= 32) + return (CodeViewRegister)(regNum + (uint)CV_ARM64_X0); + // TODO: Floating point + return CV_REG_NONE; + default: return CV_REG_NONE; } @@ -125,6 +130,16 @@ public void EmitSubprogramInfo( foreach (var range in debugVar.DebugVarInfo.Ranges) { + uint rangeLength = range.EndOffset - range.StartOffset; + + // Limit the range length to the maximum range expressible in CodeView. + // If this proves to be a problem we can emit additional records to + // describe the continued range of the variable. + if (rangeLength > 0xF000) + { + rangeLength = 0xF000; + } + switch (range.VarLoc.LocationType) { case VarLocType.VLT_REG: @@ -138,13 +153,13 @@ public void EmitSubprogramInfo( recordWriter.Write((ushort)0); // TODO: Attributes recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName, (int)range.StartOffset); recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); - recordWriter.Write((ushort)(range.EndOffset - range.StartOffset)); + recordWriter.Write((ushort)rangeLength); } } break; case VarLocType.VLT_STK: - // FIXME: REGNUM_AMBIENT_SP + // FIXME: Handle REGNUM_AMBIENT_SP cvRegNum = GetCVRegNum((uint)range.VarLoc.B); if (cvRegNum != CV_REG_NONE) { @@ -156,7 +171,7 @@ public void EmitSubprogramInfo( recordWriter.Write((uint)range.VarLoc.C); recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECREL, methodName, (int)range.StartOffset); recordWriter.EmitSymbolReference(RelocType.IMAGE_REL_SECTION, methodName); - recordWriter.Write((ushort)(range.EndOffset - range.StartOffset)); + recordWriter.Write((ushort)rangeLength); } } break; From d72a4728aaebc17030928ffc06e2fab13c2e3d85 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 2 Nov 2022 12:03:14 +0100 Subject: [PATCH 032/144] Optimize memory usage when writing section content --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 2 +- .../Compiler/ObjectWriter/ObjectWriter.cs | 2 +- .../ObjectWriter/ObjectWriterStream.cs | 182 ++++++++++++++++++ .../Compiler/ObjectWriter/SectionWriter.cs | 25 ++- .../ILCompiler.Compiler.csproj | 1 + 5 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 0d9e02eef3c04f..802a97c56c49a3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -99,7 +99,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect SectionCharacteristics.LinkerComdat; } - sectionStream = new MemoryStream(); + sectionStream = new ObjectWriterStream(); _sections.Add((sectionHeader, sectionStream, new List(), section.ComdatName)); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index e63a687b895aea..059e1ff3c2f033 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -331,7 +331,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection + /// Optimized append-only stream for writing sections. + /// + /// + /// Implements a stream of chained buffers. It supports appending existing + /// read-only buffers without copying. + /// + internal sealed class ObjectWriterStream : Stream + { + private ArrayBufferWriter _appendBuffer = new(); + private List> _buffers = new(); + private long _length; + private int _bufferIndex; + private int _bufferPosition; + private long _position; + private static byte[] _padding = new byte[16]; + + public override bool CanRead => true; + + public override bool CanSeek => true; + + public override bool CanWrite => true; + + public override long Length => _length + _appendBuffer.WrittenCount; + + public override long Position + { + get => _position; + set + { + // Flush any non-appended data + FlushAppendBuffer(); + + // Seek to the correct buffer + _position = 0; + _bufferIndex = 0; + _bufferPosition = 0; + while (_position < value && _bufferIndex < _buffers.Count) + { + if (_buffers[_bufferIndex].Length > value - _position) + { + _bufferIndex++; + _position += _buffers[_bufferIndex].Length; + } + else + { + _bufferPosition = (int)(value - _position); + _position = value; + break; + } + } + } + } + + public override void Flush() + { + FlushAppendBuffer(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return Read(buffer.AsSpan(offset, count)); + } + + public override int Read(Span buffer) + { + int bytesRead = 0; + + while (_bufferIndex < _buffers.Count) + { + var currentBuffer = _buffers[_bufferIndex].Span.Slice(_bufferPosition); + + if (currentBuffer.Length >= buffer.Length) + { + currentBuffer.Slice(0, buffer.Length).CopyTo(buffer); + bytesRead += buffer.Length; + _position += buffer.Length; + _bufferPosition += buffer.Length; + return bytesRead; + } + + currentBuffer.CopyTo(buffer); + buffer = buffer.Slice(currentBuffer.Length); + bytesRead += currentBuffer.Length; + _position += currentBuffer.Length; + _bufferIndex++; + _bufferPosition = 0; + } + + return bytesRead; + } + + public override long Seek(long offset, SeekOrigin origin) + { + Position = origin switch + { + SeekOrigin.End => Length + offset, + SeekOrigin.Current => _position + offset, + SeekOrigin.Begin => offset, + _ => throw new ArgumentOutOfRangeException(nameof(origin)) + }; + return _position; + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Write(byte[] buffer, int offset, int count) + { + Write(buffer.AsSpan(offset, count)); + } + + public override void Write(ReadOnlySpan buffer) + { + // We only support appending to the end of the stream + if (_position != Length) + { + throw new NotSupportedException("ObjectWriterStream only supports appending to the end"); + } + + buffer.CopyTo(_appendBuffer.GetSpan(buffer.Length)); + _appendBuffer.Advance(buffer.Length); + _position += buffer.Length; + _bufferPosition += buffer.Length; + } + + public void AppendData(ReadOnlyMemory data) + { + // We only support appending to the end of the stream + if (_position != Length) + { + throw new NotSupportedException("ObjectWriterStream only supports appending to the end"); + } + + FlushAppendBuffer(); + _buffers.Add(data); + _length += data.Length; + _position += data.Length; + _bufferIndex++; + _bufferPosition = 0; + } + + public void AppendPadding(int paddingLength) + { + if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) + { + _appendBuffer.GetSpan(paddingLength).Clear(); + _appendBuffer.Advance(paddingLength); + _position += paddingLength; + _bufferPosition += paddingLength; + } + else + { + AppendData(_padding.AsMemory(0, paddingLength)); + } + } + + private void FlushAppendBuffer() + { + if (_appendBuffer.WrittenCount > 0) + { + _buffers.Add(_appendBuffer.WrittenSpan.ToArray()); + _length += _appendBuffer.WrittenCount; + _bufferIndex++; + _bufferPosition = 0; + _appendBuffer.Clear(); + } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index d3335f6e43725e..fd7a4fce9ccf72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -42,14 +42,33 @@ internal SectionWriter( Stream = stream; } + public void EmitData(ReadOnlyMemory data) + { + if (Stream is ObjectWriterStream objectWriterStream) + { + objectWriterStream.AppendData(data); + } + else + { + Stream.Write(data.Span); + } + } + public void EmitAlignment(int alignment) { _objectWriter.UpdateSectionAlignment(SectionIndex, alignment); int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); - Span buffer = stackalloc byte[padding]; - buffer.Fill(_paddingByte); - Stream.Write(buffer); + if (Stream is ObjectWriterStream objectWriterStream) + { + objectWriterStream.AppendPadding(padding); + } + else + { + Span buffer = stackalloc byte[padding]; + buffer.Fill(_paddingByte); + Stream.Write(buffer); + } } public void EmitRelocation( diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 231587b200bee5..684d206c77ffdc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -599,6 +599,7 @@ + From 0aca15193c5ef526fa7a59ab8376c45f7adeb2a4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 3 Nov 2022 11:11:02 +0100 Subject: [PATCH 033/144] CodeView: Fix emitting size of big structures --- .../Compiler/ObjectWriter/CodeViewTypesBuilder.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index ed6d52b652b460..db967b426eb8c7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -332,13 +332,12 @@ public uint GetCompleteClassTypeIndex( using (LeafRecordWriter record = StartLeafRecord(classTypeDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) { Debug.Assert(memberCount <= ushort.MaxValue); - Debug.Assert(classFieldsTypeDescriptor.Size <= ushort.MaxValue); record.Write((ushort)memberCount); // Number of elements in class record.Write((ushort)0); // TODO: Options record.Write(fieldListTypeIndex); // Field descriptor index record.Write((uint)0); // Derived-from descriptor index record.Write((uint)0); // Vtshape descriptor index - record.Write((ushort)classFieldsTypeDescriptor.Size); // Size + record.WriteEncodedInteger(classFieldsTypeDescriptor.Size); // Size record.Write(classTypeDescriptor.Name); } From f5a9081e70ed5a12347eb4a396f41312915d0e7f Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 3 Nov 2022 13:10:55 +0100 Subject: [PATCH 034/144] Fix too aggressive zeroing of buffer --- .../Compiler/ObjectWriter/ObjectWriterStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index 31e81edd769f4a..246f7d36cc13c4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -156,7 +156,7 @@ public void AppendPadding(int paddingLength) { if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) { - _appendBuffer.GetSpan(paddingLength).Clear(); + _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Clear(); _appendBuffer.Advance(paddingLength); _position += paddingLength; _bufferPosition += paddingLength; From 87afd74662bfa43ad835b0ae8815dcdbbb5f25b5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 3 Nov 2022 13:11:34 +0100 Subject: [PATCH 035/144] Make sure not to dereference null returned from _debugInfo.GetLocalVariables() --- .../DependencyAnalysis/MethodCodeNode.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs index 2c5c14d9b5fdbb..a59888d2d291d2 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/DependencyAnalysis/MethodCodeNode.cs @@ -195,12 +195,23 @@ public IEnumerable GetDebugVars() i++; } - var localNames = new string[_localTypes.Length]; - - foreach (var local in _debugInfo.GetLocalVariables()) + string[] localNames; + if (_localTypes.Length > 0) + { + localNames = new string[_localTypes.Length]; + var localVariables = _debugInfo.GetLocalVariables(); + if (localVariables != null) + { + foreach (var local in localVariables) + { + if (!local.CompilerGenerated && local.Slot < localNames.Length) + localNames[local.Slot] = local.Name; + } + } + } + else { - if (!local.CompilerGenerated && local.Slot < localNames.Length) - localNames[local.Slot] = local.Name; + localNames = Array.Empty(); } foreach (var varInfo in _debugVarInfos) From f1ad210a05f2eb923dfb84315d9776d53b02779a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 3 Nov 2022 13:12:31 +0100 Subject: [PATCH 036/144] HACK: Do not emit debug information where LLVM ObjWriter would not. --- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 059e1ff3c2f033..8d245cbe3307fa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -352,7 +352,9 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 3 Nov 2022 13:30:29 +0100 Subject: [PATCH 037/144] Avoid some unnecessary name mangling calls --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 6 ++++-- .../Compiler/ObjectWriter/ObjectWriter.cs | 19 +++++++++++++------ .../Compiler/ObjectWriter/UnixObjectWriter.cs | 6 ++++-- .../Compiler/RyuJitCompilation.cs | 9 ++++++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 802a97c56c49a3..5615b05eca17fc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -357,14 +357,16 @@ protected override void EmitRelocations(int sectionIndex, List tempBuffer = stackalloc byte[4]; if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 8d245cbe3307fa..c06a81144a8ef7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -187,7 +187,10 @@ protected internal void EmitSymbolDefinition( protected virtual string ExternCName(string name) => name; - protected abstract void EmitUnwindInfo(SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo); + protected abstract void EmitUnwindInfo( + SectionWriter sectionWriter, + INodeWithCodeInfo nodeWithCodeInfo, + string currentSymbolName); protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) { @@ -282,12 +285,16 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection false; - protected override void EmitUnwindInfo(SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo) + protected override void EmitUnwindInfo( + SectionWriter sectionWriter, + INodeWithCodeInfo nodeWithCodeInfo, + string currentSymbolName) { if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { SectionWriter lsdaSectionWriter; - string currentSymbolName = ExternCName(symbolDefinitionNode.GetMangledName(_nodeFactory.NameMangler)); Span tempBuffer = stackalloc byte[4]; if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index a649b43546353c..8d314a366c89e0 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; @@ -107,16 +108,18 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) if ((_compilationOptions & RyuJitCompilationOptions.ControlFlowGuardAnnotations) != 0) options |= ObjectWritingOptions.ControlFlowGuard; + var stopwatch = new Stopwatch(); + stopwatch.Start(); if (Environment.GetEnvironmentVariable("DOTNET_USE_LLVM_OBJWRITER") == "1") LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else if (NodeFactory.Target.OperatingSystem == TargetOS.OSX) MachObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else if (NodeFactory.Target.OperatingSystem == TargetOS.Windows) CoffObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - else if (NodeFactory.Target.OperatingSystem == TargetOS.Linux) - ElfObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else - LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + ElfObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); + stopwatch.Stop(); + Console.WriteLine("Emitting object file took " + stopwatch.Elapsed); } protected override void ComputeDependencyNodeDependencies(List> obj) From 2ca35a671894981f6aa8cb1ecfa1305ec127567e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 3 Nov 2022 14:17:05 +0100 Subject: [PATCH 038/144] Cache mangled names --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 4 ++-- .../Compiler/ObjectWriter/ObjectWriter.cs | 23 +++++++++++++++---- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 4 ++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 5615b05eca17fc..64a204eed6402d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -418,13 +418,13 @@ protected override void EmitUnwindInfo( if (associatedDataNode != null) { - string symbolName = ExternCName(associatedDataNode.GetMangledName(_nodeFactory.NameMangler)); + string symbolName = GetMangledName(associatedDataNode); xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); } if (ehInfo != null) { - string symbolName = ExternCName(ehInfo.GetMangledName(_nodeFactory.NameMangler)); + string symbolName = GetMangledName(ehInfo); xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index c06a81144a8ef7..60482b488bbf62 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -31,6 +31,8 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy protected ObjectWritingOptions _options; protected bool _isSingleFileCompilation; + private Dictionary _mangledNameMap = new(); + private byte _insPaddingByte; // Standard sections @@ -187,6 +189,19 @@ protected internal void EmitSymbolDefinition( protected virtual string ExternCName(string name) => name; + protected string GetMangledName(ISymbolNode symbolNode) + { + string symbolName; + + if (!_mangledNameMap.TryGetValue(symbolNode, out symbolName)) + { + symbolName = ExternCName(symbolNode.GetMangledName(_nodeFactory.NameMangler)); + _mangledNameMap.Add(symbolNode, symbolName); + } + + return symbolName; + } + protected abstract void EmitUnwindInfo( SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo, @@ -288,7 +303,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Fri, 4 Nov 2022 14:31:21 +0100 Subject: [PATCH 039/144] Fix ArgumentOutOfRangeException when writing DWARF debug info --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 15e29881c5e26c..8c4c2654f51d85 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -751,6 +751,11 @@ public void EmitSubprogramInfo( IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, IEnumerable debugEHClauseInfos) { + if (methodTypeIndex == 0) + { + return; + } + var subprogramSpec = _memberFunctions[(int)methodTypeIndex - 1]; _dwarfFile.StringTable.GetOrCreateString(methodName); From 670a14a8606a8298eab728211c2fc250ce06ccb6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 10 Sep 2023 22:10:11 +0200 Subject: [PATCH 040/144] Fix build after rebase --- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 4 ++++ .../Compiler/ObjectWriter/CoffObjectWriter.cs | 8 ++++---- .../Compiler/ObjectWriter/ObjectWriter.cs | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index 622e359a1c0827..4c40ce2da6c1c5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -104,6 +104,10 @@ public void EmitSubprogramInfo( { using var symbolSubsection = GetSubsection(DebugSymbolsSubsectionType.Symbols); + // TODO: Do we need those? + _ = methodTypeIndex; + _ = debugEHClauseInfos; + using (var recordWriter = symbolSubsection.StartRecord(S_GPROC32_ID)) { recordWriter.Write((uint)0); // pointer to the parent diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 64a204eed6402d..4f9440e679f20b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -673,7 +673,7 @@ private sealed class CoffHeader public int Size => IsBigObj ? BigObjSize : RegularSize; - public void Write(Stream stream) + public void Write(FileStream stream) { if (!IsBigObj) { @@ -738,7 +738,7 @@ private sealed class CoffSectionHeader sizeof(ushort) + // NumberOfLineNumbers sizeof(uint); // SectionCharacteristics - public void Write(Stream stream, CoffStringTable stringTable) + public void Write(FileStream stream, CoffStringTable stringTable) { Span buffer = stackalloc byte[Size]; @@ -825,7 +825,7 @@ private sealed class CoffRelocation sizeof(uint) + // SymbolTableIndex sizeof(ushort); // Type - public void Write(Stream stream) + public void Write(FileStream stream) { Span buffer = stackalloc byte[Size]; @@ -978,7 +978,7 @@ public uint GetStringOffset(string str) return offset; } - public void Write(Stream stream) + public void Write(FileStream stream) { Span stringTableSize = stackalloc byte[4]; BinaryPrimitives.WriteInt32LittleEndian(stringTableSize, (int)(_stream.Length + 4)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 60482b488bbf62..09f3dc828e1622 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -100,6 +100,16 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) } protected bool ShouldShareSymbol(ObjectNode node) + { + // TODO: Not supported yet + if (_nodeFactory.Target.OperatingSystem == TargetOS.OSX || + _nodeFactory.Target.OperatingSystem == TargetOS.Linux) + return false; + + return ShouldShareSymbol(node, node.GetSection(_nodeFactory)); + } + + protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) { // TODO: Not supported yet if (_nodeFactory.Target.OperatingSystem == TargetOS.OSX || @@ -107,7 +117,6 @@ protected bool ShouldShareSymbol(ObjectNode node) return false; // Foldable sections are always COMDATs - ObjectNodeSection section = node.Section; if (section == ObjectNodeSection.FoldableManagedCodeUnixContentSection || section == ObjectNodeSection.FoldableManagedCodeWindowsContentSection || section == ObjectNodeSection.FoldableReadOnlyDataSection) @@ -306,8 +315,8 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Sun, 10 Sep 2023 22:22:35 +0200 Subject: [PATCH 041/144] Add support for SectionType.Uninitialized --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 11 +++----- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 26 +++++++++---------- .../Compiler/ObjectWriter/MachObjectWriter.cs | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 4f9440e679f20b..49cd5e1ae9e698 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -76,17 +76,14 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect SectionType.Executable => SectionCharacteristics.MemRead | SectionCharacteristics.MemExecute | SectionCharacteristics.ContainsCode, + SectionType.Uninitialized => + SectionCharacteristics.MemRead | SectionCharacteristics.MemWrite | + SectionCharacteristics.ContainsUninitializedData, _ => 0 } }; - if (section.Name == "bss") - { - sectionHeader.SectionCharacteristics = - SectionCharacteristics.MemRead | SectionCharacteristics.MemWrite | - SectionCharacteristics.ContainsUninitializedData; - } - else if (section == DebugTypesSection) + if (section == DebugTypesSection) { sectionHeader.SectionCharacteristics = SectionCharacteristics.MemRead | SectionCharacteristics.ContainsInitializedData | diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 0676b96494d42c..e4b3e4a1071222 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -32,8 +32,7 @@ public sealed class ElfObjectWriter : UnixObjectWriter { private ElfObjectFile _objectFile; private int _sectionIndex; - private int _bssSectionIndex; - private Stream _bssStream; + private Dictionary _bssStreams = new(); private Dictionary _sectionIndexToElfSection = new(); private Dictionary _sectionToRelocationTable = new(); @@ -59,28 +58,27 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) { - if (section.Name == "bss") - { - Debug.Assert(_bssStream == null); + string sectionName = + section.Name == "rdata" ? ".rodata" : + (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); + + sectionStream = new MemoryStream(); - _bssSectionIndex = _sectionIndex; - _bssStream = sectionStream = new MemoryStream(); + if (section.Type == SectionType.Uninitialized) + { ElfSection elfSection = new ElfBinarySection() { - Name = ".bss", + Name = sectionName, Type = ElfSectionType.NoBits, Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write, }; + _bssStreams[_sectionIndex] = sectionStream; _sectionIndexToElfSection[_sectionIndex++] = elfSection; _objectFile.AddSection(elfSection); } else { - string sectionName = - section.Name == "rdata" ? ".rodata" : - (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); - sectionStream = new MemoryStream(); ElfSection elfSection = new ElfBinarySection(sectionStream) { @@ -436,9 +434,9 @@ protected override void EmitSectionsAndLayout() _objectFile.AddSection(_symbolTable.Link.Section); _objectFile.AddSection(_symbolTable); _objectFile.AddSection(new ElfSectionHeaderStringTable()); - if (_bssStream != null) + foreach (var (bssSectionIndex, bssStream) in _bssStreams) { - _sectionIndexToElfSection[_bssSectionIndex].Size = (ulong)_bssStream.Length; + _sectionIndexToElfSection[bssSectionIndex].Size = (ulong)bssStream.Length; } _objectFile.AddSection(new ElfBinarySection(Stream.Null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 5769880c26e31f..2779a26974147f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -146,7 +146,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect { "bss" => MachSectionType.ZeroFill, ".eh_frame" => MachSectionType.Coalesced, - _ => MachSectionType.Regular + _ => section.Type == SectionType.Uninitialized ? MachSectionType.ZeroFill : MachSectionType.Regular }; MachSection machSection = new MachSection(_objectFile, segmentName, sectionName) From f7aa82772fb1927f0f0c99528e437f57190e8d63 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 10 Sep 2023 22:49:34 +0200 Subject: [PATCH 042/144] Add support for iOS-like platforms --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 48 +++++++++++++++++-- .../Compiler/ObjectWriter/ObjectWriter.cs | 4 +- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 2779a26974147f..3fbc61ac5aaa38 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -30,6 +30,7 @@ public class MachObjectWriter : UnixObjectWriter { private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); + private TargetOS _targetOS; private MachObjectFile _objectFile; private MachSegment _segment; @@ -74,6 +75,8 @@ private MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, }; _objectFile.LoadCommands.Add(_segment); + + _targetOS = factory.Target.OperatingSystem; } protected override void EmitSectionsAndLayout() @@ -93,10 +96,49 @@ protected override void EmitSectionsAndLayout() _dySymbolTable = new MachDynamicLinkEditSymbolTable(); _objectFile.LoadCommands.Add(_symbolTable); _objectFile.LoadCommands.Add(_dySymbolTable); - _objectFile.LoadCommands.Add(new MachVersionMinMacOS + + var sdkVersion = new Version(16, 0, 0); + switch (_targetOS) { - MinimumPlatformVersion = new Version(10, 12, 0) - }); + case TargetOS.OSX: + _objectFile.LoadCommands.Add(new MachVersionMinMacOS + { + MinimumPlatformVersion = new Version(10, 12, 0), + SdkVersion = sdkVersion, + }); + break; + + case TargetOS.MacCatalyst: + _objectFile.LoadCommands.Add(new MachBuildVersion + { + TargetPlatform = MachPlatform.MacCatalyst, + MinimumPlatformVersion = _objectFile.CpuType switch { + MachCpuType.X86_64 => new Version(13, 5, 0), + _ => new Version(14, 2, 0), + }, + SdkVersion = sdkVersion, + }); + break; + + case TargetOS.iOS: + case TargetOS.iOSSimulator: + case TargetOS.tvOS: + case TargetOS.tvOSSimulator: + _objectFile.LoadCommands.Add(new MachBuildVersion + { + TargetPlatform = _targetOS switch + { + TargetOS.iOS => MachPlatform.IOS, + TargetOS.iOSSimulator => MachPlatform.IOSSimulator, + TargetOS.tvOS => MachPlatform.TvOS, + TargetOS.tvOSSimulator => MachPlatform.TvOSSimulator, + _ => (MachPlatform)0, + }, + MinimumPlatformVersion = new Version(11, 0, 0), + SdkVersion = sdkVersion, + }); + break; + } // Layout the sections _objectFile.UpdateLayout(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 09f3dc828e1622..444f21924418fe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -102,7 +102,7 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) protected bool ShouldShareSymbol(ObjectNode node) { // TODO: Not supported yet - if (_nodeFactory.Target.OperatingSystem == TargetOS.OSX || + if (_nodeFactory.Target.IsOSXLike || _nodeFactory.Target.OperatingSystem == TargetOS.Linux) return false; @@ -112,7 +112,7 @@ protected bool ShouldShareSymbol(ObjectNode node) protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) { // TODO: Not supported yet - if (_nodeFactory.Target.OperatingSystem == TargetOS.OSX || + if (_nodeFactory.Target.IsOSXLike || _nodeFactory.Target.OperatingSystem == TargetOS.Linux) return false; From 2bef42c612d1490bf1dfdc56eb948b853ae2a9af Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 10 Sep 2023 22:53:01 +0200 Subject: [PATCH 043/144] Invoke object dumper from shared ObjectWriter --- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 444f21924418fe..3a11a1a35843bb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -309,6 +309,8 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Sun, 10 Sep 2023 23:20:23 +0200 Subject: [PATCH 044/144] macOS/iOS: Emit simple compact unwinding information --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 43 ++++++++++++++++--- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 18 ++++---- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 3fbc61ac5aaa38..a00e8823651daa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -587,15 +587,48 @@ void EmitCompactUnwindSymbol(string symbolName) protected override string ExternCName(string name) => "_" + name; - protected override bool EmitCompactUnwinding(DwarfFde fde) + // This represents the following DWARF code: + // DW_CFA_advance_loc: 4 + // DW_CFA_def_cfa_offset: +16 + // DW_CFA_offset: W29 -16 + // DW_CFA_offset: W30 -8 + // DW_CFA_advance_loc: 4 + // DW_CFA_def_cfa_register: W29 + // which is generated for the following frame prolog/epilog: + // stp fp, lr, [sp, #-10]! + // mov fp, sp + // ... + // ldp fp, lr, [sp], #0x10 + // ret + private static ReadOnlySpan DwarfArm64EmptyFrame => new byte[] { + 0x04, 0x00, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, + 0x04, 0x02, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x02, 0x1E, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x08, 0x01, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + protected override bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) + { + uint encoding = _compactUnwindDwarfCode; + + if (_objectFile.CpuType == MachCpuType.Arm64) + { + if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) + { + // Frame-based encoding, no saved registers + encoding = 0x04000000; + } + } + _compactUnwindCodes.Add(new CompactUnwindCode( - PcStartSymbolName: fde.PcStartSymbolName, - PcLength: (uint)fde.PcLength, - Code: _compactUnwindDwarfCode // Use DWARF + PcStartSymbolName: startSymbolName, + PcLength: (uint)length, + Code: encoding, + LsdaSymbolName: encoding != _compactUnwindDwarfCode ? lsdaSymbolName : null )); - return false; + return encoding == _compactUnwindDwarfCode; } protected override ulong GetSectionVirtualAddress(int sectionIndex) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 7c8519cb1360f0..995ff073e17793 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -46,7 +46,7 @@ protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) { } - protected virtual bool EmitCompactUnwinding(DwarfFde fde) => false; + protected virtual bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) => false; protected override void EmitUnwindInfo( SectionWriter sectionWriter, @@ -128,15 +128,17 @@ protected override void EmitUnwindInfo( } } - var fde = new DwarfFde(_dwarfCie, DwarfFde.CfiCodeToInstructions(_dwarfCie, frameInfo.BlobData)) + string startSymbolName = start != 0 ? framSymbolName : currentSymbolName; + ulong length = (ulong)(end - start); + if (!EmitCompactUnwinding(startSymbolName, length, lsdaSymbolName, blob)) { - PcStartSymbolName = start != 0 ? framSymbolName : currentSymbolName, - PcLength = (ulong)(end - start), - LsdaSymbolName = lsdaSymbolName, - }; + var fde = new DwarfFde(_dwarfCie, DwarfFde.CfiCodeToInstructions(_dwarfCie, blob)) + { + PcStartSymbolName = startSymbolName, + PcLength = (ulong)(end - start), + LsdaSymbolName = lsdaSymbolName, + }; - if (!EmitCompactUnwinding(fde)) - { _dwarfEhFrame.AddFde(fde); } } From 4567163fd1910abf881382b26fe23688fd9bd1eb Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 11:10:39 +0200 Subject: [PATCH 045/144] Add support for new TLS relocations in ELF --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index e4b3e4a1071222..85f870a196caaf 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -138,7 +138,13 @@ protected internal override void EmitRelocation( } else if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || - relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A || + relocType == RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 || + relocType == RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC || + relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 || + relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 || + relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 || + relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL) { // NOTE: Zero addend in code is currently always used for these. // R2R object writer has the same assumption. @@ -221,6 +227,12 @@ private void EmitRelocationsARM64(int sectionIndex, List rel RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfRelocationType.R_AARCH64_CALL26, RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfRelocationType.R_AARCH64_ADR_PREL_PG_HI21, RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfRelocationType.R_AARCH64_ADD_ABS_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfRelocationType.R_AARCH64_TLSLE_ADD_TPREL_HI12, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfRelocationType.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfRelocationType.R_AARCH64_TLSDESC_ADR_PAGE21, + RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfRelocationType.R_AARCH64_TLSDESC_LD64_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfRelocationType.R_AARCH64_TLSDESC_ADD_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfRelocationType.R_AARCH64_TLSDESC_CALL, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; From 8a6774c9d74aecaa586d4021e35d8fcaf42b7ce6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 11:18:29 +0200 Subject: [PATCH 046/144] Generate debug info even if managed debug info not present --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 16 ++++++++++------ .../Compiler/ObjectWriter/ObjectWriter.cs | 9 +++++---- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 8 ++++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 49cd5e1ae9e698..5c36c8ed608127 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -571,7 +571,8 @@ protected override void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, SymbolDefinition methodSymbol, - INodeWithDebugInfo debugNode) + INodeWithDebugInfo debugNode, + bool hasSequencePoints) { DebugEHClauseInfo[] clauses = null; CodeViewSymbolsBuilder debugSymbolsBuilder; @@ -600,11 +601,14 @@ protected override void EmitDebugFunctionInfo( debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? Array.Empty()); - debugSymbolsBuilder.EmitLineInfo( - _debugFileTableBuilder, - methodName, - methodSymbol.Size, - debugNode.GetNativeSequencePoints()); + if (hasSequencePoints) + { + debugSymbolsBuilder.EmitLineInfo( + _debugFileTableBuilder, + methodName, + methodSymbol.Size, + debugNode.GetNativeSequencePoints()); + } } protected override void EmitDebugSections() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 3a11a1a35843bb..cc807f78957c98 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -271,7 +271,8 @@ protected abstract void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, SymbolDefinition methodSymbol, - INodeWithDebugInfo debugNode); + INodeWithDebugInfo debugNode, + bool hasSequencePoints); protected abstract void EmitDebugSections(); @@ -386,9 +387,9 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? Array.Empty()); - _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); + if (hasSequencePoints) + { + _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); + } } protected abstract void EmitDebugSections(DwarfFile dwarfFile); From a9cc9b413ad57e98a449a0099240eb6b4937bec3 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 13:03:44 +0200 Subject: [PATCH 047/144] Fix counting the DwarfLineProgramTable layout (backport of https://github.com/xoofx/LibObjectFile/commit/dcf2ac5bd79953a54ad1fb8c1ca3627616bdf58f) --- .../LibObjectFile/Dwarf/DwarfLineProgramTable.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs index 57fb761dafc699..6e6c09e590f230 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs @@ -682,7 +682,7 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext) ulong sizeOf = 0; // unit_length - sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); + sizeOf += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); sizeOf += 2; // version (uhalf) @@ -691,11 +691,19 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext) ulong headerLengthStart = sizeOf; // minimum_instruction_length + sizeOf++; + + if (Version >= 4) + { + // maximum_operations_per_instruction + sizeOf++; + } + // default_is_stmt // line_base // line_range // opcode_base - sizeOf += 5; + sizeOf += 4; // StandardOpCodeLengths foreach (var opcodeLength in _standardOpCodeLengths) @@ -738,8 +746,8 @@ private void RecordDirectory(string directoryName, ref ulong sizeOf, out uint di { if (!_directoryNameToIndex.TryGetValue(directoryName, out dirIndex)) { - uint directoryIndex = (uint) _directoryNames.Count + 1; - _directoryNameToIndex.Add(directoryName, directoryIndex); + dirIndex = (uint) _directoryNames.Count + 1; + _directoryNameToIndex.Add(directoryName, dirIndex); sizeOf += (ulong) Encoding.UTF8.GetByteCount(directoryName) + 1; _directoryNames.Add(directoryName); } From 7eb39c1b7643885c585ca29b51aef1dfd6dadd84 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 13:04:54 +0200 Subject: [PATCH 048/144] Remove incorrect assert in MachObjectWriter (text section starts at virtual address 0) --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index a00e8823651daa..5e069bd64ecbff 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -634,7 +634,6 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt protected override ulong GetSectionVirtualAddress(int sectionIndex) { var machSection = _segment.Sections[sectionIndex]; - Debug.Assert(machSection.VirtualAddress != 0); return machSection.VirtualAddress; } From a96157d67da08f94277f2e86605f4bde360eb675 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 13:05:57 +0200 Subject: [PATCH 049/144] Temporarily disable optimization that results in incorrect LSDA pointer; needs to be investigated --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 5e069bd64ecbff..21605cabd93933 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -612,14 +612,15 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt { uint encoding = _compactUnwindDwarfCode; - if (_objectFile.CpuType == MachCpuType.Arm64) + // TODO: Re-enable this optimization + /*if (_objectFile.CpuType == MachCpuType.Arm64) { if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) { // Frame-based encoding, no saved registers encoding = 0x04000000; } - } + }*/ _compactUnwindCodes.Add(new CompactUnwindCode( PcStartSymbolName: startSymbolName, From 0e855a1a0b03c8476d37fd64cacef80e963d9799 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Sep 2023 13:20:51 +0200 Subject: [PATCH 050/144] Fix emitting unwind tables in Mach-O --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 21605cabd93933..ec0494ec7ff455 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -612,15 +612,14 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt { uint encoding = _compactUnwindDwarfCode; - // TODO: Re-enable this optimization - /*if (_objectFile.CpuType == MachCpuType.Arm64) + if (_objectFile.CpuType == MachCpuType.Arm64) { if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) { // Frame-based encoding, no saved registers encoding = 0x04000000; } - }*/ + } _compactUnwindCodes.Add(new CompactUnwindCode( PcStartSymbolName: startSymbolName, @@ -629,7 +628,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt LsdaSymbolName: encoding != _compactUnwindDwarfCode ? lsdaSymbolName : null )); - return encoding == _compactUnwindDwarfCode; + return encoding != _compactUnwindDwarfCode; } protected override ulong GetSectionVirtualAddress(int sectionIndex) From aee297e460a8337c798b3f4d170348d6d08d02e5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 14:29:11 +0200 Subject: [PATCH 051/144] Emit the MH_SUBSECTIONS_VIA_SYMBOLS header flag for Mach-O --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index ec0494ec7ff455..6b9ed6fbe441d7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -51,6 +51,7 @@ private MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) _objectFile = new MachObjectFile(); _objectFile.FileType = MachFileType.Object; _objectFile.IsLittleEndian = true; + _objectFile.Flags = MachHeaderFlags.SubsectionsViaSymbols; switch (factory.Target.Architecture) { From f728fb54bbb292bcf43a56599a3f439cd09dcd1b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 21:37:30 +0200 Subject: [PATCH 052/144] Fix seeking in ObjectWriterStream --- .../Compiler/ObjectWriter/ObjectWriterStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index 246f7d36cc13c4..7410acc6c7a52b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -47,7 +47,7 @@ public override long Position _bufferPosition = 0; while (_position < value && _bufferIndex < _buffers.Count) { - if (_buffers[_bufferIndex].Length > value - _position) + if (_buffers[_bufferIndex].Length < value - _position) { _bufferIndex++; _position += _buffers[_bufferIndex].Length; From d7ef77166f935d97a8d8e2fedbe9b85573e2165e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 21:38:48 +0200 Subject: [PATCH 053/144] Avoid excessive seeks by implementing SliceStream.CopyTo --- .../Melanzana.Streams/SliceStream.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs index eafd0c21f64935..71e8fba1b8e0cf 100644 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs +++ b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs @@ -4,6 +4,7 @@ using System; using System.IO; +using System.Buffers; namespace Melanzana.Streams { @@ -148,5 +149,30 @@ public override void Write(byte[] buffer, int offset, int count) throw new InvalidOperationException("Cannot write outside of this stream slice"); } } + + public override void CopyTo(Stream destination, int bufferSize) + { + var savedPosition = _baseStream.Position; + _baseStream.Position = _basePosition + _localPosition; + + byte[] buffer = ArrayPool.Shared.Rent(bufferSize); + try + { + int bytesRead; + long remaining = _length - _localPosition; + while (remaining > 0 && (bytesRead = _baseStream.Read(buffer, 0, (int)Math.Min(buffer.Length, remaining))) != 0) + { + _localPosition += bytesRead; + remaining = _length - _localPosition; + destination.Write(buffer, 0, bytesRead); + } + } + finally + { + ArrayPool.Shared.Return(buffer); + } + + _baseStream.Position = savedPosition; + } } } From 4b8461664db7b1c17ee22f47e17f2bb78288e583 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 21:39:13 +0200 Subject: [PATCH 054/144] Use ObjectWriterStream in ElfObjectWriter --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 85f870a196caaf..d85fa0e4b1316f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -62,7 +62,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); - sectionStream = new MemoryStream(); + sectionStream = new ObjectWriterStream(); if (section.Type == SectionType.Uninitialized) { @@ -79,7 +79,6 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect } else { - sectionStream = new MemoryStream(); ElfSection elfSection = new ElfBinarySection(sectionStream) { Name = sectionName, From a8a12b982fea852b4e850c46ea841f1164f337ef Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 22:03:35 +0200 Subject: [PATCH 055/144] Use ObjectWriterStream for Mach-O --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 6b9ed6fbe441d7..807af7e83d6f3d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -192,14 +192,15 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect _ => section.Type == SectionType.Uninitialized ? MachSectionType.ZeroFill : MachSectionType.Regular }; - MachSection machSection = new MachSection(_objectFile, segmentName, sectionName) + sectionStream = new ObjectWriterStream(); + + MachSection machSection = new MachSection(_objectFile, segmentName, sectionName, sectionStream) { Log2Alignment = 1, Type = type, Attributes = attributes, }; - sectionStream = machSection.GetWriteStream(); _segment.Sections.Add(machSection); } From 18a39abe44fe36ed18d3d3e5fe3a9a3faa8bfdda Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 21 Sep 2023 22:04:06 +0200 Subject: [PATCH 056/144] Fix setting the UNWIND_HAS_LSDA flag in compact unwind table --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 807af7e83d6f3d..851d2fa7e5d5c6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -626,7 +626,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt _compactUnwindCodes.Add(new CompactUnwindCode( PcStartSymbolName: startSymbolName, PcLength: (uint)length, - Code: encoding, + Code: encoding | (encoding != _compactUnwindDwarfCode && lsdaSymbolName != null ? 0x40000000u : 0), // UNWIND_HAS_LSDA LsdaSymbolName: encoding != _compactUnwindDwarfCode ? lsdaSymbolName : null )); From 64dc26c1386a135d4d6020296a9af607d9050650 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 26 Sep 2023 18:24:29 +0200 Subject: [PATCH 057/144] COFF: - Fix emitting TLS section - Fix off-by-one in section alignment - Fix Control Flow Guard for external methods --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 29 ++++++++++--------- .../Compiler/ObjectWriter/MachObjectWriter.cs | 2 +- .../Compiler/ObjectWriter/ObjectWriter.cs | 15 +++++++++- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 5c36c8ed608127..c1d5b82bad8c9f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -24,7 +24,7 @@ namespace ILCompiler.ObjectWriter { - public class CoffObjectWriter : ObjectWriter + public sealed class CoffObjectWriter : ObjectWriter { private Machine _machine; private List<(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName)> _sections = new(); @@ -33,6 +33,7 @@ public class CoffObjectWriter : ObjectWriter private List _symbols = new(); private Dictionary _symbolNameToIndex = new(); private Dictionary _sectionNumberToComdatAuxRecord = new(); + private HashSet _referencedMethods = new(); // Exception handling private SectionWriter _xdataSectionWriter; @@ -50,7 +51,7 @@ public class CoffObjectWriter : ObjectWriter private ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); - protected CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) + private CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { _machine = factory.Target.Architecture switch @@ -65,7 +66,10 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect { var sectionHeader = new CoffSectionHeader { - Name = section.Name.StartsWith(".") ? section.Name : "." + section.Name, + Name = + section == ObjectNodeSection.TLSSection ? ".tls$" : + section == ObjectNodeSection.HydrationTargetSection ? "hydrated" : + (section.Name.StartsWith(".") ? section.Name : "." + section.Name), SectionCharacteristics = section.Type switch { SectionType.ReadOnly => @@ -103,7 +107,7 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { Debug.Assert(alignment > 0 && BitOperations.IsPow2((uint)alignment)); - int minimumAlignment = BitOperations.Log2((uint)alignment) << 20; + int minimumAlignment = (BitOperations.Log2((uint)alignment) + 1) << 20; int currentAlignment = (int)(_sections[sectionIndex].Header.SectionCharacteristics & SectionCharacteristics.AlignMask); if (currentAlignment < minimumAlignment) @@ -175,6 +179,11 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } + protected override void EmitReferencedMethod(string symbolName) + { + _referencedMethods.Add(symbolName); + } + protected override void EmitSymbolTable() { var definedSymbols = GetDefinedSymbols(); @@ -257,16 +266,10 @@ protected override void EmitSymbolTable() SectionWriter gfidsSectionWriter = GetOrCreateSection(GfidsSection); Span tempBuffer = stackalloc byte[4]; - foreach (var (symbolName, symbolDefinition) in GetDefinedSymbols()) + foreach (var symbolName in _referencedMethods) { - // For now consider all method symbols address taken. - // We could restrict this in the future to those that are referenced from - // reflection tables, EH tables, were actually address taken in code, or are referenced from vtables. - if (symbolDefinition.Size > 0) - { - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); - gfidsSectionWriter.Stream.Write(tempBuffer); - } + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); + gfidsSectionWriter.Stream.Write(tempBuffer); } // Emit the feat.00 symbol that controls various linker behaviors diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 851d2fa7e5d5c6..df62d491adf55f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -26,7 +26,7 @@ namespace ILCompiler.ObjectWriter { - public class MachObjectWriter : UnixObjectWriter + public sealed class MachObjectWriter : UnixObjectWriter { private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index cc807f78957c98..2d1c9fc0490883 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -162,6 +162,8 @@ protected internal virtual void EmitRelocation( _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } + protected virtual void EmitReferencedMethod(string symbolName) { } + /// /// Emit symbolic relocations into object file as format specific /// relocations. @@ -348,12 +350,23 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Wed, 27 Sep 2023 00:59:55 +0200 Subject: [PATCH 058/144] COFF: Fix off-by-one error when writing more than 0xffff relocations for a section --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index c1d5b82bad8c9f..c9f372d174efde 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -298,7 +298,7 @@ protected override void EmitRelocations(int sectionIndex, List Date: Wed, 27 Sep 2023 01:20:58 +0200 Subject: [PATCH 059/144] Make ObjectWriterStream the only supported stream and fix padding emitted in code sections --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 3 +-- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 4 +-- .../Compiler/ObjectWriter/MachObjectWriter.cs | 4 +-- .../Compiler/ObjectWriter/ObjectWriter.cs | 12 ++++----- .../ObjectWriter/ObjectWriterStream.cs | 7 ++++- .../Compiler/ObjectWriter/SectionWriter.cs | 27 +++---------------- 6 files changed, 19 insertions(+), 38 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index c9f372d174efde..b56a72f4e1b354 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -62,7 +62,7 @@ private CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) }; } - protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) { var sectionHeader = new CoffSectionHeader { @@ -100,7 +100,6 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect SectionCharacteristics.LinkerComdat; } - sectionStream = new ObjectWriterStream(); _sections.Add((sectionHeader, sectionStream, new List(), section.ComdatName)); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index d85fa0e4b1316f..0a53b68b77741d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -56,14 +56,12 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) _symbolTable = new ElfSymbolTable { Link = stringSection }; } - protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) { string sectionName = section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); - sectionStream = new ObjectWriterStream(); - if (section.Type == SectionType.Uninitialized) { ElfSection elfSection = new ElfBinarySection() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index df62d491adf55f..a47c65d6290377 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -158,7 +158,7 @@ protected override void EmitObjectFile(string objectFilePath) } } - protected override void CreateSection(ObjectNodeSection section, out Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) { string segmentName = section.Name switch { @@ -192,8 +192,6 @@ protected override void CreateSection(ObjectNodeSection section, out Stream sect _ => section.Type == SectionType.Uninitialized ? MachSectionType.ZeroFill : MachSectionType.Regular }; - sectionStream = new ObjectWriterStream(); - MachSection machSection = new MachSection(_objectFile, segmentName, sectionName, sectionStream) { Log2Alignment = 1, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 2d1c9fc0490883..c7402450c6fc4e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -37,7 +37,7 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy // Standard sections private Dictionary<(string, string), int> _sectionNameToSectionIndex = new(); - private List _sectionIndexToStream = new(); + private List _sectionIndexToStream = new(); private List> _sectionIndexToRelocations = new(); // Symbol table @@ -70,18 +70,19 @@ public void Dispose() } } - protected abstract void CreateSection(ObjectNodeSection section, out Stream sectionStream); + protected abstract void CreateSection(ObjectNodeSection section, Stream sectionStream); protected internal abstract void UpdateSectionAlignment(int sectionIndex, int alignment); protected SectionWriter GetOrCreateSection(ObjectNodeSection section) { int sectionIndex; - Stream sectionStream; + ObjectWriterStream sectionStream; if (!_sectionNameToSectionIndex.TryGetValue((section.Name, section.ComdatName), out sectionIndex)) { - CreateSection(section, out sectionStream); + sectionStream = new ObjectWriterStream(section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); + CreateSection(section, sectionStream); sectionIndex = _sectionNameToSectionIndex.Count; _sectionNameToSectionIndex.Add((section.Name, section.ComdatName), sectionIndex); _sectionIndexToStream.Add(sectionStream); @@ -95,8 +96,7 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) return new SectionWriter( this, sectionIndex, - sectionStream, - section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); + sectionStream); } protected bool ShouldShareSymbol(ObjectNode node) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index 7410acc6c7a52b..e2b97c78f646b5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -15,7 +15,7 @@ namespace ILCompiler.ObjectWriter /// Implements a stream of chained buffers. It supports appending existing /// read-only buffers without copying. /// - internal sealed class ObjectWriterStream : Stream + public sealed class ObjectWriterStream : Stream { private ArrayBufferWriter _appendBuffer = new(); private List> _buffers = new(); @@ -62,6 +62,11 @@ public override long Position } } + public ObjectWriterStream(byte paddingByte) + { + _padding.AsSpan().Fill(paddingByte); + } + public override void Flush() { FlushAppendBuffer(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index fd7a4fce9ccf72..ed1eb9142a3a1d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -25,33 +25,23 @@ namespace ILCompiler.ObjectWriter public struct SectionWriter { private ObjectWriter _objectWriter; - private byte _paddingByte; public int SectionIndex { get; init; } - public Stream Stream { get; init; } + public ObjectWriterStream Stream { get; init; } internal SectionWriter( ObjectWriter objectWriter, int sectionIndex, - Stream stream, - byte paddingByte) + ObjectWriterStream stream) { _objectWriter = objectWriter; - _paddingByte = paddingByte; SectionIndex = sectionIndex; Stream = stream; } public void EmitData(ReadOnlyMemory data) { - if (Stream is ObjectWriterStream objectWriterStream) - { - objectWriterStream.AppendData(data); - } - else - { - Stream.Write(data.Span); - } + Stream.AppendData(data); } public void EmitAlignment(int alignment) @@ -59,16 +49,7 @@ public void EmitAlignment(int alignment) _objectWriter.UpdateSectionAlignment(SectionIndex, alignment); int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); - if (Stream is ObjectWriterStream objectWriterStream) - { - objectWriterStream.AppendPadding(padding); - } - else - { - Span buffer = stackalloc byte[padding]; - buffer.Fill(_paddingByte); - Stream.Write(buffer); - } + Stream.AppendPadding(padding); } public void EmitRelocation( From 5645f9acb19fae955348f5eabf5f574c052433a0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 13:17:17 +0200 Subject: [PATCH 060/144] Fix scope overlapping in NAOT DWARF info (backport of https://github.com/dotnet/llvm-project/pull/444) --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 114 ++---------------- 1 file changed, 10 insertions(+), 104 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 8c4c2654f51d85..e95bc034a66720 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -410,76 +410,6 @@ public string GetMangledName(TypeDesc type) return _nameMangler.GetMangledTypeName(type); } - private sealed class LexicalScope - { - private uint _start; - private uint _end; - private bool _isFuncScope; - private List<(DebugVarInfoMetadata, DwarfDIE)> _vars = new(); - private List _innerScopes = new(); - - public uint Start => _start; - public uint End => _end; - public bool IsFuncScope => _isFuncScope; - public List<(DebugVarInfoMetadata, DwarfDIE)> Vars => _vars; - public List InnerScopes => _innerScopes; - - public LexicalScope(uint start, uint end, bool isFuncScope) - { - _start = start; - _end = end; - _isFuncScope = isFuncScope; - } - - public LexicalScope(DebugVarRangeInfo rangeInfo) - { - _start = rangeInfo.StartOffset; - _end = rangeInfo.EndOffset; - _isFuncScope = false; - } - - private bool IsContains(DebugVarRangeInfo rangeInfo) - => _start <= rangeInfo.StartOffset && _end >= rangeInfo.EndOffset; - - public void AddVar(DebugVarInfoMetadata metadataInfo, DwarfDIE type) - { - if (metadataInfo.IsParameter && _isFuncScope) - { - _vars.Add((metadataInfo, type)); - return; - } - - foreach (var rangeInfo in metadataInfo.DebugVarInfo.Ranges) - { - if (!IsContains(rangeInfo)) - return; - - // Var belongs to inner scope - if (rangeInfo.StartOffset != _start || rangeInfo.EndOffset != _end) - { - // Try to add variable to one the inner scopes - foreach (var innerScope in _innerScopes) - { - if (innerScope.IsContains(rangeInfo)) - { - innerScope.AddVar(metadataInfo, type); - return; - } - } - - // We need to create new inner scope for this var - var newInnerScope = new LexicalScope(rangeInfo); - newInnerScope.AddVar(metadataInfo, type); - _innerScopes.Add(newInnerScope); - } - else - { - _vars.Add((metadataInfo, type)); - } - } - } - }; - // TODO: Clean-up and share with R2R code private enum RegNumAmd64 : int { @@ -712,37 +642,6 @@ private DwarfDIE EmitVar(DebugVarInfoMetadata metadataInfo, ulong methodPCStart, } } - private void EmitLexicalBlock(LexicalScope lexicalScope, ulong methodPCStart, bool methodIsStatic, DwarfDIE die) - { - if (!lexicalScope.IsFuncScope) - { - var lexicalBlock = new DwarfDIELexicalBlock - { - LowPC = methodPCStart + lexicalScope.Start, - HighPC = (int)(lexicalScope.End - lexicalScope.Start), - }; - - die.AddChild(lexicalBlock); - die = lexicalBlock; - } - - foreach (var (var, type) in lexicalScope.Vars) - { - bool isThis = var.IsParameter && var.DebugVarInfo.VarNumber == 0 && !methodIsStatic; - var dwarfVar = EmitVar(var, methodPCStart, type, isThis); - die.AddChild(dwarfVar); - if (isThis) - { - ((DwarfDIESubprogram)die).ObjectPointer = dwarfVar; - } - } - - foreach (var innerScope in lexicalScope.InnerScopes) - { - EmitLexicalBlock(innerScope, methodPCStart, methodIsStatic, die); - } - } - public void EmitSubprogramInfo( string methodName, ulong methodPCStart, @@ -771,12 +670,19 @@ public void EmitSubprogramInfo( FrameBase = new DwarfLocation(frameExpression), }; - var methodScope = new LexicalScope(0u, (uint)methodPCLength, true); + /// At the moment, the lexical scope reflects IL, not C#, meaning that + /// there is only one scope for the whole method. We could be more precise + /// in the future by pulling the scope information from the PDB. foreach (var (debugVar, typeIndex) in debugVars) { - methodScope.AddVar(debugVar, typeIndex == 0 ? null : _rootDIE.Children[(int)typeIndex - 1]); + bool isThis = debugVar.IsParameter && debugVar.DebugVarInfo.VarNumber == 0 && subprogramSpec.ObjectPointer != null; + var dwarfVar = EmitVar(debugVar, methodPCStart, typeIndex == 0 ? null : _rootDIE.Children[(int)typeIndex - 1], isThis); + subprogram.AddChild(dwarfVar); + if (isThis) + { + subprogram.ObjectPointer = dwarfVar; + } } - EmitLexicalBlock(methodScope, methodPCStart, subprogramSpec.ObjectPointer == null, subprogram); foreach (var clause in debugEHClauseInfos) { From 4025c0950431690bc4f106a01c68edc5570f5c61 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 13:35:44 +0200 Subject: [PATCH 061/144] ELF: Use the address of __managedcode in DWARF info (backport of https://github.com/dotnet/llvm-project/pull/448) --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 0a53b68b77741d..fdf4afcfbbabd8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -300,19 +300,17 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) var rootDIE = (DwarfDIECompileUnit)unit.Root; dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; dwarfFile.AddressRangeTable.Unit = unit; - ulong lowPC = ulong.MaxValue; - ulong highPC = 0; foreach (var elfSection in _objectFile.Sections) { - if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) + if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable) && + elfSection.Name == "__managedcode") { dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, elfSection.Offset, elfSection.Size)); - lowPC = Math.Max(lowPC, elfSection.Offset); - highPC = Math.Max(highPC, elfSection.Offset + elfSection.Size); + rootDIE.LowPC = elfSection.Offset; + rootDIE.HighPC = (int)elfSection.Size; + break; } } - rootDIE.LowPC = 0u; - rootDIE.HighPC = (int)highPC; } var outputContext = new DwarfWriterContext From 6e0f1b6d721972ff1999d3d0fe33aae0bf2b5aa6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 14:09:47 +0200 Subject: [PATCH 062/144] ELF: Fix emitting global symbols --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 2 +- .../Compiler/ObjectWriter/ObjectWriter.cs | 10 ++++++---- .../Compiler/ObjectWriter/SectionWriter.cs | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index fdf4afcfbbabd8..ec7187e68cff83 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -170,7 +170,7 @@ protected override void EmitSymbolTable() Value = (ulong)definition.Value, Type = definition.Size > 0 ? ElfSymbolType.Function : 0, Size = (ulong)definition.Size, - Visibility = ElfSymbolVisibility.Hidden, + Visibility = definition.Global ? ElfSymbolVisibility.Default : ElfSymbolVisibility.Hidden, }); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index c7402450c6fc4e..d621a8e015f93b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -24,7 +24,7 @@ namespace ILCompiler.ObjectWriter { public abstract class ObjectWriter : IDisposable { - protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0); + protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); protected NodeFactory _nodeFactory; @@ -186,11 +186,12 @@ protected internal void EmitSymbolDefinition( int sectionIndex, string symbolName, int offset = 0, - int size = 0) + int size = 0, + bool global = false) { _definedSymbols.Add( symbolName, - new SymbolDefinition(sectionIndex, offset, size)); + new SymbolDefinition(sectionIndex, offset, size, global)); } /// @@ -342,7 +343,8 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Wed, 27 Sep 2023 16:43:27 +0200 Subject: [PATCH 063/144] ELF: Fix TLS support on linux-x64 Release builds --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index ec7187e68cff83..7dda04ef8fc676 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -75,6 +75,18 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS _sectionIndexToElfSection[_sectionIndex++] = elfSection; _objectFile.AddSection(elfSection); } + else if (section == ObjectNodeSection.TLSSection) + { + ElfSection elfSection = new ElfBinarySection(sectionStream) + { + Name = sectionName, + Type = ElfSectionType.ProgBits, + Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write | ElfSectionFlags.Tls + }; + + _sectionIndexToElfSection[_sectionIndex++] = elfSection; + _objectFile.AddSection(elfSection); + } else { ElfSection elfSection = new ElfBinarySection(sectionStream) @@ -122,7 +134,9 @@ protected internal override void EmitRelocation( // the destination with the addend from relocation table. if (relocType == RelocType.IMAGE_REL_BASED_REL32 || - relocType == RelocType.IMAGE_REL_BASED_RELPTR32) + relocType == RelocType.IMAGE_REL_BASED_RELPTR32 || + relocType == RelocType.IMAGE_REL_TLSGD || + relocType == RelocType.IMAGE_REL_TPOFF) { addend += BinaryPrimitives.ReadInt32LittleEndian(data); BinaryPrimitives.WriteInt32LittleEndian(data, 0); @@ -162,13 +176,16 @@ protected override void EmitSymbolTable() var sortedSymbols = new List(definedSymbols.Count); foreach (var (name, definition) in definedSymbols) { + var elfSection = _sectionIndexToElfSection[definition.SectionIndex]; sortedSymbols.Add(new ElfSymbol { Name = name, Bind = ElfSymbolBind.Global, - Section = _sectionIndexToElfSection[definition.SectionIndex], + Section = elfSection, Value = (ulong)definition.Value, - Type = definition.Size > 0 ? ElfSymbolType.Function : 0, + Type = + elfSection.Flags.HasFlag(ElfSectionFlags.Tls) ? ElfSymbolType.Tls : + definition.Size > 0 ? ElfSymbolType.Function : 0, Size = (ulong)definition.Size, Visibility = definition.Global ? ElfSymbolVisibility.Default : ElfSymbolVisibility.Hidden, }); @@ -263,6 +280,8 @@ private void EmitRelocationsX64(int sectionIndex, List reloc RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_X86_64_64, RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_X86_64_PC32, RelocType.IMAGE_REL_BASED_REL32 => ElfRelocationType.R_X86_64_PLT32, + RelocType.IMAGE_REL_TLSGD => ElfRelocationType.R_X86_64_TLSGD, + RelocType.IMAGE_REL_TPOFF => ElfRelocationType.R_X86_64_TPOFF32, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; From 1d76838988036ed23719922446c89cd2deb57841 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 01:43:44 +0200 Subject: [PATCH 064/144] Return sorted set from GetUndefinedSymbols to avoid extra sorting --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 15 ++++----------- .../Compiler/ObjectWriter/ObjectWriter.cs | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index a47c65d6290377..c0132b0a40b94e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -338,7 +338,7 @@ protected override void EmitSymbolTable() _dySymbolTable.ExternalSymbolsIndex = _dySymbolTable.LocalSymbolsCount; _dySymbolTable.ExternalSymbolsCount = (uint)definedSymbols.Count; - List undefinedSymbols = new List(); + uint savedSymbolIndex = symbolIndex; foreach (var externSymbol in GetUndefinedSymbols()) { var machSymbol = new MachSymbol @@ -349,20 +349,13 @@ protected override void EmitSymbolTable() Descriptor = 0, Type = MachSymbolType.Undefined | MachSymbolType.External, }; - undefinedSymbols.Add(machSymbol); - } - - // Sort and insert all undefined external symbols - undefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); - foreach (var undefinedSymbol in undefinedSymbols) - { - _symbolTable.Symbols.Add(undefinedSymbol); - _symbolNameToIndex[undefinedSymbol.Name] = symbolIndex; + _symbolTable.Symbols.Add(machSymbol); + _symbolNameToIndex[externSymbol] = symbolIndex; symbolIndex++; } _dySymbolTable.UndefinedSymbolsIndex = _dySymbolTable.LocalSymbolsCount + _dySymbolTable.ExternalSymbolsCount; - _dySymbolTable.UndefinedSymbolsCount = (uint)undefinedSymbols.Count; + _dySymbolTable.UndefinedSymbolsCount = symbolIndex - savedSymbolIndex; } protected override void EmitRelocations(int sectionIndex, List relocationList) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index d621a8e015f93b..ad3459deba5a93 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -254,7 +254,7 @@ protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMe protected ISet GetUndefinedSymbols() { - HashSet undefinedSymbolSet = new HashSet(); + SortedSet undefinedSymbolSet = new SortedSet(StringComparer.Ordinal); foreach (var relocationList in _sectionIndexToRelocations) foreach (var symbolicRelocation in relocationList) { From a1922c53be54e41a3aab0626104a5f811afbf16c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 20:34:22 +0200 Subject: [PATCH 065/144] COFF: Fix generating COMDAT section references in big-obj files --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index b56a72f4e1b354..37bddb52fe2c44 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -202,7 +202,7 @@ protected override void EmitSymbolTable() // SizeOfRawData, NumberOfRelocations, NumberOfLineNumbers // CheckSum will be filled later in EmitObjectFile - Number = (ushort)(1 + definingSectionIndex), + Number = (uint)(1 + definingSectionIndex), Selection = definingSectionIndex == sectionIndex ? CoffComdatSelect.IMAGE_COMDAT_SELECT_ANY : CoffComdatSelect.IMAGE_COMDAT_SELECT_ASSOCIATIVE, @@ -367,17 +367,9 @@ protected override void EmitUnwindInfo( SectionWriter xdataSectionWriter; SectionWriter pdataSectionWriter; Span tempBuffer = stackalloc byte[4]; + bool shareSymbol = ShouldShareSymbol((ObjectNode)nodeWithCodeInfo); - if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) - { - xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName)); - pdataSectionWriter = GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)); - } - else - { - xdataSectionWriter = _xdataSectionWriter; - pdataSectionWriter = _pdataSectionWriter; - } + pdataSectionWriter = shareSymbol ? GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)) : _pdataSectionWriter; for (int i = 0; i < frameInfos.Length; i++) { @@ -389,6 +381,20 @@ protected override void EmitUnwindInfo( string unwindSymbolName = $"_unwind{i}{currentSymbolName}"; + if (shareSymbol) + { + // Ideally we would use `currentSymbolName` here and produce an + // associative COMDAT symbol but link.exe cannot always handle that + // and produces errors about duplicate symbols that point into the + // associative section, so we are stuck with one section per each + // unwind symbol. + xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, unwindSymbolName)); + } + else + { + xdataSectionWriter = _xdataSectionWriter; + } + // Need to emit the UNWIND_INFO at 4-byte alignment to ensure that the // pointer has the lower two bits in .pdata section set to zero. On ARM64 // non-zero bits would mean a compact encoding. @@ -928,7 +934,7 @@ private sealed class CoffSectionSymbol : CoffSymbolRecord public ushort NumberOfRelocations { get; set; } public ushort NumberOfLineNumbers { get; set; } public uint CheckSum { get; set; } - public ushort Number { get; set; } + public uint Number { get; set; } public CoffComdatSelect Selection { get; set; } private const int RegularSize = @@ -951,8 +957,12 @@ public override void Write(Stream stream, CoffStringTable stringTable, bool isBi BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(4), NumberOfRelocations); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), NumberOfLineNumbers); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), CheckSum); - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(12), Number); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(12), (ushort)Number); buffer[14] = (byte)Selection; + if (isBigObj) + { + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(16), (ushort)(Number >> 16)); + } stream.Write(buffer); } From 3e9fcc71c65d0eaf5cfecf28b3ed32bcb7c97fc0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 27 Sep 2023 21:09:51 +0200 Subject: [PATCH 066/144] Generate Mach-O for iOS-like platforms, not ELF --- .../tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 8d314a366c89e0..495a0bfbc37be1 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -112,7 +112,7 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) stopwatch.Start(); if (Environment.GetEnvironmentVariable("DOTNET_USE_LLVM_OBJWRITER") == "1") LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - else if (NodeFactory.Target.OperatingSystem == TargetOS.OSX) + else if (NodeFactory.Target.IsOSXLike) MachObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); else if (NodeFactory.Target.OperatingSystem == TargetOS.Windows) CoffObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); From 9e95e9bb18576c1b8891def7c66593c00b3f561a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 28 Sep 2023 10:29:27 +0200 Subject: [PATCH 067/144] Fix EH frames on linux-arm64 --- .../Compiler/ObjectWriter/DwarfCie.cs | 2 +- .../Compiler/ObjectWriter/DwarfFde.cs | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs index 463c22af11c623..60f83fd0c6dce6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs @@ -45,7 +45,7 @@ public DwarfCie(TargetArchitecture targetArchitecture) if (targetArchitecture == TargetArchitecture.ARM64) { CodeAlignFactor = 1; - DataAlignFactor = -8; + DataAlignFactor = -4; ReturnAddressRegister = 30; // LR Instructions = new byte[] { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs index d209c7443eb49b..0671120523d066 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs @@ -62,12 +62,13 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) { // Advance int diff = (int)((codeOffset - lastCodeOffset) / cie.CodeAlignFactor); - if (diff < 0x3f) + if (diff <= 0x3f) { cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_advance_loc | diff); } else { + Debug.Assert(diff <= 0xff); cfiCode[cfiCodeOffset++] = (byte)DW_CFA_advance_loc1; cfiCode[cfiCodeOffset++] = (byte)diff; } @@ -82,8 +83,21 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) break; case CFI_OPCODE.CFI_REL_OFFSET: - Debug.Assert(dwarfReg <= 0x3f); - cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_offset | (byte)dwarfReg); + if (dwarfReg <= 0x3f) + { + cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_offset | (byte)dwarfReg); + } + else + { + cfiCode[cfiCodeOffset++] = DW_CFA_offset_extended; + temp = (uint)dwarfReg; + do + { + cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); + temp >>= 7; + } + while (temp > 0); + } temp = (uint)((cfiOffset - cfaOffset) / cie.DataAlignFactor); do { From 9a50db5f92d5ad0656f879f4eca111b4e43ba538 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Sep 2023 10:18:41 +0200 Subject: [PATCH 068/144] COFF: Support addend for IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A relocation --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 37bddb52fe2c44..faf4a8ffe3f2ce 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -129,12 +129,21 @@ protected internal override void EmitRelocation( { case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: case RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: - case RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: case RelocType.IMAGE_REL_SECREL: case RelocType.IMAGE_REL_SECTION: Debug.Assert(addend == 0); break; + case RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: + if (addend != 0) + { + uint addInstr = BinaryPrimitives.ReadUInt32LittleEndian(data); + addInstr &= 0xFFC003FF; // keep bits 31-22, 9-0 + addInstr |= (uint)(addend << 10); // Occupy 21-10. + BinaryPrimitives.WriteUInt32LittleEndian(data, addInstr); // write the assembled instruction + } + break; + case RelocType.IMAGE_REL_BASED_DIR64: if (addend != 0) { From 6c28f5a532ec4862ea9707fc7550ea2a1137dc1c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Sep 2023 10:19:32 +0200 Subject: [PATCH 069/144] COFF: Emit alignment for .pdata section --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index faf4a8ffe3f2ce..5879330b25c0a0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -449,6 +449,7 @@ protected override void EmitUnwindInfo( } // Emit RUNTIME_FUNCTION + pdataSectionWriter.EmitAlignment(4); pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); // Only x64 has the End symbol if (_machine == Machine.Amd64) From b357425e407ce03586510fa226a877f69c9e3b55 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Sep 2023 10:21:15 +0200 Subject: [PATCH 070/144] Fix padding emitted in ObjectWriterStream.AppendPadding --- .../ObjectWriter/ObjectWriterStream.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index e2b97c78f646b5..cc3b43ce55684d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -23,7 +23,7 @@ public sealed class ObjectWriterStream : Stream private int _bufferIndex; private int _bufferPosition; private long _position; - private static byte[] _padding = new byte[16]; + private byte[] _padding = new byte[16]; public override bool CanRead => true; @@ -159,16 +159,19 @@ public void AppendData(ReadOnlyMemory data) public void AppendPadding(int paddingLength) { - if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) + if (paddingLength > 0) { - _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Clear(); - _appendBuffer.Advance(paddingLength); - _position += paddingLength; - _bufferPosition += paddingLength; - } - else - { - AppendData(_padding.AsMemory(0, paddingLength)); + if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) + { + _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Fill(_padding[0]); + _appendBuffer.Advance(paddingLength); + _position += paddingLength; + _bufferPosition += paddingLength; + } + else + { + AppendData(_padding.AsMemory(0, paddingLength)); + } } } From febce5a9e8773fb76d0f14c268f353c1704f60df Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Sep 2023 11:10:44 +0200 Subject: [PATCH 071/144] Fix ObjectWriterStream.Position setter (again) --- .../Compiler/ObjectWriter/ObjectWriterStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index cc3b43ce55684d..b845b6d5cd2b7a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -49,8 +49,8 @@ public override long Position { if (_buffers[_bufferIndex].Length < value - _position) { - _bufferIndex++; _position += _buffers[_bufferIndex].Length; + _bufferIndex++; } else { From 93e84cb71e5fcd3e35dd17e0d3675d6377b875a4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 30 Sep 2023 14:37:56 +0200 Subject: [PATCH 072/144] COFF: Emit .pdata/.xdata as associative COMDAT sections/symbols --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 27 ++++++++++++++++--- .../Compiler/ObjectWriter/ObjectWriter.cs | 11 +++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 5879330b25c0a0..036118f2911363 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -195,6 +195,16 @@ protected override void EmitReferencedMethod(string symbolName) protected override void EmitSymbolTable() { var definedSymbols = GetDefinedSymbols(); + var sectionSymbol = new string[_sections.Count]; + + foreach (var (symbolName, symbolDefinition) in definedSymbols) + { + if (symbolDefinition.Value == 0 && + sectionSymbol[symbolDefinition.SectionIndex] is null) + { + sectionSymbol[symbolDefinition.SectionIndex] = symbolName; + } + } int sectionIndex = 0; foreach (var (sectionHeader, _, _, comdatName) in _sections) @@ -239,6 +249,17 @@ protected override void EmitSymbolTable() StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL }); } + else if (sectionSymbol[sectionIndex] is not null) + { + _symbolNameToIndex.Add(sectionSymbol[sectionIndex], (uint)_symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = sectionSymbol[sectionIndex], + Value = 0, + SectionIndex = (uint)(1 + sectionIndex), + StorageClass = 3 // IMAGE_SYM_CLASS_STATIC + }); + } } sectionIndex++; } @@ -378,8 +399,6 @@ protected override void EmitUnwindInfo( Span tempBuffer = stackalloc byte[4]; bool shareSymbol = ShouldShareSymbol((ObjectNode)nodeWithCodeInfo); - pdataSectionWriter = shareSymbol ? GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)) : _pdataSectionWriter; - for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; @@ -397,11 +416,13 @@ protected override void EmitUnwindInfo( // and produces errors about duplicate symbols that point into the // associative section, so we are stuck with one section per each // unwind symbol. - xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, unwindSymbolName)); + xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName)); + pdataSectionWriter = GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)); } else { xdataSectionWriter = _xdataSectionWriter; + pdataSectionWriter = _pdataSectionWriter; } // Need to emit the UNWIND_INFO at 4-byte alignment to ensure that the diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index ad3459deba5a93..f8db84b9b5a581 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -36,7 +36,7 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy private byte _insPaddingByte; // Standard sections - private Dictionary<(string, string), int> _sectionNameToSectionIndex = new(); + private Dictionary _sectionNameToSectionIndex = new(); private List _sectionIndexToStream = new(); private List> _sectionIndexToRelocations = new(); @@ -79,14 +79,17 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) int sectionIndex; ObjectWriterStream sectionStream; - if (!_sectionNameToSectionIndex.TryGetValue((section.Name, section.ComdatName), out sectionIndex)) + if (section.ComdatName is not null || !_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) { sectionStream = new ObjectWriterStream(section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); CreateSection(section, sectionStream); - sectionIndex = _sectionNameToSectionIndex.Count; - _sectionNameToSectionIndex.Add((section.Name, section.ComdatName), sectionIndex); + sectionIndex = _sectionIndexToStream.Count; _sectionIndexToStream.Add(sectionStream); _sectionIndexToRelocations.Add(new()); + if (section.ComdatName is null) + { + _sectionNameToSectionIndex.Add(section.Name, sectionIndex); + } } else { From 0a61577b0ce9f03de907ef41522f1a42a57ee571 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 2 Oct 2023 17:20:31 +0200 Subject: [PATCH 073/144] ELF/LibObjectFile experiment: Add support for building optimized string table --- .../Elf/Sections/ElfStringTable.cs | 168 +++++++++++++++--- .../Elf/Sections/ElfSymbolTable.cs | 2 +- 2 files changed, 146 insertions(+), 24 deletions(-) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs index 447fd9db0820a2..b7de66f4237b1b 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs @@ -17,6 +17,7 @@ namespace LibObjectFile.Elf public class ElfStringTable : ElfSection { private readonly MemoryStream _table; + private readonly List _reservedStrings; private readonly Dictionary _mapStringToIndex; private readonly Dictionary _mapIndexToString; @@ -35,8 +36,9 @@ public ElfStringTable(int capacityInBytes) : base(ElfSectionType.StringTable) _table = new MemoryStream(capacityInBytes); _mapStringToIndex = new Dictionary(); _mapIndexToString = new Dictionary(); + _reservedStrings = new List(); // Always create an empty string - GetOrCreateIndex(string.Empty); + CreateIndex(string.Empty); } public override ElfSectionType Type @@ -55,6 +57,7 @@ public override ElfSectionType Type public override void UpdateLayout(DiagnosticBag diagnostics) { if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + if (_reservedStrings.Count > 0) FlushReservedStrings(); Size = (ulong)_table.Length; } @@ -73,21 +76,136 @@ protected override void Write(ElfWriter writer) writer.Stream.Write(_table.GetBuffer(), 0, (int)_table.Length); } - public uint GetOrCreateIndex(string text) + internal void ReserveString(string text) { - // Same as empty string - if (text == null) return 0; + if (text is object && !_mapStringToIndex.ContainsKey(text)) + { + _reservedStrings.Add(text); + } + } - if (_mapStringToIndex.TryGetValue(text, out uint index)) + internal void FlushReservedStrings() + { + // TODO: Use CollectionsMarshal.AsSpan + string[] reservedStrings = _reservedStrings.ToArray(); + + // Pre-sort the string based on their matching suffix + MultiKeySort(reservedStrings, 0); + + // Add the strings to string table + string lastText = null; + for (int i = 0; i < reservedStrings.Length; i++) { - return index; + var text = reservedStrings[i]; + uint index; + if (lastText != null && lastText.EndsWith(text, StringComparison.Ordinal)) + { + // Suffix matches the last symbol + index = (uint)(_table.Length - Encoding.UTF8.GetByteCount(text) - 1); + _mapIndexToString.Add(index, text); + _mapStringToIndex.Add(text, index); + } + else + { + lastText = text; + CreateIndex(text); + } + } + + _reservedStrings.Clear(); + + static char TailCharacter(string str, int pos) + { + int index = str.Length - pos - 1; + if ((uint)index < str.Length) + return str[index]; + return '\0'; + } + + static void MultiKeySort(Span input, int pos) + { + if (!MultiKeySortSmallInput(input, pos)) + { + MultiKeySortLargeInput(input, pos); + } + } + + static void MultiKeySortLargeInput(Span input, int pos) + { + tailcall: + char pivot = TailCharacter(input[0], pos); + int l = 0, h = input.Length; + for (int i = 1; i < h;) + { + char c = TailCharacter(input[i], pos); + if (c > pivot) + { + (input[l], input[i]) = (input[i], input[l]); + l++; i++; + } + else if (c < pivot) + { + h--; + (input[h], input[i]) = (input[i], input[h]); + } + else + { + i++; + } + } + + MultiKeySort(input.Slice(0, l), pos); + MultiKeySort(input.Slice(h), pos); + if (pivot != '\0') + { + // Use a loop as a poor man's tailcall + // MultiKeySort(input.Slice(l, h - l), pos + 1); + pos++; + input = input.Slice(l, h - l); + if (!MultiKeySortSmallInput(input, pos)) + { + goto tailcall; + } + } + } + + static bool MultiKeySortSmallInput(Span input, int pos) + { + if (input.Length <= 1) + return true; + + // Optimize comparing two strings + if (input.Length == 2) + { + while (true) + { + char c0 = TailCharacter(input[0], pos); + char c1 = TailCharacter(input[1], pos); + if (c0 < c1) + { + (input[0], input[1]) = (input[1], input[0]); + break; + } + else if (c0 > c1 || c0 == (char)0) + { + break; + } + pos++; + } + return true; + } + + return false; } + } - index = (uint) _table.Length; + private uint CreateIndex(string text) + { + uint index = (uint) _table.Length; _mapIndexToString.Add(index, text); _mapStringToIndex.Add(text, index); - if (text.Length == 0) + if (index == 0) { Debug.Assert(index == 0); _table.WriteByte(0); @@ -105,25 +223,26 @@ public uint GetOrCreateIndex(string text) } _table.Write(span); ArrayPool.Shared.Return(buffer); - - // Register all subsequent strings - while (text.Length > 0) - { - text = text.Substring(1); - if (_mapStringToIndex.ContainsKey(text)) - { - break; - } - var offset = reservedBytes - Encoding.UTF8.GetByteCount(text) - 1; - var subIndex = index + (uint) offset; - _mapStringToIndex.Add(text, subIndex); - _mapIndexToString.Add(subIndex, text); - } } return index; } + public uint GetOrCreateIndex(string text) + { + // Same as empty string + if (text == null) return 0; + + if (_reservedStrings.Count > 0) FlushReservedStrings(); + + if (_mapStringToIndex.TryGetValue(text, out uint index)) + { + return index; + } + + return CreateIndex(text); + } + public bool TryResolve(ElfString inStr, out ElfString outStr) { outStr = inStr; @@ -153,6 +272,8 @@ public bool TryFind(uint index, out string text) return true; } + if (_reservedStrings.Count > 0) FlushReservedStrings(); + if (_mapIndexToString.TryGetValue(index, out text)) { return true; @@ -191,9 +312,10 @@ public void Reset() _table.SetLength(0); _mapStringToIndex.Clear(); _mapIndexToString.Clear(); + _reservedStrings.Clear(); // Always create an empty string - GetOrCreateIndex(string.Empty); + CreateIndex(string.Empty); } } } \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs index a23f823931ecb9..4e7ab842d4eb79 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs @@ -227,7 +227,7 @@ public override void Verify(DiagnosticBag diagnostics) diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntrySectionParent, $"Invalid section for the symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The section of the entry `{entry}` must the same than this symbol table section"); } - stringTable.GetOrCreateIndex(entry.Name); + stringTable.ReserveString(entry.Name); // Update the last local index if (entry.Bind == ElfSymbolBind.Local) From bfb6db44401bdc422e659f58e46992988245be1c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 4 Oct 2023 18:42:57 +0200 Subject: [PATCH 074/144] LibObjectFile: Add support for >= 0xff00 sections --- .../src/LibObjectFile/Elf/ElfObjectFile.cs | 2 ++ .../LibObjectFile/Elf/ElfWriter{TEncoder}.cs | 11 ++++++---- .../Elf/Sections/ElfBinarySection.cs | 2 +- .../Elf/Sections/ElfNullSection.cs | 22 ++++++++++++++++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs index fc0b979339692b..3e72ad045588cf 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs @@ -230,6 +230,8 @@ public unsafe void UpdateLayout(DiagnosticBag diagnostics) var section = sections[i]; if (i == 0 && section.Type == ElfSectionType.Null) { + section.Size = VisibleSectionCount >= ElfNative.SHN_LORESERVE ? VisibleSectionCount : 0; + section.Link = (SectionHeaderStringTable?.SectionIndex ?? 0) >= ElfNative.SHN_LORESERVE ? SectionHeaderStringTable : null; continue; } diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs index 163adaf6c3ac7c..1bb1be65f8cd5e 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs @@ -155,8 +155,9 @@ private unsafe void WriteSectionHeader32() // entries for sections _encoder.Encode(out hdr.e_shoff, (uint)Layout.OffsetOfSectionHeaderTable); _encoder.Encode(out hdr.e_shentsize, Layout.SizeOfSectionHeaderEntry); - _encoder.Encode(out hdr.e_shnum, (ushort)ObjectFile.VisibleSectionCount); - _encoder.Encode(out hdr.e_shstrndx, (ushort)(ObjectFile.SectionHeaderStringTable?.SectionIndex ?? (ushort)0)); + _encoder.Encode(out hdr.e_shnum, ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE ? (ushort)0 : (ushort)ObjectFile.VisibleSectionCount); + uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; + _encoder.Encode(out hdr.e_shstrndx, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? (ushort)ElfNative.SHN_XINDEX : (ushort)shstrSectionIndex); Write(hdr); } @@ -181,11 +182,13 @@ private unsafe void WriteSectionHeader64() // entries for sections _encoder.Encode(out hdr.e_shoff, Layout.OffsetOfSectionHeaderTable); _encoder.Encode(out hdr.e_shentsize, (ushort)sizeof(Elf64_Shdr)); - _encoder.Encode(out hdr.e_shnum, (ushort)ObjectFile.VisibleSectionCount); - _encoder.Encode(out hdr.e_shstrndx, (ushort)(ObjectFile.SectionHeaderStringTable?.SectionIndex ?? (ushort)0)); + _encoder.Encode(out hdr.e_shnum, ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE ? (ushort)0 : (ushort)ObjectFile.VisibleSectionCount); + uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; + _encoder.Encode(out hdr.e_shstrndx, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? (ushort)ElfNative.SHN_XINDEX : (ushort)shstrSectionIndex); Write(hdr); } + private void CheckProgramHeaders() { if (ObjectFile.Segments.Count == 0) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs index 4aeaf7b2905d4d..db864d9b6dd923 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs @@ -42,7 +42,7 @@ public override ElfSectionType Type } public override ulong TableEntrySize => OriginalTableEntrySize; - + /// /// Gets or sets the associated stream to this section. /// diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs index 89f92a948afd8e..02e95eba7e97f7 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs @@ -20,13 +20,29 @@ public override void Verify(DiagnosticBag diagnostics) !Name.IsEmpty || VirtualAddress != 0 || Alignment != 0 || - !Link.IsEmpty || !Info.IsEmpty || - Offset != 0 || - Size != 0) + Offset != 0) { diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. This section should not be modified and all properties must be null"); } + + if (Size != 0 && Parent.VisibleSectionCount < ElfNative.SHN_LORESERVE) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Size is non-zero but number of sections is lower than SHN_LORESERVE"); + } + else if (Size == 0 && Parent.VisibleSectionCount >= ElfNative.SHN_LORESERVE) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Size is zero but number of sections is higher or equal to SHN_LORESERVE"); + } + + if (!Link.IsEmpty && (Parent.SectionHeaderStringTable?.SectionIndex ?? 0) < ElfNative.SHN_LORESERVE) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Link is non-zero but index of section header string section is lower than SHN_LORESERVE"); + } + else if (Link.IsEmpty && (Parent.SectionHeaderStringTable?.SectionIndex ?? 0) >= ElfNative.SHN_LORESERVE) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Link is non-zero but index of section header string section is higher or equal to SHN_LORESERVE"); + } } public override void UpdateLayout(DiagnosticBag diagnostics) From 6f0d7700df40d361fb4b155192774adc820016d4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 4 Oct 2023 18:54:16 +0200 Subject: [PATCH 075/144] ELF: Add basic COMDAT support, don't emit empty relocation sections --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 150 +++++++++++++++--- .../Compiler/ObjectWriter/ObjectWriter.cs | 13 +- 2 files changed, 132 insertions(+), 31 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 7dda04ef8fc676..001a53da4def8a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Diagnostics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Linq; using System.Numerics; @@ -34,6 +35,8 @@ public sealed class ElfObjectWriter : UnixObjectWriter private int _sectionIndex; private Dictionary _bssStreams = new(); private Dictionary _sectionIndexToElfSection = new(); + private Dictionary _elfSectionToSectionIndex = new(); + private Dictionary _comdatNameToElfSection = new(); private Dictionary _sectionToRelocationTable = new(); // Symbol table @@ -58,13 +61,27 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) { + ElfSection elfSection; + ElfGroupSection groupSection = null; string sectionName = section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); + if (section.ComdatName != null && + !_comdatNameToElfSection.TryGetValue(section.ComdatName, out groupSection)) + { + groupSection = new ElfGroupSection + { + Link = _symbolTable, + // Info = of the COMDAT symbol, to be filled later + }; + groupSection.GroupFlags = 1; // GRP_COMDAT + _comdatNameToElfSection.Add(section.ComdatName, groupSection); + } + if (section.Type == SectionType.Uninitialized) { - ElfSection elfSection = new ElfBinarySection() + elfSection = new ElfBinarySection() { Name = sectionName, Type = ElfSectionType.NoBits, @@ -72,24 +89,19 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS }; _bssStreams[_sectionIndex] = sectionStream; - _sectionIndexToElfSection[_sectionIndex++] = elfSection; - _objectFile.AddSection(elfSection); } else if (section == ObjectNodeSection.TLSSection) { - ElfSection elfSection = new ElfBinarySection(sectionStream) + elfSection = new ElfBinarySection(sectionStream) { Name = sectionName, Type = ElfSectionType.ProgBits, Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write | ElfSectionFlags.Tls }; - - _sectionIndexToElfSection[_sectionIndex++] = elfSection; - _objectFile.AddSection(elfSection); } else { - ElfSection elfSection = new ElfBinarySection(sectionStream) + elfSection = new ElfBinarySection(sectionStream) { Name = sectionName, Type = section.Name == ".eh_frame" && _objectFile.Arch == ElfArch.X86_64 ? @@ -99,20 +111,11 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS (section.Type == SectionType.Writeable ? ElfSectionFlags.Alloc | ElfSectionFlags.Write : ElfSectionFlags.Alloc) }; - - var elfRelocationTable = new ElfRelocationTable - { - Name = ".rela" + sectionName, - Link = _symbolTable, - Info = elfSection, - Alignment = 8, - }; - - _sectionIndexToElfSection[_sectionIndex++] = elfSection; - _sectionToRelocationTable[elfSection] = elfRelocationTable; - _objectFile.AddSection(elfSection); - _objectFile.AddSection(elfRelocationTable); } + + _elfSectionToSectionIndex[elfSection] = _sectionIndex; + _sectionIndexToElfSection[_sectionIndex++] = elfSection; + groupSection?.AddSection(elfSection); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -207,6 +210,12 @@ protected override void EmitSymbolTable() _symbolNameToIndex[definedSymbol.Name] = symbolIndex; symbolIndex++; } + + // Update group sections links + foreach (var (comdatName, groupSection) in _comdatNameToElfSection) + { + groupSection.Info = new ElfSectionLink(_symbolNameToIndex[comdatName]); + } } protected override void EmitRelocations(int sectionIndex, List relocationList) @@ -314,6 +323,11 @@ protected override ulong GetSectionVirtualAddress(int sectionIndex) protected override void EmitDebugSections(DwarfFile dwarfFile) { + // NOTE: We need the layout to find the offset and size of the __managedcode section + var elfDiagnostics = new DiagnosticBag(); + _objectFile.UpdateLayout(elfDiagnostics); + Debug.Assert(!elfDiagnostics.HasErrors); + foreach (var unit in dwarfFile.InfoSection.Units) { var rootDIE = (DwarfDIECompileUnit)unit.Root; @@ -321,6 +335,7 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) dwarfFile.AddressRangeTable.Unit = unit; foreach (var elfSection in _objectFile.Sections) { + // TODO: What about __managedcode in COMDAT? if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable) && elfSection.Name == "__managedcode") { @@ -455,8 +470,50 @@ void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTab } } + private void AddElfSectionWithRelocationsIfNecessary(ElfSection elfSection, ElfGroupSection groupSection = null) + { + int sectionIndex = _elfSectionToSectionIndex[elfSection]; + elfSection.Flags |= groupSection is not null ? ElfSectionFlags.Group : 0; + _objectFile.AddSection(elfSection); + + if (SectionHasRelocations(sectionIndex)) + { + var elfRelocationTable = new ElfRelocationTable + { + Name = ".rela" + elfSection.Name, + Link = _symbolTable, + Info = elfSection, + Alignment = 8, + Flags = groupSection is not null ? ElfSectionFlags.Group : 0 + }; + + _sectionToRelocationTable[elfSection] = elfRelocationTable; + _objectFile.AddSection(elfRelocationTable); + groupSection?.AddSection(elfRelocationTable); + } + } + protected override void EmitSectionsAndLayout() { + foreach (var groupSection in _comdatNameToElfSection.Values) + { + _objectFile.AddSection(groupSection); + for (int i = 0, sectionCount = groupSection.Sections.Count; i < sectionCount; i++) + { + AddElfSectionWithRelocationsIfNecessary(groupSection.Sections[i], groupSection); + } + } + + foreach (var elfSection in _sectionIndexToElfSection.Values) + { + // If the section was not already added as part of COMDAT group, + // add it now. + if (elfSection.Parent is null) + { + AddElfSectionWithRelocationsIfNecessary(elfSection); + } + } + _objectFile.AddSection(_symbolTable.Link.Section); _objectFile.AddSection(_symbolTable); _objectFile.AddSection(new ElfSectionHeaderStringTable()); @@ -470,10 +527,6 @@ protected override void EmitSectionsAndLayout() Name = ".note.GNU-stack", Type = ElfSectionType.ProgBits, }); - - var elfDiagnostics = new DiagnosticBag(); - _objectFile.UpdateLayout(elfDiagnostics); - Debug.Assert(!elfDiagnostics.HasErrors); } protected override void EmitObjectFile(string objectFilePath) @@ -489,5 +542,52 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection _sections = new(4); + + public ElfGroupSection() + { + Name = ".group"; + Type = ElfSectionType.Group; + Alignment = 4; + } + + public uint GroupFlags { get; set; } + public IReadOnlyList Sections => _sections; + public override ulong TableEntrySize => 4; + + public void AddSection(ElfSection section) => _sections.Add(section); + + public override void UpdateLayout(DiagnosticBag diagnostics) + { + Size = (ulong)(4u + (_sections.Count * 4u)); + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + foreach (var section in _sections) + { + if (section.Parent != this.Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionInfoParent, $"Invalid parent for grouped section"); + } + } + } + + protected override void Read(ElfReader reader) => throw new NotImplementedException(); + + protected override void Write(ElfWriter writer) + { + writer.Write((uint)GroupFlags); + foreach (var section in _sections) + { + writer.Write((uint)section.SectionIndex); + } + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index f8db84b9b5a581..e766adc6c14e73 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -104,9 +104,7 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section) protected bool ShouldShareSymbol(ObjectNode node) { - // TODO: Not supported yet - if (_nodeFactory.Target.IsOSXLike || - _nodeFactory.Target.OperatingSystem == TargetOS.Linux) + if (_nodeFactory.Target.IsOSXLike) return false; return ShouldShareSymbol(node, node.GetSection(_nodeFactory)); @@ -114,9 +112,7 @@ protected bool ShouldShareSymbol(ObjectNode node) protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) { - // TODO: Not supported yet - if (_nodeFactory.Target.IsOSXLike || - _nodeFactory.Target.OperatingSystem == TargetOS.Linux) + if (_nodeFactory.Target.IsOSXLike) return false; // Foldable sections are always COMDATs @@ -165,6 +161,11 @@ protected internal virtual void EmitRelocation( _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } + protected bool SectionHasRelocations(int sectionIndex) + { + return _sectionIndexToRelocations[sectionIndex].Count > 0; + } + protected virtual void EmitReferencedMethod(string symbolName) { } /// From 62c478e0563b455b0d0c23ab384c3eeb9c7b4b62 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 5 Oct 2023 13:46:32 +0200 Subject: [PATCH 076/144] ELF: Emit correct addresses and relocations in debug info, referencesection addresses using DW_AT_RANGES which can work with multiple sections --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 149 +++++++++++------- 1 file changed, 95 insertions(+), 54 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 001a53da4def8a..fd20241dc79a72 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -36,7 +36,7 @@ public sealed class ElfObjectWriter : UnixObjectWriter private Dictionary _bssStreams = new(); private Dictionary _sectionIndexToElfSection = new(); private Dictionary _elfSectionToSectionIndex = new(); - private Dictionary _comdatNameToElfSection = new(); + private Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); private Dictionary _sectionToRelocationTable = new(); // Symbol table @@ -323,30 +323,65 @@ protected override ulong GetSectionVirtualAddress(int sectionIndex) protected override void EmitDebugSections(DwarfFile dwarfFile) { - // NOTE: We need the layout to find the offset and size of the __managedcode section - var elfDiagnostics = new DiagnosticBag(); - _objectFile.UpdateLayout(elfDiagnostics); - Debug.Assert(!elfDiagnostics.HasErrors); + ElfRelocationType reloc32, reloc64; + + switch ((ElfArch)_objectFile.Arch) + { + case ElfArch.X86_64: + reloc32 = ElfRelocationType.R_X86_64_32; + reloc64 = ElfRelocationType.R_X86_64_64; + break; + case ElfArch.AARCH64: + reloc32 = ElfRelocationType.R_AARCH64_ABS32; + reloc64 = ElfRelocationType.R_AARCH64_ABS64; + break; + default: + throw new NotSupportedException("Unsupported architecture"); + } + + Dictionary sectionToSymbolIndex = new(); + ulong debugRangesSize = 0; + var debugRangesStream = new MemoryStream(); + var debugRangesSection = new ElfBinarySection(debugRangesStream) { Name = ".debug_ranges", Type = ElfSectionType.ProgBits, Alignment = 8 }; + var debugRangesRelocation = new ElfRelocationTable { Name = ".rela.debug_ranges", Link = _symbolTable, Info = debugRangesSection, Alignment = 8 }; + + var unit = dwarfFile.InfoSection.Units[0]; + var rootDIE = (DwarfDIECompileUnit)unit.Root; + + dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; + dwarfFile.AddressRangeTable.Unit = unit; - foreach (var unit in dwarfFile.InfoSection.Units) + // Point DW_AT_RANGES to beginning of our .debug_ranges section + rootDIE.Ranges = 0; + + foreach (var elfSection in _objectFile.Sections) { - var rootDIE = (DwarfDIECompileUnit)unit.Root; - dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; - dwarfFile.AddressRangeTable.Unit = unit; - foreach (var elfSection in _objectFile.Sections) + // NOTE: We could exclude some extra sections, like .dotnet_eh_table, .eh_frame, + // __modules and .note.GNU-stack but it doesn't really matter if we include them. + if (elfSection is ElfBinarySection && + elfSection.Size > 0 && + /*!elfSection.Name.Value.Equals(".dotnet_eh_table", StringComparison.Ordinal) &&*/ + !elfSection.Name.Value.Equals(".eh_frame", StringComparison.Ordinal)) { - // TODO: What about __managedcode in COMDAT? - if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable) && - elfSection.Name == "__managedcode") - { - dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, elfSection.Offset, elfSection.Size)); - rootDIE.LowPC = elfSection.Offset; - rootDIE.HighPC = (int)elfSection.Size; - break; - } + dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, elfSection.Offset, elfSection.Size)); + rootDIE.LowPC ??= elfSection.Offset; + //rootDIE.HighPC = (int)elfSection.Size; + + // Create a symbol for the section so we can make relocations relative to it. + uint sectionSymbolIndex; + sectionToSymbolIndex[elfSection] = sectionSymbolIndex = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); + + // Emit entry in .debug_ranges + debugRangesRelocation.Entries.Add(new ElfRelocation(debugRangesSize, reloc64, sectionSymbolIndex, 0)); + debugRangesRelocation.Entries.Add(new ElfRelocation(debugRangesSize + 8, reloc64, sectionSymbolIndex, (long)elfSection.Size)); + debugRangesSize += 16; } } + debugRangesSize += 16; // NULL entry + debugRangesStream.SetLength((long)debugRangesSize); + var outputContext = new DwarfWriterContext { IsLittleEndian = _objectFile.Encoding == ElfEncoding.Lsb, @@ -383,6 +418,8 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) _objectFile.AddSection(debugLineRelocation); _objectFile.AddSection(debugLocationSection); _objectFile.AddSection(debugLocationRelocation); + _objectFile.AddSection(debugRangesSection); + _objectFile.AddSection(debugRangesRelocation); uint stringSectionIndex = (uint)_symbolTable.Entries.Count; _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugStringSection }); @@ -390,40 +427,22 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugAbbrevSection }); uint infoSectionIndex = (uint)_symbolTable.Entries.Count; _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugInfoSection }); - - Dictionary codeSectionToSymbolIndex = new(); - foreach (var elfSection in _objectFile.Sections) - { - if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) - { - codeSectionToSymbolIndex[elfSection] = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); - } - } - - ElfRelocationType reloc32, reloc64; - - switch ((ElfArch)_objectFile.Arch) - { - case ElfArch.X86_64: - reloc32 = ElfRelocationType.R_X86_64_32; - reloc64 = ElfRelocationType.R_X86_64_64; - break; - case ElfArch.AARCH64: - reloc32 = ElfRelocationType.R_AARCH64_ABS32; - reloc64 = ElfRelocationType.R_AARCH64_ABS64; - break; - default: - throw new NotSupportedException("Unsupported architecture"); - } + uint rangesSectionIndex = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugRangesSection }); CopyRelocations(dwarfFile.InfoSection, debugInfoRelocation); CopyRelocations(dwarfFile.AddressRangeTable, debugAddressRangeRelocation); CopyRelocations(dwarfFile.LineSection, debugLineRelocation); CopyRelocations(dwarfFile.LocationSection, debugLocationRelocation); + // Add relocation for DW_AT_RANGES + var rangesAttribute = rootDIE.FindAttributeByKey(DwarfAttributeKind.Ranges); + debugInfoRelocation.Entries.Add(new ElfRelocation(rangesAttribute.Offset, reloc64, rangesSectionIndex, 0)); + void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTable relocTable) { + List codeRelocations = null; + relocTable.Entries.Clear(); foreach (var reloc in dwarfRelocSection.Relocations) @@ -448,23 +467,38 @@ void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTab break; } } + else + { + codeRelocations ??= new(); + codeRelocations.Add(reloc); + } } - // TODO: Sort the relocations and then linerly walk the relocation and section list at the same time - foreach (var elfSection in _objectFile.Sections) + if (codeRelocations is not null) { - if (elfSection.Flags.HasFlag(ElfSectionFlags.Executable)) + int sectionIndex = 0; + ElfSection currentSection = _objectFile.Sections[0]; + uint symbolIndex = 0; + + // Sort the code relocations by their offset, and then walk the sections + // and relocations at the same time to point them to matching section. + codeRelocations.Sort((a, b) => (int)a.Addend - (int)b.Addend); + + foreach (var reloc in codeRelocations) { - uint symbolIndex = codeSectionToSymbolIndex[elfSection]; - foreach (var reloc in dwarfRelocSection.Relocations) + if (reloc.Addend >= currentSection.Offset + currentSection.Size) { - if (reloc.Target == DwarfRelocationTarget.Code && - reloc.Addend >= elfSection.Offset && reloc.Addend < elfSection.Offset + elfSection.Size) + while (reloc.Addend >= currentSection.Offset + currentSection.Size) { - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, symbolIndex, (long)(reloc.Addend - elfSection.Offset))); + currentSection = _objectFile.Sections[++sectionIndex]; } + + Debug.Assert(currentSection.Flags.HasFlag(ElfSectionFlags.Executable)); + symbolIndex = sectionToSymbolIndex[currentSection]; } + + var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; + relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, symbolIndex, (long)(reloc.Addend - currentSection.Offset))); } } } @@ -527,6 +561,13 @@ protected override void EmitSectionsAndLayout() Name = ".note.GNU-stack", Type = ElfSectionType.ProgBits, }); + + // NOTE: We need the layout to find the offset and size of the __managedcode section + // but also to report correct method addresses in the debug information. Beyond this + // point, GetSectionVirtualAddress must return correct address for any code section. + var elfDiagnostics = new DiagnosticBag(); + _objectFile.UpdateLayout(elfDiagnostics); + Debug.Assert(!elfDiagnostics.HasErrors); } protected override void EmitObjectFile(string objectFilePath) From 14f5d179989c99012c32b5137e9faa8577abe39a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 5 Oct 2023 13:47:03 +0200 Subject: [PATCH 077/144] Add missing StringComparer.Ordinal to dictionaries --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 2 +- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 036118f2911363..26b41eedc287f4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -31,7 +31,7 @@ public sealed class CoffObjectWriter : ObjectWriter // Symbol table private List _symbols = new(); - private Dictionary _symbolNameToIndex = new(); + private Dictionary _symbolNameToIndex = new(StringComparer.Ordinal); private Dictionary _sectionNumberToComdatAuxRecord = new(); private HashSet _referencedMethods = new(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index e766adc6c14e73..8087df32a4073b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -36,12 +36,12 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy private byte _insPaddingByte; // Standard sections - private Dictionary _sectionNameToSectionIndex = new(); + private Dictionary _sectionNameToSectionIndex = new(StringComparer.Ordinal); private List _sectionIndexToStream = new(); private List> _sectionIndexToRelocations = new(); // Symbol table - private Dictionary _definedSymbols = new(); + private Dictionary _definedSymbols = new(StringComparer.Ordinal); // Debugging private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; From ec7bc5e888c719612dac88f56618e201a54349cb Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 5 Oct 2023 16:54:00 +0200 Subject: [PATCH 078/144] Remove incorrect assert --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index fd20241dc79a72..91857240d4b1dc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -492,8 +492,6 @@ void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTab { currentSection = _objectFile.Sections[++sectionIndex]; } - - Debug.Assert(currentSection.Flags.HasFlag(ElfSectionFlags.Executable)); symbolIndex = sectionToSymbolIndex[currentSection]; } From 307ca09533ea35e45fa52f997c9fd7094cd9cbce Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 18 Oct 2023 03:08:19 +0200 Subject: [PATCH 079/144] WIP: Rewritten DWARF debug info emitter --- .../DependencyAnalysis/ObjectNodeSection.cs | 1 + .../Compiler/ObjectWriter/CoffObjectWriter.cs | 4 - .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 304 ++++++ .../Dwarf/DwarfExpressionBuilder.cs | 169 ++++ .../ObjectWriter/Dwarf/DwarfFileName.cs | 7 + .../ObjectWriter/Dwarf/DwarfHelper.cs | 75 ++ .../Compiler/ObjectWriter/Dwarf/DwarfInfo.cs | 577 +++++++++++ .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 217 +++++ .../Dwarf/DwarfLineProgramTableWriter.cs | 125 +++ .../Dwarf/DwarfLineSequenceWriter.cs | 117 +++ .../Compiler/ObjectWriter/DwarfBuilder.cs | 902 ++++++------------ .../Compiler/ObjectWriter/DwarfCie.cs | 70 +- .../Compiler/ObjectWriter/DwarfEhFrame.cs | 8 +- .../Compiler/ObjectWriter/DwarfFde.cs | 6 - .../Compiler/ObjectWriter/DwarfNative.cs | 507 +++++++++- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 318 ++---- .../Compiler/ObjectWriter/MachObjectWriter.cs | 120 ++- .../Compiler/ObjectWriter/ObjectWriter.cs | 48 +- .../ObjectWriter/ObjectWriterStream.cs | 99 +- .../Compiler/ObjectWriter/SectionWriter.cs | 28 +- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 71 +- .../ILCompiler.Compiler.csproj | 8 + 22 files changed, 2700 insertions(+), 1081 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFileName.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs index 4545833ab449c2..a621e33e591019 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectNodeSection.cs @@ -9,6 +9,7 @@ public enum SectionType Writeable, Executable, Uninitialized, + Debug, } /// diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 26b41eedc287f4..2b5f1a6a49b018 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -656,10 +656,6 @@ protected override void EmitDebugSections() _debugFileTableBuilder.Write(_debugSymbolSectionWriter.Stream); } - protected override void EmitDebugStaticVars() - { - } - public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { using CoffObjectWriter objectWriter = new CoffObjectWriter(factory, options); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs new file mode 100644 index 00000000000000..cafdbf5acc9d59 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -0,0 +1,304 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class DwarfAbbrev + { + private ushort[] _definition; + + public static ushort DW_FORM_size = 0xdead; // Dummy value + + public DwarfAbbrev(ushort[] definition) + { + _definition = definition; + } + + public ushort Tag => _definition[0]; + + public bool HasChildren => _definition[1] == DW_CHILDREN_yes; + + public int AbbreviationCode { get; set; } + + public void Write(ObjectWriterStream stream, int targetPointerSize) + { + stream.WriteULEB128((ulong)AbbreviationCode); + stream.WriteULEB128(Tag); + stream.WriteULEB128(HasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no); + + for (int i = 2; i < _definition.Length; i++) + { + // Attribute + stream.WriteULEB128(_definition[i++]); + // Form + if (_definition[i] != DW_FORM_size) + { + stream.WriteULEB128(_definition[i]); + } + else if (targetPointerSize == 8) + { + stream.WriteULEB128(DW_FORM_data8); + } + else if (targetPointerSize == 4) + { + stream.WriteULEB128(DW_FORM_data4); + } + } + + stream.Write([0, 0]); + } + + public static DwarfAbbrev CompileUnit = new([ + DW_TAG_compile_unit, DW_CHILDREN_yes, + DW_AT_producer, DW_FORM_strp, + DW_AT_language, DW_FORM_data2, + DW_AT_name, DW_FORM_strp, + DW_AT_comp_dir, DW_FORM_strp, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_ranges, DW_FORM_sec_offset, + DW_AT_stmt_list, DW_FORM_sec_offset]); + + public static DwarfAbbrev BaseType = new([ + DW_TAG_base_type, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_encoding, DW_FORM_data1, + DW_AT_byte_size, DW_FORM_data1]); + + public static DwarfAbbrev EnumerationType = new([ + DW_TAG_enumeration_type, DW_CHILDREN_yes, + DW_AT_name, DW_FORM_strp, + DW_AT_type, DW_FORM_ref4, + DW_AT_byte_size, DW_FORM_data1]); + + public static DwarfAbbrev EnumerationTypeNoChildren = new([ + DW_TAG_enumeration_type, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_type, DW_FORM_ref4, + DW_AT_byte_size, DW_FORM_data1]); + + public static DwarfAbbrev Enumerator1 = new([ + DW_TAG_enumerator, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_const_value, DW_FORM_data1]); + + public static DwarfAbbrev Enumerator2 = new([ + DW_TAG_enumerator, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_const_value, DW_FORM_data2]); + + public static DwarfAbbrev Enumerator4 = new([ + DW_TAG_enumerator, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_const_value, DW_FORM_data4]); + + public static DwarfAbbrev Enumerator8 = new([ + DW_TAG_enumerator, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_const_value, DW_FORM_data8]); + + public static DwarfAbbrev TypeDef = new([ + DW_TAG_typedef, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_type, DW_FORM_ref4]); + + public static DwarfAbbrev Subprogram = new([ + DW_TAG_subprogram, DW_CHILDREN_yes, + DW_AT_specification, DW_FORM_ref4, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size, + DW_AT_frame_base, DW_FORM_exprloc, + DW_AT_object_pointer, DW_FORM_ref4]); + + public static DwarfAbbrev SubprogramNoChildren = new([ + DW_TAG_subprogram, DW_CHILDREN_no, + DW_AT_specification, DW_FORM_ref4, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size, + DW_AT_frame_base, DW_FORM_exprloc, + DW_AT_object_pointer, DW_FORM_ref4]); + + public static DwarfAbbrev SubprogramStatic = new([ + DW_TAG_subprogram, DW_CHILDREN_yes, + DW_AT_specification, DW_FORM_ref4, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size, + DW_AT_frame_base, DW_FORM_exprloc]); + + public static DwarfAbbrev SubprogramStaticNoChildren = new([ + DW_TAG_subprogram, DW_CHILDREN_no, + DW_AT_specification, DW_FORM_ref4, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size, + DW_AT_frame_base, DW_FORM_exprloc]); + + public static DwarfAbbrev SubprogramSpec = new([ + DW_TAG_subprogram, DW_CHILDREN_yes, + DW_AT_name, DW_FORM_strp, + DW_AT_linkage_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_external, DW_FORM_flag_present, + DW_AT_declaration, DW_FORM_flag_present, + DW_AT_object_pointer, DW_FORM_ref4]); + + public static DwarfAbbrev SubprogramStaticSpec = new([ + DW_TAG_subprogram, DW_CHILDREN_yes, + DW_AT_name, DW_FORM_strp, + DW_AT_linkage_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_external, DW_FORM_flag_present, + DW_AT_declaration, DW_FORM_flag_present]); + + public static DwarfAbbrev SubprogramStaticNoChildrenSpec = new([ + DW_TAG_subprogram, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_linkage_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_external, DW_FORM_flag_present, + DW_AT_declaration, DW_FORM_flag_present]); + + public static DwarfAbbrev Variable = new([ + DW_TAG_variable, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_exprloc]); + + public static DwarfAbbrev VariableLoc = new([ + DW_TAG_variable, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_sec_offset]); + + public static DwarfAbbrev VariableStatic = new([ + DW_TAG_variable, DW_CHILDREN_no, + DW_AT_specification, DW_FORM_ref4, + DW_AT_location, DW_FORM_exprloc]); + + public static DwarfAbbrev FormalParameter = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_exprloc]); + + public static DwarfAbbrev FormalParameterThis = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_exprloc, + DW_AT_artificial, DW_FORM_flag_present]); + + public static DwarfAbbrev FormalParameterLoc = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_sec_offset]); + + public static DwarfAbbrev FormalParameterThisLoc = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_decl_file, DW_FORM_data1, + DW_AT_decl_line, DW_FORM_data1, + DW_AT_type, DW_FORM_ref4, + DW_AT_location, DW_FORM_sec_offset, + DW_AT_artificial, DW_FORM_flag_present]); + + public static DwarfAbbrev FormalParameterSpec = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_type, DW_FORM_ref4]); + + public static DwarfAbbrev FormalParameterThisSpec = new([ + DW_TAG_formal_parameter, DW_CHILDREN_no, + DW_AT_type, DW_FORM_ref4, + DW_AT_artificial, DW_FORM_flag_present]); + + public static DwarfAbbrev ClassType = new([ + DW_TAG_class_type, DW_CHILDREN_yes, + DW_AT_name, DW_FORM_strp, + DW_AT_byte_size, DW_FORM_data4]); + + public static DwarfAbbrev ClassTypeNoChildren = new([ + DW_TAG_class_type, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_byte_size, DW_FORM_data4]); + + public static DwarfAbbrev ClassTypeDecl = new([ + DW_TAG_class_type, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_declaration, DW_FORM_flag_present]); + + public static DwarfAbbrev ClassMember = new([ + DW_TAG_member, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_type, DW_FORM_ref4, + DW_AT_data_member_location, DW_FORM_data4]); + + public static DwarfAbbrev ClassMemberStatic = new([ + DW_TAG_member, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp, + DW_AT_type, DW_FORM_ref4, + DW_AT_external, DW_FORM_flag_present, + DW_AT_declaration, DW_FORM_flag_present]); + + public static DwarfAbbrev PointerType = new([ + DW_TAG_pointer_type, DW_CHILDREN_no, + DW_AT_type, DW_FORM_ref4, + DW_AT_byte_size, DW_FORM_data1]); + + public static DwarfAbbrev ReferenceType = new([ + DW_TAG_reference_type, DW_CHILDREN_no, + DW_AT_type, DW_FORM_ref4, + DW_AT_byte_size, DW_FORM_data1]); + + public static DwarfAbbrev ArrayType = new([ + DW_TAG_array_type, DW_CHILDREN_yes, + DW_AT_type, DW_FORM_ref4]); + + public static DwarfAbbrev SubrangeType = new([ + DW_TAG_subrange_type, DW_CHILDREN_no, + DW_AT_upper_bound, DW_FORM_udata]); + + public static DwarfAbbrev ClassInheritance = new([ + DW_TAG_inheritance, DW_CHILDREN_no, + DW_AT_type, DW_FORM_ref4, + DW_AT_data_member_location, DW_FORM_data1]); + + public static DwarfAbbrev LexicalBlock = new([ + DW_TAG_lexical_block, DW_CHILDREN_yes, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size]); + + public static DwarfAbbrev TryBlock = new([ + DW_TAG_try_block, DW_CHILDREN_no, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size]); + + public static DwarfAbbrev CatchBlock = new([ + DW_TAG_catch_block, DW_CHILDREN_no, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size]); + + public static DwarfAbbrev VoidType = new([ + DW_TAG_unspecified_type, DW_CHILDREN_no, + DW_AT_name, DW_FORM_strp]); + + public static DwarfAbbrev VoidPointerType = new([ + DW_TAG_pointer_type, DW_CHILDREN_no]); + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs new file mode 100644 index 00000000000000..3627123d96bd23 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs @@ -0,0 +1,169 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using Internal.TypeSystem; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + internal ref struct DwarfExpressionBuilder + { + private TargetArchitecture _architecture; + private byte _targetPointerSize; + private IBufferWriter _writer; + + public DwarfExpressionBuilder(TargetArchitecture architecture, byte targetPointerSize, IBufferWriter writer) + { + _architecture = architecture; + _targetPointerSize = targetPointerSize; + _writer = writer; + } + + public void OpReg(int register) => OpDwarfReg(DwarfRegNum(_architecture, register)); + + public void OpBReg(int register, int offset = 0) => OpBDwarfReg(DwarfRegNum(_architecture, register), offset); + + public void OpDwarfReg(int register) + { + if (register <= 31) + { + OpCode((byte)(DW_OP_reg0 + register)); + } + else + { + OpCode(DW_OP_regx); + AppendULEB128((ulong)register); + } + } + + public void OpBDwarfReg(int register, int offset = 0) + { + if (register <= 31) + { + OpCode((byte)(DW_OP_breg0 + register)); + } + else + { + OpCode(DW_OP_bregx); + AppendULEB128((ulong)register); + } + AppendSLEB128(offset); + } + + public void OpDeref() => OpCode(DW_OP_deref); + + public void OpPiece(uint size = 0) + { + OpCode(DW_OP_piece); + AppendULEB128(size == 0 ? (uint)_targetPointerSize : size); + } + + private void OpCode(byte opcode) + { + var b = _writer.GetSpan(1); + b[0] = opcode; + _writer.Advance(1); + } + + private void AppendULEB128(ulong value) => DwarfHelper.WriteULEB128(_writer, value); + + private void AppendSLEB128(long value) => DwarfHelper.WriteSLEB128(_writer, value); + + private enum RegNumX86 : int + { + REGNUM_EAX, + REGNUM_ECX, + REGNUM_EDX, + REGNUM_EBX, + REGNUM_ESP, + REGNUM_EBP, + REGNUM_ESI, + REGNUM_EDI, + REGNUM_COUNT, + REGNUM_FP = REGNUM_EBP, + REGNUM_SP = REGNUM_ESP + }; + + private enum RegNumAmd64 : int + { + REGNUM_RAX, + REGNUM_RCX, + REGNUM_RDX, + REGNUM_RBX, + REGNUM_RSP, + REGNUM_RBP, + REGNUM_RSI, + REGNUM_RDI, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_R13, + REGNUM_R14, + REGNUM_R15, + REGNUM_COUNT, + REGNUM_SP = REGNUM_RSP, + REGNUM_FP = REGNUM_RBP + }; + + public static int DwarfRegNum(TargetArchitecture architecture, int regNum) + { + switch (architecture) + { + case TargetArchitecture.ARM64: + // Normal registers are directly mapped + if (regNum >= 33) + regNum = regNum - 33 + 64; // FP + return regNum; + + case TargetArchitecture.ARM: + // Normal registers are directly mapped + if (regNum >= 16) + regNum = ((regNum - 16) / 2) + 256; // FP + return regNum; + + case TargetArchitecture.X64: + return (RegNumAmd64)regNum switch + { + RegNumAmd64.REGNUM_RAX => 0, + RegNumAmd64.REGNUM_RDX => 1, + RegNumAmd64.REGNUM_RCX => 2, + RegNumAmd64.REGNUM_RBX => 3, + RegNumAmd64.REGNUM_RSI => 4, + RegNumAmd64.REGNUM_RDI => 5, + RegNumAmd64.REGNUM_RBP => 6, + RegNumAmd64.REGNUM_RSP => 7, + RegNumAmd64.REGNUM_R8 => 8, + RegNumAmd64.REGNUM_R9 => 9, + RegNumAmd64.REGNUM_R10 => 10, + RegNumAmd64.REGNUM_R11 => 11, + RegNumAmd64.REGNUM_R12 => 12, + RegNumAmd64.REGNUM_R13 => 13, + RegNumAmd64.REGNUM_R14 => 14, + RegNumAmd64.REGNUM_R15 => 15, + _ => regNum - (int)RegNumAmd64.REGNUM_COUNT + 17 // FP registers + }; + + case TargetArchitecture.X86: + return (RegNumX86)regNum switch + { + RegNumX86.REGNUM_EAX => 0, + RegNumX86.REGNUM_ECX => 1, + RegNumX86.REGNUM_EDX => 2, + RegNumX86.REGNUM_EBX => 3, + RegNumX86.REGNUM_ESP => 4, + RegNumX86.REGNUM_EBP => 5, + RegNumX86.REGNUM_ESI => 6, + RegNumX86.REGNUM_EDI => 7, + _ => regNum - (int)RegNumX86.REGNUM_COUNT + 32 // FP registers + }; + + default: + throw new NotSupportedException(); + } + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFileName.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFileName.cs new file mode 100644 index 00000000000000..56805a65689cfd --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFileName.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILCompiler.ObjectWriter +{ + internal sealed record DwarfFileName(string Name, string Directory, ulong Time = 0, ulong Size = 0); +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs new file mode 100644 index 00000000000000..214e5842010b5d --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Buffers; +using System.Numerics; + +namespace ILCompiler.ObjectWriter +{ + internal static class DwarfHelper + { + public static uint SizeOfULEB128(ulong value) + { + // bits_to_encode = (data != 0) ? 64 - CLZ(x) : 1 = 64 - CLZ(data | 1) + // bytes = ceil(bits_to_encode / 7.0); = (6 + bits_to_encode) / 7 + uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); + // Division by 7 is done by (x * 37) >> 8 where 37 = ceil(256 / 7). + // This works for 0 <= x < 256 / (7 * 37 - 256), i.e. 0 <= x <= 85. + return (x * 37) >> 8; + } + + public static uint SizeOfSLEB128(long value) + { + // The same as SizeOfULEB128 calculation but we have to account for the sign bit. + uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)(value ^ (value >> 63)) | 1UL); + return (x * 37) >> 8; + } + + public static void WriteULEB128(IBufferWriter writer, ulong value) + { + if (value >= 0x80) + { + int size = (int)SizeOfULEB128(value); + var buffer = writer.GetSpan(size); + do + { + buffer[0] = (byte)((value & 0x7f) | ((value >= 0x80) ? 0x80u : 0)); + buffer = buffer.Slice(1); + value >>= 7; + } + while (value > 0); + writer.Advance(size); + } + else + { + var buffer = writer.GetSpan(1); + buffer[0] = (byte)value; + writer.Advance(1); + } + } + + public static void WriteSLEB128(IBufferWriter writer, long value) + { + int size = (int)SizeOfSLEB128(value); + var buffer = writer.GetSpan(size); + bool cont = true; + while (cont) + { + var b = (byte)((byte)value & 0x7f); + value >>= 7; + bool isSignBitSet = (b & 0x40) != 0; + if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) + { + cont = false; + } + else + { + b |= 0x80; + } + buffer[0] = b; + buffer = buffer.Slice(1); + } + writer.Advance(size); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs new file mode 100644 index 00000000000000..4352f555d44c71 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs @@ -0,0 +1,577 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using ILCompiler.DependencyAnalysis; +using Internal.JitInterface; +using Internal.TypeSystem; +using Internal.TypeSystem.TypesDebugInfo; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + internal abstract class DwarfInfo + { + public abstract void Dump(DwarfInfoWriter writer); + } + + internal sealed class DwarfPrimitiveTypeInfo : DwarfInfo + { + private TypeFlags _typeFlags; + private int _targetPointerSize; + + public DwarfPrimitiveTypeInfo(TypeFlags typeFlags, int targetPointerSize) + { + _typeFlags = typeFlags; + _targetPointerSize = targetPointerSize; + } + + public byte ByteSize => _typeFlags switch + { + TypeFlags.Boolean => 1, + TypeFlags.Char => 2, + TypeFlags.SByte => 1, + TypeFlags.Byte => 1, + TypeFlags.Int16 => 2, + TypeFlags.UInt16 => 2, + TypeFlags.Int32 => 4, + TypeFlags.UInt32 => 4, + TypeFlags.Int64 => 8, + TypeFlags.UInt64 => 8, + TypeFlags.IntPtr => (byte)_targetPointerSize, + TypeFlags.UIntPtr => (byte)_targetPointerSize, + TypeFlags.Single => 4, + TypeFlags.Double => 8, + _ => 0, + }; + + public override void Dump(DwarfInfoWriter writer) + { + if (_typeFlags == TypeFlags.Void) + { + writer.WriteStartDIE(DwarfAbbrev.VoidType); + writer.WriteStringReference("void"); + writer.WriteEndDIE(); + } + else + { + var (name, encoding, byteSize) = _typeFlags switch + { + TypeFlags.Boolean => ("bool", DW_ATE_boolean, 1), + TypeFlags.Char => ("char16_t", DW_ATE_UTF, 2), + TypeFlags.SByte => ("sbyte", DW_ATE_signed, 1), + TypeFlags.Byte => ("byte", DW_ATE_unsigned, 1), + TypeFlags.Int16 => ("short", DW_ATE_signed, 2), + TypeFlags.UInt16 => ("ushort", DW_ATE_unsigned, 2), + TypeFlags.Int32 => ("int", DW_ATE_signed, 4), + TypeFlags.UInt32 => ("uint", DW_ATE_unsigned, 4), + TypeFlags.Int64 => ("long", DW_ATE_signed, 8), + TypeFlags.UInt64 => ("ulong", DW_ATE_unsigned, 8), + TypeFlags.IntPtr => ("nint", DW_ATE_signed, _targetPointerSize), + TypeFlags.UIntPtr => ("nuint", DW_ATE_unsigned, _targetPointerSize), + TypeFlags.Single => ("float", DW_ATE_float, 4), + TypeFlags.Double => ("double", DW_ATE_float, 8), + _ => ("", 0, 0), + }; + + writer.WriteStartDIE(DwarfAbbrev.BaseType); + writer.WriteStringReference(name); + writer.Write([(byte)encoding, (byte)byteSize]); + writer.WriteEndDIE(); + } + } + } + + internal sealed class DwarfEnumTypeInfo : DwarfInfo + { + private readonly EnumTypeDescriptor _typeDescriptor; + private readonly EnumRecordTypeDescriptor[] _typeRecords; + private readonly byte _byteSize; + + public DwarfEnumTypeInfo( + EnumTypeDescriptor typeDescriptor, + EnumRecordTypeDescriptor[] typeRecords, + byte byteSize) + { + _typeDescriptor = typeDescriptor; + _typeRecords = typeRecords; + _byteSize = byteSize; + } + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE(_typeRecords.Length > 0 ? DwarfAbbrev.EnumerationType : DwarfAbbrev.EnumerationTypeNoChildren); + writer.WriteStringReference(_typeDescriptor.Name); + writer.WriteInfoReference(_typeDescriptor.ElementType); + writer.Write([_byteSize]); + + if (_typeRecords.Length > 0) + { + DwarfAbbrev abbrev = _byteSize switch { + 1 => DwarfAbbrev.Enumerator1, + 2 => DwarfAbbrev.Enumerator2, + 4 => DwarfAbbrev.Enumerator4, + 8 => DwarfAbbrev.Enumerator8, + _ => throw new NotSupportedException() + }; + + foreach (EnumRecordTypeDescriptor typeRecord in _typeRecords) + { + writer.WriteStartDIE(abbrev); + writer.WriteStringReference(typeRecord.Name); + switch (_byteSize) + { + case 1: writer.WriteUInt8((byte)typeRecord.Value); break; + case 2: writer.WriteUInt16((ushort)typeRecord.Value); break; + case 4: writer.WriteUInt32((uint)typeRecord.Value); break; + case 8: writer.WriteUInt64(typeRecord.Value); break; + }; + writer.WriteEndDIE(); + } + } + + writer.WriteEndDIE(); + } + } + + internal sealed class DwarfPointerTypeInfo : DwarfInfo + { + private PointerTypeDescriptor _typeDescriptor; + + public DwarfPointerTypeInfo(PointerTypeDescriptor typeDescriptor) + { + _typeDescriptor = typeDescriptor; + } + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE(_typeDescriptor.IsReference != 0 ? DwarfAbbrev.ReferenceType : DwarfAbbrev.PointerType); + writer.WriteInfoReference(_typeDescriptor.ElementType); + writer.Write([_typeDescriptor.Is64Bit != 0 ? (byte)8 : (byte)4]); + writer.WriteEndDIE(); + } + } + + internal sealed class DwarfVoidPtrTypeInfo : DwarfInfo + { + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE(DwarfAbbrev.VoidPointerType); + writer.WriteEndDIE(); + } + } + + internal sealed class DwarfSimpleArrayTypeInfo : DwarfInfo + { + private readonly uint _elementType; + private readonly ulong _size; + + public DwarfSimpleArrayTypeInfo(uint elementType, ulong size) + { + _elementType = elementType; + _size = size; + } + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE(DwarfAbbrev.ArrayType); + + // DW_AT_type + writer.WriteInfoReference(_elementType); + + writer.WriteStartDIE(DwarfAbbrev.SubrangeType); + // DW_AT_upper_bound + // NOTE: This produces garbage for _size == 0 + writer.WriteULEB128(_size - 1); + writer.WriteEndDIE(); + + writer.WriteEndDIE(); + } + } + + internal sealed class DwarfMemberFunction + { + public string Name { get; private set; } + public string LinkageName { get; set; } + public MemberFunctionTypeDescriptor Descriptor { get; private set; } + public uint[] ArgumentTypes { get; private set; } + public bool IsStatic { get; private set; } + public long InfoOffset { get; set; } + + public DwarfMemberFunction( + string name, + MemberFunctionTypeDescriptor descriptor, + uint[] argumentTypes, + bool isStatic) + { + Name = name; + LinkageName = name; + Descriptor = descriptor; + ArgumentTypes = argumentTypes; + IsStatic = isStatic; + } + } + + internal sealed class DwarfClassTypeInfo : DwarfInfo + { + private readonly bool _isForwardDecl; + private readonly ClassTypeDescriptor _typeDescriptor; + private readonly ClassFieldsTypeDescriptor _classFieldsTypeDescriptor; + private readonly DataFieldDescriptor[] _fields; + private readonly List _statics; + private List _methods; + + public DwarfClassTypeInfo(ClassTypeDescriptor typeDescriptor) + { + _isForwardDecl = true; + _typeDescriptor = typeDescriptor; + } + + public DwarfClassTypeInfo( + ClassTypeDescriptor typeDescriptor, + ClassFieldsTypeDescriptor classFieldsTypeDescriptor, + DataFieldDescriptor[] fields, + StaticDataFieldDescriptor[] statics) + { + _typeDescriptor = typeDescriptor; + _classFieldsTypeDescriptor = classFieldsTypeDescriptor; + _fields = fields; + if (statics is not null) + { + _statics = new(statics.Length); + foreach (StaticDataFieldDescriptor staticDescriptor in statics) + { + _statics.Add(new DwarfStaticVariableInfo(staticDescriptor)); + } + } + } + + public void AddMemberFunction(DwarfMemberFunction memberFunction) + { + _methods ??= new(); + _methods.Add(memberFunction); + } + + private bool HasChildren => + _typeDescriptor.BaseClassId != 0 || + _fields.Length > 0 || + _methods is not null; + + public IReadOnlyList StaticVariables => _statics ?? []; + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE( + _isForwardDecl ? DwarfAbbrev.ClassTypeDecl : + HasChildren ? DwarfAbbrev.ClassType : DwarfAbbrev.ClassTypeNoChildren); + + // DW_AT_name + writer.WriteStringReference(_typeDescriptor.Name); + + if (!_isForwardDecl) + { + // DW_AT_byte_size + writer.WriteUInt32((uint)_typeDescriptor.InstanceSize); + + if (_typeDescriptor.BaseClassId != 0) + { + writer.WriteStartDIE(DwarfAbbrev.ClassInheritance); + // DW_AT_type + writer.WriteInfoReference(_typeDescriptor.BaseClassId); + // DW_AT_data_member_location + writer.Write([0]); + writer.WriteEndDIE(); + } + + int staticIndex = 0; + foreach (DataFieldDescriptor fieldDescriptor in _fields) + { + if (fieldDescriptor.Offset != 0xFFFFFFFFu) + { + writer.WriteStartDIE(DwarfAbbrev.ClassMember); + // DW_AT_name + writer.WriteStringReference(fieldDescriptor.Name); + // DW_AT_type + writer.WriteInfoReference(fieldDescriptor.FieldTypeIndex); + // DW_AT_data_member_location + writer.WriteUInt32((uint)fieldDescriptor.Offset); + writer.WriteEndDIE(); + } + else + { + _statics[staticIndex].InfoOffset = writer.Position; + writer.WriteStartDIE(DwarfAbbrev.ClassMemberStatic); + // DW_AT_name + writer.WriteStringReference(fieldDescriptor.Name); + // DW_AT_type + writer.WriteInfoReference(fieldDescriptor.FieldTypeIndex); + staticIndex++; + writer.WriteEndDIE(); + } + } + + if (_methods is not null) + { + foreach (DwarfMemberFunction method in _methods) + { + method.InfoOffset = writer.Position; + writer.WriteStartDIE( + !method.IsStatic ? DwarfAbbrev.SubprogramSpec : + method.ArgumentTypes.Length > 0 ? DwarfAbbrev.SubprogramStaticSpec : DwarfAbbrev.SubprogramStaticNoChildrenSpec); + // DW_AT_name + writer.WriteStringReference(method.Name); + // DW_AT_linkage_name + writer.WriteStringReference(method.LinkageName); + // DW_AT_decl_file, DW_AT_decl_line + writer.Write([1, 1]); + // DW_AT_type + writer.WriteInfoReference(method.Descriptor.ReturnType); + + if (!method.IsStatic) + { + // DW_AT_object_pointer + writer.WriteInfoAbsReference(writer.Position + sizeof(uint)); + + writer.WriteStartDIE(DwarfAbbrev.FormalParameterThisSpec); + // DW_AT_type + writer.WriteInfoReference(method.Descriptor.TypeIndexOfThisPointer); + writer.WriteEndDIE(); + } + + foreach (uint argumentType in method.ArgumentTypes) + { + writer.WriteStartDIE(DwarfAbbrev.FormalParameterSpec); + // DW_AT_type + writer.WriteInfoReference(argumentType); + writer.WriteEndDIE(); + } + + writer.WriteEndDIE(); + } + } + } + + writer.WriteEndDIE(); + } + } + + internal sealed class DwarfSubprogramInfo : DwarfInfo + { + private readonly string _methodName; + private readonly int _methodSize; + private readonly DwarfMemberFunction _memberFunction; + private readonly IEnumerable<(DebugVarInfoMetadata, uint)> _debugVars; + private readonly IEnumerable _debugEHClauseInfos; + private readonly bool _isStatic; + private readonly bool _hasChildren; + + public DwarfSubprogramInfo( + string methodName, + int methodSize, + DwarfMemberFunction memberFunction, + IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, + IEnumerable debugEHClauseInfos) + { + _methodName = methodName; + _methodSize = methodSize; + _memberFunction = memberFunction; + _isStatic = memberFunction.IsStatic; + _hasChildren = !_isStatic || debugVars.Any() || debugEHClauseInfos.Any(); + _debugVars = debugVars; + _debugEHClauseInfos = debugEHClauseInfos; + } + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE( + !_isStatic ? DwarfAbbrev.Subprogram : + _hasChildren ? DwarfAbbrev.SubprogramStatic : DwarfAbbrev.SubprogramStaticNoChildren); + + // DW_AT_specification + writer.WriteInfoAbsReference(_memberFunction.InfoOffset); + + // DW_AT_low_pc + writer.WriteCodeReference(_methodName); + + // DW_AT_high_pc + writer.WriteAddressSize((ulong)_methodSize); + + // DW_AT_frame_base + writer.WriteULEB128(1); + writer.Write([(byte)(DW_OP_reg0 + writer.FrameRegister)]); + + if (!_isStatic) + { + // DW_AT_object_pointer + writer.WriteInfoAbsReference(writer.Position + sizeof(uint)); + } + + /// At the moment, the lexical scope reflects IL, not C#, meaning that + /// there is only one scope for the whole method. We could be more precise + /// in the future by pulling the scope information from the PDB. + foreach ((DebugVarInfoMetadata debugVar, uint typeIndex) in _debugVars) + { + bool isThis = debugVar.IsParameter && debugVar.DebugVarInfo.VarNumber == 0 && !_isStatic; + DumpVar(writer, debugVar, typeIndex, isThis); + } + + // EH clauses + foreach (DebugEHClauseInfo clause in _debugEHClauseInfos) + { + writer.WriteStartDIE(DwarfAbbrev.TryBlock); + // DW_AT_low_pc + writer.WriteCodeReference(_methodName, clause.TryOffset); + // DW_AT_high_pc + writer.WriteAddressSize(clause.TryLength); + writer.WriteEndDIE(); + + writer.WriteStartDIE(DwarfAbbrev.CatchBlock); + // DW_AT_low_pc + writer.WriteCodeReference(_methodName, clause.HandlerOffset); + // DW_AT_high_pc + writer.WriteAddressSize(clause.HandlerLength); + writer.WriteEndDIE(); + } + + writer.WriteEndDIE(); + } + + private void DumpVar(DwarfInfoWriter writer, DebugVarInfoMetadata metadataInfo, uint typeIndex, bool isThis) + { + bool usesDebugLoc = metadataInfo.DebugVarInfo.Ranges.Length != 1; + + if (metadataInfo.IsParameter) + { + if (isThis) + { + writer.WriteStartDIE(usesDebugLoc ? DwarfAbbrev.FormalParameterThisLoc : DwarfAbbrev.FormalParameterThis); + } + else + { + writer.WriteStartDIE(usesDebugLoc ? DwarfAbbrev.FormalParameterLoc : DwarfAbbrev.FormalParameter); + } + } + else + { + writer.WriteStartDIE(usesDebugLoc ? DwarfAbbrev.VariableLoc : DwarfAbbrev.Variable); + } + + // DW_AT_name + writer.WriteStringReference(isThis ? "this" : metadataInfo.Name); + + // DW_AT_decl_file, DW_AT_decl_line + writer.Write([1, 1]); + + // DW_AT_type + writer.WriteInfoReference(typeIndex); + + // DW_AT_location + if (usesDebugLoc) + { + writer.WriteStartLocationList(); + foreach (var range in metadataInfo.DebugVarInfo.Ranges) + { + var expressionBuilder = writer.GetExpressionBuilder(); + DumpVarLocation(expressionBuilder, range.VarLoc); + writer.WriteLocationListExpression(_methodName, range.StartOffset, range.EndOffset, expressionBuilder); + } + writer.WriteEndLocationList(); + } + else + { + var expressionBuilder = writer.GetExpressionBuilder(); + DumpVarLocation(expressionBuilder, metadataInfo.DebugVarInfo.Ranges[0].VarLoc); + writer.WriteExpression(expressionBuilder); + } + + writer.WriteEndDIE(); + } + + private static void DumpVarLocation(DwarfExpressionBuilder e, VarLoc loc) + { + switch (loc.LocationType) + { + case VarLocType.VLT_REG: + case VarLocType.VLT_REG_FP: + e.OpReg(loc.B); + break; + case VarLocType.VLT_REG_BYREF: + e.OpBReg(loc.B); + break; + case VarLocType.VLT_STK: + case VarLocType.VLT_STK2: + case VarLocType.VLT_FPSTK: + case VarLocType.VLT_STK_BYREF: + e.OpBReg(loc.B, loc.C); + if (loc.LocationType == VarLocType.VLT_STK_BYREF) + { + e.OpDeref(); + } + break; + case VarLocType.VLT_REG_REG: + e.OpReg(loc.C); + e.OpPiece(); + e.OpReg(loc.B); + e.OpPiece(); + break; + case VarLocType.VLT_REG_STK: + e.OpReg(loc.B); + e.OpPiece(); + e.OpBReg(loc.C, loc.D); + e.OpPiece(); + break; + case VarLocType.VLT_STK_REG: + e.OpBReg(loc.C, loc.D); + e.OpPiece(); + e.OpReg(loc.B); + e.OpPiece(); + break; + default: + // Unsupported + Debug.Assert(loc.LocationType != VarLocType.VLT_FIXED_VA); + break; + } + } + } + + internal sealed class DwarfStaticVariableInfo : DwarfInfo + { + private readonly StaticDataFieldDescriptor _descriptor; + + public long InfoOffset { get; set; } + + public DwarfStaticVariableInfo(StaticDataFieldDescriptor descriptor) + { + _descriptor = descriptor; + } + + public override void Dump(DwarfInfoWriter writer) + { + writer.WriteStartDIE(DwarfAbbrev.VariableStatic); + + // DW_AT_specification + writer.WriteInfoAbsReference(InfoOffset); + // DW_AT_location + uint length = 1 + (uint)writer.TargetPointerSize; // DW_OP_addr + if (_descriptor.IsStaticDataInObject != 0) + length += 2; // DW_OP_deref, DW_OP_deref + if (_descriptor.StaticOffset != 0) + length += 1 + DwarfHelper.SizeOfULEB128(_descriptor.StaticOffset); // DW_OP_plus_uconst + writer.WriteULEB128(length); + writer.Write([DW_OP_addr]); + writer.WriteCodeReference(_descriptor.StaticDataName); + if (_descriptor.IsStaticDataInObject != 0) + writer.Write([DW_OP_deref, DW_OP_deref]); + if (_descriptor.StaticOffset != 0) + { + writer.Write([DW_OP_plus_uconst]); + writer.WriteULEB128(_descriptor.StaticOffset); + } + + writer.WriteEndDIE(); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs new file mode 100644 index 00000000000000..19b04a19f5ecfb --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -0,0 +1,217 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Diagnostics; +using ILCompiler.DependencyAnalysis; +using Internal.TypeSystem; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class DwarfInfoWriter : IDisposable + { + private sealed record InfoReference(uint TypeIndex, int Position, byte[] Data); + + private readonly SectionWriter _infoSectionWriter; + private readonly ObjectWriterStream _stringTableWriter; + private readonly SectionWriter _abbrevSectionWriter; + private readonly SectionWriter _locSectionWriter; + private readonly SectionWriter _rangeSectionWriter; + private readonly DwarfBuilder _builder; + private readonly RelocType _codeRelocType; + private readonly List _lateBoundReferences = new(); + private readonly Stack _dieStack = new(); + private readonly List _usedAbbrevs = new(); + private readonly ArrayBufferWriter _expressionBufferWriter = new(); + + public DwarfInfoWriter( + SectionWriter infoSectionWriter, + ObjectWriterStream stringTableWriter, + SectionWriter abbrevSectionWriter, + SectionWriter locSectionWriter, + SectionWriter rangeSectionWriter, + DwarfBuilder builder, + RelocType codeRelocType) + { + _infoSectionWriter = infoSectionWriter; + _stringTableWriter = stringTableWriter; + _abbrevSectionWriter = abbrevSectionWriter; + _locSectionWriter = locSectionWriter; + _rangeSectionWriter = rangeSectionWriter; + _builder = builder; + _codeRelocType = codeRelocType; + } + + public TargetArchitecture TargetArchitecture => _builder.TargetArchitecture; + public int FrameRegister => _builder.FrameRegister; + public byte TargetPointerSize => _builder.TargetPointerSize; + public long Position => _infoSectionWriter.Stream.Position; + + public void WriteStartDIE(DwarfAbbrev abbrev) + { + if (_dieStack.Count > 0 && !_dieStack.Peek().HasChildren) + { + throw new InvalidOperationException($"Trying to write a children into DIE (Tag {_dieStack.Peek().Tag}) with DW_CHILDREN_no"); + } + + if (abbrev.AbbreviationCode == 0) + { + _usedAbbrevs.Add(abbrev); + abbrev.AbbreviationCode = _usedAbbrevs.Count; + } + + _dieStack.Push(abbrev); + WriteULEB128((ulong)abbrev.AbbreviationCode); + } + + public void WriteEndDIE() + { + var abbrev = _dieStack.Pop(); + if (abbrev.HasChildren) + { + // End children list + WriteUInt8(0); + } + } + + public void Write(ReadOnlySpan buffer) => _infoSectionWriter.Stream.Write(buffer); + public void WriteULEB128(ulong value) => _infoSectionWriter.Stream.WriteULEB128(value); + public void WriteUInt8(byte value) => _infoSectionWriter.Stream.WriteUInt8(value); + public void WriteUInt16(ushort value) => _infoSectionWriter.Stream.WriteUInt16(value); + public void WriteUInt32(uint value) => _infoSectionWriter.Stream.WriteUInt32(value); + public void WriteUInt64(ulong value) => _infoSectionWriter.Stream.WriteUInt64(value); + + public void WriteAddressSize(ulong value) + { + switch (TargetPointerSize) + { + case 4: WriteUInt32((uint)value); break; + case 8: WriteUInt64(value); break; + default: throw new NotSupportedException(); + } + } + + public void WriteStringReference(string value) + { + long stringsOffset = _stringTableWriter.Position; + _stringTableWriter.WriteUtf8String(value); + + Debug.Assert(stringsOffset < uint.MaxValue); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_str", (int)stringsOffset); + } + + public void WriteInfoAbsReference(long offset) + { + Debug.Assert(offset < uint.MaxValue); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", (int)offset); + } + + public void WriteInfoReference(uint typeIndex) + { + uint offset = _builder.ResolveOffset(typeIndex); + + if (offset == 0) + { + // Late bound forward reference + var data = new byte[sizeof(uint)]; + _lateBoundReferences.Add(new InfoReference(typeIndex, (int)_infoSectionWriter.Stream.Position, data)); + _infoSectionWriter.Stream.AppendData(data); + } + else + { + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", (int)offset); + } + } + + public void WriteCodeReference(string methodName, uint offset = 0) + { + _infoSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)offset); + } + + public void WriteLineReference(long offset) + { + Debug.Assert(offset < uint.MaxValue); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_line", (int)offset); + } + + public DwarfExpressionBuilder GetExpressionBuilder() + { + _expressionBufferWriter.Clear(); + return new DwarfExpressionBuilder(TargetArchitecture, TargetPointerSize, _expressionBufferWriter); + } + + public void WriteExpression(DwarfExpressionBuilder expressionBuilder) + { + _ = expressionBuilder; + WriteULEB128((uint)_expressionBufferWriter.WrittenCount); + Write(_expressionBufferWriter.WrittenSpan); + } + + public void WriteStartLocationList() + { + long offset = _locSectionWriter.Stream.Position; + Debug.Assert(offset < uint.MaxValue); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_loc", (int)offset); + } + + public void WriteLocationListExpression(string methodName, uint startOffset, uint endOffset, DwarfExpressionBuilder expressionBuilder) + { + _ = expressionBuilder; + _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)startOffset); + _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)endOffset); + _locSectionWriter.Stream.WriteUInt16((ushort)_expressionBufferWriter.WrittenCount); + _locSectionWriter.Stream.Write(_expressionBufferWriter.WrittenSpan); + } + + public void WriteEndLocationList() + { + _locSectionWriter.Stream.Write(stackalloc byte[TargetPointerSize * 2]); + } + + public void WriteStartRangeList() + { + long offset = _rangeSectionWriter.Stream.Position; + Debug.Assert(offset < uint.MaxValue); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_ranges", (int)offset); + } + + public void WriteRangeListEntry(string symbolName, uint startOffset, uint endOffset) + { + _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, (int)startOffset); + _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, (int)endOffset); + } + + public void WriteEndRangeList() + { + _rangeSectionWriter.Stream.Write(stackalloc byte[TargetPointerSize * 2]); + } + + public void Dispose() + { + Debug.Assert(_dieStack.Count == 0); + + // Flush late bound forward references + int streamOffset = (int)_infoSectionWriter.Stream.Position; + foreach (var lateBoundReference in _lateBoundReferences) + { + uint offset = _builder.ResolveOffset(lateBoundReference.TypeIndex); + + _infoSectionWriter.EmitRelocation( + - streamOffset + lateBoundReference.Position, + lateBoundReference.Data, + RelocType.IMAGE_REL_BASED_HIGHLOW, + ".debug_info", + (int)offset); + } + + // Write abbreviation section + foreach (var abbrev in _usedAbbrevs) + { + abbrev.Write(_abbrevSectionWriter.Stream, TargetPointerSize); + } + _abbrevSectionWriter.Stream.Write([0, 0]); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs new file mode 100644 index 00000000000000..54a3ffca424dab --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs @@ -0,0 +1,125 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using ILCompiler.DependencyAnalysis; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class DwarfLineProgramTableWriter : IDisposable + { + private readonly SectionWriter _lineSectionWriter; + private readonly byte _targetPointerSize; + private readonly RelocType _codeRelocType; + private readonly Dictionary _directoryNameToIndex = new(); + private readonly Dictionary _fileNameToIndex = new(); + private readonly byte[] _sizeBuffer; + + public const byte MaximumOperationsPerInstruction = 1; + public const sbyte LineBase = -5; + public const byte LineRange = 14; + public const byte OpCodeBase = 13; + + private static ReadOnlySpan StandardOpCodeLengths => + [ + 0, // DW_LNS_copy + 1, // DW_LNS_advance_pc + 1, // DW_LNS_advance_line + 1, // DW_LNS_set_file + 1, // DW_LNS_set_column + 0, // DW_LNS_negate_stmt + 0, // DW_LNS_set_basic_block + 0, // DW_LNS_const_add_pc + 1, // DW_LNS_fixed_advance_pc + 0, // DW_LNS_set_prologue_end + 0, // DW_LNS_set_epilogue_begin + 1, // DW_LNS_set_isa + ]; + + public DwarfLineProgramTableWriter( + SectionWriter lineSectionWriter, + IReadOnlyList fileNames, + byte targetPointerSize, + byte minimumInstructionLength, + RelocType codeRelocType) + { + _lineSectionWriter = lineSectionWriter; + _targetPointerSize = targetPointerSize; + _codeRelocType = codeRelocType; + + // Length + _sizeBuffer = new byte[sizeof(uint)]; + lineSectionWriter.Stream.AppendData(_sizeBuffer); + // Version + lineSectionWriter.Stream.WriteUInt16(4); + // Header Length + var headerSizeBuffer = new byte[sizeof(uint)]; + lineSectionWriter.Stream.AppendData(headerSizeBuffer); + var headerStart = lineSectionWriter.Stream.Position; + lineSectionWriter.Stream.WriteUInt8(minimumInstructionLength); + lineSectionWriter.Stream.WriteUInt8(MaximumOperationsPerInstruction); + // default_is_stmt + lineSectionWriter.Stream.WriteUInt8(1); + // line_base + lineSectionWriter.Stream.WriteUInt8(unchecked((byte)LineBase)); + // line_range + lineSectionWriter.Stream.WriteUInt8(LineRange); + // opcode_base + lineSectionWriter.Stream.WriteUInt8(OpCodeBase); + // standard_opcode_lengths + foreach (var opcodeLength in StandardOpCodeLengths) + { + lineSectionWriter.Stream.WriteULEB128(opcodeLength); + } + + // Directory names + uint directoryIndex = 1; + foreach (var fileName in fileNames) + { + if (fileName.Directory is string directoryName && + !string.IsNullOrEmpty(directoryName) && + !_directoryNameToIndex.ContainsKey(directoryName)) + { + lineSectionWriter.Stream.WriteUtf8String(directoryName); + _directoryNameToIndex.Add(directoryName, directoryIndex); + directoryIndex++; + } + } + // Terminate directory list (empty string) + lineSectionWriter.Stream.WriteUInt8(0); + + // File names + uint fileNameIndex = 1; + foreach (var fileName in fileNames) + { + directoryIndex = fileName.Directory is string directoryName && !string.IsNullOrEmpty(directoryName) ? _directoryNameToIndex[directoryName] : 0; + + lineSectionWriter.Stream.WriteUtf8String(fileName.Name); + lineSectionWriter.Stream.WriteULEB128(directoryIndex); + lineSectionWriter.Stream.WriteULEB128(fileName.Time); + lineSectionWriter.Stream.WriteULEB128(fileName.Size); + + _fileNameToIndex[fileName] = fileNameIndex; + fileNameIndex++; + } + // Terminate file name list (empty string) + lineSectionWriter.Stream.WriteUInt8(0); + + // Update header size + BinaryPrimitives.WriteInt32LittleEndian(headerSizeBuffer, (int)(lineSectionWriter.Stream.Position - headerStart)); + } + + public void Dispose() + { + // Update size + BinaryPrimitives.WriteInt32LittleEndian(_sizeBuffer, (int)(_lineSectionWriter.Stream.Position - sizeof(uint))); + } + + public void WriteLineSequence(DwarfLineSequenceWriter lineSequenceWriter) + { + lineSequenceWriter.Write(_lineSectionWriter, _targetPointerSize, _codeRelocType); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs new file mode 100644 index 00000000000000..8b9a951439b938 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs @@ -0,0 +1,117 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using ILCompiler.DependencyAnalysis; +using static ILCompiler.ObjectWriter.DwarfNative; + +namespace ILCompiler.ObjectWriter +{ + internal sealed class DwarfLineSequenceWriter + { + private readonly ObjectWriterStream _writer; + private readonly string _sectionName; + private readonly byte _minimumInstructionLength; + private readonly uint _maxDeltaAddressPerSpecialCode; + + // DWARF state machine + private ulong _address; + private int _fileNameIndex; + private int _line = 1; + private int _column; + + public DwarfLineSequenceWriter(string sectionName, byte minimumInstructionLength) + { + _writer = new ObjectWriterStream(); + _sectionName = sectionName; + + // Calculations hard code this + Debug.Assert(DwarfLineProgramTableWriter.MaximumOperationsPerInstruction == 1); + + byte maxOperationAdvance = (255 - DwarfLineProgramTableWriter.OpCodeBase) / DwarfLineProgramTableWriter.LineRange; + _maxDeltaAddressPerSpecialCode = (uint)(maxOperationAdvance * minimumInstructionLength); + _minimumInstructionLength = minimumInstructionLength; + } + + public void EmitLineInfo(int fileNameIndex, ulong methodAddress, NativeSequencePoint sequencePoint) + { + if (_column != sequencePoint.ColNumber) + { + _column = sequencePoint.ColNumber; + _writer.WriteUInt8(DW_LNS_set_column); + _writer.WriteULEB128((uint)_column); + } + + if (_fileNameIndex != fileNameIndex) + { + _fileNameIndex = fileNameIndex; + _writer.WriteUInt8(DW_LNS_set_file); + _writer.WriteULEB128((uint)_fileNameIndex); + } + + int deltaLine = sequencePoint.LineNumber - _line; + if (deltaLine != 0) + { + bool canEncodeLineInSpecialCode = + deltaLine >= DwarfLineProgramTableWriter.LineBase && + deltaLine < DwarfLineProgramTableWriter.LineBase + DwarfLineProgramTableWriter.LineRange; + + if (!canEncodeLineInSpecialCode) + { + _writer.WriteUInt8(DW_LNS_advance_line); + _writer.WriteSLEB128(deltaLine); + deltaLine = 0; + } + } + + ulong deltaAddress = (ulong)sequencePoint.NativeOffset + methodAddress - _address; + if (deltaAddress > _maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * _maxDeltaAddressPerSpecialCode)) + { + deltaAddress -= _maxDeltaAddressPerSpecialCode; + _writer.WriteUInt8(DW_LNS_const_add_pc); + } + + if (deltaAddress > 0 || deltaLine != 0) + { + ulong operationAdvance = deltaAddress / _minimumInstructionLength; + ulong opcode = + operationAdvance * DwarfLineProgramTableWriter.LineRange + + DwarfLineProgramTableWriter.OpCodeBase + (ulong)(deltaLine - DwarfLineProgramTableWriter.LineBase); + if (opcode > 255) + { + _writer.WriteUInt8(DW_LNS_advance_pc); + _writer.WriteULEB128((uint)operationAdvance); + if (deltaLine != 0) + { + _writer.WriteUInt8((byte)(DwarfLineProgramTableWriter.OpCodeBase + deltaLine - DwarfLineProgramTableWriter.LineBase)); + } + else + { + _writer.WriteUInt8(DW_LNS_copy); + } + } + else + { + _writer.WriteUInt8((byte)opcode); + } + } + + _line = sequencePoint.LineNumber; + _address = (ulong)sequencePoint.NativeOffset + methodAddress; + } + + public void Write(SectionWriter lineSection, byte targetPointerSize, RelocType codeRelocType) + { + // Set the address to beginning of section + lineSection.Stream.Write([0, (byte)(1u + targetPointerSize), DW_LNE_set_address]); + lineSection.EmitSymbolReference(codeRelocType, _sectionName, 0); + + // TODO: Optimize + _writer.Position = 0; + _writer.CopyTo(lineSection.Stream); + + // FIXME: Double row? + lineSection.Stream.Write([0, 1, DW_LNE_end_sequence]); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index e95bc034a66720..c1028807a3cee5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -2,85 +2,245 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.Diagnostics; using System.IO; - +using System.Linq; using ILCompiler.DependencyAnalysis; -using Internal.JitInterface; using Internal.TypeSystem; using Internal.TypeSystem.TypesDebugInfo; - -using LibObjectFile.Dwarf; using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter { internal sealed class DwarfBuilder : ITypesDebugInfoWriter { - private NameMangler _nameMangler; - private TargetArchitecture _architecture; - private int _targetPointerSize; - private int _frameRegister; - private DwarfFile _dwarfFile; - private DwarfDIECompileUnit _rootDIE; - private DwarfLineProgramTable _lineTable; - private Dictionary _lineSequences = new(); - private Dictionary _emittedFileName; - - private List _memberFunctionTypeInfos = new(); - private List _memberFunctions = new(); - private Dictionary _primitiveDwarfTypes = new(); - private Dictionary<(uint, uint), uint> _simpleArrayDwarfTypes = new(); // (elementTypeIndex, size) -> arrayTypeIndex - private List<(DwarfDIEMember, StaticDataFieldDescriptor)> _staticFields = new(); - - public DwarfFile DwarfFile => _dwarfFile; - - public DwarfBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, bool useDwarf5) + private sealed record SectionInfo(string SectionSymbolName, ulong Size); + private sealed record MemberFunctionTypeInfo(MemberFunctionTypeDescriptor MemberDescriptor, uint[] ArgumentTypes, bool IsStatic); + + + private readonly NameMangler _nameMangler; + private readonly TargetArchitecture _architecture; + private readonly byte _targetPointerSize; + private readonly bool _useDwarf5; + private readonly int _frameRegister; + private readonly byte _minimumInstructionLength; + private readonly RelocType _codeRelocType; + + private readonly Dictionary _lineSequences = new(); + private readonly Dictionary _fileNameMap = new(); // fileName -> _fileNames index (1-based) + private readonly List _fileNames = new(); + + private readonly List _sections = new(); + + private readonly List _memberFunctionTypeInfos = new(); + private readonly List _memberFunctions = new(); + private readonly Dictionary _primitiveDwarfTypes = new(); + private readonly Dictionary<(uint, uint), uint> _simpleArrayDwarfTypes = new(); // (elementTypeIndex, size) -> arrayTypeIndex + private readonly List _staticFields = new(); + + private readonly List _dwarfTypes = new(); + private uint[] _dwarfTypeOffsets; + private readonly List _dwarfSubprograms = new(); + + public DwarfBuilder( + NameMangler nameMangler, + TargetArchitecture targetArchitecture, + bool useDwarf5) { _nameMangler = nameMangler; _architecture = targetArchitecture; + _useDwarf5 = useDwarf5; - if (targetArchitecture == TargetArchitecture.ARM64) + switch (targetArchitecture) { - _targetPointerSize = 8; - _frameRegister = 29; // FP + case TargetArchitecture.ARM64: + _targetPointerSize = 8; + _frameRegister = 29; // FP + _minimumInstructionLength = 4; + _codeRelocType = RelocType.IMAGE_REL_BASED_DIR64; + break; + + case TargetArchitecture.ARM: + _targetPointerSize = 4; + _frameRegister = 7; // R7 + _minimumInstructionLength = 4; + _codeRelocType = RelocType.IMAGE_REL_BASED_HIGHLOW; + break; + + case TargetArchitecture.X64: + _targetPointerSize = 8; + _frameRegister = 6; // RBP + _minimumInstructionLength = 1; + _codeRelocType = RelocType.IMAGE_REL_BASED_DIR64; + break; + + case TargetArchitecture.X86: + _targetPointerSize = 4; + _frameRegister = 5; // EBP + _minimumInstructionLength = 1; + _codeRelocType = RelocType.IMAGE_REL_BASED_HIGHLOW; + break; + + default: + throw new NotSupportedException("Unsupported architecture"); } - else if (targetArchitecture == TargetArchitecture.X64) - { - _targetPointerSize = 8; - _frameRegister = 6; // RBP + } + + public TargetArchitecture TargetArchitecture => _architecture; + public byte TargetPointerSize => _targetPointerSize; + public int FrameRegister => _frameRegister; + + public uint ResolveOffset(uint typeIndex) + { + return typeIndex == 0 ? 0u : _dwarfTypeOffsets[typeIndex - 1]; + } + + public void Write( + SectionWriter infoSectionWriter, + SectionWriter stringSectionWriter, + SectionWriter abbrevSectionWriter, + SectionWriter locSectionWriter, + SectionWriter rangeSectionWriter, + SectionWriter lineSectionWriter, + SectionWriter arangeSectionWriter) + { + WriteInfoTable(infoSectionWriter, stringSectionWriter, abbrevSectionWriter, locSectionWriter, rangeSectionWriter); + WriteLineInfoTable(lineSectionWriter); + WriteAddressRangeTable(arangeSectionWriter); + } + + public void WriteInfoTable( + SectionWriter infoSectionWriter, + SectionWriter stringSectionWriter, + SectionWriter abbrevSectionWriter, + SectionWriter locSectionWriter, + SectionWriter rangeSectionWriter) + { + // Length + byte[] sizeBuffer = new byte[sizeof(uint)]; + infoSectionWriter.Stream.AppendData(sizeBuffer); + // Version + infoSectionWriter.Stream.WriteUInt16((ushort)(_useDwarf5 ? 5u : 4u)); + if (_useDwarf5) + { + // Unit type, Address Size + infoSectionWriter.Stream.Write([DW_UT_compile, _targetPointerSize]); + // Abbrev offset + infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); } else { - throw new NotSupportedException("Unsupported architecture"); - } + // Abbrev offset + infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); + // Address Size + infoSectionWriter.Stream.Write([_targetPointerSize]); + } + + using (DwarfInfoWriter dwarfInfoWriter = new( + infoSectionWriter, + stringSectionWriter.Stream, + abbrevSectionWriter, + locSectionWriter, + rangeSectionWriter, + this, + _codeRelocType)) + { + dwarfInfoWriter.WriteStartDIE(DwarfAbbrev.CompileUnit); + + // DW_AT_producer + dwarfInfoWriter.WriteStringReference("NetRuntime"); + // DW_AT_language + dwarfInfoWriter.WriteUInt16(DW_LANG_C_plus_plus); + // DW_AT_name + dwarfInfoWriter.WriteStringReference("il.cpp"); + // DW_AT_comp_dir + dwarfInfoWriter.WriteStringReference("/_"); + // DW_AT_low_pc + dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); + // DW_AT_ranges + dwarfInfoWriter.WriteStartRangeList(); + foreach (var sectionInfo in _sections) + { + dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); + } + dwarfInfoWriter.WriteEndRangeList(); + // DW_AT_stmt_list + dwarfInfoWriter.WriteLineReference(0); - _dwarfFile = new DwarfFile(); + _dwarfTypeOffsets = new uint[_dwarfTypes.Count]; - _lineTable = new DwarfLineProgramTable(); - _lineTable.AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; + int typeIndex = 0; + foreach (DwarfInfo type in _dwarfTypes) + { + _dwarfTypeOffsets[typeIndex] = (uint)dwarfInfoWriter.Position; + type.Dump(dwarfInfoWriter); + typeIndex++; + } - _rootDIE = new DwarfDIECompileUnit - { - Producer = "CoreRT", // TODO: Change - Language = DwarfLanguageKind.CPlusPlus, - Name = "IL.c", - CompDir = "/tmp", - StmtList = _lineTable, - }; + foreach (DwarfInfo subprogram in _dwarfSubprograms) + { + subprogram.Dump(dwarfInfoWriter); + } - var compilationUnit = new DwarfCompilationUnit() - { - AddressSize = _targetPointerSize == 8 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32, - Root = _rootDIE, - Version = (ushort)(useDwarf5 ? 5u : 4u), - }; + foreach (DwarfStaticVariableInfo staticField in _staticFields) + { + staticField.Dump(dwarfInfoWriter); + } + + dwarfInfoWriter.WriteEndDIE(); + } - _dwarfFile.InfoSection.AddUnit(compilationUnit); - _dwarfFile.LineSection.AddLineProgramTable(_lineTable); + // End of compile unit + infoSectionWriter.Stream.Write([(byte)0]); + + // Update the size + BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(infoSectionWriter.Stream.Length - sizeof(uint))); + } + + private void WriteLineInfoTable(SectionWriter lineSectionWriter) + { + using (var lineProgramTableWriter = new DwarfLineProgramTableWriter( + lineSectionWriter, + _fileNames, + _targetPointerSize, + _minimumInstructionLength, + _codeRelocType)) + { + foreach (DwarfLineSequenceWriter lineSequence in _lineSequences.Values) + { + lineProgramTableWriter.WriteLineSequence(lineSequence); + } + } + } - _emittedFileName = new(); + private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) + { + // Length + var sizeBuffer = new byte[sizeof(uint)]; + arangeSectionWriter.Stream.AppendData(sizeBuffer); + // Version + arangeSectionWriter.Stream.WriteUInt16(2); + // Debug Info Offset + arangeSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", 0); + // Address size, Segment selector size + arangeSectionWriter.Stream.Write([_targetPointerSize, 0]); + // Ranges have to be aligned + arangeSectionWriter.EmitAlignment(_targetPointerSize * 2); + foreach (var sectionInfo in _sections) + { + arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); + switch (_targetPointerSize) + { + case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; + case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; + default: throw new NotSupportedException(); + } + } + arangeSectionWriter.Stream.Write(stackalloc byte[_targetPointerSize * 2]); + // Update the size + BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(arangeSectionWriter.Stream.Length - sizeof(uint))); } public uint GetPrimitiveTypeIndex(TypeDesc type) @@ -96,36 +256,9 @@ private uint GetPrimitiveTypeIndex(TypeFlags typeFlags) return index; } - if (typeFlags == TypeFlags.Void) - { - _rootDIE.AddChild(new DwarfDIEUnspecifiedType { Name = "void" }); - } - else - { - var (name, encoding, byteSize) = typeFlags switch { - TypeFlags.Boolean => ("bool", DW_ATE_boolean, 1), - TypeFlags.Char => ("char16_t", DW_ATE_UTF, 2), - TypeFlags.SByte => ("sbyte", DW_ATE_signed, 1), - TypeFlags.Byte => ("byte", DW_ATE_unsigned, 1), - TypeFlags.Int16 => ("short", DW_ATE_signed, 2), - TypeFlags.UInt16 => ("ushort", DW_ATE_unsigned, 2), - TypeFlags.Int32 => ("int", DW_ATE_signed, 4), - TypeFlags.UInt32 => ("uint", DW_ATE_unsigned, 4), - TypeFlags.Int64 => ("long", DW_ATE_signed, 8), - TypeFlags.UInt64 => ("ulong", DW_ATE_unsigned, 8), - TypeFlags.IntPtr => ("nint", DW_ATE_signed, _targetPointerSize), - TypeFlags.UIntPtr => ("nuint", DW_ATE_unsigned, _targetPointerSize), - TypeFlags.Single => ("float", DW_ATE_float, 4), - TypeFlags.Double => ("double", DW_ATE_float, 8), - _ => ("", 0, 0), - }; - - _rootDIE.AddChild(new DwarfDIEBaseType { Name = name, Encoding = encoding, ByteSize = byteSize}); - } - - uint typeIndex = (uint)_rootDIE.Children.Count; + _dwarfTypes.Add(new DwarfPrimitiveTypeInfo(typeFlags, _targetPointerSize)); + uint typeIndex = (uint)_dwarfTypes.Count; _primitiveDwarfTypes.Add(typeFlags, typeIndex); - return typeIndex; } @@ -134,7 +267,7 @@ public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) uint voidTypeIndex = GetPrimitiveTypeIndex(TypeFlags.Void); // Creating a pointer to what DWARF considers Void type (DW_TAG_unspecified_type - - // per http://eagercon.com/dwarf/issues/minutes-001017.htm) leads to unhappines + // per http://eagercon.com/dwarf/issues/minutes-001017.htm) leads to unhappiness // since debuggers don't really know how to handle that. The Clang symbol parser // in LLDB only handles DW_TAG_unspecified_type if it's named // "nullptr_t" or "decltype(nullptr)". @@ -143,29 +276,14 @@ public uint GetPointerTypeIndex(PointerTypeDescriptor pointerDescriptor) // clang would generate (pointer type with no element type specified). if (pointerDescriptor.ElementType == voidTypeIndex) { - _rootDIE.AddChild(new DwarfDIEPointerType()); + _dwarfTypes.Add(new DwarfVoidPtrTypeInfo()); } else { - if (pointerDescriptor.IsReference == 1) - { - _rootDIE.AddChild(new DwarfDIEReferenceType - { - Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], - ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, - }); - } - else - { - _rootDIE.AddChild(new DwarfDIEPointerType - { - Type = _rootDIE.Children[(int)pointerDescriptor.ElementType - 1], - ByteSize = pointerDescriptor.Is64Bit == 1 ? 8 : 4, - }); - } + _dwarfTypes.Add(new DwarfPointerTypeInfo(pointerDescriptor)); } - return (uint)_rootDIE.Children.Count; + return (uint)_dwarfTypes.Count; } private uint GetSimpleArrayTypeIndex(uint elementIndex, uint size) @@ -175,11 +293,8 @@ private uint GetSimpleArrayTypeIndex(uint elementIndex, uint size) return index; } - var arrayType = new DwarfDIEArrayType { Type = _rootDIE.Children[(int)elementIndex - 1] }; - arrayType.AddChild(new DwarfDIESubrangeType { UpperBound = (int)size }); - _rootDIE.AddChild(arrayType); - - uint typeIndex = (uint)_rootDIE.Children.Count; + _dwarfTypes.Add(new DwarfSimpleArrayTypeInfo(elementIndex, size)); + uint typeIndex = (uint)_dwarfTypes.Count; _simpleArrayDwarfTypes.Add((elementIndex, size), typeIndex); return typeIndex; @@ -189,101 +304,63 @@ public uint GetArrayTypeIndex( ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayDescriptor) { - int fieldOffset = _targetPointerSize; - var classType = new DwarfDIEClassType { Name = classDescriptor.Name }; + // Create corresponding class info + ClassTypeDescriptor arrayClassDescriptor = classDescriptor; - if (classDescriptor.BaseClassId != 0) - { - classType.AddChild(new DwarfDIEInheritance - { - Type = _rootDIE.Children[(int)classDescriptor.BaseClassId - 1], - DataMemberLocation = new DwarfLocation(0), - }); - } + List fieldDescriptors = new(); + ulong fieldOffset = _targetPointerSize; - classType.AddChild(new DwarfDIEMember + fieldDescriptors.Add(new DataFieldDescriptor { + FieldTypeIndex = GetPrimitiveTypeIndex(TypeFlags.Int32), + Offset = fieldOffset, Name = "m_NumComponents", - Type = _rootDIE.Children[(int)GetPrimitiveTypeIndex(TypeFlags.Int32) - 1], - DataMemberLocation = new DwarfLocation(fieldOffset), }); fieldOffset += _targetPointerSize; - if (arrayDescriptor.IsMultiDimensional == 1) + if (arrayDescriptor.IsMultiDimensional != 0) { - classType.AddChild(new DwarfDIEMember + fieldDescriptors.Add(new DataFieldDescriptor { + FieldTypeIndex = GetSimpleArrayTypeIndex(GetPrimitiveTypeIndex(TypeFlags.Int32), arrayDescriptor.Rank), + Offset = fieldOffset, Name = "m_Bounds", - Type = _rootDIE.Children[(int)GetSimpleArrayTypeIndex(GetPrimitiveTypeIndex(TypeFlags.Int32), arrayDescriptor.Rank) - 1], - DataMemberLocation = new DwarfLocation(fieldOffset), }); - fieldOffset += 2 * 4 * (int)arrayDescriptor.Rank; + fieldOffset += 2u * 4u * (ulong)arrayDescriptor.Rank; } - classType.AddChild(new DwarfDIEMember + fieldDescriptors.Add(new DataFieldDescriptor { + FieldTypeIndex = GetSimpleArrayTypeIndex(arrayDescriptor.ElementType, 0), + Offset = fieldOffset, Name = "m_Data", - Type = _rootDIE.Children[(int)GetSimpleArrayTypeIndex(arrayDescriptor.ElementType, 0) - 1], - DataMemberLocation = new DwarfLocation(fieldOffset), }); - classType.ByteSize = fieldOffset; + // TODO: Verify that this makes sense + arrayClassDescriptor.InstanceSize = fieldOffset; - _rootDIE.AddChild(classType); + ClassFieldsTypeDescriptor fieldsTypeDesc = new ClassFieldsTypeDescriptor + { + Size = _targetPointerSize, + FieldsCount = arrayDescriptor.IsMultiDimensional != 0 ? 3 : 2, + }; - return (uint)_rootDIE.Children.Count; + return GetCompleteClassTypeIndex(arrayClassDescriptor, fieldsTypeDesc, fieldDescriptors.ToArray(), null); } public uint GetEnumTypeIndex( EnumTypeDescriptor typeDescriptor, EnumRecordTypeDescriptor[] typeRecords) { - var elementType = _rootDIE.Children[(int)typeDescriptor.ElementType - 1]; - var enumerationType = new DwarfDIEEnumerationType - { - Name = typeDescriptor.Name, - Type = elementType, - ByteSize = ((DwarfDIEBaseType)elementType).ByteSize, - }; - - foreach (EnumRecordTypeDescriptor typeRecord in typeRecords) - { - enumerationType.AddChild(new DwarfDIEEnumerator - { - Name = typeRecord.Name, - ConstValue = (int)typeRecord.Value, - }); - } - - _rootDIE.AddChild(enumerationType); - - return (uint)_rootDIE.Children.Count; + byte byteSize = ((DwarfPrimitiveTypeInfo)_dwarfTypes[(int)typeDescriptor.ElementType - 1]).ByteSize; + _dwarfTypes.Add(new DwarfEnumTypeInfo(typeDescriptor, typeRecords, byteSize)); + return (uint)_dwarfTypes.Count; } public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) { - _dwarfFile.StringTable.GetOrCreateString(classDescriptor.Name); - - var classType = new DwarfDIEClassType - { - Name = classDescriptor.Name, - Declaration = true, - }; - - if (classDescriptor.BaseClassId != 0) - { - classType.AddChild(new DwarfDIEInheritance - { - Type = _rootDIE.Children[(int)classDescriptor.BaseClassId - 1], - DataMemberLocation = new DwarfLocation(0), - }); - } - - // Size = ClassDescriptor.InstanceSize? - - _rootDIE.AddChild(classType); - - return (uint)_rootDIE.Children.Count; + _dwarfTypes.Add(new DwarfClassTypeInfo(classDescriptor)); + return (uint)_dwarfTypes.Count; } public uint GetCompleteClassTypeIndex( @@ -292,115 +369,34 @@ public uint GetCompleteClassTypeIndex( DataFieldDescriptor[] fields, StaticDataFieldDescriptor[] statics) { - _dwarfFile.StringTable.GetOrCreateString(classTypeDescriptor.Name); - - var classType = new DwarfDIEClassType - { - Name = classTypeDescriptor.Name, - ByteSize = (int)classTypeDescriptor.InstanceSize, - }; - - if (classTypeDescriptor.BaseClassId != 0) - { - classType.AddChild(new DwarfDIEInheritance - { - Type = _rootDIE.Children[(int)classTypeDescriptor.BaseClassId - 1], - DataMemberLocation = new DwarfLocation(0), - }); - } - - int staticIndex = 0; - foreach (DataFieldDescriptor fieldDescriptor in fields) - { - _dwarfFile.StringTable.GetOrCreateString(fieldDescriptor.Name); - - var member = new DwarfDIEMember - { - Name = fieldDescriptor.Name, - Type = _rootDIE.Children[(int)fieldDescriptor.FieldTypeIndex - 1], - }; - - if (fieldDescriptor.Offset != 0xFFFFFFFFu) - { - member.DataMemberLocation = new DwarfLocation((int)fieldDescriptor.Offset); - } - else - { - member.Declaration = true; - member.AddAttribute(new DwarfAttribute { Kind = DwarfAttributeKind.External, ValueAsU64 = 1 }); - _staticFields.Add((member, statics[staticIndex])); - staticIndex++; - } - - classType.AddChild(member); - } - - // TODO: static members - - _rootDIE.AddChild(classType); - - return (uint)_rootDIE.Children.Count; + var classInfo = new DwarfClassTypeInfo(classTypeDescriptor, classFieldsTypeDescriptor, fields, statics); + _dwarfTypes.Add(classInfo); + _staticFields.AddRange(classInfo.StaticVariables); + return (uint)_dwarfTypes.Count; } - private sealed class DwarfMemberFunctionTypeInfo : DwarfDIEDeclaration - { - public MemberFunctionTypeDescriptor MemberDescriptor { get; init; } - public uint[] ArgumentTypes { get; init; } - public bool IsStatic { get; init; } - }; - public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescriptor, uint[] argumentTypes) { - _memberFunctionTypeInfos.Add(new DwarfMemberFunctionTypeInfo - { - MemberDescriptor = memberDescriptor, - ArgumentTypes = argumentTypes, - IsStatic = memberDescriptor.TypeIndexOfThisPointer == GetPrimitiveTypeIndex(TypeFlags.Void), - }); + _memberFunctionTypeInfos.Add(new MemberFunctionTypeInfo( + memberDescriptor, + argumentTypes, + memberDescriptor.TypeIndexOfThisPointer == GetPrimitiveTypeIndex(TypeFlags.Void))); return (uint)_memberFunctionTypeInfos.Count; } public uint GetMemberFunctionId(MemberFunctionIdTypeDescriptor memberIdDescriptor) { - DwarfMemberFunctionTypeInfo memberFunctionTypeInfo = - _memberFunctionTypeInfos[(int)memberIdDescriptor.MemberFunction - 1]; - MemberFunctionTypeDescriptor memberDescriptor = memberFunctionTypeInfo.MemberDescriptor; - DwarfDIEClassType parentClass = - (DwarfDIEClassType)_rootDIE.Children[(int)memberIdDescriptor.ParentClass - 1]; - - _dwarfFile.StringTable.GetOrCreateString(memberIdDescriptor.Name); - - var subprogram = new DwarfDIESubprogram - { - Name = memberIdDescriptor.Name, - LinkageName = memberIdDescriptor.Name, - Type = _rootDIE.Children[(int)memberDescriptor.ReturnType - 1], - // decl file, decl line - External = true, - Declaration = true, - }; - - if (!memberFunctionTypeInfo.IsStatic) - { - subprogram.ObjectPointer = new DwarfDIEFormalParameter - { - Type = _rootDIE.Children[(int)memberDescriptor.TypeIndexOfThisPointer - 1], - Artificial = true, - }; - subprogram.AddChild(subprogram.ObjectPointer); - } - - foreach (var argType in memberFunctionTypeInfo.ArgumentTypes) - { - subprogram.AddChild(new DwarfDIEFormalParameter - { - Type = _rootDIE.Children[(int)argType - 1], - }); - } + MemberFunctionTypeInfo memberFunctionTypeInfo = _memberFunctionTypeInfos[(int)memberIdDescriptor.MemberFunction - 1]; + DwarfClassTypeInfo parentClass = (DwarfClassTypeInfo)_dwarfTypes[(int)(memberIdDescriptor.ParentClass - 1)]; + DwarfMemberFunction memberFunction = new DwarfMemberFunction( + memberIdDescriptor.Name, + memberFunctionTypeInfo.MemberDescriptor, + memberFunctionTypeInfo.ArgumentTypes, + memberFunctionTypeInfo.IsStatic); - parentClass.AddChild(subprogram); - _memberFunctions.Add(subprogram); + parentClass.AddMemberFunction(memberFunction); + _memberFunctions.Add(memberFunction); return (uint)_memberFunctions.Count; } @@ -410,377 +406,67 @@ public string GetMangledName(TypeDesc type) return _nameMangler.GetMangledTypeName(type); } - // TODO: Clean-up and share with R2R code - private enum RegNumAmd64 : int - { - REGNUM_RAX, - REGNUM_RCX, - REGNUM_RDX, - REGNUM_RBX, - REGNUM_RSP, - REGNUM_RBP, - REGNUM_RSI, - REGNUM_RDI, - REGNUM_R8, - REGNUM_R9, - REGNUM_R10, - REGNUM_R11, - REGNUM_R12, - REGNUM_R13, - REGNUM_R14, - REGNUM_R15, - REGNUM_COUNT, - REGNUM_SP = REGNUM_RSP, - REGNUM_FP = REGNUM_RBP - }; - - private int DwarfRegNum(int regNum) - { - if (_architecture == TargetArchitecture.ARM64) - { - // Normal registers are directly mapped - if (regNum >= 33) - regNum = regNum - 33 + 64; // FP - return regNum; - } - else if (_architecture == TargetArchitecture.X64) - { - return (RegNumAmd64)regNum switch - { - RegNumAmd64.REGNUM_RAX => 0, - RegNumAmd64.REGNUM_RDX => 1, - RegNumAmd64.REGNUM_RCX => 2, - RegNumAmd64.REGNUM_RBX => 3, - RegNumAmd64.REGNUM_RSI => 4, - RegNumAmd64.REGNUM_RDI => 5, - RegNumAmd64.REGNUM_RBP => 6, - RegNumAmd64.REGNUM_RSP => 7, - RegNumAmd64.REGNUM_R8 => 8, - RegNumAmd64.REGNUM_R9 => 9, - RegNumAmd64.REGNUM_R10 => 10, - RegNumAmd64.REGNUM_R11 => 11, - RegNumAmd64.REGNUM_R12 => 12, - RegNumAmd64.REGNUM_R13 => 13, - RegNumAmd64.REGNUM_R14 => 14, - RegNumAmd64.REGNUM_R15 => 15, - _ => regNum - (int)RegNumAmd64.REGNUM_COUNT + 17 // FP registers - }; - } - else - { - throw new NotSupportedException(); - } - } - - - private DwarfOperation DwarfReg(int regNum) - { - int dwarfRegNum = DwarfRegNum(regNum); - if (dwarfRegNum < 32) - { - return new DwarfOperation { Kind = (DwarfOperationKind)((int)DwarfOperationKind.Reg0 + dwarfRegNum) }; - } - else - { - return new DwarfOperation - { - Kind = DwarfOperationKind.Regx, - Operand1 = { U64 = (uint)dwarfRegNum }, - }; - } - } - - private DwarfOperation DwarfBreg(int regNum, int offset = 0) - { - int dwarfRegNum = DwarfRegNum(regNum); - if (dwarfRegNum < 32) - { - return new DwarfOperation - { - Kind = (DwarfOperationKind)((int)DwarfOperationKind.Breg0 + dwarfRegNum), - Operand2 = { I64 = offset }, - }; - } - else - { - return new DwarfOperation - { - Kind = DwarfOperationKind.Bregx, - Operand1 = { U64 = (uint)dwarfRegNum }, - Operand2 = { I64 = offset }, - }; - } - } - - private DwarfExpression DwarfVarLocation(VarLoc loc) - { - var e = new DwarfExpression(); - - switch (loc.LocationType) - { - case VarLocType.VLT_REG: - case VarLocType.VLT_REG_FP: - e.AddOperation(DwarfReg(loc.B)); - break; - case VarLocType.VLT_REG_BYREF: - e.AddOperation(DwarfBreg(loc.B)); - break; - case VarLocType.VLT_STK: - case VarLocType.VLT_STK2: - case VarLocType.VLT_FPSTK: - case VarLocType.VLT_STK_BYREF: - e.AddOperation(DwarfBreg(loc.B, loc.C)); - if (loc.LocationType == VarLocType.VLT_STK_BYREF) - { - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); - } - break; - case VarLocType.VLT_REG_REG: - e.AddOperation(DwarfReg(loc.C)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - e.AddOperation(DwarfReg(loc.B)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - break; - case VarLocType.VLT_REG_STK: - case VarLocType.VLT_STK_REG: - if (loc.LocationType == VarLocType.VLT_REG_STK) - { - e.AddOperation(DwarfReg(loc.B)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - e.AddOperation(DwarfBreg(loc.C, loc.D)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - } - else - { - e.AddOperation(DwarfBreg(loc.C, loc.D)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - e.AddOperation(DwarfReg(loc.B)); - e.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Piece }); - } - break; - default: - // Unsupported - Debug.Assert(loc.LocationType != VarLocType.VLT_FIXED_VA); - return null; - } - - return e; - } - - private DwarfDIE EmitVar(DebugVarInfoMetadata metadataInfo, ulong methodPCStart, DwarfDIE type, bool isThis) - { - string varName = metadataInfo.Name; - DwarfLocation? location = null; - - if (metadataInfo.DebugVarInfo.Ranges.Length == 1) - { - var e = DwarfVarLocation(metadataInfo.DebugVarInfo.Ranges[0].VarLoc); - if (e != null) - { - location = new DwarfLocation(e); - } - else - { - Console.WriteLine("F: " + metadataInfo.Name); - } - } - else - { - var locationList = new DwarfLocationList(); - foreach (var range in metadataInfo.DebugVarInfo.Ranges) - { - var e = DwarfVarLocation(range.VarLoc); - if (e != null) - { - locationList.AddLocationListEntry(new DwarfLocationListEntry - { - Start = range.StartOffset + methodPCStart, - End = range.EndOffset + methodPCStart, - Expression = e, - }); - } - } - _dwarfFile.LocationSection.AddLocationList(locationList); - location = locationList; - } - - if (metadataInfo.IsParameter) - { - var formalParameter = new DwarfDIEFormalParameter - { - Name = isThis ? "this" : varName, - // decl file, line - Type = type, - }; - - if (location != null) - { - formalParameter.Location = location; - } - - if (isThis) - { - formalParameter.Artificial = true; - } - - return formalParameter; - } - else - { - var variable = new DwarfDIEVariable - { - Name = varName, - Type = type, - }; - - if (location != null) - { - variable.Location = location; - } - - return variable; - } - } - public void EmitSubprogramInfo( string methodName, - ulong methodPCStart, int methodPCLength, uint methodTypeIndex, IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, - IEnumerable debugEHClauseInfos) + DebugEHClauseInfo[] debugEHClauseInfos) { if (methodTypeIndex == 0) { return; } - var subprogramSpec = _memberFunctions[(int)methodTypeIndex - 1]; - - _dwarfFile.StringTable.GetOrCreateString(methodName); - subprogramSpec.LinkageName = methodName; - - var frameExpression = new DwarfExpression(); - frameExpression.AddOperation(new DwarfOperation { Kind = (DwarfOperationKind)((int)DwarfOperationKind.Reg0 + _frameRegister) }); - var subprogram = new DwarfDIESubprogram - { - Specification = subprogramSpec, - LowPC = methodPCStart, - HighPC = methodPCLength, - FrameBase = new DwarfLocation(frameExpression), - }; - - /// At the moment, the lexical scope reflects IL, not C#, meaning that - /// there is only one scope for the whole method. We could be more precise - /// in the future by pulling the scope information from the PDB. - foreach (var (debugVar, typeIndex) in debugVars) - { - bool isThis = debugVar.IsParameter && debugVar.DebugVarInfo.VarNumber == 0 && subprogramSpec.ObjectPointer != null; - var dwarfVar = EmitVar(debugVar, methodPCStart, typeIndex == 0 ? null : _rootDIE.Children[(int)typeIndex - 1], isThis); - subprogram.AddChild(dwarfVar); - if (isThis) - { - subprogram.ObjectPointer = dwarfVar; - } - } + DwarfMemberFunction memberFunction = _memberFunctions[(int)methodTypeIndex - 1]; + memberFunction.LinkageName = methodName; - foreach (var clause in debugEHClauseInfos) - { - subprogram.AddChild(new DwarfDIETryBlock - { - LowPC = methodPCStart + clause.TryOffset, - HighPC = (int)clause.TryLength, - }); - - subprogram.AddChild(new DwarfDIECatchBlock - { - LowPC = methodPCStart + clause.HandlerOffset, - HighPC = (int)clause.HandlerLength, - }); - } - - _rootDIE.AddChild(subprogram); + _dwarfSubprograms.Add(new DwarfSubprogramInfo( + methodName, + methodPCLength, + memberFunction, + debugVars.ToArray(), + debugEHClauseInfos)); } - public void EmitLineInfo(int sectionIndex, ulong methodPCStart, IEnumerable sequencePoints) + public void EmitLineInfo(int sectionIndex, string sectionSymbolName, ulong methodAddress, IEnumerable sequencePoints) { - DwarfLineSequence lineSequence; + DwarfLineSequenceWriter lineSequence; // Create line sequence for every section so they can get the // base address relocated properly. if (!_lineSequences.TryGetValue(sectionIndex, out lineSequence)) { - lineSequence = new DwarfLineSequence(); - _lineTable.AddLineSequence(lineSequence); + lineSequence = new DwarfLineSequenceWriter(sectionSymbolName, _minimumInstructionLength); _lineSequences.Add(sectionIndex, lineSequence); } - foreach (var sequencePoint in sequencePoints) - { - DwarfFileName dwarfFileName; + int fileNameIndex = 0; + string lastFileName = null; - if (!_emittedFileName.TryGetValue(sequencePoint.FileName, out dwarfFileName)) + foreach (NativeSequencePoint sequencePoint in sequencePoints) + { + if (lastFileName != sequencePoint.FileName) { - dwarfFileName = new DwarfFileName + if (!_fileNameMap.TryGetValue(sequencePoint.FileName, out fileNameIndex)) { - Name = Path.GetFileName(sequencePoint.FileName), - Directory = Path.GetDirectoryName(sequencePoint.FileName), - }; - _emittedFileName.Add(sequencePoint.FileName, dwarfFileName); - _lineTable.FileNames.Add(dwarfFileName); + var dwarfFileName = string.IsNullOrEmpty(sequencePoint.FileName) ? + new DwarfFileName("", null) : + new DwarfFileName(Path.GetFileName(sequencePoint.FileName), Path.GetDirectoryName(sequencePoint.FileName)); + _fileNames.Add(dwarfFileName); + fileNameIndex = _fileNames.Count; + _fileNameMap.Add(sequencePoint.FileName, fileNameIndex); + } + lastFileName = sequencePoint.FileName; } - lineSequence.Add(new DwarfLine - { - File = dwarfFileName, - Address = methodPCStart + (ulong)sequencePoint.NativeOffset, - Column = (uint)sequencePoint.ColNumber, - Line = (uint)sequencePoint.LineNumber, - }); + lineSequence.EmitLineInfo(fileNameIndex, methodAddress, sequencePoint); } } - public void EmitStaticVars(Func resolveNameToAddress) + public void EmitSectionInfo(string sectionSymbolName, ulong size) { - foreach (var (memberSpec, staticVarInfo) in _staticFields) - { - var staticAddress = resolveNameToAddress(staticVarInfo.StaticDataName); - - if (staticAddress == 0) - { - continue; - } - - var expression = new DwarfExpression(); - expression.AddOperation(new DwarfOperation - { - Kind = DwarfOperationKind.Addr, - Operand1 = { U64 = staticAddress }, - }); - - if (staticVarInfo.IsStaticDataInObject == 1) - { - expression.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); - expression.AddOperation(new DwarfOperation { Kind = DwarfOperationKind.Deref }); - } - - if (staticVarInfo.StaticOffset != 0) - { - expression.AddOperation(new DwarfOperation - { - Kind = DwarfOperationKind.PlusUconst, - Operand1 = { U64 = staticVarInfo.StaticOffset }, - }); - } - - var variable = new DwarfDIEVariable - { - Specification = memberSpec, - Location = new DwarfLocation(expression), - }; - - _rootDIE.AddChild(variable); - } + _sections.Add(new SectionInfo(sectionSymbolName, size)); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs index 60f83fd0c6dce6..fa8c74d6a0ae71 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs @@ -2,12 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.IO; -using System.Buffers.Binary; - using Internal.TypeSystem; - -using Melanzana.MachO; using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter @@ -42,37 +37,42 @@ public DwarfCie(TargetArchitecture targetArchitecture) PointerEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4; LsdaEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4; - if (targetArchitecture == TargetArchitecture.ARM64) - { - CodeAlignFactor = 1; - DataAlignFactor = -4; - ReturnAddressRegister = 30; // LR - Instructions = new byte[] - { - DW_CFA_def_cfa, - 31, // SP - 0, // Offset from SP - }; - InitialCFAOffset = 0; - } - else if (targetArchitecture == TargetArchitecture.X64) - { - CodeAlignFactor = 1; - DataAlignFactor = -8; - ReturnAddressRegister = 16; // RA - Instructions = new byte[] - { - DW_CFA_def_cfa, - 7, // RSP - 8, // Offset from RSP - DW_CFA_offset | 16, // RIP - 1, // RIP is at -8 - }; - InitialCFAOffset = 8; - } - else + switch (targetArchitecture) { - throw new NotSupportedException(); + case TargetArchitecture.ARM64: + CodeAlignFactor = 1; + DataAlignFactor = -4; + ReturnAddressRegister = 30; // LR + Instructions = new byte[] + { + DW_CFA_def_cfa, + 31, // SP + 0, // Offset from SP + }; + InitialCFAOffset = 0; + break; + + //case TargetArchitecture.ARM: + + case TargetArchitecture.X64: + CodeAlignFactor = 1; + DataAlignFactor = -8; + ReturnAddressRegister = 16; // RA + Instructions = new byte[] + { + DW_CFA_def_cfa, + 7, // RSP + 8, // Offset from RSP + DW_CFA_offset | 16, // RIP + 1, // RIP is at -8 + }; + InitialCFAOffset = 8; + break; + + //case TargetArchitecture.X86: + + default: + throw new NotSupportedException(); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs index 758f6dcb547b21..e5db70f35c8068 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs @@ -3,15 +3,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; using System.Buffers.Binary; using ILCompiler.DependencyAnalysis; using Internal.Text; -using LibObjectFile.Dwarf; -using Melanzana.MachO; using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter @@ -85,7 +81,7 @@ private void WriteCie(DwarfCie cie) 1u + // Version (uint)augmentationString.Length + 1u + DwarfHelper.SizeOfULEB128(cie.CodeAlignFactor) + - DwarfHelper.SizeOfILEB128(cie.DataAlignFactor) + + DwarfHelper.SizeOfSLEB128(cie.DataAlignFactor) + DwarfHelper.SizeOfULEB128(cie.ReturnAddressRegister) + (uint)(augmentationLength > 0 ? DwarfHelper.SizeOfULEB128(augmentationLength) + augmentationLength : 0) + (uint)cie.Instructions.Length; @@ -98,7 +94,7 @@ private void WriteCie(DwarfCie cie) stream.Write(augmentationString.UnderlyingArray); stream.WriteULEB128(cie.CodeAlignFactor); - stream.WriteILEB128(cie.DataAlignFactor); + stream.WriteSLEB128(cie.DataAlignFactor); stream.WriteULEB128(cie.ReturnAddressRegister); stream.WriteULEB128(augmentationLength); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs index 0671120523d066..02da816018601d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs @@ -3,13 +3,7 @@ using System; using System.Diagnostics; -using System.IO; using System.Buffers; -using System.Buffers.Binary; - -using Internal.TypeSystem; - -using Melanzana.MachO; using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs index 0cbce71c9316ea..e2fed04506994f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs @@ -55,23 +55,494 @@ public static class DwarfNative public const byte DW_CFA_GNU_negative_offset_extended = 0x2f; public const byte DW_CFA_AARCH64_negate_ra_state = 0x2d; - public const int DW_ATE_address = 0x01; - public const int DW_ATE_boolean = 0x02; - public const int DW_ATE_complex_float = 0x03; - public const int DW_ATE_float = 0x04; - public const int DW_ATE_signed = 0x05; - public const int DW_ATE_signed_char = 0x06; - public const int DW_ATE_unsigned = 0x07; - public const int DW_ATE_unsigned_char = 0x08; - public const int DW_ATE_imaginary_float = 0x09; /* DWARF3 */ - public const int DW_ATE_packed_decimal = 0x0a; /* DWARF3f */ - public const int DW_ATE_numeric_string = 0x0b; /* DWARF3f */ - public const int DW_ATE_edited = 0x0c; /* DWARF3f */ - public const int DW_ATE_signed_fixed = 0x0d; /* DWARF3f */ - public const int DW_ATE_unsigned_fixed = 0x0e; /* DWARF3f */ - public const int DW_ATE_decimal_float = 0x0f; /* DWARF3f */ - public const int DW_ATE_UTF = 0x10; /* DWARF4 */ - public const int DW_ATE_UCS = 0x11; /* DWARF5 */ - public const int DW_ATE_ASCII = 0x12; /* DWARF5 */ + public const byte DW_ATE_address = 0x01; + public const byte DW_ATE_boolean = 0x02; + public const byte DW_ATE_complex_float = 0x03; + public const byte DW_ATE_float = 0x04; + public const byte DW_ATE_signed = 0x05; + public const byte DW_ATE_signed_char = 0x06; + public const byte DW_ATE_unsigned = 0x07; + public const byte DW_ATE_unsigned_char = 0x08; + public const byte DW_ATE_imaginary_float = 0x09; /* DWARF3 */ + public const byte DW_ATE_packed_decimal = 0x0a; /* DWARF3f */ + public const byte DW_ATE_numeric_string = 0x0b; /* DWARF3f */ + public const byte DW_ATE_edited = 0x0c; /* DWARF3f */ + public const byte DW_ATE_signed_fixed = 0x0d; /* DWARF3f */ + public const byte DW_ATE_unsigned_fixed = 0x0e; /* DWARF3f */ + public const byte DW_ATE_decimal_float = 0x0f; /* DWARF3f */ + public const byte DW_ATE_UTF = 0x10; /* DWARF4 */ + public const byte DW_ATE_UCS = 0x11; /* DWARF5 */ + public const byte DW_ATE_ASCII = 0x12; /* DWARF5 */ + + public const ushort DW_TAG_array_type = 1; + public const ushort DW_TAG_class_type = 2; + public const ushort DW_TAG_entry_point = 3; + public const ushort DW_TAG_enumeration_type = 4; + public const ushort DW_TAG_formal_parameter = 5; + public const ushort DW_TAG_imported_declaration = 8; + public const ushort DW_TAG_label = 10; + public const ushort DW_TAG_lexical_block = 11; + public const ushort DW_TAG_member = 13; + public const ushort DW_TAG_pointer_type = 15; + public const ushort DW_TAG_reference_type = 16; + public const ushort DW_TAG_compile_unit = 17; + public const ushort DW_TAG_string_type = 18; + public const ushort DW_TAG_structure_type = 19; + public const ushort DW_TAG_subroutine_type = 21; + public const ushort DW_TAG_typedef = 22; + public const ushort DW_TAG_union_type = 23; + public const ushort DW_TAG_unspecified_parameters = 24; + public const ushort DW_TAG_variant = 25; + public const ushort DW_TAG_common_block = 26; + public const ushort DW_TAG_common_inclusion = 27; + public const ushort DW_TAG_inheritance = 28; + public const ushort DW_TAG_inlined_subroutine = 29; + public const ushort DW_TAG_module = 30; + public const ushort DW_TAG_ptr_to_member_type = 31; + public const ushort DW_TAG_set_type = 32; + public const ushort DW_TAG_subrange_type = 33; + public const ushort DW_TAG_with_stmt = 34; + public const ushort DW_TAG_access_declaration = 35; + public const ushort DW_TAG_base_type = 36; + public const ushort DW_TAG_catch_block = 37; + public const ushort DW_TAG_const_type = 38; + public const ushort DW_TAG_constant = 39; + public const ushort DW_TAG_enumerator = 40; + public const ushort DW_TAG_file_type = 41; + public const ushort DW_TAG_friend = 42; + public const ushort DW_TAG_namelist = 43; + public const ushort DW_TAG_namelist_item = 44; + public const ushort DW_TAG_packed_type = 45; + public const ushort DW_TAG_subprogram = 46; + public const ushort DW_TAG_template_type_param = 47; + public const ushort DW_TAG_template_value_param = 48; + public const ushort DW_TAG_thrown_type = 49; + public const ushort DW_TAG_try_block = 50; + public const ushort DW_TAG_variant_part = 51; + public const ushort DW_TAG_variable = 52; + public const ushort DW_TAG_volatile_type = 53; + public const ushort DW_TAG_dwarf_procedure = 54; + public const ushort DW_TAG_restrict_type = 55; + public const ushort DW_TAG_interface_type = 56; + public const ushort DW_TAG_namespace = 57; + public const ushort DW_TAG_imported_module = 58; + public const ushort DW_TAG_unspecified_type = 59; + public const ushort DW_TAG_partial_unit = 60; + public const ushort DW_TAG_imported_unit = 61; + public const ushort DW_TAG_mutable_type = 62; + public const ushort DW_TAG_condition = 63; + public const ushort DW_TAG_shared_type = 64; + public const ushort DW_TAG_type_unit = 65; + public const ushort DW_TAG_rvalue_reference_type = 66; + public const ushort DW_TAG_template_alias = 67; + public const ushort DW_TAG_coarray_type = 68; + public const ushort DW_TAG_generic_subrange = 69; + public const ushort DW_TAG_dynamic_type = 70; + public const ushort DW_TAG_atomic_type = 71; + public const ushort DW_TAG_call_site = 72; + public const ushort DW_TAG_call_site_parameter = 73; + public const ushort DW_TAG_skeleton_unit = 74; + public const ushort DW_TAG_immutable_type = 75; + + public const ushort DW_FORM_addr = 1; + public const ushort DW_FORM_block2 = 3; + public const ushort DW_FORM_block4 = 4; + public const ushort DW_FORM_data2 = 5; + public const ushort DW_FORM_data4 = 6; + public const ushort DW_FORM_data8 = 7; + public const ushort DW_FORM_string = 8; + public const ushort DW_FORM_block = 9; + public const ushort DW_FORM_block1 = 10; + public const ushort DW_FORM_data1 = 11; + public const ushort DW_FORM_flag = 12; + public const ushort DW_FORM_sdata = 13; + public const ushort DW_FORM_strp = 14; + public const ushort DW_FORM_udata = 15; + public const ushort DW_FORM_ref_addr = 16; + public const ushort DW_FORM_ref1 = 17; + public const ushort DW_FORM_ref2 = 18; + public const ushort DW_FORM_ref4 = 19; + public const ushort DW_FORM_ref8 = 20; + public const ushort DW_FORM_ref_udata = 21; + public const ushort DW_FORM_indirect = 22; + public const ushort DW_FORM_sec_offset = 23; + public const ushort DW_FORM_exprloc = 24; + public const ushort DW_FORM_flag_present = 25; + public const ushort DW_FORM_strx = 26; + public const ushort DW_FORM_addrx = 27; + public const ushort DW_FORM_ref_sup4 = 28; + public const ushort DW_FORM_strp_sup = 29; + public const ushort DW_FORM_data16 = 30; + public const ushort DW_FORM_line_strp = 31; + public const ushort DW_FORM_ref_sig8 = 32; + public const ushort DW_FORM_implicit_const = 33; + public const ushort DW_FORM_loclistx = 34; + public const ushort DW_FORM_rnglistx = 35; + public const ushort DW_FORM_ref_sup8 = 36; + public const ushort DW_FORM_strx1 = 37; + public const ushort DW_FORM_strx2 = 38; + public const ushort DW_FORM_strx3 = 39; + public const ushort DW_FORM_strx4 = 40; + public const ushort DW_FORM_addrx1 = 41; + public const ushort DW_FORM_addrx2 = 42; + public const ushort DW_FORM_addrx3 = 43; + public const ushort DW_FORM_addrx4 = 44; + + public const ushort DW_AT_sibling = 1; + public const ushort DW_AT_location = 2; + public const ushort DW_AT_name = 3; + public const ushort DW_AT_ordering = 9; + public const ushort DW_AT_subscr_data = 10; + public const ushort DW_AT_byte_size = 11; + public const ushort DW_AT_bit_offset = 12; + public const ushort DW_AT_bit_size = 13; + public const ushort DW_AT_element_list = 15; + public const ushort DW_AT_stmt_list = 16; + public const ushort DW_AT_low_pc = 17; + public const ushort DW_AT_high_pc = 18; + public const ushort DW_AT_language = 19; + public const ushort DW_AT_member = 20; + public const ushort DW_AT_discr = 21; + public const ushort DW_AT_discr_value = 22; + public const ushort DW_AT_visibility = 23; + public const ushort DW_AT_import = 24; + public const ushort DW_AT_string_length = 25; + public const ushort DW_AT_common_reference = 26; + public const ushort DW_AT_comp_dir = 27; + public const ushort DW_AT_const_value = 28; + public const ushort DW_AT_containing_type = 29; + public const ushort DW_AT_default_value = 30; + public const ushort DW_AT_inline = 32; + public const ushort DW_AT_is_optional = 33; + public const ushort DW_AT_lower_bound = 34; + public const ushort DW_AT_producer = 37; + public const ushort DW_AT_prototyped = 39; + public const ushort DW_AT_return_addr = 42; + public const ushort DW_AT_start_scope = 44; + public const ushort DW_AT_bit_stride = 46; + public const ushort DW_AT_upper_bound = 47; + public const ushort DW_AT_abstract_origin = 49; + public const ushort DW_AT_accessibility = 50; + public const ushort DW_AT_address_class = 51; + public const ushort DW_AT_artificial = 52; + public const ushort DW_AT_base_types = 53; + public const ushort DW_AT_calling_convention = 54; + public const ushort DW_AT_count = 55; + public const ushort DW_AT_data_member_location = 56; + public const ushort DW_AT_decl_column = 57; + public const ushort DW_AT_decl_file = 58; + public const ushort DW_AT_decl_line = 59; + public const ushort DW_AT_declaration = 60; + public const ushort DW_AT_discr_list = 61; + public const ushort DW_AT_encoding = 62; + public const ushort DW_AT_external = 63; + public const ushort DW_AT_frame_base = 64; + public const ushort DW_AT_friend = 65; + public const ushort DW_AT_identifier_case = 66; + public const ushort DW_AT_macro_info = 67; + public const ushort DW_AT_namelist_item = 68; + public const ushort DW_AT_priority = 69; + public const ushort DW_AT_segment = 70; + public const ushort DW_AT_specification = 71; + public const ushort DW_AT_static_link = 72; + public const ushort DW_AT_type = 73; + public const ushort DW_AT_use_location = 74; + public const ushort DW_AT_variable_parameter = 75; + public const ushort DW_AT_virtuality = 76; + public const ushort DW_AT_vtable_elem_location = 77; + public const ushort DW_AT_allocated = 78; + public const ushort DW_AT_associated = 79; + public const ushort DW_AT_data_location = 80; + public const ushort DW_AT_byte_stride = 81; + public const ushort DW_AT_entry_pc = 82; + public const ushort DW_AT_use_UTF8 = 83; + public const ushort DW_AT_extension = 84; + public const ushort DW_AT_ranges = 85; + public const ushort DW_AT_trampoline = 86; + public const ushort DW_AT_call_column = 87; + public const ushort DW_AT_call_file = 88; + public const ushort DW_AT_call_line = 89; + public const ushort DW_AT_description = 90; + public const ushort DW_AT_binary_scale = 91; + public const ushort DW_AT_decimal_scale = 92; + public const ushort DW_AT_small = 93; + public const ushort DW_AT_decimal_sign = 94; + public const ushort DW_AT_digit_count = 95; + public const ushort DW_AT_picture_string = 96; + public const ushort DW_AT_mutable = 97; + public const ushort DW_AT_threads_scaled = 98; + public const ushort DW_AT_explicit = 99; + public const ushort DW_AT_object_pointer = 100; + public const ushort DW_AT_endianity = 101; + public const ushort DW_AT_elemental = 102; + public const ushort DW_AT_pure = 103; + public const ushort DW_AT_recursive = 104; + public const ushort DW_AT_signature = 105; + public const ushort DW_AT_main_subprogram = 106; + public const ushort DW_AT_data_bit_offset = 107; + public const ushort DW_AT_const_expr = 108; + public const ushort DW_AT_enum_class = 109; + public const ushort DW_AT_linkage_name = 110; + public const ushort DW_AT_string_length_bit_size = 111; + public const ushort DW_AT_string_length_byte_size = 112; + public const ushort DW_AT_rank = 113; + public const ushort DW_AT_str_offsets_base = 114; + public const ushort DW_AT_addr_base = 115; + public const ushort DW_AT_rnglists_base = 116; + public const ushort DW_AT_dwo_id = 117; + public const ushort DW_AT_dwo_name = 118; + public const ushort DW_AT_reference = 119; + public const ushort DW_AT_rvalue_reference = 120; + public const ushort DW_AT_macros = 121; + public const ushort DW_AT_call_all_calls = 122; + public const ushort DW_AT_call_all_source_calls = 123; + public const ushort DW_AT_call_all_tail_calls = 124; + public const ushort DW_AT_call_return_pc = 125; + public const ushort DW_AT_call_value = 126; + public const ushort DW_AT_call_origin = 127; + public const ushort DW_AT_call_parameter = 128; + public const ushort DW_AT_call_pc = 129; + public const ushort DW_AT_call_tail_call = 130; + public const ushort DW_AT_call_target = 131; + public const ushort DW_AT_call_target_clobbered = 132; + public const ushort DW_AT_call_data_location = 133; + public const ushort DW_AT_call_data_value = 134; + public const ushort DW_AT_noreturn = 135; + public const ushort DW_AT_alignment = 136; + public const ushort DW_AT_export_symbols = 137; + public const ushort DW_AT_deleted = 138; + public const ushort DW_AT_defaulted = 139; + public const ushort DW_AT_loclists_base = 140; + + public const byte DW_OP_addr = 3; + public const byte DW_OP_deref = 6; + public const byte DW_OP_const1u = 8; + public const byte DW_OP_const1s = 9; + public const byte DW_OP_const2u = 10; + public const byte DW_OP_const2s = 11; + public const byte DW_OP_const4u = 12; + public const byte DW_OP_const4s = 13; + public const byte DW_OP_const8u = 14; + public const byte DW_OP_const8s = 15; + public const byte DW_OP_constu = 16; + public const byte DW_OP_consts = 17; + public const byte DW_OP_dup = 18; + public const byte DW_OP_drop = 19; + public const byte DW_OP_over = 20; + public const byte DW_OP_pick = 21; + public const byte DW_OP_swap = 22; + public const byte DW_OP_rot = 23; + public const byte DW_OP_xderef = 24; + public const byte DW_OP_abs = 25; + public const byte DW_OP_and = 26; + public const byte DW_OP_div = 27; + public const byte DW_OP_minus = 28; + public const byte DW_OP_mod = 29; + public const byte DW_OP_mul = 30; + public const byte DW_OP_neg = 31; + public const byte DW_OP_not = 32; + public const byte DW_OP_or = 33; + public const byte DW_OP_plus = 34; + public const byte DW_OP_plus_uconst = 35; + public const byte DW_OP_shl = 36; + public const byte DW_OP_shr = 37; + public const byte DW_OP_shra = 38; + public const byte DW_OP_xor = 39; + public const byte DW_OP_bra = 40; + public const byte DW_OP_eq = 41; + public const byte DW_OP_ge = 42; + public const byte DW_OP_gt = 43; + public const byte DW_OP_le = 44; + public const byte DW_OP_lt = 45; + public const byte DW_OP_ne = 46; + public const byte DW_OP_skip = 47; + public const byte DW_OP_lit0 = 48; + public const byte DW_OP_lit1 = 49; + public const byte DW_OP_lit2 = 50; + public const byte DW_OP_lit3 = 51; + public const byte DW_OP_lit4 = 52; + public const byte DW_OP_lit5 = 53; + public const byte DW_OP_lit6 = 54; + public const byte DW_OP_lit7 = 55; + public const byte DW_OP_lit8 = 56; + public const byte DW_OP_lit9 = 57; + public const byte DW_OP_lit10 = 58; + public const byte DW_OP_lit11 = 59; + public const byte DW_OP_lit12 = 60; + public const byte DW_OP_lit13 = 61; + public const byte DW_OP_lit14 = 62; + public const byte DW_OP_lit15 = 63; + public const byte DW_OP_lit16 = 64; + public const byte DW_OP_lit17 = 65; + public const byte DW_OP_lit18 = 66; + public const byte DW_OP_lit19 = 67; + public const byte DW_OP_lit20 = 68; + public const byte DW_OP_lit21 = 69; + public const byte DW_OP_lit22 = 70; + public const byte DW_OP_lit23 = 71; + public const byte DW_OP_lit24 = 72; + public const byte DW_OP_lit25 = 73; + public const byte DW_OP_lit26 = 74; + public const byte DW_OP_lit27 = 75; + public const byte DW_OP_lit28 = 76; + public const byte DW_OP_lit29 = 77; + public const byte DW_OP_lit30 = 78; + public const byte DW_OP_lit31 = 79; + public const byte DW_OP_reg0 = 80; + public const byte DW_OP_reg1 = 81; + public const byte DW_OP_reg2 = 82; + public const byte DW_OP_reg3 = 83; + public const byte DW_OP_reg4 = 84; + public const byte DW_OP_reg5 = 85; + public const byte DW_OP_reg6 = 86; + public const byte DW_OP_reg7 = 87; + public const byte DW_OP_reg8 = 88; + public const byte DW_OP_reg9 = 89; + public const byte DW_OP_reg10 = 90; + public const byte DW_OP_reg11 = 91; + public const byte DW_OP_reg12 = 92; + public const byte DW_OP_reg13 = 93; + public const byte DW_OP_reg14 = 94; + public const byte DW_OP_reg15 = 95; + public const byte DW_OP_reg16 = 96; + public const byte DW_OP_reg17 = 97; + public const byte DW_OP_reg18 = 98; + public const byte DW_OP_reg19 = 99; + public const byte DW_OP_reg20 = 100; + public const byte DW_OP_reg21 = 101; + public const byte DW_OP_reg22 = 102; + public const byte DW_OP_reg23 = 103; + public const byte DW_OP_reg24 = 104; + public const byte DW_OP_reg25 = 105; + public const byte DW_OP_reg26 = 106; + public const byte DW_OP_reg27 = 107; + public const byte DW_OP_reg28 = 108; + public const byte DW_OP_reg29 = 109; + public const byte DW_OP_reg30 = 110; + public const byte DW_OP_reg31 = 111; + public const byte DW_OP_breg0 = 112; + public const byte DW_OP_breg1 = 113; + public const byte DW_OP_breg2 = 114; + public const byte DW_OP_breg3 = 115; + public const byte DW_OP_breg4 = 116; + public const byte DW_OP_breg5 = 117; + public const byte DW_OP_breg6 = 118; + public const byte DW_OP_breg7 = 119; + public const byte DW_OP_breg8 = 120; + public const byte DW_OP_breg9 = 121; + public const byte DW_OP_breg10 = 122; + public const byte DW_OP_breg11 = 123; + public const byte DW_OP_breg12 = 124; + public const byte DW_OP_breg13 = 125; + public const byte DW_OP_breg14 = 126; + public const byte DW_OP_breg15 = 127; + public const byte DW_OP_breg16 = 128; + public const byte DW_OP_breg17 = 129; + public const byte DW_OP_breg18 = 130; + public const byte DW_OP_breg19 = 131; + public const byte DW_OP_breg20 = 132; + public const byte DW_OP_breg21 = 133; + public const byte DW_OP_breg22 = 134; + public const byte DW_OP_breg23 = 135; + public const byte DW_OP_breg24 = 136; + public const byte DW_OP_breg25 = 137; + public const byte DW_OP_breg26 = 138; + public const byte DW_OP_breg27 = 139; + public const byte DW_OP_breg28 = 140; + public const byte DW_OP_breg29 = 141; + public const byte DW_OP_breg30 = 142; + public const byte DW_OP_breg31 = 143; + public const byte DW_OP_regx = 144; + public const byte DW_OP_fbreg = 145; + public const byte DW_OP_bregx = 146; + public const byte DW_OP_piece = 147; + public const byte DW_OP_deref_size = 148; + public const byte DW_OP_xderef_size = 149; + public const byte DW_OP_nop = 150; + public const byte DW_OP_push_object_address = 151; + public const byte DW_OP_call2 = 152; + public const byte DW_OP_call4 = 153; + public const byte DW_OP_call_ref = 154; + public const byte DW_OP_form_tls_address = 155; + public const byte DW_OP_call_frame_cfa = 156; + public const byte DW_OP_bit_piece = 157; + public const byte DW_OP_implicit_value = 158; + public const byte DW_OP_stack_value = 159; + public const byte DW_OP_implicit_pointer = 160; + public const byte DW_OP_addrx = 161; + public const byte DW_OP_constx = 162; + public const byte DW_OP_entry_value = 163; + public const byte DW_OP_const_type = 164; + public const byte DW_OP_regval_type = 165; + public const byte DW_OP_deref_type = 166; + public const byte DW_OP_xderef_type = 167; + public const byte DW_OP_convert = 168; + public const byte DW_OP_reinterpret = 169; + + public const byte DW_CHILDREN_no = 0; + public const byte DW_CHILDREN_yes = 1; + + public const byte DW_LNS_copy = 1; + public const byte DW_LNS_advance_pc = 2; + public const byte DW_LNS_advance_line = 3; + public const byte DW_LNS_set_file = 4; + public const byte DW_LNS_set_column = 5; + public const byte DW_LNS_negate_stmt = 6; + public const byte DW_LNS_set_basic_block = 7; + public const byte DW_LNS_const_add_pc = 8; + public const byte DW_LNS_fixed_advance_pc = 9; + public const byte DW_LNS_set_prologue_end = 10; + public const byte DW_LNS_set_epilogue_begin = 11; + public const byte DW_LNS_set_isa = 12; + + public const byte DW_LNE_end_sequence = 1; + public const byte DW_LNE_set_address = 2; + public const byte DW_LNE_define_file = 3; + public const byte DW_LNE_set_discriminator = 4; + + public const byte DW_UT_compile = 1; + public const byte DW_UT_type = 2; + public const byte DW_UT_partial = 3; + public const byte DW_UT_skeleton = 4; + public const byte DW_UT_split_compile = 5; + public const byte DW_UT_split_type = 6; + + public const ushort DW_LANG_C89 = 1; + public const ushort DW_LANG_C = 2; + public const ushort DW_LANG_Ada83 = 3; + public const ushort DW_LANG_C_plus_plus = 4; + public const ushort DW_LANG_Cobol74 = 5; + public const ushort DW_LANG_Cobol85 = 6; + public const ushort DW_LANG_Fortran77 = 7; + public const ushort DW_LANG_Fortran90 = 8; + public const ushort DW_LANG_Pascal83 = 9; + public const ushort DW_LANG_Modula2 = 10; + public const ushort DW_LANG_Java = 11; + public const ushort DW_LANG_C99 = 12; + public const ushort DW_LANG_Ada95 = 13; + public const ushort DW_LANG_Fortran95 = 14; + public const ushort DW_LANG_PLI = 15; + public const ushort DW_LANG_ObjC = 16; + public const ushort DW_LANG_ObjC_plus_plus = 17; + public const ushort DW_LANG_UPC = 18; + public const ushort DW_LANG_D = 19; + public const ushort DW_LANG_Python = 20; + public const ushort DW_LANG_OpenCL = 21; + public const ushort DW_LANG_Go = 22; + public const ushort DW_LANG_Modula3 = 23; + public const ushort DW_LANG_Haskel = 24; + public const ushort DW_LANG_C_plus_plus_03 = 25; + public const ushort DW_LANG_C_plus_plus_11 = 26; + public const ushort DW_LANG_OCaml = 27; + public const ushort DW_LANG_Rust = 28; + public const ushort DW_LANG_C11 = 29; + public const ushort DW_LANG_Swift = 30; + public const ushort DW_LANG_Julia = 31; + public const ushort DW_LANG_Dylan = 32; + public const ushort DW_LANG_C_plus_plus_14 = 33; + public const ushort DW_LANG_Fortran03 = 34; + public const ushort DW_LANG_Fortran08 = 35; + public const ushort DW_LANG_RenderScript = 36; + public const ushort DW_LANG_BLISS = 37; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 91857240d4b1dc..83ebb0fcee35dc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -5,43 +5,29 @@ using System.Collections.Generic; using System.IO; using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Linq; -using System.Numerics; -using System.Buffers; using System.Buffers.Binary; - using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; using Internal.TypeSystem; -using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; -using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; - -using Melanzana.MachO; using LibObjectFile; using LibObjectFile.Elf; -using LibObjectFile.Dwarf; -using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter { public sealed class ElfObjectWriter : UnixObjectWriter { - private ElfObjectFile _objectFile; + private readonly ElfObjectFile _objectFile; private int _sectionIndex; - private Dictionary _bssStreams = new(); - private Dictionary _sectionIndexToElfSection = new(); - private Dictionary _elfSectionToSectionIndex = new(); - private Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); - private Dictionary _sectionToRelocationTable = new(); + private readonly Dictionary _bssStreams = new(); + private readonly Dictionary _sectionIndexToElfSection = new(); + private readonly Dictionary _elfSectionToSectionIndex = new(); + private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); + private readonly Dictionary _sectionToRelocationTable = new(); + private readonly List _debugSections = new(); // Symbol table - private Dictionary _symbolNameToIndex = new(); - private ElfSymbolTable _symbolTable; + private readonly Dictionary _symbolNameToIndex = new(); + private readonly ElfSymbolTable _symbolTable; private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) @@ -65,17 +51,17 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS ElfGroupSection groupSection = null; string sectionName = section.Name == "rdata" ? ".rodata" : - (section.Name.StartsWith("_") || section.Name.StartsWith(".") ? section.Name : "." + section.Name); + (section.Name.StartsWith('_') || section.Name.StartsWith('.') ? section.Name : "." + section.Name); if (section.ComdatName != null && !_comdatNameToElfSection.TryGetValue(section.ComdatName, out groupSection)) { groupSection = new ElfGroupSection { + GroupFlags = 1, // GRP_COMDAT Link = _symbolTable, // Info = of the COMDAT symbol, to be filled later }; - groupSection.GroupFlags = 1; // GRP_COMDAT _comdatNameToElfSection.Add(section.ComdatName, groupSection); } @@ -106,13 +92,22 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS Name = sectionName, Type = section.Name == ".eh_frame" && _objectFile.Arch == ElfArch.X86_64 ? (ElfSectionType)ElfNative.SHT_IA_64_UNWIND : ElfSectionType.ProgBits, - Flags = - section.Type == SectionType.Executable ? ElfSectionFlags.Alloc | ElfSectionFlags.Executable : - (section.Type == SectionType.Writeable ? ElfSectionFlags.Alloc | ElfSectionFlags.Write : - ElfSectionFlags.Alloc) + Flags = section.Type switch + { + SectionType.Executable => ElfSectionFlags.Alloc | ElfSectionFlags.Executable, + SectionType.Writeable => ElfSectionFlags.Alloc | ElfSectionFlags.Write, + SectionType.Debug => sectionName == ".debug_str" ? ElfSectionFlags.Merge | ElfSectionFlags.Strings : 0, + _ => ElfSectionFlags.Alloc, + }, + Alignment = 1 }; } + if (section.Type == SectionType.Debug) + { + _debugSections.Add(elfSection); + } + _elfSectionToSectionIndex[elfSection] = _sectionIndex; _sectionIndexToElfSection[_sectionIndex++] = elfSection; groupSection?.AddSection(elfSection); @@ -120,7 +115,7 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - var elfSection = _sectionIndexToElfSection[sectionIndex]; + ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); } @@ -139,14 +134,15 @@ protected internal override void EmitRelocation( if (relocType == RelocType.IMAGE_REL_BASED_REL32 || relocType == RelocType.IMAGE_REL_BASED_RELPTR32 || relocType == RelocType.IMAGE_REL_TLSGD || - relocType == RelocType.IMAGE_REL_TPOFF) + relocType == RelocType.IMAGE_REL_TPOFF || + relocType == RelocType.IMAGE_REL_BASED_HIGHLOW) { addend += BinaryPrimitives.ReadInt32LittleEndian(data); BinaryPrimitives.WriteInt32LittleEndian(data, 0); } else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) { - var a = BinaryPrimitives.ReadUInt64LittleEndian(data); + ulong a = BinaryPrimitives.ReadUInt64LittleEndian(data); addend += checked((int)a); BinaryPrimitives.WriteUInt64LittleEndian(data, 0); } @@ -175,11 +171,11 @@ protected override void EmitSymbolTable() { uint symbolIndex = (uint)_symbolTable.Entries.Count; - var definedSymbols = GetDefinedSymbols(); - var sortedSymbols = new List(definedSymbols.Count); - foreach (var (name, definition) in definedSymbols) + IDictionary definedSymbols = GetDefinedSymbols(); + List sortedSymbols = new(definedSymbols.Count); + foreach ((string name, SymbolDefinition definition) in definedSymbols) { - var elfSection = _sectionIndexToElfSection[definition.SectionIndex]; + ElfSection elfSection = _sectionIndexToElfSection[definition.SectionIndex]; sortedSymbols.Add(new ElfSymbol { Name = name, @@ -194,17 +190,20 @@ protected override void EmitSymbolTable() }); } - foreach (var externSymbol in GetUndefinedSymbols()) + foreach (string externSymbol in GetUndefinedSymbols()) { - sortedSymbols.Add(new ElfSymbol + if (!_symbolNameToIndex.ContainsKey(externSymbol)) { - Name = externSymbol, - Bind = ElfSymbolBind.Global, - }); + sortedSymbols.Add(new ElfSymbol + { + Name = externSymbol, + Bind = ElfSymbolBind.Global, + }); + } } sortedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); - foreach (var definedSymbol in sortedSymbols) + foreach (ElfSymbol definedSymbol in sortedSymbols) { _symbolTable.Entries.Add(definedSymbol); _symbolNameToIndex[definedSymbol.Name] = symbolIndex; @@ -212,7 +211,7 @@ protected override void EmitSymbolTable() } // Update group sections links - foreach (var (comdatName, groupSection) in _comdatNameToElfSection) + foreach ((string comdatName, ElfGroupSection groupSection) in _comdatNameToElfSection) { groupSection.Info = new ElfSectionLink(_symbolNameToIndex[comdatName]); } @@ -236,14 +235,15 @@ protected override void EmitRelocations(int sectionIndex, List relocationList) { - var elfSection = _sectionIndexToElfSection[sectionIndex]; - if (_sectionToRelocationTable.TryGetValue(elfSection, out var relocationTable)) + ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; + if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) { - foreach (var symbolicRelocation in relocationList) + foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - ElfRelocationType type = symbolicRelocation.Type switch { + ElfRelocationType type = symbolicRelocation.Type switch + { RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_AARCH64_ABS64, RelocType.IMAGE_REL_BASED_HIGHLOW => ElfRelocationType.R_AARCH64_ABS32, RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_AARCH64_PREL32, @@ -259,7 +259,7 @@ private void EmitRelocationsARM64(int sectionIndex, List rel _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - var addend = symbolicRelocation.Addend; + int addend = symbolicRelocation.Addend; relocationTable.Entries.Add(new ElfRelocation { @@ -278,14 +278,16 @@ private void EmitRelocationsARM64(int sectionIndex, List rel private void EmitRelocationsX64(int sectionIndex, List relocationList) { - var elfSection = _sectionIndexToElfSection[sectionIndex]; - if (_sectionToRelocationTable.TryGetValue(elfSection, out var relocationTable)) + ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; + if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) { - foreach (var symbolicRelocation in relocationList) + foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - ElfRelocationType type = symbolicRelocation.Type switch { + ElfRelocationType type = symbolicRelocation.Type switch + { + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfRelocationType.R_X86_64_32, RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_X86_64_64, RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_X86_64_PC32, RelocType.IMAGE_REL_BASED_REL32 => ElfRelocationType.R_X86_64_PLT32, @@ -294,7 +296,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - var addend = symbolicRelocation.Addend; + int addend = symbolicRelocation.Addend; if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) { addend -= 4; @@ -315,189 +317,29 @@ private void EmitRelocationsX64(int sectionIndex, List reloc } } - protected override ulong GetSectionVirtualAddress(int sectionIndex) + protected override string GetSectionSymbolName(int sectionIndex) { - // Use file offset - return _sectionIndexToElfSection[sectionIndex].Offset; + // FIXME: We really want symbol name for relocations and it has to be unique for COMDAT + return _sectionIndexToElfSection[sectionIndex].Name.Value; } - protected override void EmitDebugSections(DwarfFile dwarfFile) + protected override void EmitDebugSections() { - ElfRelocationType reloc32, reloc64; + base.EmitDebugSections(); - switch ((ElfArch)_objectFile.Arch) + foreach (ElfSection debugSection in _debugSections) { - case ElfArch.X86_64: - reloc32 = ElfRelocationType.R_X86_64_32; - reloc64 = ElfRelocationType.R_X86_64_64; - break; - case ElfArch.AARCH64: - reloc32 = ElfRelocationType.R_AARCH64_ABS32; - reloc64 = ElfRelocationType.R_AARCH64_ABS64; - break; - default: - throw new NotSupportedException("Unsupported architecture"); + AddElfSectionWithRelocationsIfNecessary(debugSection); } - Dictionary sectionToSymbolIndex = new(); - ulong debugRangesSize = 0; - var debugRangesStream = new MemoryStream(); - var debugRangesSection = new ElfBinarySection(debugRangesStream) { Name = ".debug_ranges", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugRangesRelocation = new ElfRelocationTable { Name = ".rela.debug_ranges", Link = _symbolTable, Info = debugRangesSection, Alignment = 8 }; - - var unit = dwarfFile.InfoSection.Units[0]; - var rootDIE = (DwarfDIECompileUnit)unit.Root; - - dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; - dwarfFile.AddressRangeTable.Unit = unit; - - // Point DW_AT_RANGES to beginning of our .debug_ranges section - rootDIE.Ranges = 0; - - foreach (var elfSection in _objectFile.Sections) + uint symbolIndex = (uint)_symbolTable.Entries.Count; + foreach (ElfSection elfSection in _objectFile.Sections) { - // NOTE: We could exclude some extra sections, like .dotnet_eh_table, .eh_frame, - // __modules and .note.GNU-stack but it doesn't really matter if we include them. - if (elfSection is ElfBinarySection && - elfSection.Size > 0 && - /*!elfSection.Name.Value.Equals(".dotnet_eh_table", StringComparison.Ordinal) &&*/ - !elfSection.Name.Value.Equals(".eh_frame", StringComparison.Ordinal)) + if (elfSection is ElfBinarySection) { - dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, elfSection.Offset, elfSection.Size)); - rootDIE.LowPC ??= elfSection.Offset; - //rootDIE.HighPC = (int)elfSection.Size; - - // Create a symbol for the section so we can make relocations relative to it. - uint sectionSymbolIndex; - sectionToSymbolIndex[elfSection] = sectionSymbolIndex = (uint)_symbolTable.Entries.Count; _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); - - // Emit entry in .debug_ranges - debugRangesRelocation.Entries.Add(new ElfRelocation(debugRangesSize, reloc64, sectionSymbolIndex, 0)); - debugRangesRelocation.Entries.Add(new ElfRelocation(debugRangesSize + 8, reloc64, sectionSymbolIndex, (long)elfSection.Size)); - debugRangesSize += 16; - } - } - - debugRangesSize += 16; // NULL entry - debugRangesStream.SetLength((long)debugRangesSize); - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = _objectFile.Encoding == ElfEncoding.Lsb, - EnableRelocation = true, - AddressSize = _objectFile.FileClass == ElfFileClass.Is64 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32, - DebugLineStream = new MemoryStream(), - DebugAbbrevStream = new MemoryStream(), - DebugStringStream = new MemoryStream(), - DebugAddressRangeStream = new MemoryStream(), - DebugInfoStream = new MemoryStream(), - DebugLocationStream = new MemoryStream(), - }; - - dwarfFile.Write(outputContext); - - var debugInfoSection = new ElfBinarySection(outputContext.DebugInfoStream) { Name = ".debug_info", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugInfoRelocation = new ElfRelocationTable { Name = ".rela.debug_info", Link = _symbolTable, Info = debugInfoSection, Alignment = 8 }; - var debugAbbrevSection = new ElfBinarySection(outputContext.DebugAbbrevStream) { Name = ".debug_abbrev", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugAddressRangeSection = new ElfBinarySection(outputContext.DebugAddressRangeStream) { Name = ".debug_aranges", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugAddressRangeRelocation = new ElfRelocationTable { Name = ".rela.debug_aranges", Link = _symbolTable, Info = debugAddressRangeSection, Alignment = 8 }; - var debugStringSection = new ElfBinarySection(outputContext.DebugStringStream) { Name = ".debug_str", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugLineSection = new ElfBinarySection(outputContext.DebugLineStream) { Name = ".debug_line", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugLineRelocation = new ElfRelocationTable { Name = ".rela.debug_line", Link = _symbolTable, Info = debugLineSection, Alignment = 8 }; - var debugLocationSection = new ElfBinarySection(outputContext.DebugLocationStream) { Name = ".debug_loc", Type = ElfSectionType.ProgBits, Alignment = 8 }; - var debugLocationRelocation = new ElfRelocationTable { Name = ".rela.debug_loc", Link = _symbolTable, Info = debugLocationSection, Alignment = 8 }; - - _objectFile.AddSection(debugInfoSection); - _objectFile.AddSection(debugInfoRelocation); - _objectFile.AddSection(debugAbbrevSection); - _objectFile.AddSection(debugAddressRangeSection); - _objectFile.AddSection(debugAddressRangeRelocation); - _objectFile.AddSection(debugStringSection); - _objectFile.AddSection(debugLineSection); - _objectFile.AddSection(debugLineRelocation); - _objectFile.AddSection(debugLocationSection); - _objectFile.AddSection(debugLocationRelocation); - _objectFile.AddSection(debugRangesSection); - _objectFile.AddSection(debugRangesRelocation); - - uint stringSectionIndex = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugStringSection }); - uint abbrevSectionIndex = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugAbbrevSection }); - uint infoSectionIndex = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugInfoSection }); - uint rangesSectionIndex = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = debugRangesSection }); - - CopyRelocations(dwarfFile.InfoSection, debugInfoRelocation); - CopyRelocations(dwarfFile.AddressRangeTable, debugAddressRangeRelocation); - CopyRelocations(dwarfFile.LineSection, debugLineRelocation); - CopyRelocations(dwarfFile.LocationSection, debugLocationRelocation); - - // Add relocation for DW_AT_RANGES - var rangesAttribute = rootDIE.FindAttributeByKey(DwarfAttributeKind.Ranges); - debugInfoRelocation.Entries.Add(new ElfRelocation(rangesAttribute.Offset, reloc64, rangesSectionIndex, 0)); - - void CopyRelocations(DwarfRelocatableSection dwarfRelocSection, ElfRelocationTable relocTable) - { - List codeRelocations = null; - - relocTable.Entries.Clear(); - - foreach (var reloc in dwarfRelocSection.Relocations) - { - if (reloc.Target != DwarfRelocationTarget.Code) - { - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; - - switch (reloc.Target) - { - case DwarfRelocationTarget.DebugString: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, stringSectionIndex, (long)reloc.Addend)); - break; - case DwarfRelocationTarget.DebugAbbrev: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, abbrevSectionIndex, (long)reloc.Addend)); - break; - case DwarfRelocationTarget.DebugInfo: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, infoSectionIndex, (long)reloc.Addend)); - break; - default: - Debug.Fail("Unknown relocation"); - break; - } - } - else - { - codeRelocations ??= new(); - codeRelocations.Add(reloc); - } - } - - if (codeRelocations is not null) - { - int sectionIndex = 0; - ElfSection currentSection = _objectFile.Sections[0]; - uint symbolIndex = 0; - - // Sort the code relocations by their offset, and then walk the sections - // and relocations at the same time to point them to matching section. - codeRelocations.Sort((a, b) => (int)a.Addend - (int)b.Addend); - - foreach (var reloc in codeRelocations) - { - if (reloc.Addend >= currentSection.Offset + currentSection.Size) - { - while (reloc.Addend >= currentSection.Offset + currentSection.Size) - { - currentSection = _objectFile.Sections[++sectionIndex]; - } - symbolIndex = sectionToSymbolIndex[currentSection]; - } - - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? reloc64 : reloc32; - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, symbolIndex, (long)(reloc.Addend - currentSection.Offset))); - } + _symbolNameToIndex[elfSection.Name] = symbolIndex; + symbolIndex++; } } } @@ -527,7 +369,7 @@ private void AddElfSectionWithRelocationsIfNecessary(ElfSection elfSection, ElfG protected override void EmitSectionsAndLayout() { - foreach (var groupSection in _comdatNameToElfSection.Values) + foreach (ElfGroupSection groupSection in _comdatNameToElfSection.Values) { _objectFile.AddSection(groupSection); for (int i = 0, sectionCount = groupSection.Sections.Count; i < sectionCount; i++) @@ -536,7 +378,7 @@ protected override void EmitSectionsAndLayout() } } - foreach (var elfSection in _sectionIndexToElfSection.Values) + foreach (ElfSection elfSection in _sectionIndexToElfSection.Values) { // If the section was not already added as part of COMDAT group, // add it now. @@ -549,7 +391,7 @@ protected override void EmitSectionsAndLayout() _objectFile.AddSection(_symbolTable.Link.Section); _objectFile.AddSection(_symbolTable); _objectFile.AddSection(new ElfSectionHeaderStringTable()); - foreach (var (bssSectionIndex, bssStream) in _bssStreams) + foreach ((int bssSectionIndex, Stream bssStream) in _bssStreams) { _sectionIndexToElfSection[bssSectionIndex].Size = (ulong)bssStream.Length; } @@ -559,13 +401,6 @@ protected override void EmitSectionsAndLayout() Name = ".note.GNU-stack", Type = ElfSectionType.ProgBits, }); - - // NOTE: We need the layout to find the offset and size of the __managedcode section - // but also to report correct method addresses in the debug information. Beyond this - // point, GetSectionVirtualAddress must return correct address for any code section. - var elfDiagnostics = new DiagnosticBag(); - _objectFile.UpdateLayout(elfDiagnostics); - Debug.Assert(!elfDiagnostics.HasErrors); } protected override void EmitObjectFile(string objectFilePath) @@ -584,7 +419,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection _sections = new(4); + private readonly List _sections = new(4); public ElfGroupSection() { @@ -608,9 +443,9 @@ public override void Verify(DiagnosticBag diagnostics) { base.Verify(diagnostics); - foreach (var section in _sections) + foreach (ElfSection section in _sections) { - if (section.Parent != this.Parent) + if (section.Parent != Parent) { diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionInfoParent, $"Invalid parent for grouped section"); } @@ -621,10 +456,11 @@ public override void Verify(DiagnosticBag diagnostics) protected override void Write(ElfWriter writer) { - writer.Write((uint)GroupFlags); - foreach (var section in _sections) + writer.Write(GroupFlags); + + foreach (ElfSection section in _sections) { - writer.Write((uint)section.SectionIndex); + writer.Write(section.SectionIndex); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index c0132b0a40b94e..73764beeb5d9ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -5,24 +5,13 @@ using System.Collections.Generic; using System.IO; using System.Diagnostics; -using System.Runtime.InteropServices; using System.Linq; using System.Numerics; -using System.Buffers; using System.Buffers.Binary; - using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; using Internal.TypeSystem; -using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; -using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; - using Melanzana.MachO; -using LibObjectFile.Dwarf; -using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter { @@ -30,28 +19,30 @@ public sealed class MachObjectWriter : UnixObjectWriter { private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); - private TargetOS _targetOS; - private MachObjectFile _objectFile; - private MachSegment _segment; + private readonly TargetOS _targetOS; + private readonly MachObjectFile _objectFile; + private readonly MachSegment _segment; // Exception handling sections private MachSection _compactUnwindSection; - private List _compactUnwindCodes = new(); - private uint _compactUnwindDwarfCode; + private readonly List _compactUnwindCodes = new(); + private readonly uint _compactUnwindDwarfCode; // Symbol table - private Dictionary _sectionIndexToSymbolIndex = new(); - private Dictionary _symbolNameToIndex = new(); + private readonly Dictionary _sectionIndexToSymbolIndex = new(); + private readonly Dictionary _symbolNameToIndex = new(); private MachSymbolTable _symbolTable; private MachDynamicLinkEditSymbolTable _dySymbolTable; private MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { - _objectFile = new MachObjectFile(); - _objectFile.FileType = MachFileType.Object; - _objectFile.IsLittleEndian = true; - _objectFile.Flags = MachHeaderFlags.SubsectionsViaSymbols; + _objectFile = new MachObjectFile + { + FileType = MachFileType.Object, + IsLittleEndian = true, + Flags = MachHeaderFlags.SubsectionsViaSymbols + }; switch (factory.Target.Architecture) { @@ -133,7 +124,7 @@ protected override void EmitSectionsAndLayout() TargetOS.iOSSimulator => MachPlatform.IOSSimulator, TargetOS.tvOS => MachPlatform.TvOS, TargetOS.tvOSSimulator => MachPlatform.TvOSSimulator, - _ => (MachPlatform)0, + _ => 0, }, MinimumPlatformVersion = new Version(11, 0, 0), SdkVersion = sdkVersion, @@ -164,7 +155,12 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS { "rdata" => "__TEXT", ".eh_frame" => "__TEXT", - _ => section.Type == SectionType.Executable ? "__TEXT" : "__DATA" + _ => section.Type switch + { + SectionType.Executable => "__TEXT", + SectionType.Debug => "__DWARF", + _ => "__DATA" + } }; string sectionName = section.Name switch @@ -174,6 +170,12 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS "rdata" => "__const", "bss" => "__bss", ".eh_frame" => "__eh_frame", + ".debug_info" => "__debug_info", + ".debug_abbrev" => "__debug_abbrev", + ".debug_aranges" => "__debug_aranges", + ".debug_str" => "__debug_str", + ".debug_line" => "__debug_line", + ".debug_loc" => "__debug_loc", _ => section.Name }; @@ -181,8 +183,12 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS { ".dotnet_eh_table" => MachSectionAttributes.Debug, ".eh_frame" => MachSectionAttributes.LiveSupport | MachSectionAttributes.StripStaticSymbols | MachSectionAttributes.NoTableOfContents, - _ => section.Type == SectionType.Executable ? - MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions : 0 + _ => section.Type switch + { + SectionType.Executable => MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, + SectionType.Debug => MachSectionAttributes.Debug, + _ => 0 + } }; MachSectionType type = section.Name switch @@ -204,7 +210,7 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - var machSection = _segment.Sections[sectionIndex]; + MachSection machSection = _segment.Sections[sectionIndex]; Debug.Assert(BitOperations.IsPow2(alignment)); machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); } @@ -217,6 +223,29 @@ protected internal override void EmitRelocation( string symbolName, int addend) { + if (symbolName.StartsWith('.')) // Code symbols are prefixed with `_`, so `.` implies section relocation + { + // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly + MachSection machSection = _segment.Sections[sectionIndex]; + if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug)) + { + switch (relocType) + { + case RelocType.IMAGE_REL_BASED_DIR64: + BinaryPrimitives.WriteInt64LittleEndian(data, addend); + break; + + case RelocType.IMAGE_REL_BASED_HIGHLOW: + BinaryPrimitives.WriteInt32LittleEndian(data, addend); + break; + + default: + throw new NotSupportedException("Unsupported relocation in debug section"); + } + return; + } + } + // For most relocations we write the addend directly into the // data. The exceptions are IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 // and IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A. @@ -293,7 +322,7 @@ protected override void EmitSymbolTable() // Create section base symbols. They're used for PC relative relocations // to subtract the base of the section. int sectionIndex = 0; - foreach (var machSection in _segment.Sections) + foreach (MachSection machSection in _segment.Sections) { var machSymbol = new MachSymbol { @@ -313,11 +342,11 @@ protected override void EmitSymbolTable() _dySymbolTable.LocalSymbolsCount = symbolIndex; // Sort and insert all defined symbols - var definedSymbols = GetDefinedSymbols(); + IDictionary definedSymbols = GetDefinedSymbols(); var sortedDefinedSymbols = new List(definedSymbols.Count); - foreach (var (name, definition) in definedSymbols) + foreach ((string name, SymbolDefinition definition) in definedSymbols) { - var section = _segment.Sections[definition.SectionIndex]; + MachSection section = _segment.Sections[definition.SectionIndex]; sortedDefinedSymbols.Add(new MachSymbol { Name = name, @@ -328,7 +357,7 @@ protected override void EmitSymbolTable() }); } sortedDefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); - foreach (var definedSymbol in sortedDefinedSymbols) + foreach (MachSymbol definedSymbol in sortedDefinedSymbols) { _symbolTable.Symbols.Add(definedSymbol); _symbolNameToIndex[definedSymbol.Name] = symbolIndex; @@ -339,7 +368,7 @@ protected override void EmitSymbolTable() _dySymbolTable.ExternalSymbolsCount = (uint)definedSymbols.Count; uint savedSymbolIndex = symbolIndex; - foreach (var externSymbol in GetUndefinedSymbols()) + foreach (string externSymbol in GetUndefinedSymbols()) { var machSymbol = new MachSymbol { @@ -375,7 +404,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; relocationList.Reverse(); - foreach (var symbolicRelocation in relocationList) + foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; @@ -415,8 +444,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc IsPCRelative = false, }); } - else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32 || - symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + else if (symbolicRelocation.Type is RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_REL32) { sectionRelocations.Add( new MachRelocation @@ -441,7 +469,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; relocationList.Reverse(); - foreach (var symbolicRelocation in relocationList) + foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; @@ -458,8 +486,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel IsPCRelative = true, }); } - else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || - symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + else if (symbolicRelocation.Type is RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 or RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) { if (symbolicRelocation.Addend != 0) { @@ -539,8 +566,8 @@ private void EmitRelocationsArm64(int sectionIndex, List rel private void EmitCompactUnwindTable() { - using var compactUnwindStream = _compactUnwindSection.GetWriteStream(); - var definedSymbols = GetDefinedSymbols(); + using Stream compactUnwindStream = _compactUnwindSection.GetWriteStream(); + IDictionary definedSymbols = GetDefinedSymbols(); IList symbols = _symbolTable.Symbols; Span tempBuffer = stackalloc byte[8]; @@ -624,13 +651,14 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt return encoding != _compactUnwindDwarfCode; } - protected override ulong GetSectionVirtualAddress(int sectionIndex) + protected override string GetSectionSymbolName(int sectionIndex) { - var machSection = _segment.Sections[sectionIndex]; - return machSection.VirtualAddress; + MachSection machSection = _segment.Sections[sectionIndex]; + return machSection.SectionName; } - protected override void EmitDebugSections(DwarfFile dwarfFile) + + /*protected override void EmitDebugSections(DwarfFile dwarfFile) { ulong highPC = 0; foreach (var machSection in _segment.Sections) @@ -681,7 +709,7 @@ protected override void EmitDebugSections(DwarfFile dwarfFile) _segment.Sections.Add(debugLocationSection); _objectFile.UpdateLayout(); - } + }*/ public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 8087df32a4073b..b8783aec41a72c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -4,20 +4,11 @@ using System; using System.Collections.Generic; using System.IO; -using System.Diagnostics; -using System.Runtime.InteropServices; using System.Linq; -using System.Numerics; -using System.Buffers; -using System.Buffers.Binary; - using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; namespace ILCompiler.ObjectWriter @@ -27,21 +18,21 @@ public abstract class ObjectWriter : IDisposable protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); - protected NodeFactory _nodeFactory; - protected ObjectWritingOptions _options; - protected bool _isSingleFileCompilation; + protected readonly NodeFactory _nodeFactory; + protected readonly ObjectWritingOptions _options; + protected readonly bool _isSingleFileCompilation; - private Dictionary _mangledNameMap = new(); + private readonly Dictionary _mangledNameMap = new(); - private byte _insPaddingByte; + private readonly byte _insPaddingByte; // Standard sections - private Dictionary _sectionNameToSectionIndex = new(StringComparer.Ordinal); - private List _sectionIndexToStream = new(); - private List> _sectionIndexToRelocations = new(); + private readonly Dictionary _sectionNameToSectionIndex = new(StringComparer.Ordinal); + protected readonly List _sectionIndexToStream = new(); + private readonly List> _sectionIndexToRelocations = new(); // Symbol table - private Dictionary _definedSymbols = new(StringComparer.Ordinal); + private readonly Dictionary _definedSymbols = new(StringComparer.Ordinal); // Debugging private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; @@ -64,7 +55,7 @@ protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) public void Dispose() { // Close all the streams - foreach (var sectionStream in _sectionIndexToStream) + foreach (ObjectWriterStream sectionStream in _sectionIndexToStream) { sectionStream.Close(); } @@ -124,10 +115,10 @@ protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) if (_isSingleFileCompilation) return false; - if (!(node is ISymbolNode)) + if (node is not ISymbolNode) return false; - // These intentionally clash with one another, but are merged with linker directives so should not be Comdat folded + // These intentionally clash with one another, but are merged with linker directives so should not be COMDAT folded if (node is ModulesSectionNode) return false; @@ -272,7 +263,7 @@ protected ISet GetUndefinedSymbols() protected abstract ITypesDebugInfoWriter CreateDebugInfoBuilder(); - protected virtual ulong GetSectionVirtualAddress(int sectionIndex) => 0; + protected virtual string GetSectionSymbolName(int sectionIndex) => null; protected abstract void EmitDebugFunctionInfo( uint methodTypeIndex, @@ -283,8 +274,6 @@ protected abstract void EmitDebugFunctionInfo( protected abstract void EmitDebugSections(); - protected abstract void EmitDebugStaticVars(); - protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) { // Pre-create some of the sections @@ -354,7 +343,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection relocationList in _sectionIndexToRelocations) { EmitRelocations(relocSectionIndex, relocationList); relocSectionIndex++; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index b845b6d5cd2b7a..42396ccf0e1f18 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -3,8 +3,11 @@ using System; using System.Buffers; +using System.Buffers.Binary; using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.Text; namespace ILCompiler.ObjectWriter { @@ -17,13 +20,13 @@ namespace ILCompiler.ObjectWriter /// public sealed class ObjectWriterStream : Stream { - private ArrayBufferWriter _appendBuffer = new(); - private List> _buffers = new(); + private readonly ArrayBufferWriter _appendBuffer = new(); + private readonly List> _buffers = new(); private long _length; private int _bufferIndex; private int _bufferPosition; private long _position; - private byte[] _padding = new byte[16]; + private readonly byte[] _padding = new byte[16]; public override bool CanRead => true; @@ -35,7 +38,7 @@ public sealed class ObjectWriterStream : Stream public override long Position { - get => _position; + get => _position + _appendBuffer.WrittenCount; set { // Flush any non-appended data @@ -62,7 +65,7 @@ public override long Position } } - public ObjectWriterStream(byte paddingByte) + public ObjectWriterStream(byte paddingByte = 0) { _padding.AsSpan().Fill(paddingByte); } @@ -81,9 +84,11 @@ public override int Read(Span buffer) { int bytesRead = 0; - while (_bufferIndex < _buffers.Count) + // _bufferIndex and _bufferPosition is only valid after seeking when + // _position < _length + while (_position < _length && _bufferIndex < _buffers.Count) { - var currentBuffer = _buffers[_bufferIndex].Span.Slice(_bufferPosition); + ReadOnlySpan currentBuffer = _buffers[_bufferIndex].Span.Slice(_bufferPosition); if (currentBuffer.Length >= buffer.Length) { @@ -110,11 +115,11 @@ public override long Seek(long offset, SeekOrigin origin) Position = origin switch { SeekOrigin.End => Length + offset, - SeekOrigin.Current => _position + offset, + SeekOrigin.Current => Position + offset, SeekOrigin.Begin => offset, _ => throw new ArgumentOutOfRangeException(nameof(origin)) }; - return _position; + return Position; } public override void SetLength(long value) @@ -129,32 +134,18 @@ public override void Write(byte[] buffer, int offset, int count) public override void Write(ReadOnlySpan buffer) { - // We only support appending to the end of the stream - if (_position != Length) - { - throw new NotSupportedException("ObjectWriterStream only supports appending to the end"); - } - + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); buffer.CopyTo(_appendBuffer.GetSpan(buffer.Length)); _appendBuffer.Advance(buffer.Length); - _position += buffer.Length; - _bufferPosition += buffer.Length; } public void AppendData(ReadOnlyMemory data) { - // We only support appending to the end of the stream - if (_position != Length) - { - throw new NotSupportedException("ObjectWriterStream only supports appending to the end"); - } - + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); FlushAppendBuffer(); _buffers.Add(data); _length += data.Length; _position += data.Length; - _bufferIndex++; - _bufferPosition = 0; } public void AppendPadding(int paddingLength) @@ -165,8 +156,6 @@ public void AppendPadding(int paddingLength) { _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Fill(_padding[0]); _appendBuffer.Advance(paddingLength); - _position += paddingLength; - _bufferPosition += paddingLength; } else { @@ -175,14 +164,66 @@ public void AppendPadding(int paddingLength) } } + public void WriteULEB128(ulong value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + DwarfHelper.WriteULEB128(_appendBuffer, value); + } + + public void WriteSLEB128(long value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + DwarfHelper.WriteSLEB128(_appendBuffer, value); + } + + public void WriteUInt8(byte value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + Span buffer = _appendBuffer.GetSpan(1); + buffer[0] = value; + _appendBuffer.Advance(1); + } + + public void WriteUInt16(ushort value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + Span buffer = _appendBuffer.GetSpan(sizeof(ushort)); + BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); + _appendBuffer.Advance(sizeof(ushort)); + } + + public void WriteUInt32(uint value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + Span buffer = _appendBuffer.GetSpan(sizeof(uint)); + BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); + _appendBuffer.Advance(sizeof(uint)); + } + + public void WriteUInt64(ulong value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + Span buffer = _appendBuffer.GetSpan(sizeof(ulong)); + BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); + _appendBuffer.Advance(sizeof(ulong)); + } + + public void WriteUtf8String(string value) + { + Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); + int size = Encoding.UTF8.GetByteCount(value) + 1; + Span buffer = _appendBuffer.GetSpan(size); + Encoding.UTF8.GetBytes(value, buffer); + buffer[size - 1] = 0; + _appendBuffer.Advance(size); + } + private void FlushAppendBuffer() { if (_appendBuffer.WrittenCount > 0) { _buffers.Add(_appendBuffer.WrittenSpan.ToArray()); _length += _appendBuffer.WrittenCount; - _bufferIndex++; - _bufferPosition = 0; _appendBuffer.Clear(); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index 033128b62dcd36..8fa49a462ec3d0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -2,29 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.IO; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Linq; -using System.Numerics; -using System.Buffers; -using System.Buffers.Binary; - using ILCompiler.DependencyAnalysis; -using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; -using Internal.TypeSystem; -using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; -using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; namespace ILCompiler.ObjectWriter { public struct SectionWriter { - private ObjectWriter _objectWriter; + private readonly ObjectWriter _objectWriter; public int SectionIndex { get; init; } public ObjectWriterStream Stream { get; init; } @@ -39,12 +23,12 @@ internal SectionWriter( Stream = stream; } - public void EmitData(ReadOnlyMemory data) + public readonly void EmitData(ReadOnlyMemory data) { Stream.AppendData(data); } - public void EmitAlignment(int alignment) + public readonly void EmitAlignment(int alignment) { _objectWriter.UpdateSectionAlignment(SectionIndex, alignment); @@ -52,7 +36,7 @@ public void EmitAlignment(int alignment) Stream.AppendPadding(padding); } - public void EmitRelocation( + public readonly void EmitRelocation( int relativeOffset, Span data, RelocType relocType, @@ -68,7 +52,7 @@ public void EmitRelocation( addend); } - public void EmitSymbolDefinition( + public readonly void EmitSymbolDefinition( string symbolName, int relativeOffset = 0, int size = 0, @@ -82,7 +66,7 @@ public void EmitSymbolDefinition( global); } - public void EmitSymbolReference( + public readonly void EmitSymbolReference( RelocType relocType, string symbolName, int addend = 0) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 109af2a5bcc065..551850c8f5fb96 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -2,27 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Generic; -using System.IO; -using System.Diagnostics; -using System.Runtime.InteropServices; using System.Linq; -using System.Numerics; -using System.Buffers; using System.Buffers.Binary; - using ILCompiler.DependencyAnalysis; -using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; -using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; - -using LibObjectFile; -using LibObjectFile.Dwarf; -using static ILCompiler.ObjectWriter.DwarfNative; namespace ILCompiler.ObjectWriter { @@ -152,7 +136,6 @@ protected override void EmitDebugFunctionInfo( INodeWithDebugInfo debugNode, bool hasSequencePoints) { - var lowPC = GetSectionVirtualAddress(methodSymbol.SectionIndex) + (ulong)methodSymbol.Value; DebugEHClauseInfo[] clauses = null; if (debugNode is INodeWithCodeInfo nodeWithCodeInfo) @@ -162,23 +145,54 @@ protected override void EmitDebugFunctionInfo( _dwarfBuilder.EmitSubprogramInfo( methodName, - lowPC, methodSymbol.Size, methodTypeIndex, debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), - clauses ?? Array.Empty()); + clauses ?? []); if (hasSequencePoints) { - _dwarfBuilder.EmitLineInfo(methodSymbol.SectionIndex, lowPC, debugNode.GetNativeSequencePoints()); + _dwarfBuilder.EmitLineInfo( + methodSymbol.SectionIndex, + GetSectionSymbolName(methodSymbol.SectionIndex), + (ulong)methodSymbol.Value, + debugNode.GetNativeSequencePoints()); } } - protected abstract void EmitDebugSections(DwarfFile dwarfFile); + //protected abstract void EmitDebugSections(DwarfFile dwarfFile); + + private readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); + private readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); + private readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); + private readonly ObjectNodeSection DebugLocSection = new ObjectNodeSection(".debug_loc", SectionType.Debug); + private readonly ObjectNodeSection DebugRangesSection = new ObjectNodeSection(".debug_ranges", SectionType.Debug); + private readonly ObjectNodeSection DebugLineSection = new ObjectNodeSection(".debug_line", SectionType.Debug); + private readonly ObjectNodeSection DebugARangesSection = new ObjectNodeSection(".debug_aranges", SectionType.Debug); protected override void EmitDebugSections() { - EmitDebugSections(_dwarfBuilder.DwarfFile); + for (int i = 0; i < _sectionIndexToStream.Count; i++) + { + _dwarfBuilder.EmitSectionInfo(GetSectionSymbolName(i), (ulong)_sectionIndexToStream[i].Length); + } + + SectionWriter infoSectionWriter = GetOrCreateSection(DebugInfoSection); + SectionWriter stringSectionWriter = GetOrCreateSection(DebugStringSection); + SectionWriter abbrevSectionWriter = GetOrCreateSection(DebugAbbrevSection); + SectionWriter locSectionWriter = GetOrCreateSection(DebugLocSection); + SectionWriter rangeSectionWriter = GetOrCreateSection(DebugRangesSection); + SectionWriter lineSectionWriter = GetOrCreateSection(DebugLineSection); + SectionWriter arangeSectionWriter = GetOrCreateSection(DebugARangesSection); + + _dwarfBuilder.Write( + infoSectionWriter, + stringSectionWriter, + abbrevSectionWriter, + locSectionWriter, + rangeSectionWriter, + lineSectionWriter, + arangeSectionWriter); } protected override void CreateEhSections() @@ -211,18 +225,5 @@ protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() _nodeFactory.Target.Architecture, _options.HasFlag(ObjectWritingOptions.UseDwarf5)); } - - protected override void EmitDebugStaticVars() - { - var definedSymbols = GetDefinedSymbols(); - _dwarfBuilder.EmitStaticVars( - symbolName => - { - if (definedSymbols.TryGetValue(ExternCName(symbolName), out var symbolDef)) - return GetSectionVirtualAddress(symbolDef.SectionIndex) + (ulong)symbolDef.Value; - return 0; - } - ); - } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 684d206c77ffdc..0c3d0efd48ff05 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -588,6 +588,14 @@ + + + + + + + + From e8a19ff52a40537ca5a74599d6a3392786081f75 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 20 Oct 2023 12:57:01 +0200 Subject: [PATCH 080/144] Fix state change in ObjectWriterStream triggering an Assert --- .../Compiler/ObjectWriter/ObjectWriterStream.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index 42396ccf0e1f18..bac3c58e6e0029 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -223,6 +223,7 @@ private void FlushAppendBuffer() if (_appendBuffer.WrittenCount > 0) { _buffers.Add(_appendBuffer.WrittenSpan.ToArray()); + _position += _appendBuffer.WrittenCount; _length += _appendBuffer.WrittenCount; _appendBuffer.Clear(); } From fedcab7bf1c1602c6e25dcede77856b8b3f53207 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 20 Oct 2023 15:20:54 +0200 Subject: [PATCH 081/144] WIP: Mach-O/DWARF --- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 10 +++ .../Compiler/ObjectWriter/Dwarf/DwarfInfo.cs | 2 +- .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 2 + .../Compiler/ObjectWriter/DwarfBuilder.cs | 65 ++++++++++++------- .../Compiler/ObjectWriter/MachObjectWriter.cs | 44 +++++++++---- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 2 +- 6 files changed, 86 insertions(+), 39 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index cafdbf5acc9d59..f1c5277c4eb6e3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -60,6 +60,16 @@ public void Write(ObjectWriterStream stream, int targetPointerSize) DW_AT_ranges, DW_FORM_sec_offset, DW_AT_stmt_list, DW_FORM_sec_offset]); + public static DwarfAbbrev CompileUnitNoRanges = new([ + DW_TAG_compile_unit, DW_CHILDREN_yes, + DW_AT_producer, DW_FORM_strp, + DW_AT_language, DW_FORM_data2, + DW_AT_name, DW_FORM_strp, + DW_AT_comp_dir, DW_FORM_strp, + DW_AT_low_pc, DW_FORM_addr, + DW_AT_high_pc, DW_FORM_size, + DW_AT_stmt_list, DW_FORM_sec_offset]); + public static DwarfAbbrev BaseType = new([ DW_TAG_base_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs index 4352f555d44c71..7db3eee56ab783 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs @@ -562,7 +562,7 @@ public override void Dump(DwarfInfoWriter writer) length += 1 + DwarfHelper.SizeOfULEB128(_descriptor.StaticOffset); // DW_OP_plus_uconst writer.WriteULEB128(length); writer.Write([DW_OP_addr]); - writer.WriteCodeReference(_descriptor.StaticDataName); + writer.WriteCodeReference(writer.ExternCName(_descriptor.StaticDataName)); if (_descriptor.IsStaticDataInObject != 0) writer.Write([DW_OP_deref, DW_OP_deref]); if (_descriptor.StaticOffset != 0) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index 19b04a19f5ecfb..95fcc19dbf82ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -49,6 +49,8 @@ public DwarfInfoWriter( public byte TargetPointerSize => _builder.TargetPointerSize; public long Position => _infoSectionWriter.Stream.Position; + public string ExternCName(string name) => _builder.ExternCName(name); + public void WriteStartDIE(DwarfAbbrev abbrev) { if (_dieStack.Count > 0 && !_dieStack.Peek().HasChildren) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index c1028807a3cee5..386409946cc026 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -27,6 +27,7 @@ private sealed record MemberFunctionTypeInfo(MemberFunctionTypeDescriptor Member private readonly int _frameRegister; private readonly byte _minimumInstructionLength; private readonly RelocType _codeRelocType; + private readonly bool _isOSXLike; private readonly Dictionary _lineSequences = new(); private readonly Dictionary _fileNameMap = new(); // fileName -> _fileNames index (1-based) @@ -46,40 +47,38 @@ private sealed record MemberFunctionTypeInfo(MemberFunctionTypeDescriptor Member public DwarfBuilder( NameMangler nameMangler, - TargetArchitecture targetArchitecture, + TargetDetails target, bool useDwarf5) { _nameMangler = nameMangler; - _architecture = targetArchitecture; + _architecture = target.Architecture; _useDwarf5 = useDwarf5; + _isOSXLike = target.IsOSXLike; + _minimumInstructionLength = (byte)target.MinimumCodeAlignment; - switch (targetArchitecture) + switch (target.Architecture) { case TargetArchitecture.ARM64: _targetPointerSize = 8; _frameRegister = 29; // FP - _minimumInstructionLength = 4; _codeRelocType = RelocType.IMAGE_REL_BASED_DIR64; break; case TargetArchitecture.ARM: _targetPointerSize = 4; _frameRegister = 7; // R7 - _minimumInstructionLength = 4; _codeRelocType = RelocType.IMAGE_REL_BASED_HIGHLOW; break; case TargetArchitecture.X64: _targetPointerSize = 8; _frameRegister = 6; // RBP - _minimumInstructionLength = 1; _codeRelocType = RelocType.IMAGE_REL_BASED_DIR64; break; case TargetArchitecture.X86: _targetPointerSize = 4; _frameRegister = 5; // EBP - _minimumInstructionLength = 1; _codeRelocType = RelocType.IMAGE_REL_BASED_HIGHLOW; break; @@ -92,10 +91,8 @@ public DwarfBuilder( public byte TargetPointerSize => _targetPointerSize; public int FrameRegister => _frameRegister; - public uint ResolveOffset(uint typeIndex) - { - return typeIndex == 0 ? 0u : _dwarfTypeOffsets[typeIndex - 1]; - } + public uint ResolveOffset(uint typeIndex) => typeIndex == 0 ? 0u : _dwarfTypeOffsets[typeIndex - 1]; + public string ExternCName(string name) => _isOSXLike ? "_" + name : name; public void Write( SectionWriter infoSectionWriter, @@ -147,7 +144,7 @@ public void WriteInfoTable( this, _codeRelocType)) { - dwarfInfoWriter.WriteStartDIE(DwarfAbbrev.CompileUnit); + dwarfInfoWriter.WriteStartDIE(_isOSXLike ? DwarfAbbrev.CompileUnitNoRanges : DwarfAbbrev.CompileUnit); // DW_AT_producer dwarfInfoWriter.WriteStringReference("NetRuntime"); @@ -157,15 +154,25 @@ public void WriteInfoTable( dwarfInfoWriter.WriteStringReference("il.cpp"); // DW_AT_comp_dir dwarfInfoWriter.WriteStringReference("/_"); - // DW_AT_low_pc - dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); - // DW_AT_ranges - dwarfInfoWriter.WriteStartRangeList(); - foreach (var sectionInfo in _sections) + if (_isOSXLike) { - dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); + // DW_AT_low_pc + dwarfInfoWriter.WriteAddressSize(0); + // DW_AT_high_pc + dwarfInfoWriter.WriteCodeReference(_sections[^1].SectionSymbolName, (uint)_sections[^1].Size); + } + else + { + // DW_AT_low_pc + dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); + // DW_AT_ranges + dwarfInfoWriter.WriteStartRangeList(); + foreach (var sectionInfo in _sections) + { + dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); + } + dwarfInfoWriter.WriteEndRangeList(); } - dwarfInfoWriter.WriteEndRangeList(); // DW_AT_stmt_list dwarfInfoWriter.WriteLineReference(0); @@ -228,14 +235,22 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) arangeSectionWriter.Stream.Write([_targetPointerSize, 0]); // Ranges have to be aligned arangeSectionWriter.EmitAlignment(_targetPointerSize * 2); - foreach (var sectionInfo in _sections) + if (_isOSXLike) { - arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); - switch (_targetPointerSize) + arangeSectionWriter.Stream.WriteUInt64(0); + arangeSectionWriter.EmitSymbolReference(_codeRelocType, _sections[^1].SectionSymbolName, (int)_sections[^1].Size); + } + else + { + foreach (var sectionInfo in _sections) { - case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; - case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; - default: throw new NotSupportedException(); + arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); + switch (_targetPointerSize) + { + case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; + case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; + default: throw new NotSupportedException(); + } } } arangeSectionWriter.Stream.Write(stackalloc byte[_targetPointerSize * 2]); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 73764beeb5d9ca..3d2a4cc1fdb934 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -2,12 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; -using System.IO; using System.Diagnostics; +using System.Globalization; +using System.IO; using System.Linq; using System.Numerics; -using System.Buffers.Binary; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; @@ -81,7 +82,6 @@ protected override void EmitSectionsAndLayout() // Preset the size of the compact unwind section which is not generated yet Size = 32u * (ulong)_compactUnwindCodes.Count, }; - _segment.Sections.Add(_compactUnwindSection); // Insert all the load commands to ensure we have correct layout _symbolTable = new MachSymbolTable(_objectFile); @@ -140,6 +140,8 @@ protected override void EmitSectionsAndLayout() protected override void EmitObjectFile(string objectFilePath) { + _segment.Sections.Add(_compactUnwindSection); + // Update layout again to account for symbol table and relocation tables _objectFile.UpdateLayout(); @@ -172,6 +174,7 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS ".eh_frame" => "__eh_frame", ".debug_info" => "__debug_info", ".debug_abbrev" => "__debug_abbrev", + ".debug_ranges" => "__debug_ranges", ".debug_aranges" => "__debug_aranges", ".debug_str" => "__debug_str", ".debug_line" => "__debug_line", @@ -223,27 +226,45 @@ protected internal override void EmitRelocation( string symbolName, int addend) { - if (symbolName.StartsWith('.')) // Code symbols are prefixed with `_`, so `.` implies section relocation + // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly + MachSection machSection = _segment.Sections[sectionIndex]; + if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug) && + machSection.SegmentName == "__DWARF") { - // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly - MachSection machSection = _segment.Sections[sectionIndex]; - if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug)) + if (symbolName.StartsWith('.')) { switch (relocType) { case RelocType.IMAGE_REL_BASED_DIR64: BinaryPrimitives.WriteInt64LittleEndian(data, addend); break; - case RelocType.IMAGE_REL_BASED_HIGHLOW: BinaryPrimitives.WriteInt32LittleEndian(data, addend); break; - default: throw new NotSupportedException("Unsupported relocation in debug section"); } - return; } + else if (symbolName.StartsWith('l')) + { + Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); + int targetSectionIndex = int.Parse(symbolName.AsSpan().Slice("lsection".Length), CultureInfo.InvariantCulture); + BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[targetSectionIndex].VirtualAddress + (ulong)addend); + } + else + { + Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); + IDictionary definedSymbols = GetDefinedSymbols(); + if (definedSymbols.TryGetValue(symbolName, out SymbolDefinition symbolDefinition)) + { + BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[symbolDefinition.SectionIndex].VirtualAddress + (ulong)symbolDefinition.Value + (ulong)addend); + } + else + { + Console.WriteLine($"DEBUG references undefined symbol: {symbolName}"); + } + } + return; } // For most relocations we write the addend directly into the @@ -653,8 +674,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt protected override string GetSectionSymbolName(int sectionIndex) { - MachSection machSection = _segment.Sections[sectionIndex]; - return machSection.SectionName; + return "lsection" + sectionIndex; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 551850c8f5fb96..2fbd801fec9158 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -222,7 +222,7 @@ protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { return _dwarfBuilder = new DwarfBuilder( _nodeFactory.NameMangler, - _nodeFactory.Target.Architecture, + _nodeFactory.Target, _options.HasFlag(ObjectWritingOptions.UseDwarf5)); } } From 5cda00af199bd4531152a94ee263d0a416573c5c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 20 Oct 2023 22:28:22 +0200 Subject: [PATCH 082/144] DWARF Mach-O relocations done right --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 12 +- .../Compiler/ObjectWriter/MachObjectWriter.cs | 189 +++++++----------- 2 files changed, 80 insertions(+), 121 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 386409946cc026..150f754154f8ee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -144,7 +144,7 @@ public void WriteInfoTable( this, _codeRelocType)) { - dwarfInfoWriter.WriteStartDIE(_isOSXLike ? DwarfAbbrev.CompileUnitNoRanges : DwarfAbbrev.CompileUnit); + dwarfInfoWriter.WriteStartDIE(/*_isOSXLike ? DwarfAbbrev.CompileUnitNoRanges :*/ DwarfAbbrev.CompileUnit); // DW_AT_producer dwarfInfoWriter.WriteStringReference("NetRuntime"); @@ -154,7 +154,7 @@ public void WriteInfoTable( dwarfInfoWriter.WriteStringReference("il.cpp"); // DW_AT_comp_dir dwarfInfoWriter.WriteStringReference("/_"); - if (_isOSXLike) + /*if (_isOSXLike) { // DW_AT_low_pc dwarfInfoWriter.WriteAddressSize(0); @@ -162,7 +162,7 @@ public void WriteInfoTable( dwarfInfoWriter.WriteCodeReference(_sections[^1].SectionSymbolName, (uint)_sections[^1].Size); } else - { + {*/ // DW_AT_low_pc dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); // DW_AT_ranges @@ -172,7 +172,7 @@ public void WriteInfoTable( dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); } dwarfInfoWriter.WriteEndRangeList(); - } + //} // DW_AT_stmt_list dwarfInfoWriter.WriteLineReference(0); @@ -235,12 +235,12 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) arangeSectionWriter.Stream.Write([_targetPointerSize, 0]); // Ranges have to be aligned arangeSectionWriter.EmitAlignment(_targetPointerSize * 2); - if (_isOSXLike) + /*if (_isOSXLike) { arangeSectionWriter.Stream.WriteUInt64(0); arangeSectionWriter.EmitSymbolReference(_codeRelocType, _sections[^1].SectionSymbolName, (int)_sections[^1].Size); } - else + else*/ { foreach (var sectionInfo in _sections) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 3d2a4cc1fdb934..5d2d824990e2a1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -30,7 +30,6 @@ private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, private readonly uint _compactUnwindDwarfCode; // Symbol table - private readonly Dictionary _sectionIndexToSymbolIndex = new(); private readonly Dictionary _symbolNameToIndex = new(); private MachSymbolTable _symbolTable; private MachDynamicLinkEditSymbolTable _dySymbolTable; @@ -135,6 +134,24 @@ protected override void EmitSectionsAndLayout() // Layout the sections _objectFile.UpdateLayout(); + // Generate section base symbols. The section symbols are used for PC relative relocations + // to subtract the base of the section, and in DWARF to emit section relative relocations. + uint sectionIndex = 0; + foreach (MachSection machSection in _segment.Sections) + { + var machSymbol = new MachSymbol + { + Name = $"lsection{sectionIndex}", + Section = machSection, + Value = machSection.VirtualAddress, + Descriptor = 0, + Type = MachSymbolType.Section, + }; + _symbolTable.Symbols.Add(machSymbol); + _symbolNameToIndex[machSymbol.Name] = sectionIndex; + sectionIndex++; + } + EmitCompactUnwindTable(); } @@ -226,45 +243,59 @@ protected internal override void EmitRelocation( string symbolName, int addend) { - // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly - MachSection machSection = _segment.Sections[sectionIndex]; - if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug) && - machSection.SegmentName == "__DWARF") + if (relocType is RelocType.IMAGE_REL_BASED_DIR64 or RelocType.IMAGE_REL_BASED_HIGHLOW) { - if (symbolName.StartsWith('.')) + // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly + MachSection machSection = _segment.Sections[sectionIndex]; + if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug) && + machSection.SegmentName == "__DWARF") { - switch (relocType) + // DWARF section to DWARF section relocation + if (symbolName.StartsWith('.')) { - case RelocType.IMAGE_REL_BASED_DIR64: - BinaryPrimitives.WriteInt64LittleEndian(data, addend); - break; - case RelocType.IMAGE_REL_BASED_HIGHLOW: - BinaryPrimitives.WriteInt32LittleEndian(data, addend); - break; - default: - throw new NotSupportedException("Unsupported relocation in debug section"); + switch (relocType) + { + case RelocType.IMAGE_REL_BASED_DIR64: + BinaryPrimitives.WriteInt64LittleEndian(data, addend); + break; + case RelocType.IMAGE_REL_BASED_HIGHLOW: + BinaryPrimitives.WriteInt32LittleEndian(data, addend); + break; + default: + throw new NotSupportedException("Unsupported relocation in debug section"); + } + return; } - } - else if (symbolName.StartsWith('l')) - { - Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); - int targetSectionIndex = int.Parse(symbolName.AsSpan().Slice("lsection".Length), CultureInfo.InvariantCulture); - BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[targetSectionIndex].VirtualAddress + (ulong)addend); - } - else - { - Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); - IDictionary definedSymbols = GetDefinedSymbols(); - if (definedSymbols.TryGetValue(symbolName, out SymbolDefinition symbolDefinition)) + // DWARF section to code/data section relocation + else if (IsSectionSymbolName(symbolName)) { - BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[symbolDefinition.SectionIndex].VirtualAddress + (ulong)symbolDefinition.Value + (ulong)addend); + Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); + int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; + BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[targetSectionIndex].VirtualAddress + (ulong)addend); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } + // DWARF section to code/data symbol else { - Console.WriteLine($"DEBUG references undefined symbol: {symbolName}"); + Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); + IDictionary definedSymbols = GetDefinedSymbols(); + if (definedSymbols.TryGetValue(symbolName, out SymbolDefinition symbolDefinition)) + { + symbolName = GetSectionSymbolName(symbolDefinition.SectionIndex); + BinaryPrimitives.WriteUInt64LittleEndian( + data, + _segment.Sections[symbolDefinition.SectionIndex].VirtualAddress + (ulong)symbolDefinition.Value); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); + } + else + { + Console.WriteLine($"DEBUG references undefined symbol: {symbolName}"); + return; + } } + + return; } - return; } // For most relocations we write the addend directly into the @@ -338,27 +369,9 @@ protected internal override void EmitRelocation( protected override void EmitSymbolTable() { - uint symbolIndex = 0; - - // Create section base symbols. They're used for PC relative relocations - // to subtract the base of the section. - int sectionIndex = 0; - foreach (MachSection machSection in _segment.Sections) - { - var machSymbol = new MachSymbol - { - Name = "lsection" + sectionIndex, - Section = machSection, - Value = machSection.VirtualAddress, - Descriptor = 0, - Type = MachSymbolType.Section, - }; - _symbolTable.Symbols.Add(machSymbol); - _sectionIndexToSymbolIndex[sectionIndex] = symbolIndex; - symbolIndex++; - sectionIndex++; - } - + // We already emitted symbols for all non-debug sections in EmitSectionsAndLayout, + // these symbols are local and we need to account for them. + uint symbolIndex = (uint)_symbolTable.Symbols.Count; _dySymbolTable.LocalSymbolsIndex = 0; _dySymbolTable.LocalSymbolsCount = symbolIndex; @@ -431,14 +444,15 @@ private void EmitRelocationsX64(int sectionIndex, List reloc if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) { + bool isExternal = !IsSectionSymbolName(symbolicRelocation.SymbolName); sectionRelocations.Add( new MachRelocation { Address = symbolicRelocation.Offset, - SymbolOrSectionIndex = symbolIndex, + SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, RelocationType = MachRelocationType.X86_64Unsigned, - IsExternal = true, + IsExternal = isExternal, IsPCRelative = false, }); } @@ -448,7 +462,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc new MachRelocation { Address = symbolicRelocation.Offset, - SymbolOrSectionIndex = _sectionIndexToSymbolIndex[sectionIndex], + SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, RelocationType = MachRelocationType.X86_64Subtractor, IsExternal = true, @@ -543,14 +557,15 @@ private void EmitRelocationsArm64(int sectionIndex, List rel } else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) { + bool isExternal = !IsSectionSymbolName(symbolicRelocation.SymbolName); sectionRelocations.Add( new MachRelocation { Address = symbolicRelocation.Offset, - SymbolOrSectionIndex = symbolIndex, + SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, RelocationType = MachRelocationType.Arm64Unsigned, - IsExternal = true, + IsExternal = isExternal, IsPCRelative = false, }); } @@ -561,7 +576,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel new MachRelocation { Address = symbolicRelocation.Offset, - SymbolOrSectionIndex = _sectionIndexToSymbolIndex[sectionIndex], + SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, RelocationType = MachRelocationType.Arm64Subtractor, IsExternal = true, @@ -672,64 +687,8 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt return encoding != _compactUnwindDwarfCode; } - protected override string GetSectionSymbolName(int sectionIndex) - { - return "lsection" + sectionIndex; - } - - - /*protected override void EmitDebugSections(DwarfFile dwarfFile) - { - ulong highPC = 0; - foreach (var machSection in _segment.Sections) - { - if (machSection.Attributes.HasFlag(MachSectionAttributes.SomeInstructions)) - { - highPC = Math.Max(highPC, machSection.VirtualAddress + machSection.Size); - } - } - - foreach (var unit in dwarfFile.InfoSection.Units) - { - var rootDIE = (DwarfDIECompileUnit)unit.Root; - rootDIE.LowPC = 0u; - rootDIE.HighPC = (int)highPC; - dwarfFile.AddressRangeTable.AddressSize = unit.AddressSize; - dwarfFile.AddressRangeTable.Unit = unit; - dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, highPC)); - } - - var debugInfoSection = new MachSection(_objectFile, "__DWARF", "__debug_info") { Attributes = MachSectionAttributes.Debug }; - var debugAbbrevSection = new MachSection(_objectFile, "__DWARF", "__debug_abbrev") { Attributes = MachSectionAttributes.Debug }; - var debugAddressRangeSection = new MachSection(_objectFile, "__DWARF", "__debug_aranges") { Attributes = MachSectionAttributes.Debug }; - var debugStringSection = new MachSection(_objectFile, "__DWARF", "__debug_str") { Attributes = MachSectionAttributes.Debug }; - var debugLineSection = new MachSection(_objectFile, "__DWARF", "__debug_line") { Attributes = MachSectionAttributes.Debug }; - var debugLocationSection = new MachSection(_objectFile, "__DWARF", "__debug_loc") { Attributes = MachSectionAttributes.Debug }; - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = _objectFile.IsLittleEndian, - EnableRelocation = false, - AddressSize = DwarfAddressSize.Bit64, - DebugLineStream = debugLineSection.GetWriteStream(), - DebugAbbrevStream = debugAbbrevSection.GetWriteStream(), - DebugStringStream = debugStringSection.GetWriteStream(), - DebugAddressRangeStream = debugAddressRangeSection.GetWriteStream(), - DebugInfoStream = debugInfoSection.GetWriteStream(), - DebugLocationStream = debugLocationSection.GetWriteStream(), - }; - - dwarfFile.Write(outputContext); - - _segment.Sections.Add(debugInfoSection); - _segment.Sections.Add(debugAbbrevSection); - _segment.Sections.Add(debugAddressRangeSection); - _segment.Sections.Add(debugStringSection); - _segment.Sections.Add(debugLineSection); - _segment.Sections.Add(debugLocationSection); - - _objectFile.UpdateLayout(); - }*/ + protected override string GetSectionSymbolName(int sectionIndex) => "lsection" + sectionIndex; + private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { From 5d548589ece4bca0a676815f1cf87b176a222a56 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 22 Oct 2023 18:44:57 +0200 Subject: [PATCH 083/144] Do not output debug information for static variables that were trimmed --- .../Compiler/UserDefinedTypeDescriptor.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index 26d008f8377fee..c526dd448c760d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -672,6 +672,8 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) { if (NodeFactory.Target.OperatingSystem != TargetOS.Windows) { + bool marked; + StaticDataFieldDescriptor staticDesc = new StaticDataFieldDescriptor { StaticOffset = (ulong)fieldOffsetEmit @@ -683,12 +685,20 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) if (fieldDesc.IsThreadStatic) { staticDesc.StaticDataName = threadStaticDataName; staticDesc.IsStaticDataInObject = isNativeAOT ? 1 : 0; + marked = NodeFactory.TypeThreadStaticsSymbol((MetadataType)defType).Marked; } else if (fieldDesc.HasGCStaticBase) { staticDesc.StaticDataName = gcStaticDataName; staticDesc.IsStaticDataInObject = isNativeAOT ? 1 : 0; + marked = NodeFactory.TypeGCStaticsSymbol((MetadataType)defType).Marked; } else { staticDesc.StaticDataName = nonGcStaticDataName; staticDesc.IsStaticDataInObject = 0; + marked = NodeFactory.TypeNonGCStaticsSymbol((MetadataType)defType).Marked; + } + + if (!marked) + { + continue; } staticsDescs.Add(staticDesc); From cd4a543d5b894101c8824f0a69ee7c817a77def7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 22 Oct 2023 22:05:12 +0200 Subject: [PATCH 084/144] WIP: Cleanup --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 53 ++++++++----------- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 10 ---- .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 2 +- .../Compiler/ObjectWriter/DwarfBuilder.cs | 44 +++++---------- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 16 +++--- .../Compiler/ObjectWriter/MachObjectWriter.cs | 8 +-- .../Compiler/ObjectWriter/ObjectWriter.cs | 37 ++++++++----- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 39 +++++++++++--- .../tools/aot/ILCompiler/ILCompiler.csproj | 1 + 9 files changed, 102 insertions(+), 108 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 2b5f1a6a49b018..12ef7190a12860 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -26,8 +26,10 @@ namespace ILCompiler.ObjectWriter { public sealed class CoffObjectWriter : ObjectWriter { + private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName, string SymbolName); + private Machine _machine; - private List<(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName)> _sections = new(); + private List _sections = new(); // Symbol table private List _symbols = new(); @@ -62,7 +64,7 @@ private CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) }; } - protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { var sectionHeader = new CoffSectionHeader { @@ -94,13 +96,12 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS SectionCharacteristics.MemDiscardable; } - if (section.ComdatName != null) + if (comdatName is not null) { - sectionHeader.SectionCharacteristics |= - SectionCharacteristics.LinkerComdat; + sectionHeader.SectionCharacteristics |= SectionCharacteristics.LinkerComdat; } - _sections.Add((sectionHeader, sectionStream, new List(), section.ComdatName)); + _sections.Add(new SectionDefinition(sectionHeader, sectionStream, new List(), comdatName, symbolName)); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -195,25 +196,15 @@ protected override void EmitReferencedMethod(string symbolName) protected override void EmitSymbolTable() { var definedSymbols = GetDefinedSymbols(); - var sectionSymbol = new string[_sections.Count]; - - foreach (var (symbolName, symbolDefinition) in definedSymbols) - { - if (symbolDefinition.Value == 0 && - sectionSymbol[symbolDefinition.SectionIndex] is null) - { - sectionSymbol[symbolDefinition.SectionIndex] = symbolName; - } - } int sectionIndex = 0; - foreach (var (sectionHeader, _, _, comdatName) in _sections) + foreach (SectionDefinition section in _sections) { - if (sectionHeader.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerComdat)) + if (section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerComdat)) { // We find the defining section of the COMDAT symbol. That one is marked // as "ANY" selection type. All the other ones are marked as associated. - SymbolDefinition definingSymbol = definedSymbols[comdatName]; + SymbolDefinition definingSymbol = definedSymbols[section.ComdatName]; int definingSectionIndex = definingSymbol.SectionIndex; var auxRecord = new CoffSectionSymbol @@ -230,7 +221,7 @@ protected override void EmitSymbolTable() _sectionNumberToComdatAuxRecord[sectionIndex] = auxRecord; _symbols.Add(new CoffSymbol { - Name = sectionHeader.Name, + Name = section.Header.Name, Value = 0, SectionIndex = (uint)(1 + sectionIndex), StorageClass = 3, // IMAGE_SYM_CLASS_STATIC @@ -240,21 +231,21 @@ protected override void EmitSymbolTable() if (definingSectionIndex == sectionIndex) { - _symbolNameToIndex.Add(comdatName, (uint)_symbols.Count); + _symbolNameToIndex.Add(section.ComdatName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol { - Name = comdatName, + Name = section.ComdatName, Value = (uint)definingSymbol.Value, SectionIndex = (uint)(1 + definingSymbol.SectionIndex), StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL }); } - else if (sectionSymbol[sectionIndex] is not null) + else if (section.SymbolName is not null) { - _symbolNameToIndex.Add(sectionSymbol[sectionIndex], (uint)_symbols.Count); + _symbolNameToIndex.Add(section.SymbolName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol { - Name = sectionSymbol[sectionIndex], + Name = section.SymbolName, Value = 0, SectionIndex = (uint)(1 + sectionIndex), StorageClass = 3 // IMAGE_SYM_CLASS_STATIC @@ -416,8 +407,8 @@ protected override void EmitUnwindInfo( // and produces errors about duplicate symbols that point into the // associative section, so we are stuck with one section per each // unwind symbol. - xdataSectionWriter = GetOrCreateSection(GetSharedSection(ObjectNodeSection.XDataSection, currentSymbolName)); - pdataSectionWriter = GetOrCreateSection(GetSharedSection(PDataSection, currentSymbolName)); + xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection, currentSymbolName, unwindSymbolName); + pdataSectionWriter = GetOrCreateSection(PDataSection, currentSymbolName, null); } else { @@ -501,7 +492,7 @@ protected override void EmitObjectFile(string objectFilePath) // Calculate size of section data and assign offsets uint dataOffset = (uint)(coffHeader.Size + _sections.Count * CoffSectionHeader.Size); int sectionIndex = 0; - foreach (var section in _sections) + foreach (SectionDefinition section in _sections) { section.Header.SizeOfRawData = (uint)section.Stream.Length; @@ -530,7 +521,7 @@ protected override void EmitObjectFile(string objectFilePath) // Write COFF section headers sectionIndex = 0; - foreach (var section in _sections) + foreach (SectionDefinition section in _sections) { section.Header.Write(outputFileStream, stringTable); @@ -552,7 +543,7 @@ protected override void EmitObjectFile(string objectFilePath) } // Writer section content and relocations - foreach (var section in _sections) + foreach (SectionDefinition section in _sections) { if (!section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.ContainsUninitializedData)) { @@ -625,7 +616,7 @@ protected override void EmitDebugFunctionInfo( { // If the method is emitted in COMDAT section then we need to create an // associated COMDAT section for the debugging symbols. - var sectionWriter = GetOrCreateSection(GetSharedSection(DebugSymbolSection, methodName)); + var sectionWriter = GetOrCreateSection(DebugSymbolSection, methodName, null); debugSymbolsBuilder = new CodeViewSymbolsBuilder(_nodeFactory.Target.Architecture, sectionWriter); } else diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index f1c5277c4eb6e3..cafdbf5acc9d59 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -60,16 +60,6 @@ public void Write(ObjectWriterStream stream, int targetPointerSize) DW_AT_ranges, DW_FORM_sec_offset, DW_AT_stmt_list, DW_FORM_sec_offset]); - public static DwarfAbbrev CompileUnitNoRanges = new([ - DW_TAG_compile_unit, DW_CHILDREN_yes, - DW_AT_producer, DW_FORM_strp, - DW_AT_language, DW_FORM_data2, - DW_AT_name, DW_FORM_strp, - DW_AT_comp_dir, DW_FORM_strp, - DW_AT_low_pc, DW_FORM_addr, - DW_AT_high_pc, DW_FORM_size, - DW_AT_stmt_list, DW_FORM_sec_offset]); - public static DwarfAbbrev BaseType = new([ DW_TAG_base_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index 95fcc19dbf82ca..b95c467ad4753d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -192,7 +192,7 @@ public void WriteEndRangeList() public void Dispose() { - Debug.Assert(_dieStack.Count == 0); + //Debug.Assert(_dieStack.Count == 0); // Flush late bound forward references int streamOffset = (int)_infoSectionWriter.Stream.Position; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 150f754154f8ee..6bd3e0dc024d39 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -154,25 +154,15 @@ public void WriteInfoTable( dwarfInfoWriter.WriteStringReference("il.cpp"); // DW_AT_comp_dir dwarfInfoWriter.WriteStringReference("/_"); - /*if (_isOSXLike) + // DW_AT_low_pc + dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); + // DW_AT_ranges + dwarfInfoWriter.WriteStartRangeList(); + foreach (var sectionInfo in _sections) { - // DW_AT_low_pc - dwarfInfoWriter.WriteAddressSize(0); - // DW_AT_high_pc - dwarfInfoWriter.WriteCodeReference(_sections[^1].SectionSymbolName, (uint)_sections[^1].Size); + dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); } - else - {*/ - // DW_AT_low_pc - dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); - // DW_AT_ranges - dwarfInfoWriter.WriteStartRangeList(); - foreach (var sectionInfo in _sections) - { - dwarfInfoWriter.WriteRangeListEntry(sectionInfo.SectionSymbolName, 0, (uint)sectionInfo.Size); - } - dwarfInfoWriter.WriteEndRangeList(); - //} + dwarfInfoWriter.WriteEndRangeList(); // DW_AT_stmt_list dwarfInfoWriter.WriteLineReference(0); @@ -235,22 +225,14 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) arangeSectionWriter.Stream.Write([_targetPointerSize, 0]); // Ranges have to be aligned arangeSectionWriter.EmitAlignment(_targetPointerSize * 2); - /*if (_isOSXLike) - { - arangeSectionWriter.Stream.WriteUInt64(0); - arangeSectionWriter.EmitSymbolReference(_codeRelocType, _sections[^1].SectionSymbolName, (int)_sections[^1].Size); - } - else*/ + foreach (var sectionInfo in _sections) { - foreach (var sectionInfo in _sections) + arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); + switch (_targetPointerSize) { - arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); - switch (_targetPointerSize) - { - case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; - case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; - default: throw new NotSupportedException(); - } + case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; + case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; + default: throw new NotSupportedException(); } } arangeSectionWriter.Stream.Write(stackalloc byte[_targetPointerSize * 2]); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 83ebb0fcee35dc..57ec90cea0aa12 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -45,7 +45,7 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) _symbolTable = new ElfSymbolTable { Link = stringSection }; } - protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { ElfSection elfSection; ElfGroupSection groupSection = null; @@ -53,8 +53,8 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith('_') || section.Name.StartsWith('.') ? section.Name : "." + section.Name); - if (section.ComdatName != null && - !_comdatNameToElfSection.TryGetValue(section.ComdatName, out groupSection)) + if (comdatName is not null && + !_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) { groupSection = new ElfGroupSection { @@ -62,7 +62,7 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS Link = _symbolTable, // Info = of the COMDAT symbol, to be filled later }; - _comdatNameToElfSection.Add(section.ComdatName, groupSection); + _comdatNameToElfSection.Add(comdatName, groupSection); } if (section.Type == SectionType.Uninitialized) @@ -111,6 +111,8 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS _elfSectionToSectionIndex[elfSection] = _sectionIndex; _sectionIndexToElfSection[_sectionIndex++] = elfSection; groupSection?.AddSection(elfSection); + + base.CreateSection(section, comdatName, symbolName ?? elfSection.Name.Value, sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -317,12 +319,6 @@ private void EmitRelocationsX64(int sectionIndex, List reloc } } - protected override string GetSectionSymbolName(int sectionIndex) - { - // FIXME: We really want symbol name for relocations and it has to be unique for COMDAT - return _sectionIndexToElfSection[sectionIndex].Name.Value; - } - protected override void EmitDebugSections() { base.EmitDebugSections(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 5d2d824990e2a1..b9ae69c70ef219 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -168,7 +168,7 @@ protected override void EmitObjectFile(string objectFilePath) } } - protected override void CreateSection(ObjectNodeSection section, Stream sectionStream) + protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { string segmentName = section.Name switch { @@ -225,7 +225,10 @@ protected override void CreateSection(ObjectNodeSection section, Stream sectionS Attributes = attributes, }; + int sectionIndex = _segment.Sections.Count; _segment.Sections.Add(machSection); + + base.CreateSection(section, comdatName, symbolName ?? $"lsection{sectionIndex}", sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) @@ -281,7 +284,7 @@ protected internal override void EmitRelocation( IDictionary definedSymbols = GetDefinedSymbols(); if (definedSymbols.TryGetValue(symbolName, out SymbolDefinition symbolDefinition)) { - symbolName = GetSectionSymbolName(symbolDefinition.SectionIndex); + symbolName = $"lsection{symbolDefinition.SectionIndex}"; BinaryPrimitives.WriteUInt64LittleEndian( data, _segment.Sections[symbolDefinition.SectionIndex].VirtualAddress + (ulong)symbolDefinition.Value); @@ -687,7 +690,6 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt return encoding != _compactUnwindDwarfCode; } - protected override string GetSectionSymbolName(int sectionIndex) => "lsection" + sectionIndex; private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index b8783aec41a72c..252c0dd2800506 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -28,7 +28,7 @@ protected sealed record SymbolicRelocation(int Offset, RelocType Type, string Sy // Standard sections private readonly Dictionary _sectionNameToSectionIndex = new(StringComparer.Ordinal); - protected readonly List _sectionIndexToStream = new(); + private readonly List _sectionIndexToStream = new(); private readonly List> _sectionIndexToRelocations = new(); // Symbol table @@ -61,23 +61,37 @@ public void Dispose() } } - protected abstract void CreateSection(ObjectNodeSection section, Stream sectionStream); + protected abstract void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream); protected internal abstract void UpdateSectionAlignment(int sectionIndex, int alignment); - protected SectionWriter GetOrCreateSection(ObjectNodeSection section) + /// + /// Get or creates an object file section. + /// + /// Base section name and type definition. + /// Name of the COMDAT symbol or null. + /// Name of the section definiting symbol for COMDAT or null + /// Writer for a given section. + /// + /// When creating a COMDAT section both and + /// has to be specified. specifies the group section. For the primary + /// symbol both and will be the same. + /// For associated sections, such as exception or debugging information, the + /// will be different. + /// + protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string comdatName = null, string symbolName = null) { int sectionIndex; ObjectWriterStream sectionStream; - if (section.ComdatName is not null || !_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) + if (comdatName is not null || !_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) { sectionStream = new ObjectWriterStream(section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); - CreateSection(section, sectionStream); sectionIndex = _sectionIndexToStream.Count; + CreateSection(section, comdatName, symbolName, sectionStream); _sectionIndexToStream.Add(sectionStream); _sectionIndexToRelocations.Add(new()); - if (section.ComdatName is null) + if (comdatName is null) { _sectionNameToSectionIndex.Add(section.Name, sectionIndex); } @@ -263,8 +277,6 @@ protected ISet GetUndefinedSymbols() protected abstract ITypesDebugInfoWriter CreateDebugInfoBuilder(); - protected virtual string GetSectionSymbolName(int sectionIndex) => null; - protected abstract void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, @@ -315,12 +327,9 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection _sections = new(); // Exception handling sections private SectionWriter _lsdaSectionWriter; @@ -24,12 +29,29 @@ public abstract class UnixObjectWriter : ObjectWriter protected int EhFrameSectionIndex => _ehFrameSectionIndex; private static ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null); + private static ObjectNodeSection EhFrameSection = new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null); protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { } + protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) + { + if (section.Type != SectionType.Debug && + section != LsdaSection && + section != EhFrameSection && + (comdatName is null || Equals(comdatName, symbolName))) + { + // Record code and data sections that can be referenced from debugging information + _sections.Add(new SectionDefinition(symbolName, sectionStream)); + } + else + { + _sections.Add(null); + } + } + protected virtual bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) => false; protected override void EmitUnwindInfo( @@ -45,7 +67,7 @@ protected override void EmitUnwindInfo( if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) { - lsdaSectionWriter = GetOrCreateSection(GetSharedSection(LsdaSection, currentSymbolName)); + lsdaSectionWriter = GetOrCreateSection(LsdaSection, currentSymbolName, $"_lsda0{currentSymbolName}"); } else { @@ -150,18 +172,16 @@ protected override void EmitDebugFunctionInfo( debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), clauses ?? []); - if (hasSequencePoints) + if (hasSequencePoints && _sections[methodSymbol.SectionIndex] is SectionDefinition section) { _dwarfBuilder.EmitLineInfo( methodSymbol.SectionIndex, - GetSectionSymbolName(methodSymbol.SectionIndex), + section.SymbolName, (ulong)methodSymbol.Value, debugNode.GetNativeSequencePoints()); } } - //protected abstract void EmitDebugSections(DwarfFile dwarfFile); - private readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); private readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); private readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); @@ -172,9 +192,12 @@ protected override void EmitDebugFunctionInfo( protected override void EmitDebugSections() { - for (int i = 0; i < _sectionIndexToStream.Count; i++) + foreach (SectionDefinition section in _sections) { - _dwarfBuilder.EmitSectionInfo(GetSectionSymbolName(i), (ulong)_sectionIndexToStream[i].Length); + if (section is not null) + { + _dwarfBuilder.EmitSectionInfo(section.SymbolName, (ulong)section.SectionStream.Length); + } } SectionWriter infoSectionWriter = GetOrCreateSection(DebugInfoSection); @@ -201,7 +224,7 @@ protected override void CreateEhSections() // Create sections for exception handling _lsdaSectionWriter = GetOrCreateSection(LsdaSection); - ehFrameSectionWriter = GetOrCreateSection(new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null)); + ehFrameSectionWriter = GetOrCreateSection(EhFrameSection); _lsdaSectionWriter.EmitAlignment(8); ehFrameSectionWriter.EmitAlignment(8); _ehFrameSectionIndex = ehFrameSectionWriter.SectionIndex; diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj index d3ccae71ef5cb4..742ae9d27a2b6e 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj @@ -81,6 +81,7 @@ + Date: Mon, 23 Oct 2023 12:16:38 +0200 Subject: [PATCH 085/144] Rework how symbol tables are generated, and how DWARF relocations are emitted --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 130 ++++++++---------- .../Compiler/ObjectWriter/Dwarf/DwarfInfo.cs | 28 ++-- .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 31 ++--- .../Dwarf/DwarfLineSequenceWriter.cs | 6 +- .../Compiler/ObjectWriter/DwarfBuilder.cs | 42 ++++-- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 45 +++--- .../Compiler/ObjectWriter/MachObjectWriter.cs | 70 ++++------ .../Compiler/ObjectWriter/ObjectWriter.cs | 24 ++-- .../Compiler/ObjectWriter/SectionWriter.cs | 14 +- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 57 +++++--- 10 files changed, 225 insertions(+), 222 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 12ef7190a12860..7434f3e87fdf77 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -99,6 +99,43 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa if (comdatName is not null) { sectionHeader.SectionCharacteristics |= SectionCharacteristics.LinkerComdat; + + // We find the defining section of the COMDAT symbol. That one is marked + // as "ANY" selection type. All the other ones are marked as associated. + bool isPrimary = Equals(comdatName, symbolName); + uint sectionIndex = (uint)_sections.Count + 1u; + uint definingSectionIndex = isPrimary ? sectionIndex : ((CoffSymbol)_symbols[(int)_symbolNameToIndex[comdatName]]).SectionIndex; + + var auxRecord = new CoffSectionSymbol + { + // SizeOfRawData, NumberOfRelocations, NumberOfLineNumbers + // CheckSum will be filled later in EmitObjectFile + + Number = definingSectionIndex, + Selection = isPrimary ? + CoffComdatSelect.IMAGE_COMDAT_SELECT_ANY : + CoffComdatSelect.IMAGE_COMDAT_SELECT_ASSOCIATIVE, + }; + + _sectionNumberToComdatAuxRecord[_sections.Count] = auxRecord; + _symbols.Add(new CoffSymbol + { + Name = sectionHeader.Name, + Value = 0, + SectionIndex = sectionIndex, + StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, + NumberOfAuxiliaryRecords = 1, + }); + _symbols.Add(auxRecord); + + _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = symbolName, + Value = 0, + SectionIndex = sectionIndex, + StorageClass = isPrimary ? CoffSymbolClass.IMAGE_SYM_CLASS_EXTERNAL : CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, + }); } _sections.Add(new SectionDefinition(sectionHeader, sectionStream, new List(), comdatName, symbolName)); @@ -120,11 +157,11 @@ protected internal override void UpdateSectionAlignment(int sectionIndex, int al protected internal override void EmitRelocation( int sectionIndex, - int offset, + long offset, Span data, RelocType relocType, string symbolName, - int addend) + long addend) { switch (relocType) { @@ -163,7 +200,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); + (int)addend); addend = 0; } break; @@ -176,7 +213,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); + (int)addend); addend = 0; } break; @@ -193,68 +230,10 @@ protected override void EmitReferencedMethod(string symbolName) _referencedMethods.Add(symbolName); } - protected override void EmitSymbolTable() + protected override void EmitSymbolTable( + IDictionary definedSymbols, + SortedSet undefinedSymbols) { - var definedSymbols = GetDefinedSymbols(); - - int sectionIndex = 0; - foreach (SectionDefinition section in _sections) - { - if (section.Header.SectionCharacteristics.HasFlag(SectionCharacteristics.LinkerComdat)) - { - // We find the defining section of the COMDAT symbol. That one is marked - // as "ANY" selection type. All the other ones are marked as associated. - SymbolDefinition definingSymbol = definedSymbols[section.ComdatName]; - int definingSectionIndex = definingSymbol.SectionIndex; - - var auxRecord = new CoffSectionSymbol - { - // SizeOfRawData, NumberOfRelocations, NumberOfLineNumbers - // CheckSum will be filled later in EmitObjectFile - - Number = (uint)(1 + definingSectionIndex), - Selection = definingSectionIndex == sectionIndex ? - CoffComdatSelect.IMAGE_COMDAT_SELECT_ANY : - CoffComdatSelect.IMAGE_COMDAT_SELECT_ASSOCIATIVE, - }; - - _sectionNumberToComdatAuxRecord[sectionIndex] = auxRecord; - _symbols.Add(new CoffSymbol - { - Name = section.Header.Name, - Value = 0, - SectionIndex = (uint)(1 + sectionIndex), - StorageClass = 3, // IMAGE_SYM_CLASS_STATIC - NumberOfAuxiliaryRecords = 1 - }); - _symbols.Add(auxRecord); - - if (definingSectionIndex == sectionIndex) - { - _symbolNameToIndex.Add(section.ComdatName, (uint)_symbols.Count); - _symbols.Add(new CoffSymbol - { - Name = section.ComdatName, - Value = (uint)definingSymbol.Value, - SectionIndex = (uint)(1 + definingSymbol.SectionIndex), - StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL - }); - } - else if (section.SymbolName is not null) - { - _symbolNameToIndex.Add(section.SymbolName, (uint)_symbols.Count); - _symbols.Add(new CoffSymbol - { - Name = section.SymbolName, - Value = 0, - SectionIndex = (uint)(1 + sectionIndex), - StorageClass = 3 // IMAGE_SYM_CLASS_STATIC - }); - } - } - sectionIndex++; - } - foreach (var (symbolName, symbolDefinition) in definedSymbols) { if (!_symbolNameToIndex.ContainsKey(symbolName)) @@ -265,18 +244,18 @@ protected override void EmitSymbolTable() Name = symbolName, Value = (uint)symbolDefinition.Value, SectionIndex = (uint)(1 + symbolDefinition.SectionIndex), - StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_EXTERNAL, }); } } - foreach (var symbolName in GetUndefinedSymbols()) + foreach (var symbolName in undefinedSymbols) { _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol { Name = symbolName, - StorageClass = 2 // IMAGE_SYM_CLASS_EXTERNAL + StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_EXTERNAL, }); } @@ -296,7 +275,7 @@ protected override void EmitSymbolTable() _symbols.Add(new CoffSymbol { Name = "@feat.00", - StorageClass = 3, // IMAGE_SYM_CLASS_STATIC + StorageClass = CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, SectionIndex = uint.MaxValue, // IMAGE_SYM_ABSOLUTE Value = 0x800, // cfGuardCF flags this object as control flow guard aware }); @@ -641,7 +620,7 @@ protected override void EmitDebugFunctionInfo( } } - protected override void EmitDebugSections() + protected override void EmitDebugSections(IDictionary definedSymbols) { _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); _debugFileTableBuilder.Write(_debugSymbolSectionWriter.Stream); @@ -869,13 +848,20 @@ private abstract class CoffSymbolRecord public abstract void Write(Stream stream, CoffStringTable stringTable, bool isBigObj); } + private enum CoffSymbolClass : byte + { + IMAGE_SYM_CLASS_EXTERNAL = 2, + IMAGE_SYM_CLASS_STATIC = 3, + IMAGE_SYM_CLASS_LABEL = 6, + } + private sealed class CoffSymbol : CoffSymbolRecord { public string Name { get; set; } public uint Value { get; set; } public uint SectionIndex { get; set; } public ushort Type { get; set; } - public byte StorageClass { get; set; } + public CoffSymbolClass StorageClass { get; set; } public byte NumberOfAuxiliaryRecords { get; set; } private const int NameSize = 8; @@ -929,7 +915,7 @@ public override void Write(Stream stream, CoffStringTable stringTable, bool isBi sliceIndex = NameSize + 6; } BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(sliceIndex), Type); - buffer[sliceIndex + 2] = StorageClass; + buffer[sliceIndex + 2] = (byte)StorageClass; buffer[sliceIndex + 3] = NumberOfAuxiliaryRecords; stream.Write(buffer); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs index 7db3eee56ab783..f796dc8ac8d288 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs @@ -360,7 +360,8 @@ public override void Dump(DwarfInfoWriter writer) internal sealed class DwarfSubprogramInfo : DwarfInfo { - private readonly string _methodName; + private readonly string _sectionSymbolName; + private readonly long _methodAddress; private readonly int _methodSize; private readonly DwarfMemberFunction _memberFunction; private readonly IEnumerable<(DebugVarInfoMetadata, uint)> _debugVars; @@ -369,13 +370,15 @@ internal sealed class DwarfSubprogramInfo : DwarfInfo private readonly bool _hasChildren; public DwarfSubprogramInfo( - string methodName, + string sectionSymbolName, + long methodAddress, int methodSize, DwarfMemberFunction memberFunction, IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, IEnumerable debugEHClauseInfos) { - _methodName = methodName; + _sectionSymbolName = sectionSymbolName; + _methodAddress = methodAddress; _methodSize = methodSize; _memberFunction = memberFunction; _isStatic = memberFunction.IsStatic; @@ -394,7 +397,7 @@ public override void Dump(DwarfInfoWriter writer) writer.WriteInfoAbsReference(_memberFunction.InfoOffset); // DW_AT_low_pc - writer.WriteCodeReference(_methodName); + writer.WriteCodeReference(_sectionSymbolName, _methodAddress); // DW_AT_high_pc writer.WriteAddressSize((ulong)_methodSize); @@ -423,14 +426,14 @@ public override void Dump(DwarfInfoWriter writer) { writer.WriteStartDIE(DwarfAbbrev.TryBlock); // DW_AT_low_pc - writer.WriteCodeReference(_methodName, clause.TryOffset); + writer.WriteCodeReference(_sectionSymbolName, _methodAddress + clause.TryOffset); // DW_AT_high_pc writer.WriteAddressSize(clause.TryLength); writer.WriteEndDIE(); writer.WriteStartDIE(DwarfAbbrev.CatchBlock); // DW_AT_low_pc - writer.WriteCodeReference(_methodName, clause.HandlerOffset); + writer.WriteCodeReference(_sectionSymbolName, _methodAddress + clause.HandlerOffset); // DW_AT_high_pc writer.WriteAddressSize(clause.HandlerLength); writer.WriteEndDIE(); @@ -476,7 +479,11 @@ private void DumpVar(DwarfInfoWriter writer, DebugVarInfoMetadata metadataInfo, { var expressionBuilder = writer.GetExpressionBuilder(); DumpVarLocation(expressionBuilder, range.VarLoc); - writer.WriteLocationListExpression(_methodName, range.StartOffset, range.EndOffset, expressionBuilder); + writer.WriteLocationListExpression( + _sectionSymbolName, + _methodAddress + range.StartOffset, + _methodAddress + range.EndOffset, + expressionBuilder); } writer.WriteEndLocationList(); } @@ -537,18 +544,19 @@ private static void DumpVarLocation(DwarfExpressionBuilder e, VarLoc loc) } } - internal sealed class DwarfStaticVariableInfo : DwarfInfo + internal sealed class DwarfStaticVariableInfo { private readonly StaticDataFieldDescriptor _descriptor; public long InfoOffset { get; set; } + public string Name => _descriptor.StaticDataName; public DwarfStaticVariableInfo(StaticDataFieldDescriptor descriptor) { _descriptor = descriptor; } - public override void Dump(DwarfInfoWriter writer) + public void Dump(DwarfInfoWriter writer, string sectionSymbolName, long address) { writer.WriteStartDIE(DwarfAbbrev.VariableStatic); @@ -562,7 +570,7 @@ public override void Dump(DwarfInfoWriter writer) length += 1 + DwarfHelper.SizeOfULEB128(_descriptor.StaticOffset); // DW_OP_plus_uconst writer.WriteULEB128(length); writer.Write([DW_OP_addr]); - writer.WriteCodeReference(writer.ExternCName(_descriptor.StaticDataName)); + writer.WriteCodeReference(sectionSymbolName, address); if (_descriptor.IsStaticDataInObject != 0) writer.Write([DW_OP_deref, DW_OP_deref]); if (_descriptor.StaticOffset != 0) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index b95c467ad4753d..a1b25da6b9c10d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -49,8 +49,6 @@ public DwarfInfoWriter( public byte TargetPointerSize => _builder.TargetPointerSize; public long Position => _infoSectionWriter.Stream.Position; - public string ExternCName(string name) => _builder.ExternCName(name); - public void WriteStartDIE(DwarfAbbrev abbrev) { if (_dieStack.Count > 0 && !_dieStack.Peek().HasChildren) @@ -101,13 +99,13 @@ public void WriteStringReference(string value) _stringTableWriter.WriteUtf8String(value); Debug.Assert(stringsOffset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_str", (int)stringsOffset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_str", stringsOffset); } public void WriteInfoAbsReference(long offset) { Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", (int)offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", offset); } public void WriteInfoReference(uint typeIndex) @@ -123,19 +121,20 @@ public void WriteInfoReference(uint typeIndex) } else { - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", (int)offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", offset); } } - public void WriteCodeReference(string methodName, uint offset = 0) + public void WriteCodeReference(string sectionSymbolName, long offset = 0) { - _infoSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)offset); + Debug.Assert(offset >= 0); + _infoSectionWriter.EmitSymbolReference(_codeRelocType, sectionSymbolName, offset); } public void WriteLineReference(long offset) { Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_line", (int)offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_line", offset); } public DwarfExpressionBuilder GetExpressionBuilder() @@ -158,11 +157,11 @@ public void WriteStartLocationList() _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_loc", (int)offset); } - public void WriteLocationListExpression(string methodName, uint startOffset, uint endOffset, DwarfExpressionBuilder expressionBuilder) + public void WriteLocationListExpression(string methodName, long startOffset, long endOffset, DwarfExpressionBuilder expressionBuilder) { _ = expressionBuilder; - _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)startOffset); - _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, (int)endOffset); + _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, startOffset); + _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, endOffset); _locSectionWriter.Stream.WriteUInt16((ushort)_expressionBufferWriter.WrittenCount); _locSectionWriter.Stream.Write(_expressionBufferWriter.WrittenSpan); } @@ -176,13 +175,13 @@ public void WriteStartRangeList() { long offset = _rangeSectionWriter.Stream.Position; Debug.Assert(offset < uint.MaxValue); - _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_ranges", (int)offset); + _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_ranges", offset); } - public void WriteRangeListEntry(string symbolName, uint startOffset, uint endOffset) + public void WriteRangeListEntry(string symbolName, long startOffset, long endOffset) { - _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, (int)startOffset); - _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, (int)endOffset); + _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, startOffset); + _rangeSectionWriter.EmitSymbolReference(_codeRelocType, symbolName, endOffset); } public void WriteEndRangeList() @@ -192,7 +191,7 @@ public void WriteEndRangeList() public void Dispose() { - //Debug.Assert(_dieStack.Count == 0); + // Debug.Assert(_dieStack.Count == 0); // Flush late bound forward references int streamOffset = (int)_infoSectionWriter.Stream.Position; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs index 8b9a951439b938..4a9b891987257a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs @@ -33,7 +33,7 @@ public DwarfLineSequenceWriter(string sectionName, byte minimumInstructionLength _minimumInstructionLength = minimumInstructionLength; } - public void EmitLineInfo(int fileNameIndex, ulong methodAddress, NativeSequencePoint sequencePoint) + public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePoint sequencePoint) { if (_column != sequencePoint.ColNumber) { @@ -64,7 +64,7 @@ public void EmitLineInfo(int fileNameIndex, ulong methodAddress, NativeSequenceP } } - ulong deltaAddress = (ulong)sequencePoint.NativeOffset + methodAddress - _address; + ulong deltaAddress = (ulong)sequencePoint.NativeOffset + (ulong)methodAddress - _address; if (deltaAddress > _maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * _maxDeltaAddressPerSpecialCode)) { deltaAddress -= _maxDeltaAddressPerSpecialCode; @@ -97,7 +97,7 @@ public void EmitLineInfo(int fileNameIndex, ulong methodAddress, NativeSequenceP } _line = sequencePoint.LineNumber; - _address = (ulong)sequencePoint.NativeOffset + methodAddress; + _address = (ulong)sequencePoint.NativeOffset + (ulong)methodAddress; } public void Write(SectionWriter lineSection, byte targetPointerSize, RelocType codeRelocType) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index 6bd3e0dc024d39..c2777934d0ace1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -16,9 +16,9 @@ namespace ILCompiler.ObjectWriter { internal sealed class DwarfBuilder : ITypesDebugInfoWriter { - private sealed record SectionInfo(string SectionSymbolName, ulong Size); - private sealed record MemberFunctionTypeInfo(MemberFunctionTypeDescriptor MemberDescriptor, uint[] ArgumentTypes, bool IsStatic); - + private record struct SectionInfo(string SectionSymbolName, ulong Size); + private record struct MemberFunctionTypeInfo(MemberFunctionTypeDescriptor MemberDescriptor, uint[] ArgumentTypes, bool IsStatic); + public delegate (string SectionSymbolName, long Address) ResolveStaticVariable(string name); private readonly NameMangler _nameMangler; private readonly TargetArchitecture _architecture; @@ -27,7 +27,6 @@ private sealed record MemberFunctionTypeInfo(MemberFunctionTypeDescriptor Member private readonly int _frameRegister; private readonly byte _minimumInstructionLength; private readonly RelocType _codeRelocType; - private readonly bool _isOSXLike; private readonly Dictionary _lineSequences = new(); private readonly Dictionary _fileNameMap = new(); // fileName -> _fileNames index (1-based) @@ -53,7 +52,6 @@ public DwarfBuilder( _nameMangler = nameMangler; _architecture = target.Architecture; _useDwarf5 = useDwarf5; - _isOSXLike = target.IsOSXLike; _minimumInstructionLength = (byte)target.MinimumCodeAlignment; switch (target.Architecture) @@ -92,7 +90,6 @@ public DwarfBuilder( public int FrameRegister => _frameRegister; public uint ResolveOffset(uint typeIndex) => typeIndex == 0 ? 0u : _dwarfTypeOffsets[typeIndex - 1]; - public string ExternCName(string name) => _isOSXLike ? "_" + name : name; public void Write( SectionWriter infoSectionWriter, @@ -101,9 +98,16 @@ public void Write( SectionWriter locSectionWriter, SectionWriter rangeSectionWriter, SectionWriter lineSectionWriter, - SectionWriter arangeSectionWriter) + SectionWriter arangeSectionWriter, + ResolveStaticVariable resolveStaticVariable) { - WriteInfoTable(infoSectionWriter, stringSectionWriter, abbrevSectionWriter, locSectionWriter, rangeSectionWriter); + WriteInfoTable( + infoSectionWriter, + stringSectionWriter, + abbrevSectionWriter, + locSectionWriter, + rangeSectionWriter, + resolveStaticVariable); WriteLineInfoTable(lineSectionWriter); WriteAddressRangeTable(arangeSectionWriter); } @@ -113,7 +117,8 @@ public void WriteInfoTable( SectionWriter stringSectionWriter, SectionWriter abbrevSectionWriter, SectionWriter locSectionWriter, - SectionWriter rangeSectionWriter) + SectionWriter rangeSectionWriter, + ResolveStaticVariable resolveStaticVariable) { // Length byte[] sizeBuffer = new byte[sizeof(uint)]; @@ -144,7 +149,7 @@ public void WriteInfoTable( this, _codeRelocType)) { - dwarfInfoWriter.WriteStartDIE(/*_isOSXLike ? DwarfAbbrev.CompileUnitNoRanges :*/ DwarfAbbrev.CompileUnit); + dwarfInfoWriter.WriteStartDIE(DwarfAbbrev.CompileUnit); // DW_AT_producer dwarfInfoWriter.WriteStringReference("NetRuntime"); @@ -183,7 +188,11 @@ public void WriteInfoTable( foreach (DwarfStaticVariableInfo staticField in _staticFields) { - staticField.Dump(dwarfInfoWriter); + (string sectionSymbolName, long address) = resolveStaticVariable(staticField.Name); + if (sectionSymbolName is not null) + { + staticField.Dump(dwarfInfoWriter, sectionSymbolName, address); + } } dwarfInfoWriter.WriteEndDIE(); @@ -405,6 +414,8 @@ public string GetMangledName(TypeDesc type) public void EmitSubprogramInfo( string methodName, + string sectionSymbolName, + long methodAddress, int methodPCLength, uint methodTypeIndex, IEnumerable<(DebugVarInfoMetadata, uint)> debugVars, @@ -419,14 +430,19 @@ public void EmitSubprogramInfo( memberFunction.LinkageName = methodName; _dwarfSubprograms.Add(new DwarfSubprogramInfo( - methodName, + sectionSymbolName, + methodAddress, methodPCLength, memberFunction, debugVars.ToArray(), debugEHClauseInfos)); } - public void EmitLineInfo(int sectionIndex, string sectionSymbolName, ulong methodAddress, IEnumerable sequencePoints) + public void EmitLineInfo( + int sectionIndex, + string sectionSymbolName, + long methodAddress, + IEnumerable sequencePoints) { DwarfLineSequenceWriter lineSequence; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 57ec90cea0aa12..d7f72498b58640 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -17,9 +17,8 @@ namespace ILCompiler.ObjectWriter public sealed class ElfObjectWriter : UnixObjectWriter { private readonly ElfObjectFile _objectFile; - private int _sectionIndex; private readonly Dictionary _bssStreams = new(); - private readonly Dictionary _sectionIndexToElfSection = new(); + private readonly List _sections = new(); private readonly Dictionary _elfSectionToSectionIndex = new(); private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); private readonly Dictionary _sectionToRelocationTable = new(); @@ -52,6 +51,7 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa string sectionName = section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith('_') || section.Name.StartsWith('.') ? section.Name : "." + section.Name); + int sectionIndex = _sections.Count; if (comdatName is not null && !_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) @@ -74,7 +74,7 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write, }; - _bssStreams[_sectionIndex] = sectionStream; + _bssStreams[sectionIndex] = sectionStream; } else if (section == ObjectNodeSection.TLSSection) { @@ -108,8 +108,8 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa _debugSections.Add(elfSection); } - _elfSectionToSectionIndex[elfSection] = _sectionIndex; - _sectionIndexToElfSection[_sectionIndex++] = elfSection; + _elfSectionToSectionIndex[elfSection] = sectionIndex; + _sections.Add(elfSection); groupSection?.AddSection(elfSection); base.CreateSection(section, comdatName, symbolName ?? elfSection.Name.Value, sectionStream); @@ -117,17 +117,17 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; + ElfSection elfSection = _sections[sectionIndex]; elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); } protected internal override void EmitRelocation( int sectionIndex, - int offset, + long offset, Span data, RelocType relocType, string symbolName, - int addend) + long addend) { // We read the addend from the data and clear it. This is necessary // to produce correct addends in the `.rela` sections which override @@ -145,7 +145,7 @@ protected internal override void EmitRelocation( else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) { ulong a = BinaryPrimitives.ReadUInt64LittleEndian(data); - addend += checked((int)a); + addend += checked((long)a); BinaryPrimitives.WriteUInt64LittleEndian(data, 0); } else if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || @@ -169,15 +169,16 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - protected override void EmitSymbolTable() + protected override void EmitSymbolTable( + IDictionary definedSymbols, + SortedSet undefinedSymbols) { uint symbolIndex = (uint)_symbolTable.Entries.Count; - IDictionary definedSymbols = GetDefinedSymbols(); List sortedSymbols = new(definedSymbols.Count); foreach ((string name, SymbolDefinition definition) in definedSymbols) { - ElfSection elfSection = _sectionIndexToElfSection[definition.SectionIndex]; + ElfSection elfSection = _sections[definition.SectionIndex]; sortedSymbols.Add(new ElfSymbol { Name = name, @@ -192,7 +193,7 @@ protected override void EmitSymbolTable() }); } - foreach (string externSymbol in GetUndefinedSymbols()) + foreach (string externSymbol in undefinedSymbols) { if (!_symbolNameToIndex.ContainsKey(externSymbol)) { @@ -237,7 +238,7 @@ protected override void EmitRelocations(int sectionIndex, List relocationList) { - ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; + ElfSection elfSection = _sections[sectionIndex]; if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) { foreach (SymbolicRelocation symbolicRelocation in relocationList) @@ -261,14 +262,12 @@ private void EmitRelocationsARM64(int sectionIndex, List rel _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - int addend = symbolicRelocation.Addend; - relocationTable.Entries.Add(new ElfRelocation { SymbolIndex = symbolIndex, Type = type, Offset = (ulong)symbolicRelocation.Offset, - Addend = addend + Addend = symbolicRelocation.Addend }); } } @@ -280,7 +279,7 @@ private void EmitRelocationsARM64(int sectionIndex, List rel private void EmitRelocationsX64(int sectionIndex, List relocationList) { - ElfSection elfSection = _sectionIndexToElfSection[sectionIndex]; + ElfSection elfSection = _sections[sectionIndex]; if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) { foreach (SymbolicRelocation symbolicRelocation in relocationList) @@ -298,7 +297,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - int addend = symbolicRelocation.Addend; + long addend = symbolicRelocation.Addend; if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) { addend -= 4; @@ -319,9 +318,9 @@ private void EmitRelocationsX64(int sectionIndex, List reloc } } - protected override void EmitDebugSections() + protected override void EmitDebugSections(IDictionary definedSymbols) { - base.EmitDebugSections(); + base.EmitDebugSections(definedSymbols); foreach (ElfSection debugSection in _debugSections) { @@ -374,7 +373,7 @@ protected override void EmitSectionsAndLayout() } } - foreach (ElfSection elfSection in _sectionIndexToElfSection.Values) + foreach (ElfSection elfSection in _sections) { // If the section was not already added as part of COMDAT group, // add it now. @@ -389,7 +388,7 @@ protected override void EmitSectionsAndLayout() _objectFile.AddSection(new ElfSectionHeaderStringTable()); foreach ((int bssSectionIndex, Stream bssStream) in _bssStreams) { - _sectionIndexToElfSection[bssSectionIndex].Size = (ulong)bssStream.Length; + _sections[bssSectionIndex].Size = (ulong)bssStream.Length; } _objectFile.AddSection(new ElfBinarySection(Stream.Null) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index b9ae69c70ef219..f4e21edb836525 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -151,8 +151,6 @@ protected override void EmitSectionsAndLayout() _symbolNameToIndex[machSymbol.Name] = sectionIndex; sectionIndex++; } - - EmitCompactUnwindTable(); } protected override void EmitObjectFile(string objectFilePath) @@ -240,11 +238,11 @@ protected internal override void UpdateSectionAlignment(int sectionIndex, int al protected internal override void EmitRelocation( int sectionIndex, - int offset, + long offset, Span data, RelocType relocType, string symbolName, - int addend) + long addend) { if (relocType is RelocType.IMAGE_REL_BASED_DIR64 or RelocType.IMAGE_REL_BASED_HIGHLOW) { @@ -262,7 +260,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt64LittleEndian(data, addend); break; case RelocType.IMAGE_REL_BASED_HIGHLOW: - BinaryPrimitives.WriteInt32LittleEndian(data, addend); + BinaryPrimitives.WriteUInt32LittleEndian(data, (uint)addend); break; default: throw new NotSupportedException("Unsupported relocation in debug section"); @@ -270,32 +268,14 @@ protected internal override void EmitRelocation( return; } // DWARF section to code/data section relocation - else if (IsSectionSymbolName(symbolName)) + else { + Debug.Assert(IsSectionSymbolName(symbolName)); Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[targetSectionIndex].VirtualAddress + (ulong)addend); base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - // DWARF section to code/data symbol - else - { - Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); - IDictionary definedSymbols = GetDefinedSymbols(); - if (definedSymbols.TryGetValue(symbolName, out SymbolDefinition symbolDefinition)) - { - symbolName = $"lsection{symbolDefinition.SectionIndex}"; - BinaryPrimitives.WriteUInt64LittleEndian( - data, - _segment.Sections[symbolDefinition.SectionIndex].VirtualAddress + (ulong)symbolDefinition.Value); - base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); - } - else - { - Console.WriteLine($"DEBUG references undefined symbol: {symbolName}"); - return; - } - } return; } @@ -330,7 +310,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend - offset); + (int)(addend - offset)); } else if (sectionIndex == EhFrameSectionIndex) { @@ -339,7 +319,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend - offset); + (int)(addend - offset)); } else { @@ -349,7 +329,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); + (int)addend); } } addend = 0; @@ -362,7 +342,7 @@ protected internal override void EmitRelocation( BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - addend); + (int)addend); addend = 0; } } @@ -370,7 +350,9 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - protected override void EmitSymbolTable() + protected override void EmitSymbolTable( + IDictionary definedSymbols, + SortedSet undefinedSymbols) { // We already emitted symbols for all non-debug sections in EmitSectionsAndLayout, // these symbols are local and we need to account for them. @@ -379,7 +361,6 @@ protected override void EmitSymbolTable() _dySymbolTable.LocalSymbolsCount = symbolIndex; // Sort and insert all defined symbols - IDictionary definedSymbols = GetDefinedSymbols(); var sortedDefinedSymbols = new List(definedSymbols.Count); foreach ((string name, SymbolDefinition definition) in definedSymbols) { @@ -405,7 +386,7 @@ protected override void EmitSymbolTable() _dySymbolTable.ExternalSymbolsCount = (uint)definedSymbols.Count; uint savedSymbolIndex = symbolIndex; - foreach (string externSymbol in GetUndefinedSymbols()) + foreach (string externSymbol in undefinedSymbols) { var machSymbol = new MachSymbol { @@ -422,6 +403,8 @@ protected override void EmitSymbolTable() _dySymbolTable.UndefinedSymbolsIndex = _dySymbolTable.LocalSymbolsCount + _dySymbolTable.ExternalSymbolsCount; _dySymbolTable.UndefinedSymbolsCount = symbolIndex - savedSymbolIndex; + + EmitCompactUnwindTable(definedSymbols); } protected override void EmitRelocations(int sectionIndex, List relocationList) @@ -451,7 +434,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, RelocationType = MachRelocationType.X86_64Unsigned, @@ -464,7 +447,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, RelocationType = MachRelocationType.X86_64Subtractor, @@ -474,7 +457,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, RelocationType = MachRelocationType.X86_64Unsigned, @@ -487,7 +470,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, RelocationType = MachRelocationType.X86_64Branch, @@ -516,7 +499,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, RelocationType = MachRelocationType.Arm64Branch26, @@ -531,7 +514,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)symbolicRelocation.Addend, Length = 4, RelocationType = MachRelocationType.Arm64Addend, @@ -550,7 +533,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, RelocationType = type, @@ -564,7 +547,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, RelocationType = MachRelocationType.Arm64Unsigned, @@ -578,7 +561,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, RelocationType = MachRelocationType.Arm64Subtractor, @@ -588,7 +571,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel sectionRelocations.Add( new MachRelocation { - Address = symbolicRelocation.Offset, + Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, RelocationType = MachRelocationType.Arm64Unsigned, @@ -603,10 +586,9 @@ private void EmitRelocationsArm64(int sectionIndex, List rel } } - private void EmitCompactUnwindTable() + private void EmitCompactUnwindTable(IDictionary definedSymbols) { using Stream compactUnwindStream = _compactUnwindSection.GetWriteStream(); - IDictionary definedSymbols = GetDefinedSymbols(); IList symbols = _symbolTable.Symbols; Span tempBuffer = stackalloc byte[8]; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 252c0dd2800506..a36bea755e96ca 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -16,11 +16,11 @@ namespace ILCompiler.ObjectWriter public abstract class ObjectWriter : IDisposable { protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); - protected sealed record SymbolicRelocation(int Offset, RelocType Type, string SymbolName, int Addend = 0); + protected sealed record SymbolicRelocation(long Offset, RelocType Type, string SymbolName, long Addend = 0); protected readonly NodeFactory _nodeFactory; protected readonly ObjectWritingOptions _options; - protected readonly bool _isSingleFileCompilation; + private readonly bool _isSingleFileCompilation; private readonly Dictionary _mangledNameMap = new(); @@ -157,11 +157,11 @@ protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, s /// protected internal virtual void EmitRelocation( int sectionIndex, - int offset, + long offset, Span data, RelocType relocType, string symbolName, - int addend) + long addend) { _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } @@ -194,7 +194,7 @@ protected virtual void EmitReferencedMethod(string symbolName) { } protected internal void EmitSymbolDefinition( int sectionIndex, string symbolName, - int offset = 0, + long offset = 0, int size = 0, bool global = false) { @@ -206,7 +206,9 @@ protected internal void EmitSymbolDefinition( /// /// Emit symbolic definitions into object file symbols. /// - protected abstract void EmitSymbolTable(); + protected abstract void EmitSymbolTable( + IDictionary definedSymbols, + SortedSet undefinedSymbols); protected virtual string ExternCName(string name) => name; @@ -259,9 +261,7 @@ protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMe protected abstract void CreateEhSections(); - protected IDictionary GetDefinedSymbols() => _definedSymbols; - - protected ISet GetUndefinedSymbols() + private SortedSet GetUndefinedSymbols() { SortedSet undefinedSymbolSet = new SortedSet(StringComparer.Ordinal); foreach (var relocationList in _sectionIndexToRelocations) @@ -284,7 +284,7 @@ protected abstract void EmitDebugFunctionInfo( INodeWithDebugInfo debugNode, bool hasSequencePoints); - protected abstract void EmitDebugSections(); + protected abstract void EmitDebugSections(IDictionary definedSymbols); protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) { @@ -418,10 +418,10 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection relocationList in _sectionIndexToRelocations) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index 8fa49a462ec3d0..5d7e8f23ac189f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -37,15 +37,15 @@ public readonly void EmitAlignment(int alignment) } public readonly void EmitRelocation( - int relativeOffset, + long relativeOffset, Span data, RelocType relocType, string symbolName, - int addend) + long addend) { _objectWriter.EmitRelocation( SectionIndex, - (int)Stream.Position + relativeOffset, + Stream.Position + relativeOffset, data, relocType, symbolName, @@ -54,14 +54,14 @@ public readonly void EmitRelocation( public readonly void EmitSymbolDefinition( string symbolName, - int relativeOffset = 0, + long relativeOffset = 0, int size = 0, bool global = false) { _objectWriter.EmitSymbolDefinition( SectionIndex, symbolName, - (int)Stream.Position + relativeOffset, + Stream.Position + relativeOffset, size, global); } @@ -69,13 +69,13 @@ public readonly void EmitSymbolDefinition( public readonly void EmitSymbolReference( RelocType relocType, string symbolName, - int addend = 0) + long addend = 0) { Span buffer = stackalloc byte[relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint)]; buffer.Clear(); _objectWriter.EmitRelocation( SectionIndex, - (int)Stream.Position, + Stream.Position, buffer, relocType, symbolName, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 2a831bfd277bc5..38899685ea1f3f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -30,6 +30,13 @@ private sealed record SectionDefinition(string SymbolName, Stream SectionStream) private static ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null); private static ObjectNodeSection EhFrameSection = new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null); + private readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); + private readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); + private readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); + private readonly ObjectNodeSection DebugLocSection = new ObjectNodeSection(".debug_loc", SectionType.Debug); + private readonly ObjectNodeSection DebugRangesSection = new ObjectNodeSection(".debug_ranges", SectionType.Debug); + private readonly ObjectNodeSection DebugLineSection = new ObjectNodeSection(".debug_line", SectionType.Debug); + private readonly ObjectNodeSection DebugARangesSection = new ObjectNodeSection(".debug_aranges", SectionType.Debug); protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) @@ -165,32 +172,29 @@ protected override void EmitDebugFunctionInfo( clauses = nodeWithCodeInfo.DebugEHClauseInfos; } - _dwarfBuilder.EmitSubprogramInfo( - methodName, - methodSymbol.Size, - methodTypeIndex, - debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), - clauses ?? []); - - if (hasSequencePoints && _sections[methodSymbol.SectionIndex] is SectionDefinition section) + if (_sections[methodSymbol.SectionIndex] is SectionDefinition section) { - _dwarfBuilder.EmitLineInfo( - methodSymbol.SectionIndex, + _dwarfBuilder.EmitSubprogramInfo( + methodName, section.SymbolName, - (ulong)methodSymbol.Value, - debugNode.GetNativeSequencePoints()); + methodSymbol.Value, + methodSymbol.Size, + methodTypeIndex, + debugNode.GetDebugVars().Select(debugVar => (debugVar, GetVarTypeIndex(debugNode.IsStateMachineMoveNextMethod, debugVar))), + clauses ?? []); + + if (hasSequencePoints) + { + _dwarfBuilder.EmitLineInfo( + methodSymbol.SectionIndex, + section.SymbolName, + methodSymbol.Value, + debugNode.GetNativeSequencePoints()); + } } } - private readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); - private readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); - private readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); - private readonly ObjectNodeSection DebugLocSection = new ObjectNodeSection(".debug_loc", SectionType.Debug); - private readonly ObjectNodeSection DebugRangesSection = new ObjectNodeSection(".debug_ranges", SectionType.Debug); - private readonly ObjectNodeSection DebugLineSection = new ObjectNodeSection(".debug_line", SectionType.Debug); - private readonly ObjectNodeSection DebugARangesSection = new ObjectNodeSection(".debug_aranges", SectionType.Debug); - - protected override void EmitDebugSections() + protected override void EmitDebugSections(IDictionary definedSymbols) { foreach (SectionDefinition section in _sections) { @@ -215,7 +219,16 @@ protected override void EmitDebugSections() locSectionWriter, rangeSectionWriter, lineSectionWriter, - arangeSectionWriter); + arangeSectionWriter, + symbolName => + { + if (definedSymbols.TryGetValue(ExternCName(symbolName), out SymbolDefinition symbolDef) && + _sections[symbolDef.SectionIndex] is SectionDefinition section) + { + return (section.SymbolName, symbolDef.Value); + } + return (null, 0); + }); } protected override void CreateEhSections() From 8530c75a16b7d348137976901614dec1dd4bdb4e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 12:17:26 +0200 Subject: [PATCH 086/144] Revert accidental change --- src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj index 742ae9d27a2b6e..d3ccae71ef5cb4 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj @@ -81,7 +81,6 @@ - Date: Mon, 23 Oct 2023 13:42:01 +0200 Subject: [PATCH 087/144] Update LibObjectFile to version 0.5.0. --- .../aot/external/LibObjectFile/readme.md | 3 +- .../LibObjectFile.CodeGen.csproj | 4 +- .../LibObjectFile.Tests/Dwarf/DwarfTests.cs | 10 +- .../LibObjectFile.Tests/Elf/ElfSimpleTests.cs | 57 +++++++ .../LibObjectFile.Tests.csproj | 9 +- .../src/LibObjectFile.Tests/LinuxUtil.cs | 2 +- .../LibObjectFile/src/LibObjectFile.sln | 2 +- .../src/LibObjectFile/DiagnosticId.cs | 3 + .../src/LibObjectFile/Dwarf/DwarfAttribute.cs | 12 +- .../src/LibObjectFile/Dwarf/DwarfHelper.cs | 35 ++--- .../Dwarf/DwarfLineProgramTable.cs | 4 +- .../LibObjectFile/Dwarf/DwarfLocationList.cs | 23 +++ .../Dwarf/DwarfLocationListEntry.cs | 7 +- .../src/LibObjectFile/Elf/ElfObjectFile.cs | 33 +++-- .../src/LibObjectFile/Elf/ElfPrinter.cs | 29 ++-- .../LibObjectFile/Elf/ElfReader{TDecoder}.cs | 139 +++++++++++++++--- .../src/LibObjectFile/Elf/ElfSegmentRange.cs | 12 +- .../LibObjectFile/Elf/ElfWriter{TEncoder}.cs | 34 ++++- .../Elf/Sections/ElfNullSection.cs | 22 +-- .../Elf/Sections/ElfSymbolTable.cs | 40 ++++- .../ElfSymbolTableSectionHeaderIndices.cs | 126 ++++++++++++++++ .../src/LibObjectFile/LibObjectFile.csproj | 9 +- .../ObjectFileStreamExtensions.cs | 2 +- .../LibObjectFile/src/objdasm/objdasm.csproj | 4 +- 24 files changed, 488 insertions(+), 133 deletions(-) create mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs diff --git a/src/coreclr/tools/aot/external/LibObjectFile/readme.md b/src/coreclr/tools/aot/external/LibObjectFile/readme.md index 4af648d8b7f3a2..aa2467cbf1fbb0 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/readme.md +++ b/src/coreclr/tools/aot/external/LibObjectFile/readme.md @@ -51,7 +51,8 @@ elf.Write(outStream); - Integration with ELF to support easy reading/writing back - Support for relocatable sections - Use of a Diagnostics API to validate file format (on read/before write) -- Library requiring .NET `netstandard2.1`+ and compatible with `netcoreapp3.0`+ +- Library requiring `net7.0` + - If you are looking for `netstandard2.1` support you will need to use `0.4.0` version ## Documentation diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj index 0e8fa3e0eae47b..8c186f55fc2799 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj @@ -1,6 +1,6 @@  - net6.0 + net7.0 Exe false @@ -11,7 +11,7 @@ - + PreserveNewest diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs index 6a159ab29a917c..1793215c6da971 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs @@ -80,7 +80,7 @@ public void TestDebugLineHelloWorld() { var cppName = "helloworld"; var cppExe = $"{cppName}_debug"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -o {cppExe}"); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -o {cppExe}"); ElfObjectFile elf; using (var inStream = File.OpenRead(cppExe)) @@ -139,7 +139,7 @@ public void TestDebugLineLibMultipleObjs() { var cppName = "lib"; var libShared = $"{cppName}_debug.so"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}_a.cpp {cppName}_b.cpp -g -shared -o {libShared}"); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}_a.cpp {cppName}_b.cpp -gdwarf-4 -shared -o {libShared}"); ElfObjectFile elf; using (var inStream = File.OpenRead(libShared)) @@ -198,7 +198,7 @@ public void TestDebugLineSmall() { var cppName = "small"; var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); ElfObjectFile elf; using (var inStream = File.OpenRead(cppObj)) { @@ -256,7 +256,7 @@ public void TestDebugLineMultipleFunctions() { var cppName = "multiple_functions"; var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); ElfObjectFile elf; using (var inStream = File.OpenRead(cppObj)) @@ -314,7 +314,7 @@ public void TestDebugInfoSmall() { var cppName = "small"; var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -g -c -o {cppObj}"); + LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); ElfObjectFile elf; using (var inStream = File.OpenRead(cppObj)) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs index 658975d0b559ec..75e36f51dd220a 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs @@ -421,5 +421,62 @@ public void TestAlignedSection() Assert.AreEqual(alignedSection.UpperAlignment, codeSection.Offset, "Invalid alignment"); } + + [Test] + public void TestManySections() + { + var elf = new ElfObjectFile(ElfArch.X86_64); + var stringTable = new ElfStringTable(); + var symbolTable = new ElfSymbolTable { Link = stringTable }; + + for (int i = 0; i < ushort.MaxValue; i++) + { + var section = new ElfBinarySection { Name = $".section{i}" }; + elf.AddSection(section); + symbolTable.Entries.Add(new ElfSymbol { Type = ElfSymbolType.Section, Section = section }); + } + + elf.AddSection(stringTable); + elf.AddSection(symbolTable); + elf.AddSection(new ElfSectionHeaderStringTable()); + + var diagnostics = elf.Verify(); + Assert.True(diagnostics.HasErrors); + Assert.AreEqual(DiagnosticId.ELF_ERR_MissingSectionHeaderIndices, diagnostics.Messages[0].Id); + + elf.AddSection(new ElfSymbolTableSectionHeaderIndices { Link = symbolTable }); + diagnostics = elf.Verify(); + Assert.False(diagnostics.HasErrors); + + uint visibleSectionCount = elf.VisibleSectionCount; + + using (var outStream = File.OpenWrite("manysections")) + { + elf.Write(outStream); + outStream.Flush(); + } + + using (var inStream = File.OpenRead("manysections")) + { + elf = ElfObjectFile.Read(inStream); + } + + Assert.AreEqual(visibleSectionCount, elf.VisibleSectionCount); + Assert.True(elf.Sections[0] is ElfNullSection); + Assert.True(elf.Sections[1] is ElfProgramHeaderTable); + + for (int i = 0; i < ushort.MaxValue; i++) + { + Assert.True(elf.Sections[i + 2] is ElfBinarySection); + Assert.AreEqual($".section{i}", elf.Sections[i + 2].Name.Value); + } + + Assert.True(elf.Sections[ushort.MaxValue + 3] is ElfSymbolTable); + symbolTable = (ElfSymbolTable)elf.Sections[ushort.MaxValue + 3]; + for (int i = 0; i < ushort.MaxValue; i++) + { + Assert.AreEqual($".section{i}", symbolTable.Entries[i + 1].Section.Section.Name.Value); + } + } } } \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj index 094beb5118c2a1..924e41dbe0e5d6 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj @@ -1,8 +1,7 @@  - net6.0 - 8.0 + net7.0 true false @@ -38,9 +37,9 @@ - - - + + + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs index 77cfe3bd70fe45..06205fcb0d3562 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs @@ -17,7 +17,7 @@ public static string ReadElf(string file, string arguments = "-W -a") return RunLinuxExe("readelf", $"{file} {arguments}"); } - public static string RunLinuxExe(string exe, string arguments, string distribution = "Ubuntu-18.04") + public static string RunLinuxExe(string exe, string arguments, string distribution = "Ubuntu") { if (exe == null) throw new ArgumentNullException(nameof(exe)); if (arguments == null) throw new ArgumentNullException(nameof(arguments)); diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln index 494ef1b06cfe77..91e14458030749 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln @@ -13,8 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject ..\.gitignore = ..\.gitignore ..\changelog.md = ..\changelog.md - ..\.github\workflows\CI.yml = ..\.github\workflows\CI.yml Directory.Build.props = Directory.Build.props + ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml dotnet-releaser.toml = dotnet-releaser.toml ..\license.txt = ..\license.txt ..\readme.md = ..\readme.md diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs index 6f2c645577881b..170dd8443015ba 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs @@ -69,6 +69,8 @@ public enum DiagnosticId ELF_ERR_InvalidStreamForSectionNoBits = 156, ELF_ERR_InvalidNullSection = 157, ELF_ERR_InvalidAlignmentOutOfRange = 158, + ELF_ERR_MissingSectionHeaderIndices = 159, + ELF_ERR_MissingNullSection = 159, AR_ERR_InvalidMagicLength = 1000, AR_ERR_MagicNotFound = 1001, @@ -110,6 +112,7 @@ public enum DiagnosticId DWARF_ERR_InvalidParentUnitForAddressRangeTable = 2017, DWARF_ERR_InvalidParentForDIE = 2018, DWARF_WRN_InvalidExtendedOpCodeLength = 2019, + DWARF_ERR_InvalidParentForLocationList = 2020, } } \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs index 7ccaaccb185001..db0c381574bbd8 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs @@ -88,13 +88,23 @@ public override void Verify(DiagnosticBag diagnostics) if (thisSection != attrSection) { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForDIE, $"Invalid parent for the DIE {attrDIE} referenced by the attribute {this}. It must be within the same parent {attrSection.GetType()}."); + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForDIE, $"Invalid parent for the DIE {attrDIE} referenced by the attribute {this}. It must be within the same parent {thisSection.GetType()}."); } } else if (ValueAsObject is DwarfExpression expr) { expr.Verify(diagnostics); } + else if (ValueAsObject is DwarfLocationList locationList) + { + var thisSection = this.GetParentFile(); + var locationListSection = locationList.GetParentFile(); + + if (thisSection != locationListSection) + { + diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForLocationList, $"Invalid parent for the LocationList {locationList} referenced by the attribute {this}. It must be within the same parent {thisSection.GetType()}."); + } + } } public int CompareTo(DwarfAttribute other) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs index eedb5fc5a226ed..daad1a95ae35e2 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs @@ -3,6 +3,7 @@ // See the license.txt file in the project root for more information. using System.Text; +using System.Numerics; namespace LibObjectFile.Dwarf { @@ -31,35 +32,21 @@ public static uint SizeOfUInt(DwarfAddressSize addressSize) public static uint SizeOfULEB128(ulong value) { - if (value == 0) return 1; + // bits_to_encode = (data != 0) ? 64 - CLZ(x) : 1 = 64 - CLZ(data | 1) + // bytes = ceil(bits_to_encode / 7.0); = (6 + bits_to_encode) / 7 + uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); - uint sizeOf = 0; - while (value != 0) - { - value >>= 7; - sizeOf++; - } - - return sizeOf; + // Division by 7 is done by (x * 37) >> 8 where 37 = ceil(256 / 7). + // This works for 0 <= x < 256 / (7 * 37 - 256), i.e. 0 <= x <= 85. + return (x * 37) >> 8; } public static uint SizeOfILEB128(long value) { - if (value == 0) return 1; - uint sizeOf = 0; - while (true) - { - sizeOf++; - var b = (byte) value; - value >>= 7; - bool isSignBitSet = (b & 0x40) != 0; - if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) - { - break; - } - } - - return sizeOf; + // The same as SizeOfULEB128 calculation but we have to account for the sign bit. + value ^= value >> 63; + uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)value | 1UL); + return (x * 37) >> 8; } public static DwarfAttributeEncoding GetAttributeEncoding(DwarfAttributeKindEx kind) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs index 6e6c09e590f230..185f5d3a00dc59 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs @@ -710,7 +710,7 @@ protected override void UpdateLayout(DwarfLayoutContext layoutContext) { sizeOf += DwarfHelper.SizeOfULEB128(opcodeLength); } - + // Write directory names _directoryNameToIndex.Clear(); _directoryNames.Clear(); @@ -1373,4 +1373,4 @@ public override string ToString() return $"Section .debug_line, {nameof(Version)}: {Version}, {nameof(Is64BitEncoding)}: {Is64BitEncoding}, {nameof(FileNames)}: {FileNames.Count}, {nameof(LineSequences)}: {LineSequences.Count}"; } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs index 8a5f373647df92..d7ab162ca313ed 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs @@ -2,6 +2,7 @@ // This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. +using System.Text; using System.Collections.Generic; namespace LibObjectFile.Dwarf @@ -80,5 +81,27 @@ protected override void Write(DwarfWriter writer) writer.WriteUInt(0); writer.WriteUInt(0); } + + public override string ToString() + { + var builder = new StringBuilder(); + + for (int i = 0; i < _locationListEntries.Count; i++) + { + if (i == 3) + { + builder.Append(", ..."); + return builder.ToString(); + } + else if (i != 0) + { + builder.Append(", "); + } + + builder.Append(_locationListEntries[i].ToString()); + } + + return builder.ToString(); + } } } \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs index d3c262f84a81fc..829acb2a86074d 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs @@ -76,5 +76,10 @@ protected override void Write(DwarfWriter writer) Expression.WriteInternal(writer, inLocationSection: true); } } + + public override string ToString() + { + return $"Location: {Start:x} - {End:x} {Expression}"; + } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs index 3e72ad045588cf..a21f0ba71a7d42 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs @@ -179,6 +179,12 @@ public override void Verify(DiagnosticBag diagnostics) diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderFileClassNone, $"Cannot compute the layout with an {nameof(ElfObjectFile)} having a {nameof(FileClass)} == {ElfFileClass.None}"); } + if (VisibleSectionCount >= ElfNative.SHN_LORESERVE && + Sections[0] is not ElfNullSection) + { + diagnostics.Error(DiagnosticId.ELF_ERR_MissingNullSection, $"Section count is higher than SHN_LORESERVE ({ElfNative.SHN_LORESERVE}) but the first section is not a NULL section"); + } + foreach (var segment in Segments) { segment.Verify(diagnostics); @@ -230,8 +236,6 @@ public unsafe void UpdateLayout(DiagnosticBag diagnostics) var section = sections[i]; if (i == 0 && section.Type == ElfSectionType.Null) { - section.Size = VisibleSectionCount >= ElfNative.SHN_LORESERVE ? VisibleSectionCount : 0; - section.Link = (SectionHeaderStringTable?.SectionIndex ?? 0) >= ElfNative.SHN_LORESERVE ? SectionHeaderStringTable : null; continue; } @@ -255,12 +259,23 @@ public unsafe void UpdateLayout(DiagnosticBag diagnostics) shstrTable.Reset(); // Prepare all section names (to calculate the name indices and the size of the SectionNames) - for (var j = 0; j < sections.Count; j++) + // Do it in two passes to generate optimal string table + for (var pass = 0; pass < 2; pass++) { - var otherSection = sections[j]; - if ((j == 0 && otherSection.Type == ElfSectionType.Null)) continue; - if (otherSection.IsShadow) continue; - otherSection.Name = otherSection.Name.WithIndex(shstrTable.GetOrCreateIndex(otherSection.Name)); + for (var j = 0; j < sections.Count; j++) + { + var otherSection = sections[j]; + if ((j == 0 && otherSection.Type == ElfSectionType.Null)) continue; + if (otherSection.IsShadow) continue; + if (pass == 0) + { + shstrTable.ReserveString(otherSection.Name); + } + else + { + otherSection.Name = otherSection.Name.WithIndex(shstrTable.GetOrCreateIndex(otherSection.Name)); + } + } } } @@ -278,9 +293,9 @@ public unsafe void UpdateLayout(DiagnosticBag diagnostics) } // The Section Header Table will be put just after all the sections - Layout.OffsetOfSectionHeaderTable = offset; + Layout.OffsetOfSectionHeaderTable = AlignHelper.AlignToUpper(offset, FileClass == ElfFileClass.Is32 ? 4u : 8u); - Layout.TotalSize = offset + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; + Layout.TotalSize = Layout.OffsetOfSectionHeaderTable + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; } // Update program headers with offsets from auto layout diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs index 631b1b2123af69..f6666b33f962e7 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs @@ -68,7 +68,14 @@ public static void PrintElfHeader(ElfObjectFile elf, TextWriter writer) writer.WriteLine($" Size of program headers: {elf.Layout.SizeOfProgramHeaderEntry} (bytes)"); writer.WriteLine($" Number of program headers: {elf.Segments.Count}"); writer.WriteLine($" Size of section headers: {elf.Layout.SizeOfSectionHeaderEntry} (bytes)"); - writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}"); + if (elf.VisibleSectionCount >= ElfNative.SHN_LORESERVE || elf.VisibleSectionCount == 0) + { + writer.WriteLine($" Number of section headers: 0 ({elf.VisibleSectionCount})"); + } + else + { + writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}"); + } writer.WriteLine($" Section header string table index: {elf.SectionHeaderStringTable?.SectionIndex ?? 0}"); } @@ -97,7 +104,7 @@ public static void PrintSectionHeaders(ElfObjectFile elf, TextWriter writer) W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), - l (large), p (processor specific)"); + D (mbind), l (large), p (processor specific)"); } public static void PrintSectionGroups(ElfObjectFile elf, TextWriter writer) @@ -105,13 +112,6 @@ public static void PrintSectionGroups(ElfObjectFile elf, TextWriter writer) if (elf == null) throw new ArgumentNullException(nameof(elf)); if (writer == null) throw new ArgumentNullException(nameof(writer)); - if (elf.Sections.Count == 0) - { - writer.WriteLine(); - writer.WriteLine("There are no sections to group in this file."); - return; - } - writer.WriteLine(); writer.WriteLine("There are no section groups in this file."); // TODO @@ -252,8 +252,15 @@ public static void PrintUnwind(ElfObjectFile elf, TextWriter writer) if (elf == null) throw new ArgumentNullException(nameof(elf)); if (writer == null) throw new ArgumentNullException(nameof(writer)); - writer.WriteLine(); - writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported."); + if (elf.Arch == ElfArchEx.I386 || elf.Arch == ElfArchEx.X86_64) + { + writer.WriteLine("No processor specific unwind information to decode"); + } + else + { + writer.WriteLine(); + writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported."); + } } diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs index 6f5edecc11cb92..2ddcd836b1385b 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; +using static System.Collections.Specialized.BitVector32; namespace LibObjectFile.Elf { @@ -17,8 +18,8 @@ internal abstract class ElfReader : ElfReader where TDecoder : struct, private TDecoder _decoder; private ulong _startOfFile; private ushort _programHeaderCount; - private ushort _sectionHeaderCount; - private ushort _sectionStringTableIndex; + private uint _sectionHeaderCount; + private uint _sectionStringTableIndex; private bool _isFirstSectionValidNull; private bool _hasValidSectionStringTable; @@ -193,7 +194,7 @@ private ElfSegment ReadProgramHeader64(int phdrIndex) private void ReadSections() { - if (_sectionHeaderCount == 0) return; + if (Layout.OffsetOfSectionHeaderTable == 0) return; // Write section header table ReadSectionHeaderTable(); @@ -210,9 +211,25 @@ private void ReadSectionHeaderTable() return; } - for (int i = 0; i < _sectionHeaderCount; i++) + uint i = 0; + + if (_sectionHeaderCount == 0) + { + // We are dealing with an object file that has more than SHN_LORESERVE + // (0xff00) sections. It has to begin with a NULL section header where + // its Size contains the real number of sections, and Link optionally + // points to string table section if it's section index is too high. + if (ReadExtendedNullSectionTableEntry()) + { + i = 1; + ObjectFile.AddSection(new ElfNullSection()); + _isFirstSectionValidNull = true; + } + } + + for (; i < _sectionHeaderCount; i++) { - var offset = Layout.OffsetOfSectionHeaderTable + (ulong)i * Layout.SizeOfSectionHeaderEntry; + var offset = Layout.OffsetOfSectionHeaderTable + i * Layout.SizeOfSectionHeaderEntry; if (offset >= (ulong)Stream.Length) { @@ -228,12 +245,12 @@ private void ReadSectionHeaderTable() } } - private ElfSection ReadSectionTableEntry(int sectionIndex) + private ElfSection ReadSectionTableEntry(uint sectionIndex) { return ObjectFile.FileClass == ElfFileClass.Is32 ? ReadSectionTableEntry32(sectionIndex) : ReadSectionTableEntry64(sectionIndex); } - private ElfSection ReadSectionTableEntry32(int sectionIndex) + private ElfSection ReadSectionTableEntry32(uint sectionIndex) { var streamOffset = Stream.Position; if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Shdr rawSection)) @@ -267,7 +284,7 @@ private ElfSection ReadSectionTableEntry32(int sectionIndex) return section; } - private ElfSection ReadSectionTableEntry64(int sectionIndex) + private ElfSection ReadSectionTableEntry64(uint sectionIndex) { var streamOffset = Stream.Position; if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Shdr rawSection)) @@ -300,13 +317,75 @@ private ElfSection ReadSectionTableEntry64(int sectionIndex) return section; } + + private bool ReadExtendedNullSectionTableEntry() + { + uint sh_type; + ulong sh_size; + uint sh_link; + bool isNull; + + Stream.Position = (long)Layout.OffsetOfSectionHeaderTable; + + if (ObjectFile.FileClass == ElfFileClass.Is32) + { + + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Shdr rawSection32)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader32Size, $"Unable to read entirely NULL section header. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {Layout.OffsetOfSectionHeaderTable} from the stream"); + return false; + } + + sh_type = _decoder.Decode(rawSection32.sh_type); + sh_size = _decoder.Decode(rawSection32.sh_size); + sh_link = _decoder.Decode(rawSection32.sh_link); + rawSection32.sh_size = 0; + rawSection32.sh_link = 0; + isNull = rawSection32.IsNull; + } + else + { + if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Shdr rawSection64)) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader64Size, $"Unable to read entirely NULL section header. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {Layout.OffsetOfSectionHeaderTable} from the stream"); + return false; + } + + sh_type = _decoder.Decode(rawSection64.sh_type); + sh_size = _decoder.Decode(rawSection64.sh_size); + sh_link = _decoder.Decode(rawSection64.sh_link); + rawSection64.sh_size = 0; + rawSection64.sh_link = 0; + isNull = rawSection64.IsNull; + } + + if (!isNull) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSectionExpectingUndefined, $"Invalid Section [0] {(ElfSectionType)sh_type}. Expecting {ElfNative.SHN_UNDEF}"); + return false; + } + + if (sh_size >= uint.MaxValue) + { + Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderCount, $"Extended section count [{sh_size}] exceeds {uint.MaxValue}"); + return false; + } + + _sectionHeaderCount = (uint)sh_size; + if (_sectionStringTableIndex == ElfNative.SHN_XINDEX) + { + _sectionStringTableIndex = sh_link; + } + + return true; + } public override ElfSectionLink ResolveLink(ElfSectionLink link, string errorMessageFormat) { if (errorMessageFormat == null) throw new ArgumentNullException(nameof(errorMessageFormat)); // Connect section Link instance - if (!link.IsSpecial) + if (!link.IsEmpty) { if (link.SpecialIndex == _sectionStringTableIndex) { @@ -317,13 +396,21 @@ public override ElfSectionLink ResolveLink(ElfSectionLink link, string errorMess var sectionIndex = link.SpecialIndex; bool sectionFound = false; - foreach (var section in ObjectFile.Sections) + if (sectionIndex < ObjectFile.Sections.Count && ObjectFile.Sections[(int)sectionIndex].SectionIndex == sectionIndex) { - if (section.SectionIndex == sectionIndex) + link = new ElfSectionLink(ObjectFile.Sections[(int)sectionIndex]); + sectionFound = true; + } + else + { + foreach (var section in ObjectFile.Sections) { - link = new ElfSectionLink(section); - sectionFound = true; - break; + if (section.SectionIndex == sectionIndex) + { + link = new ElfSectionLink(section); + sectionFound = true; + break; + } } } @@ -425,7 +512,7 @@ private void VerifyAndFixProgramHeadersAndSections() // Make sure to pre-sort all sections by offset var orderedSections = new List(ObjectFile.Sections.Count); orderedSections.AddRange(ObjectFile.Sections); - orderedSections.Sort(CompareSectionOffsetsDelegate); + orderedSections.Sort(CompareSectionOffsetsAndSizesDelegate); // Store the stream index to recover the same order when saving back. for(int i = 0; i < orderedSections.Count; i++) { @@ -461,10 +548,10 @@ private void VerifyAndFixProgramHeadersAndSections() lastOffset = section.Offset + section.Size - 1; // Verify overlapping sections and generate and error - for (int j = i + 1; j < orderedSections.Count; j++) + if (i + 1 < orderedSections.Count) { - var otherSection = orderedSections[j]; - if (section.Contains(otherSection) || otherSection.Contains(section)) + var otherSection = orderedSections[i + 1]; + if (otherSection.Offset < section.Offset + section.Size) { Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidOverlappingSections, $"The section {section} [{section.Offset} : {section.Offset + section.Size - 1}] is overlapping with the section {otherSection} [{otherSection.Offset} : {otherSection.Offset + otherSection.Size - 1}]"); } @@ -609,7 +696,7 @@ private void VerifyAndFixProgramHeadersAndSections() } } - private ElfSection CreateElfSection(int sectionIndex, ElfSectionType sectionType, bool isNullSection) + private ElfSection CreateElfSection(uint sectionIndex, ElfSectionType sectionType, bool isNullSection) { ElfSection section = null; @@ -644,6 +731,9 @@ private ElfSection CreateElfSection(int sectionIndex, ElfSectionType sectionType case ElfSectionType.Note: section = new ElfNoteTable(); break; + case ElfSectionType.SymbolTableSectionHeaderIndices: + section = new ElfSymbolTableSectionHeaderIndices(); + break; } // If the section is not a builtin section, try to offload to a delegate @@ -754,11 +844,16 @@ public override ushort Decode(ElfNative.Elf64_Versym src) return _decoder.Decode(src); } - private static readonly Comparison CompareSectionOffsetsDelegate = new Comparison(CompareSectionOffsets); + private static readonly Comparison CompareSectionOffsetsAndSizesDelegate = new Comparison(CompareSectionOffsetsAndSizes); - private static int CompareSectionOffsets(ElfSection left, ElfSection right) + private static int CompareSectionOffsetsAndSizes(ElfSection left, ElfSection right) { - return left.Offset.CompareTo(right.Offset); + int result = left.Offset.CompareTo(right.Offset); + if (result == 0) + { + result = left.Size.CompareTo(right.Size); + } + return result; } } } \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs index 4ad4805136558d..e33ffb4287a2c5 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs @@ -99,17 +99,7 @@ public ulong Size return 0; } - var parent = BeginSection.Parent; - ulong size = 0; - for (uint i = BeginSection.Index; i < EndSection.Index; i++) - { - var section = parent.Sections[(int)i]; - if (section.HasContent) - { - size += section.Size; - } - } - + ulong size = EndSection.Offset - BeginSection.Offset; size -= BeginOffset; size += EndOffset < 0 ? (ulong)((long)EndSection.Size + EndOffset + 1) : (ulong)(EndOffset + 1); return size; diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs index 1bb1be65f8cd5e..de3c122820c012 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs @@ -230,10 +230,16 @@ private void WriteSections() private void WriteSectionHeaderTable() { var offset = (ulong)Stream.Position - _startOfFile; - if (offset != Layout.OffsetOfSectionHeaderTable) + var diff = Layout.OffsetOfSectionHeaderTable - offset; + if (diff < 0 || diff > 8) { throw new InvalidOperationException("Internal error. Unexpected offset for SectionHeaderTable"); } + else if (diff != 0) + { + // Alignment + Stream.Write(stackalloc byte[(int)diff]); + } // Then write all regular sections var sections = ObjectFile.Sections; @@ -265,8 +271,17 @@ private void WriteSectionTableEntry32(ElfSection section) _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); _encoder.Encode(out shdr.sh_addr, (uint)section.VirtualAddress); _encoder.Encode(out shdr.sh_offset, (uint)section.Offset); - _encoder.Encode(out shdr.sh_size, (uint)section.Size); - _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + if (section.Index == 0 && ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE) + { + _encoder.Encode(out shdr.sh_size, ObjectFile.VisibleSectionCount); + uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; + _encoder.Encode(out shdr.sh_link, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? shstrSectionIndex : 0); + } + else + { + _encoder.Encode(out shdr.sh_size, (uint)section.Size); + _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + } _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); _encoder.Encode(out shdr.sh_addralign, (uint)section.Alignment); _encoder.Encode(out shdr.sh_entsize, (uint)section.TableEntrySize); @@ -281,8 +296,17 @@ private void WriteSectionTableEntry64(ElfSection section) _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); _encoder.Encode(out shdr.sh_addr, section.VirtualAddress); _encoder.Encode(out shdr.sh_offset, section.Offset); - _encoder.Encode(out shdr.sh_size, section.Size); - _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + if (section.Index == 0 && ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE) + { + _encoder.Encode(out shdr.sh_size, ObjectFile.VisibleSectionCount); + uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; + _encoder.Encode(out shdr.sh_link, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? shstrSectionIndex : 0); + } + else + { + _encoder.Encode(out shdr.sh_size, section.Size); + _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); + } _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); _encoder.Encode(out shdr.sh_addralign, section.Alignment); _encoder.Encode(out shdr.sh_entsize, section.TableEntrySize); diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs index 02e95eba7e97f7..89f92a948afd8e 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs @@ -20,29 +20,13 @@ public override void Verify(DiagnosticBag diagnostics) !Name.IsEmpty || VirtualAddress != 0 || Alignment != 0 || + !Link.IsEmpty || !Info.IsEmpty || - Offset != 0) + Offset != 0 || + Size != 0) { diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. This section should not be modified and all properties must be null"); } - - if (Size != 0 && Parent.VisibleSectionCount < ElfNative.SHN_LORESERVE) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Size is non-zero but number of sections is lower than SHN_LORESERVE"); - } - else if (Size == 0 && Parent.VisibleSectionCount >= ElfNative.SHN_LORESERVE) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Size is zero but number of sections is higher or equal to SHN_LORESERVE"); - } - - if (!Link.IsEmpty && (Parent.SectionHeaderStringTable?.SectionIndex ?? 0) < ElfNative.SHN_LORESERVE) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Link is non-zero but index of section header string section is lower than SHN_LORESERVE"); - } - else if (Link.IsEmpty && (Parent.SectionHeaderStringTable?.SectionIndex ?? 0) >= ElfNative.SHN_LORESERVE) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. Link is non-zero but index of section header string section is higher or equal to SHN_LORESERVE"); - } } public override void UpdateLayout(DiagnosticBag diagnostics) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs index 4e7ab842d4eb79..cd1c8f62b095f0 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs @@ -149,7 +149,8 @@ private void Write32(ElfWriter writer) writer.Encode(out sym.st_size, (uint)entry.Size); sym.st_info = (byte)(((byte) entry.Bind << 4) | (byte) entry.Type); sym.st_other = (byte) ((byte) entry.Visibility & 3); - writer.Encode(out sym.st_shndx, (ElfNative.Elf32_Half) entry.Section.GetIndex()); + var sectionIndex = entry.Section.GetIndex(); + writer.Encode(out sym.st_shndx, sectionIndex < ElfNative.SHN_LORESERVE || entry.Section.IsSpecial ? (ElfNative.Elf32_Half)sectionIndex : (ElfNative.Elf32_Half)ElfNative.SHN_XINDEX); writer.Write(sym); } @@ -169,7 +170,8 @@ private void Write64(ElfWriter writer) writer.Encode(out sym.st_size, entry.Size); sym.st_info = (byte)(((byte)entry.Bind << 4) | (byte)entry.Type); sym.st_other = (byte)((byte)entry.Visibility & 3); - writer.Encode(out sym.st_shndx, (ElfNative.Elf64_Half)entry.Section.GetIndex()); + var sectionIndex = entry.Section.GetIndex(); + writer.Encode(out sym.st_shndx, sectionIndex < ElfNative.SHN_LORESERVE || entry.Section.IsSpecial ? (ElfNative.Elf64_Half)sectionIndex : (ElfNative.Elf64_Half)ElfNative.SHN_XINDEX); writer.Write(sym); } @@ -183,6 +185,7 @@ protected override void AfterRead(ElfReader reader) for (int i = 0; i < Entries.Count; i++) { var entry = Entries[i]; + if (stringTable != null) { if (stringTable.TryResolve(entry.Name, out var newEntry)) @@ -195,7 +198,10 @@ protected override void AfterRead(ElfReader reader) } } - entry.Section = reader.ResolveLink(entry.Section, $"Invalid link section index {entry.Section.SpecialIndex} for symbol table entry [{i}] from symbol table section [{this}]"); + if (entry.Section.SpecialIndex < ElfNative.SHN_LORESERVE) + { + entry.Section = reader.ResolveLink(entry.Section, $"Invalid link section index {entry.Section.SpecialIndex} for symbol table entry [{i}] from symbol table section [{this}]"); + } Entries[i] = entry; } @@ -212,6 +218,7 @@ public override void Verify(DiagnosticBag diagnostics) } bool isAllowingLocal = true; + bool needsSectionHeaderIndices = false; for (int i = 0; i < Entries.Count; i++) { @@ -222,9 +229,14 @@ public override void Verify(DiagnosticBag diagnostics) diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSymbolEntryNonNull, $"Invalid entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The first entry must be null/undefined"); } - if (entry.Section.Section != null && entry.Section.Section.Parent != Parent) + if (entry.Section.Section != null) { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntrySectionParent, $"Invalid section for the symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The section of the entry `{entry}` must the same than this symbol table section"); + if (entry.Section.Section.Parent != Parent) + { + diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntrySectionParent, $"Invalid section for the symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The section of the entry `{entry}` must the same than this symbol table section"); + } + + needsSectionHeaderIndices |= entry.Section.GetIndex() >= ElfNative.SHN_LORESERVE; } stringTable.ReserveString(entry.Name); @@ -244,6 +256,24 @@ public override void Verify(DiagnosticBag diagnostics) isAllowingLocal = false; } } + + if (needsSectionHeaderIndices) + { + bool foundSectionHeaderIndices = false; + foreach (ElfSection otherSection in Parent.Sections) + { + if (otherSection is ElfSymbolTableSectionHeaderIndices && otherSection.Link.Section == this) + { + foundSectionHeaderIndices = true; + break; + } + } + + if (!foundSectionHeaderIndices) + { + diagnostics.Error(DiagnosticId.ELF_ERR_MissingSectionHeaderIndices, $"Symbol table [{Name.Value}] references section indexes higher than SHN_LORESERVE and accompanying {nameof(ElfSymbolTableSectionHeaderIndices)} section is missing"); + } + } } public override unsafe void UpdateLayout(DiagnosticBag diagnostics) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs new file mode 100644 index 00000000000000..483c529456fd04 --- /dev/null +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs @@ -0,0 +1,126 @@ +// Copyright (c) Alexandre Mutel. All rights reserved. +// This file is licensed under the BSD-Clause 2 license. +// See the license.txt file in the project root for more information. + +using System; +using System.Collections.Generic; + +namespace LibObjectFile.Elf +{ + /// + /// A section with the type + /// + public sealed class ElfSymbolTableSectionHeaderIndices : ElfSection + { + public const string DefaultName = ".symtab_shndx"; + + private readonly List _entries; + + public ElfSymbolTableSectionHeaderIndices() : base(ElfSectionType.SymbolTableSectionHeaderIndices) + { + Name = DefaultName; + _entries = new List(); + } + + public override ElfSectionType Type + { + get => base.Type; + set + { + if (value != ElfSectionType.SymbolTableSectionHeaderIndices) + { + throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfSymbolTableSectionHeaderIndices)}`. Only `{ElfSectionType.SymbolTableSectionHeaderIndices}` is valid"); + } + base.Type = value; + } + } + + public override unsafe ulong TableEntrySize => sizeof(uint); + + protected override void Read(ElfReader reader) + { + var numberOfEntries = base.Size / TableEntrySize; + _entries.Clear(); + _entries.Capacity = (int)numberOfEntries; + for (ulong i = 0; i < numberOfEntries; i++) + { + _entries.Add(reader.ReadU32()); + } + } + + protected override void Write(ElfWriter writer) + { + // Write all entries + for (int i = 0; i < _entries.Count; i++) + { + writer.WriteU32(_entries[i]); + } + } + + protected override void AfterRead(ElfReader reader) + { + // Verify that the link is safe and configured as expected + Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, reader.Diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); + + for (int i = 0; i < _entries.Count; i++) + { + var entry = _entries[i]; + if (entry != 0) + { + var resolvedLink = reader.ResolveLink(new ElfSectionLink(entry), $"Invalid link section index {entry} for symbol table entry [{i}] from symbol table section [{this}]"); + + // Update the link in symbol table + var symbolTableEntry = symbolTable.Entries[i]; + symbolTableEntry.Section = resolvedLink; + symbolTable.Entries[i] = symbolTableEntry; + } + } + } + + public override void Verify(DiagnosticBag diagnostics) + { + base.Verify(diagnostics); + + // Verify that the link is safe and configured as expected + if (!Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable)) + { + return; + } + } + + public override unsafe void UpdateLayout(DiagnosticBag diagnostics) + { + if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); + + // Verify that the link is safe and configured as expected + Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); + + int numberOfEntries = 0; + for (int i = 0; i < symbolTable.Entries.Count; i++) + { + if (symbolTable.Entries[i].Section.Section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) + { + numberOfEntries = i + 1; + } + } + + _entries.Capacity = numberOfEntries; + _entries.Clear(); + + for (int i = 0; i < numberOfEntries; i++) + { + var section = symbolTable.Entries[i].Section.Section; + if (section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) + { + _entries.Add(section.SectionIndex); + } + else + { + _entries.Add(0); + } + } + + Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : (ulong)numberOfEntries * sizeof(uint); + } + } +} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj index 031c1981ef64d2..735d863e12a2ed 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj @@ -1,8 +1,7 @@  - netstandard2.1 - 8.0 + net7.0 true @@ -27,14 +26,14 @@ - + - + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs index e35826d358560f..027abd2d544356 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs @@ -60,7 +60,7 @@ public static string ReadStringUTF8NullTerminated(this Stream stream) break; } - if (textLength > buffer.Length) + if (textLength >= buffer.Length) { var newBuffer = ArrayPool.Shared.Rent((int)textLength * 2); Array.Copy(buffer, 0, newBuffer, 0, buffer.Length); diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj index a5926ad96b0fc0..fa42be0bd4986a 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj @@ -2,13 +2,13 @@ Exe - net6.0 + net7.0 LibObjectFile.Disasm false - + From 157dbdc5eb6a2f2b6b9a27601ba7f113dbf8068a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 12:57:33 +0200 Subject: [PATCH 088/144] Fix ELF section symbols and DW_AT_low_pc in DWARF debug info --- .../Compiler/ObjectWriter/DwarfBuilder.cs | 2 +- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs index c2777934d0ace1..879b2ffa02c466 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs @@ -160,7 +160,7 @@ public void WriteInfoTable( // DW_AT_comp_dir dwarfInfoWriter.WriteStringReference("/_"); // DW_AT_low_pc - dwarfInfoWriter.WriteCodeReference(_sections[0].SectionSymbolName); + dwarfInfoWriter.WriteAddressSize(0); // DW_AT_ranges dwarfInfoWriter.WriteStartRangeList(); foreach (var sectionInfo in _sections) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index d7f72498b58640..13fed2604d8bb7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -112,6 +112,13 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa _sections.Add(elfSection); groupSection?.AddSection(elfSection); + // Emit section symbol into symbpol table (for COMDAT the defining symbol is section symbol) + if (comdatName is null) + { + _symbolNameToIndex[elfSection.Name] = (uint)_symbolTable.Entries.Count; + _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); + } + base.CreateSection(section, comdatName, symbolName ?? elfSection.Name.Value, sectionStream); } @@ -326,17 +333,6 @@ protected override void EmitDebugSections(IDictionary { AddElfSectionWithRelocationsIfNecessary(debugSection); } - - uint symbolIndex = (uint)_symbolTable.Entries.Count; - foreach (ElfSection elfSection in _objectFile.Sections) - { - if (elfSection is ElfBinarySection) - { - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); - _symbolNameToIndex[elfSection.Name] = symbolIndex; - symbolIndex++; - } - } } private void AddElfSectionWithRelocationsIfNecessary(ElfSection elfSection, ElfGroupSection groupSection = null) From d7f4e2d0ae4d1a79bab42bd0beeacd85fd1a03e4 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 13:48:53 +0200 Subject: [PATCH 089/144] Disable MinVer package in LibObjectFile --- .../LibObjectFile/src/LibObjectFile/LibObjectFile.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj index 735d863e12a2ed..be7c9ea8498eb6 100644 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj +++ b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj @@ -30,10 +30,10 @@ - + From 941e0a35b44a5e63042d78dbd80205e29511852b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 13:49:35 +0200 Subject: [PATCH 090/144] ELF: Generate symbol table section index if there's more than 0xff00 sections --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 13fed2604d8bb7..2a77b2c87c07c8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -392,6 +392,11 @@ protected override void EmitSectionsAndLayout() Name = ".note.GNU-stack", Type = ElfSectionType.ProgBits, }); + + if (_objectFile.Sections.Count >= ElfNative.SHN_LORESERVE) + { + _objectFile.AddSection(new ElfSymbolTableSectionHeaderIndices { Link = _symbolTable }); + } } protected override void EmitObjectFile(string objectFilePath) From a00cd1284b220340fbc045fa3762b92e0ae7b8d2 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 15:11:45 +0200 Subject: [PATCH 091/144] Revert "Do not output debug information for static variables that were trimmed" This reverts commit 4ce59b178619fdc842c86ecd47f48040e60f7f88. --- .../Compiler/UserDefinedTypeDescriptor.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs index c526dd448c760d..26d008f8377fee 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs @@ -672,8 +672,6 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) { if (NodeFactory.Target.OperatingSystem != TargetOS.Windows) { - bool marked; - StaticDataFieldDescriptor staticDesc = new StaticDataFieldDescriptor { StaticOffset = (ulong)fieldOffsetEmit @@ -685,20 +683,12 @@ private uint GetClassTypeIndex(TypeDesc type, bool needsCompleteType) if (fieldDesc.IsThreadStatic) { staticDesc.StaticDataName = threadStaticDataName; staticDesc.IsStaticDataInObject = isNativeAOT ? 1 : 0; - marked = NodeFactory.TypeThreadStaticsSymbol((MetadataType)defType).Marked; } else if (fieldDesc.HasGCStaticBase) { staticDesc.StaticDataName = gcStaticDataName; staticDesc.IsStaticDataInObject = isNativeAOT ? 1 : 0; - marked = NodeFactory.TypeGCStaticsSymbol((MetadataType)defType).Marked; } else { staticDesc.StaticDataName = nonGcStaticDataName; staticDesc.IsStaticDataInObject = 0; - marked = NodeFactory.TypeNonGCStaticsSymbol((MetadataType)defType).Marked; - } - - if (!marked) - { - continue; } staticsDescs.Add(staticDesc); From ea9360fbcbb1b7ff513d9af58145c69c822d6a88 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 14:00:18 +0200 Subject: [PATCH 092/144] Fix typo --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 2a77b2c87c07c8..c361a4f08b9db1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -112,7 +112,7 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa _sections.Add(elfSection); groupSection?.AddSection(elfSection); - // Emit section symbol into symbpol table (for COMDAT the defining symbol is section symbol) + // Emit section symbol into symbol table (for COMDAT the defining symbol is section symbol) if (comdatName is null) { _symbolNameToIndex[elfSection.Name] = (uint)_symbolTable.Entries.Count; From 81ac747c0271e84df2fd81948c5d73d30383604a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 23 Oct 2023 15:11:25 +0200 Subject: [PATCH 093/144] Fix null dereference in CoffObjectWriter.CreateSection --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 7434f3e87fdf77..d4ca22e2bfbde7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -128,14 +128,17 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa }); _symbols.Add(auxRecord); - _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); - _symbols.Add(new CoffSymbol + if (symbolName is not null) { - Name = symbolName, - Value = 0, - SectionIndex = sectionIndex, - StorageClass = isPrimary ? CoffSymbolClass.IMAGE_SYM_CLASS_EXTERNAL : CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, - }); + _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); + _symbols.Add(new CoffSymbol + { + Name = symbolName, + Value = 0, + SectionIndex = sectionIndex, + StorageClass = isPrimary ? CoffSymbolClass.IMAGE_SYM_CLASS_EXTERNAL : CoffSymbolClass.IMAGE_SYM_CLASS_STATIC, + }); + } } _sections.Add(new SectionDefinition(sectionHeader, sectionStream, new List(), comdatName, symbolName)); From f1a1bfa7c7ac5d9c6e4b0487f01e1da9e091bd3d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 24 Oct 2023 13:41:44 +0200 Subject: [PATCH 094/144] COFF: Add X86 support (tested on SmolSharp.HelloWorld) --- .../ObjectWriter/CodeViewSymbolsBuilder.cs | 15 +++ .../ObjectWriter/CodeViewTypesBuilder.cs | 2 - .../Compiler/ObjectWriter/CoffObjectWriter.cs | 126 +++++++++++------- 3 files changed, 94 insertions(+), 49 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs index 4c40ce2da6c1c5..e65be3456153eb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs @@ -60,6 +60,21 @@ private CodeViewRegister GetCVRegNum(uint regNum) { switch (_targetArchitecture) { + case TargetArchitecture.X86: + return regNum switch + { + 0u => CV_REG_EAX, + 1u => CV_REG_ECX, + 2u => CV_REG_EDX, + 3u => CV_REG_EBX, + 4u => CV_REG_ESP, + 5u => CV_REG_EBP, + 6u => CV_REG_ESI, + 7u => CV_REG_EDI, + // TODO: Floating point + _ => CV_REG_NONE, + }; + case TargetArchitecture.X64: return regNum switch { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs index db967b426eb8c7..a0ca102b167521 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs @@ -39,7 +39,6 @@ namespace ILCompiler.ObjectWriter internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter { private NameMangler _nameMangler; - private TargetArchitecture _architecture; private Stream _outputStream; private int _targetPointerSize; @@ -54,7 +53,6 @@ internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, Stream outputStream) { _nameMangler = nameMangler; - _architecture = targetArchitecture; _outputStream = outputStream; _targetPointerSize = targetArchitecture switch { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index d4ca22e2bfbde7..66ccac284824ea 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -58,6 +58,7 @@ private CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) { _machine = factory.Target.Architecture switch { + TargetArchitecture.X86 => Machine.I386, TargetArchitecture.X64 => Machine.Amd64, TargetArchitecture.ARM64 => Machine.Arm64, _ => throw new NotSupportedException("Unsupported architecture") @@ -211,6 +212,7 @@ protected internal override void EmitRelocation( case RelocType.IMAGE_REL_BASED_REL32: case RelocType.IMAGE_REL_BASED_ADDR32NB: case RelocType.IMAGE_REL_BASED_ABSOLUTE: + case RelocType.IMAGE_REL_BASED_HIGHLOW: if (addend != 0) { BinaryPrimitives.WriteInt32LittleEndian( @@ -303,58 +305,81 @@ protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, - RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, - RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_AMD64_ADDR32, - RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_AMD64_ADDR64, - RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, - RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, - RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_AMD64_SECREL, - RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_AMD64_SECTION, - _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") - }, - }); - } - } - else if (_machine == Machine.Arm64) - { - foreach (var relocation in relocationList) - { - coffRelocations.Add(new CoffRelocation + VirtualAddress = (uint)relocation.Offset, + SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], + Type = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_I386_DIR32NB, + RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_I386_DIR32NB, + RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_I386_DIR32, + RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_I386_REL32, + RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_I386_REL32, + RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_I386_SECREL, + RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_I386_SECTION, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }, + }); + } + break; + + case Machine.Amd64: + foreach (var relocation in relocationList) { - VirtualAddress = (uint)relocation.Offset, - SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], - Type = relocation.Type switch + coffRelocations.Add(new CoffRelocation { - RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, - RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, - RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_ARM64_ADDR32, - RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_ARM64_ADDR64, - RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, - RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => CoffRelocationType.IMAGE_REL_ARM64_BRANCH26, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => CoffRelocationType.IMAGE_REL_ARM64_PAGEBASE_REL21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => CoffRelocationType.IMAGE_REL_ARM64_PAGEOFFSET_12A, - RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_ARM64_SECREL, - RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_ARM64_SECTION, - _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") - }, - }); - } - } - else - { - throw new NotSupportedException("Unsupported architecture"); + VirtualAddress = (uint)relocation.Offset, + SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], + Type = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, + RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, + RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_AMD64_ADDR32, + RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_AMD64_ADDR64, + RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, + RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, + RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_AMD64_SECREL, + RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_AMD64_SECTION, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }, + }); + } + break; + + case Machine.Arm64: + foreach (var relocation in relocationList) + { + coffRelocations.Add(new CoffRelocation + { + VirtualAddress = (uint)relocation.Offset, + SymbolTableIndex = _symbolNameToIndex[relocation.SymbolName], + Type = relocation.Type switch + { + RelocType.IMAGE_REL_BASED_ABSOLUTE => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, + RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, + RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_ARM64_ADDR32, + RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_ARM64_ADDR64, + RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, + RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => CoffRelocationType.IMAGE_REL_ARM64_BRANCH26, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => CoffRelocationType.IMAGE_REL_ARM64_PAGEBASE_REL21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => CoffRelocationType.IMAGE_REL_ARM64_PAGEOFFSET_12A, + RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_ARM64_SECREL, + RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_ARM64_SECTION, + _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") + }, + }); + } + break; + + default: + throw new NotSupportedException("Unsupported architecture"); } } } @@ -785,6 +810,13 @@ public void Write(FileStream stream, CoffStringTable stringTable) private enum CoffRelocationType { + IMAGE_REL_I386_ABSOLUTE = 0, + IMAGE_REL_I386_DIR32 = 6, + IMAGE_REL_I386_DIR32NB = 7, + IMAGE_REL_I386_SECTION = 10, + IMAGE_REL_I386_SECREL = 11, + IMAGE_REL_I386_REL32 = 20, + IMAGE_REL_AMD64_ABSOLUTE = 0, IMAGE_REL_AMD64_ADDR64 = 1, IMAGE_REL_AMD64_ADDR32 = 2, From 07dd8a6bc58f1a7e668f37816f72fa60bd5a1c26 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 12 Nov 2023 16:53:06 +0100 Subject: [PATCH 095/144] Fix COMDAT symbol values --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 66ccac284824ea..ef936624e18180 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -241,7 +241,12 @@ protected override void EmitSymbolTable( { foreach (var (symbolName, symbolDefinition) in definedSymbols) { - if (!_symbolNameToIndex.ContainsKey(symbolName)) + if (_symbolNameToIndex.TryGetValue(symbolName, out uint symbolIndex)) + { + // Update value for COMDAT symbols + ((CoffSymbol)_symbols[(int)symbolIndex]).Value = (uint)symbolDefinition.Value; + } + else { _symbolNameToIndex.Add(symbolName, (uint)_symbols.Count); _symbols.Add(new CoffSymbol From d89308d5fd90c0135c898965e147d744d3b5914b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 17 Nov 2023 12:36:11 +0100 Subject: [PATCH 096/144] Do not generate broken debug info for non-methods --- .../Compiler/ObjectWriter/ObjectWriter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index a36bea755e96ca..48d880d9c76383 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -403,12 +403,10 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Sat, 25 Nov 2023 16:06:20 +0100 Subject: [PATCH 097/144] Add generic StringTableBuilder and use it in COFF --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 42 ++--- .../ObjectWriter/StringTableBuilder.cs | 178 ++++++++++++++++++ .../ILCompiler.Compiler.csproj | 1 + 3 files changed, 197 insertions(+), 24 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index ef936624e18180..417f3ceeef49d6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -528,6 +528,15 @@ protected override void EmitObjectFile(string objectFilePath) coffHeader.PointerToSymbolTable = dataOffset; + // Optimize the string table + foreach (var coffSymbolRecord in _symbols) + { + if (coffSymbolRecord is CoffSymbol coffSymbol) + { + stringTable.ReserveString(coffSymbol.Name); + } + } + // Write COFF header coffHeader.Write(outputFileStream); @@ -575,9 +584,9 @@ protected override void EmitObjectFile(string objectFilePath) // Write symbol table Debug.Assert(outputFileStream.Position == coffHeader.PointerToSymbolTable); - foreach (var coffSymbol in _symbols) + foreach (var coffSymbolRecord in _symbols) { - coffSymbol.Write(outputFileStream, stringTable, coffHeader.IsBigObj); + coffSymbolRecord.Write(outputFileStream, stringTable, coffHeader.IsBigObj); } // Write string table @@ -1012,36 +1021,21 @@ public override void Write(Stream stream, CoffStringTable stringTable, bool isBi } } - private sealed class CoffStringTable + private sealed class CoffStringTable : StringTableBuilder { - private MemoryStream _stream = new(); - private Dictionary _stringToOffset = new(); + public new uint Size => (uint)(base.Size + 4); - public uint GetStringOffset(string str) + public new uint GetStringOffset(string text) { - uint offset; - - if (_stringToOffset.TryGetValue(str, out offset)) - { - return offset; - } - - offset = (uint)(_stream.Position + 4); - var strBytes = Encoding.UTF8.GetBytes(str); // TODO: Pool buffers - _stream.Write(strBytes); - _stream.WriteByte(0); - _stringToOffset[str] = offset; - - return offset; + return base.GetStringOffset(text) + 4; } - public void Write(FileStream stream) + public new void Write(FileStream stream) { Span stringTableSize = stackalloc byte[4]; - BinaryPrimitives.WriteInt32LittleEndian(stringTableSize, (int)(_stream.Length + 4)); + BinaryPrimitives.WriteUInt32LittleEndian(stringTableSize, Size); stream.Write(stringTableSize); - _stream.Position = 0; - _stream.CopyTo(stream); + base.Write(stream); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs new file mode 100644 index 00000000000000..84b957dcbc272f --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs @@ -0,0 +1,178 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Linq; + +namespace ILCompiler.ObjectWriter +{ + public class StringTableBuilder + { + private readonly MemoryStream _stream = new(); + private readonly SortedSet _reservedStrings = new(StringComparer.Ordinal); + private Dictionary _stringToOffset = new(StringComparer.Ordinal); + + public void Write(FileStream stream) + { + _stream.Position = 0; + _stream.CopyTo(stream); + } + + public uint Size => (uint)_stream.Length; + + public void ReserveString(string text) + { + if (text is object && !_stringToOffset.ContainsKey(text)) + { + _reservedStrings.Add(text); + } + } + + private void FlushReservedStrings() + { + // TODO: Use CollectionsMarshal.AsSpan + string[] reservedStrings = _reservedStrings.ToArray(); + + // Pre-sort the string based on their matching suffix + MultiKeySort(reservedStrings, 0); + + // Add the strings to string table + string lastText = null; + for (int i = 0; i < reservedStrings.Length; i++) + { + var text = reservedStrings[i]; + uint index; + if (lastText != null && lastText.EndsWith(text, StringComparison.Ordinal)) + { + // Suffix matches the last symbol + index = (uint)(_stream.Length - Encoding.UTF8.GetByteCount(text) - 1); + _stringToOffset.Add(text, index); + } + else + { + lastText = text; + CreateIndex(text); + } + } + + _reservedStrings.Clear(); + + static char TailCharacter(string str, int pos) + { + int index = str.Length - pos - 1; + if ((uint)index < str.Length) + return str[index]; + return '\0'; + } + + static void MultiKeySort(Span input, int pos) + { + if (!MultiKeySortSmallInput(input, pos)) + { + MultiKeySortLargeInput(input, pos); + } + } + + static void MultiKeySortLargeInput(Span input, int pos) + { + tailcall: + char pivot = TailCharacter(input[0], pos); + int l = 0, h = input.Length; + for (int i = 1; i < h;) + { + char c = TailCharacter(input[i], pos); + if (c > pivot) + { + (input[l], input[i]) = (input[i], input[l]); + l++; i++; + } + else if (c < pivot) + { + h--; + (input[h], input[i]) = (input[i], input[h]); + } + else + { + i++; + } + } + + MultiKeySort(input.Slice(0, l), pos); + MultiKeySort(input.Slice(h), pos); + if (pivot != '\0') + { + // Use a loop as a poor man's tailcall + // MultiKeySort(input.Slice(l, h - l), pos + 1); + pos++; + input = input.Slice(l, h - l); + if (!MultiKeySortSmallInput(input, pos)) + { + goto tailcall; + } + } + } + + static bool MultiKeySortSmallInput(Span input, int pos) + { + if (input.Length <= 1) + return true; + + // Optimize comparing two strings + if (input.Length == 2) + { + while (true) + { + char c0 = TailCharacter(input[0], pos); + char c1 = TailCharacter(input[1], pos); + if (c0 < c1) + { + (input[0], input[1]) = (input[1], input[0]); + break; + } + else if (c0 > c1 || c0 == (char)0) + { + break; + } + pos++; + } + return true; + } + + return false; + } + } + + private uint CreateIndex(string text) + { + uint offset = (uint)_stream.Position; + int reservedBytes = Encoding.UTF8.GetByteCount(text) + 1; + byte[] buffer = ArrayPool.Shared.Rent(reservedBytes); + var span = new Span(buffer, 0, reservedBytes); + Encoding.UTF8.GetBytes(text, span); + span[reservedBytes - 1] = 0; + _stream.Write(span); + _stringToOffset[text] = offset; + return offset; + } + + public uint GetStringOffset(string text) + { + if (_reservedStrings.Count > 0) + { + FlushReservedStrings(); + } + + if (_stringToOffset.TryGetValue(text, out uint index)) + { + return index; + } + + return CreateIndex(text); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 0c3d0efd48ff05..4729885f05339d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -614,6 +614,7 @@ + From d92d31aef4bd5cbd3a768a5e1cd6a2944e9ac36e Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 26 Nov 2023 23:27:46 +0100 Subject: [PATCH 098/144] Fix couple of bugs in last commit: - Section names need to come first in the string table because of limited space for their reference by offset. This caused the "managedcode$I" and "modules$I" section names to be garbage when there were many symbols. - Fix missing array pool return. --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 18 +++++++++--------- .../ObjectWriter/StringTableBuilder.cs | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 417f3ceeef49d6..1ef723f5e4e7c7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -528,15 +528,6 @@ protected override void EmitObjectFile(string objectFilePath) coffHeader.PointerToSymbolTable = dataOffset; - // Optimize the string table - foreach (var coffSymbolRecord in _symbols) - { - if (coffSymbolRecord is CoffSymbol coffSymbol) - { - stringTable.ReserveString(coffSymbol.Name); - } - } - // Write COFF header coffHeader.Write(outputFileStream); @@ -582,6 +573,15 @@ protected override void EmitObjectFile(string objectFilePath) } } + // Optimize the string table + foreach (var coffSymbolRecord in _symbols) + { + if (coffSymbolRecord is CoffSymbol coffSymbol) + { + stringTable.ReserveString(coffSymbol.Name); + } + } + // Write symbol table Debug.Assert(outputFileStream.Position == coffHeader.PointerToSymbolTable); foreach (var coffSymbolRecord in _symbols) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs index 84b957dcbc272f..b072852a13a266 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs @@ -156,6 +156,7 @@ private uint CreateIndex(string text) Encoding.UTF8.GetBytes(text, span); span[reservedBytes - 1] = 0; _stream.Write(span); + ArrayPool.Shared.Return(buffer); _stringToOffset[text] = offset; return offset; } From 6ff8ae9ae3357285d3e67eee9a74f25eb1300e82 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 27 Nov 2023 00:15:37 +0100 Subject: [PATCH 099/144] COFF: Add support for '//BBBBBB' section names. --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 1ef723f5e4e7c7..72499a4f2e4101 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -801,10 +801,29 @@ public void Write(FileStream stream, CoffStringTable stringTable) } else { - string longName = $"/{stringTable.GetStringOffset(Name)}\0\0\0\0\0\0"; - for (int i = 0; i < 8; i++) + buffer.Clear(); + buffer[0] = (byte)'/'; + uint offset = stringTable.GetStringOffset(Name); + if (offset <= 9999999) + { + Span charBuffer = stackalloc char[16]; + int charsWritten; + offset.TryFormat(charBuffer, out charsWritten); + for (int i = 0; i < charsWritten; i++) + { + buffer[1 + i] = (byte)charBuffer[i]; + } + } + else { - buffer[i] = (byte)longName[i]; + ReadOnlySpan s_base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"u8; + // Maximum expressible offset is 64^6 which is less than uint.MaxValue + buffer[1] = (byte)'/'; + for (int i = 0; i < 6; i++) + { + buffer[7 - i] = s_base64Alphabet[(int)(offset % 64)]; + offset /= 64; + } } } From 018f7270f6e749a400c9ed02792284456d5bd5f5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 6 Dec 2023 14:47:09 +0100 Subject: [PATCH 100/144] Add simple ELF writer Remove LibObjectFile dependency --- .../Compiler/ObjectWriter/ElfNative.cs | 246 + .../Compiler/ObjectWriter/ElfObjectWriter.cs | 707 +- .../ObjectWriter/StringTableBuilder.cs | 9 +- .../ILCompiler.Compiler.csproj | 2 +- .../aot/external/LibObjectFile/changelog.md | 32 - .../LibObjectFile/doc/ar_class_diagram.png | Bin 37660 -> 0 bytes .../LibObjectFile/doc/elf_class_diagram.png | Bin 119276 -> 0 bytes .../aot/external/LibObjectFile/doc/readme.md | 242 - .../LibObjectFile/img/libobjectfile.png | Bin 6489 -> 0 bytes .../aot/external/LibObjectFile/license.txt | 23 - .../aot/external/LibObjectFile/readme.md | 111 - .../external/LibObjectFile/src/.dockerignore | 4 - .../LibObjectFile/src/Directory.Build.props | 7 - .../aot/external/LibObjectFile/src/Dockerfile | 17 - .../LibObjectFile.CodeGen.csproj | 23 - .../LibObjectFile.CodeGen/Program.Dwarf.cs | 787 - .../src/LibObjectFile.CodeGen/Program.cs | 327 - .../src/LibObjectFile.CodeGen/dwarf.h | 1432 -- .../src/LibObjectFile.CodeGen/elf.h | 3367 ---- .../src/LibObjectFile.Tests/Ar/ArTestBase.cs | 42 - .../src/LibObjectFile.Tests/Ar/ArTests.cs | 431 - .../LibObjectFile.Tests/Dwarf/DwarfTests.cs | 546 - .../LibObjectFile.Tests/Elf/ElfSimpleTests.cs | 482 - .../LibObjectFile.Tests/Elf/ElfTestBase.cs | 98 - .../LibObjectFile.Tests.csproj | 49 - .../src/LibObjectFile.Tests/LinuxUtil.cs | 101 - .../LibObjectFile.Tests/TestFiles/cmnlib.b00 | Bin 180 -> 0 bytes .../src/LibObjectFile.Tests/helloworld.cpp | 5 - .../src/LibObjectFile.Tests/lib_a.cpp | 4 - .../src/LibObjectFile.Tests/lib_b.cpp | 4 - .../multiple_functions.cpp | 14 - .../src/LibObjectFile.Tests/small.cpp | 22 - .../LibObjectFile/src/LibObjectFile.sln | 59 - .../src/LibObjectFile.sln.DotSettings | 16 - .../LibObjectFile/src/LibObjectFile/Ar/Ar.cd | 65 - .../src/LibObjectFile/Ar/ArArchiveFile.cs | 381 - .../LibObjectFile/Ar/ArArchiveFileReader.cs | 352 - .../Ar/ArArchiveFileReaderOptions.cs | 41 - .../LibObjectFile/Ar/ArArchiveFileWriter.cs | 203 - .../src/LibObjectFile/Ar/ArArchiveKind.cs | 32 - .../src/LibObjectFile/Ar/ArBinaryFile.cs | 39 - .../src/LibObjectFile/Ar/ArElfFile.cs | 62 - .../src/LibObjectFile/Ar/ArFile.cs | 148 - .../LibObjectFile/Ar/ArFileEntry.Constants.cs | 84 - .../src/LibObjectFile/Ar/ArLongNamesTable.cs | 148 - .../src/LibObjectFile/Ar/ArObject.cs | 35 - .../src/LibObjectFile/Ar/ArSymbol.cs | 48 - .../src/LibObjectFile/Ar/ArSymbolTable.cs | 242 - .../src/LibObjectFile/DiagnosticBag.cs | 106 - .../src/LibObjectFile/DiagnosticId.cs | 118 - .../src/LibObjectFile/DiagnosticKind.cs | 22 - .../src/LibObjectFile/DiagnosticMessage.cs | 53 - .../LibObjectFile/Dwarf/DwarfAbbreviation.cs | 241 - .../Dwarf/DwarfAbbreviationItem.cs | 125 - .../Dwarf/DwarfAbbreviationItemKey.cs | 61 - .../Dwarf/DwarfAbbreviationTable.cs | 86 - .../LibObjectFile/Dwarf/DwarfAccessibility.cs | 15 - .../LibObjectFile/Dwarf/DwarfAddressRange.cs | 27 - .../Dwarf/DwarfAddressRangeTable.cs | 277 - .../LibObjectFile/Dwarf/DwarfAddressSize.cs | 19 - .../Dwarf/DwarfArrayOrderingKind.cs | 13 - .../src/LibObjectFile/Dwarf/DwarfAttribute.cs | 1001 - .../Dwarf/DwarfAttributeDescriptor.cs | 55 - .../Dwarf/DwarfAttributeDescriptors.cs | 82 - .../Dwarf/DwarfAttributeEncoding.cs | 50 - .../Dwarf/DwarfAttributeFormEx.cs | 64 - .../Dwarf/DwarfAttributeKindEx.cs | 66 - .../Dwarf/DwarfAttributeValue.cs | 21 - .../Dwarf/DwarfCallingConventionEx.cs | 59 - .../Dwarf/DwarfCompilationUnit.cs | 81 - .../src/LibObjectFile/Dwarf/DwarfConstant.cs | 71 - .../src/LibObjectFile/Dwarf/DwarfContainer.cs | 16 - .../src/LibObjectFile/Dwarf/DwarfDIE.cs | 516 - .../Dwarf/DwarfDIEDeclaration.cs | 28 - .../Dwarf/DwarfDiscriminantListKind.cs | 13 - .../LibObjectFile/Dwarf/DwarfElfContext.cs | 341 - .../LibObjectFile/Dwarf/DwarfExpression.cs | 132 - .../src/LibObjectFile/Dwarf/DwarfFile.cs | 456 - .../src/LibObjectFile/Dwarf/DwarfFileName.cs | 30 - .../src/LibObjectFile/Dwarf/DwarfHelper.cs | 114 - .../Dwarf/DwarfIdentifierCaseKind.cs | 17 - .../LibObjectFile/Dwarf/DwarfInfoSection.cs | 105 - .../LibObjectFile/Dwarf/DwarfInlineKind.cs | 17 - .../src/LibObjectFile/Dwarf/DwarfInteger.cs | 41 - .../Dwarf/DwarfLanguageKindEx.cs | 59 - .../LibObjectFile/Dwarf/DwarfLayoutConfig.cs | 37 - .../LibObjectFile/Dwarf/DwarfLayoutContext.cs | 26 - .../src/LibObjectFile/Dwarf/DwarfLine.cs | 184 - .../Dwarf/DwarfLineProgramTable.cs | 1376 -- .../LibObjectFile/Dwarf/DwarfLineSection.cs | 90 - .../LibObjectFile/Dwarf/DwarfLineSequence.cs | 71 - .../src/LibObjectFile/Dwarf/DwarfLineState.cs | 157 - .../src/LibObjectFile/Dwarf/DwarfLocation.cs | 55 - .../LibObjectFile/Dwarf/DwarfLocationList.cs | 107 - .../Dwarf/DwarfLocationListEntry.cs | 85 - .../Dwarf/DwarfLocationSection.cs | 89 - .../src/LibObjectFile/Dwarf/DwarfObject.cs | 92 - .../src/LibObjectFile/Dwarf/DwarfOperation.cs | 1172 -- .../Dwarf/DwarfOperationKindEx.cs | 59 - .../src/LibObjectFile/Dwarf/DwarfPrinter.cs | 234 - .../src/LibObjectFile/Dwarf/DwarfReader.cs | 170 - .../LibObjectFile/Dwarf/DwarfReaderContext.cs | 30 - .../LibObjectFile/Dwarf/DwarfReaderWriter.cs | 173 - .../Dwarf/DwarfReaderWriterContext.cs | 29 - .../Dwarf/DwarfRelocatableSection.cs | 67 - .../LibObjectFile/Dwarf/DwarfRelocation.cs | 33 - .../Dwarf/DwarfRelocationTarget.cs | 17 - .../src/LibObjectFile/Dwarf/DwarfSection.cs | 31 - .../LibObjectFile/Dwarf/DwarfSectionLink.cs | 48 - .../Dwarf/DwarfStreamExtensions.cs | 97 - .../LibObjectFile/Dwarf/DwarfStringTable.cs | 89 - .../src/LibObjectFile/Dwarf/DwarfTagEx.cs | 62 - .../src/LibObjectFile/Dwarf/DwarfUnit.cs | 241 - .../src/LibObjectFile/Dwarf/DwarfUnitKind.cs | 63 - .../LibObjectFile/Dwarf/DwarfVirtuality.cs | 15 - .../LibObjectFile/Dwarf/DwarfVisibility.cs | 15 - .../src/LibObjectFile/Dwarf/DwarfWriter.cs | 45 - .../LibObjectFile/Dwarf/DwarfWriterContext.cs | 26 - .../src/LibObjectFile/Elf/Elf.cd | 154 - .../src/LibObjectFile/Elf/ElfArch.cs | 67 - .../src/LibObjectFile/Elf/ElfDecoderDirect.cs | 102 - .../src/LibObjectFile/Elf/ElfDecoderSwap.cs | 104 - .../src/LibObjectFile/Elf/ElfEncoderDirect.cs | 102 - .../src/LibObjectFile/Elf/ElfEncoderSwap.cs | 104 - .../src/LibObjectFile/Elf/ElfEncoding.cs | 29 - .../src/LibObjectFile/Elf/ElfFileClass.cs | 30 - .../src/LibObjectFile/Elf/ElfFilePart.cs | 93 - .../src/LibObjectFile/Elf/ElfFilePartList.cs | 82 - .../src/LibObjectFile/Elf/ElfFileType.cs | 39 - .../src/LibObjectFile/Elf/ElfHeaderFlags.cs | 58 - .../LibObjectFile/Elf/ElfNativeExtensions.cs | 104 - .../src/LibObjectFile/Elf/ElfOSAbi2.cs | 64 - .../src/LibObjectFile/Elf/ElfObject.cs | 37 - .../src/LibObjectFile/Elf/ElfObjectFile.cs | 778 - .../Elf/ElfObjectFileExtensions.cs | 83 - .../src/LibObjectFile/Elf/ElfPrinter.cs | 817 - .../src/LibObjectFile/Elf/ElfReader.cs | 60 - .../src/LibObjectFile/Elf/ElfReaderDirect.cs | 18 - .../src/LibObjectFile/Elf/ElfReaderOptions.cs | 47 - .../src/LibObjectFile/Elf/ElfReaderSwap.cs | 18 - .../LibObjectFile/Elf/ElfReader{TDecoder}.cs | 859 - .../src/LibObjectFile/Elf/ElfSection.cs | 198 - .../LibObjectFile/Elf/ElfSectionExtension.cs | 154 - .../src/LibObjectFile/Elf/ElfSectionFlags.cs | 72 - .../src/LibObjectFile/Elf/ElfSectionLink.cs | 147 - .../Elf/ElfSectionSpecialType.cs | 38 - .../src/LibObjectFile/Elf/ElfSectionType.cs | 132 - .../src/LibObjectFile/Elf/ElfSegment.cs | 140 - .../src/LibObjectFile/Elf/ElfSegmentFlags.cs | 61 - .../LibObjectFile/Elf/ElfSegmentFlagsCore.cs | 35 - .../src/LibObjectFile/Elf/ElfSegmentRange.cs | 146 - .../src/LibObjectFile/Elf/ElfSegmentType.cs | 61 - .../LibObjectFile/Elf/ElfSegmentTypeCore.cs | 52 - .../src/LibObjectFile/Elf/ElfString.cs | 111 - .../src/LibObjectFile/Elf/ElfWriter.cs | 52 - .../src/LibObjectFile/Elf/ElfWriterDirect.cs | 18 - .../src/LibObjectFile/Elf/ElfWriterSwap.cs | 18 - .../LibObjectFile/Elf/ElfWriter{TEncoder}.cs | 316 - .../src/LibObjectFile/Elf/IElfDecoder.cs | 49 - .../src/LibObjectFile/Elf/IElfEncoder.cs | 49 - .../Elf/Sections/ElfAlignedShadowSection.cs | 68 - .../Elf/Sections/ElfBinarySection.cs | 82 - .../Elf/Sections/ElfBinaryShadowSection.cs | 39 - .../Elf/Sections/ElfCustomNote.cs | 107 - .../LibObjectFile/Elf/Sections/ElfGnuNote.cs | 14 - .../Elf/Sections/ElfGnuNoteABITag.cs | 83 - .../Elf/Sections/ElfGnuNoteBuildId.cs | 58 - .../Elf/Sections/ElfGnuNoteOSKind.cs | 32 - .../src/LibObjectFile/Elf/Sections/ElfNote.cs | 48 - .../Elf/Sections/ElfNoteTable.cs | 175 - .../LibObjectFile/Elf/Sections/ElfNoteType.cs | 65 - .../Elf/Sections/ElfNullSection.cs | 45 - .../Elf/Sections/ElfProgramHeaderTable.cs | 93 - .../Elf/Sections/ElfRelocation.cs | 58 - .../Elf/Sections/ElfRelocationContext.cs | 20 - .../Elf/Sections/ElfRelocationTable.cs | 314 - .../Sections/ElfRelocationTableExtensions.cs | 235 - .../Elf/Sections/ElfRelocationType.cs | 66 - .../Sections/ElfSectionHeaderStringTable.cs | 19 - .../Elf/Sections/ElfShadowSection.cs | 19 - .../Elf/Sections/ElfStringTable.cs | 321 - .../LibObjectFile/Elf/Sections/ElfSymbol.cs | 92 - .../Elf/Sections/ElfSymbolBind.cs | 64 - .../Elf/Sections/ElfSymbolTable.cs | 286 - .../ElfSymbolTableSectionHeaderIndices.cs | 126 - .../Elf/Sections/ElfSymbolType.cs | 84 - .../Elf/Sections/ElfSymbolVisibility.cs | 34 - .../src/LibObjectFile/IObjectFileNodeLink.cs | 13 - .../src/LibObjectFile/LibObjectFile.csproj | 40 - .../LibObjectFile.csproj.DotSettings | 2 - .../src/LibObjectFile/ObjectFileException.cs | 27 - .../src/LibObjectFile/ObjectFileExtensions.cs | 141 - .../src/LibObjectFile/ObjectFileNode.cs | 152 - .../LibObjectFile/ObjectFileReaderWriter.cs | 341 - .../ObjectFileStreamExtensions.cs | 234 - .../src/LibObjectFile/RelocationSize.cs | 14 - .../src/LibObjectFile/Utils/AlignHelper.cs | 41 - .../src/LibObjectFile/Utils/SliceStream.cs | 148 - .../src/LibObjectFile/Utils/ThrowHelper.cs | 84 - .../src/LibObjectFile/ValueKind.cs | 22 - .../LibObjectFile.Dwarf.generated.cs | 15181 ---------------- .../generated/LibObjectFile.Elf.generated.cs | 14546 --------------- .../LibObjectFile/src/dotnet-releaser.toml | 9 - .../LibObjectFile/src/objdasm/ObjDisasmApp.cs | 180 - .../LibObjectFile/src/objdasm/Program.cs | 87 - .../LibObjectFile/src/objdasm/objdasm.csproj | 19 - .../LibObjectFile/src/test-with-docker.sh | 14 - 207 files changed, 738 insertions(+), 59674 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/changelog.md delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/doc/readme.md delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/license.txt delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/readme.md delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/helloworld.cpp delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs delete mode 100644 src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj delete mode 100755 src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs new file mode 100644 index 00000000000000..ddf1f09b1a6e6d --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -0,0 +1,246 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +namespace ILCompiler.ObjectWriter +{ + public static class ElfNative + { + public const byte EV_CURRENT = 1; + + public const ushort ET_REL = 1; + + public const byte ELFCLASS32 = 1; + public const byte ELFCLASS64 = 2; + + public const byte ELFDATA2LSB = 1; + + public const ushort EM_386 = 3; + public const ushort EM_X86_64 = 62; + public const ushort EM_AARCH64 = 183; + + public const uint SHT_NULL = 0; + public const uint SHT_PROGBITS = 1; + public const uint SHT_SYMTAB = 2; + public const uint SHT_STRTAB = 3; + public const uint SHT_RELA = 4; + public const uint SHT_HASH = 5; + public const uint SHT_DYNAMIC = 6; + public const uint SHT_NOTE = 7; + public const uint SHT_NOBITS = 8; + public const uint SHT_REL = 9; + public const uint SHT_SHLIB = 10; + public const uint SHT_DYNSYM = 11; + public const uint SHT_INIT_ARRAY = 14; + public const uint SHT_FINI_ARRAY = 15; + public const uint SHT_PREINIT_ARRAY = 16; + public const uint SHT_GROUP = 17; + public const uint SHT_SYMTAB_SHNDX = 18; + public const uint SHT_IA_64_UNWIND = 1879048193; + + public const uint SHF_WRITE = 1; + public const uint SHF_ALLOC = 2; + public const uint SHF_EXECINSTR = 4; + public const uint SHF_MERGE = 16; + public const uint SHF_STRINGS = 32; + public const uint SHF_INFO_LINK = 64; + public const uint SHF_LINK_ORDER = 128; + public const uint SHF_OS_NONCONFORMING = 256; + public const uint SHF_GROUP = 512; + public const uint SHF_TLS = 1024; + public const uint SHF_COMPRESSED = 2048; + + public const uint SHN_UNDEF = 0; + public const uint SHN_LORESERVE = 65280; + public const uint SHN_XINDEX = 65535; + + public const byte STT_NOTYPE = 0; + public const byte STT_OBJECT = 1; + public const byte STT_FUNC = 2; + public const byte STT_SECTION = 3; + public const byte STT_FILE = 4; + public const byte STT_COMMON = 5; + public const byte STT_TLS = 6; + + public const byte STV_DEFAULT = 0; + public const byte STV_INTERNAL = 1; + public const byte STV_HIDDEN = 2; + public const byte STV_PROTECTED = 3; + + public const byte STB_LOCAL = 0; + public const byte STB_GLOBAL = 1; + public const byte STB_WEAK = 2; + + public const uint R_X86_64_NONE = 0; + public const uint R_X86_64_64 = 1; + public const uint R_X86_64_PC32 = 2; + public const uint R_X86_64_GOT32 = 3; + public const uint R_X86_64_PLT32 = 4; + public const uint R_X86_64_COPY = 5; + public const uint R_X86_64_GLOB_DAT = 6; + public const uint R_X86_64_JUMP_SLOT = 7; + public const uint R_X86_64_RELATIVE = 8; + public const uint R_X86_64_GOTPCREL = 9; + public const uint R_X86_64_32 = 10; + public const uint R_X86_64_32S = 11; + public const uint R_X86_64_16 = 12; + public const uint R_X86_64_PC16 = 13; + public const uint R_X86_64_8 = 14; + public const uint R_X86_64_PC8 = 15; + public const uint R_X86_64_DTPMOD64 = 16; + public const uint R_X86_64_DTPOFF64 = 17; + public const uint R_X86_64_TPOFF64 = 18; + public const uint R_X86_64_TLSGD = 19; + public const uint R_X86_64_TLSLD = 20; + public const uint R_X86_64_DTPOFF32 = 21; + public const uint R_X86_64_GOTTPOFF = 22; + public const uint R_X86_64_TPOFF32 = 23; + public const uint R_X86_64_PC64 = 24; + public const uint R_X86_64_GOTOFF64 = 25; + public const uint R_X86_64_GOTPC32 = 26; + public const uint R_X86_64_GOT64 = 27; + public const uint R_X86_64_GOTPCREL64 = 28; + public const uint R_X86_64_GOTPC64 = 29; + public const uint R_X86_64_GOTPLT64 = 30; + public const uint R_X86_64_PLTOFF64 = 31; + public const uint R_X86_64_SIZE32 = 32; + public const uint R_X86_64_SIZE64 = 33; + public const uint R_X86_64_GOTPC32_TLSDESC = 34; + public const uint R_X86_64_TLSDESC_CALL = 35; + public const uint R_X86_64_TLSDESC = 36; + public const uint R_X86_64_IRELATIVE = 37; + public const uint R_X86_64_RELATIVE64 = 38; + + public const uint R_AARCH64_NONE = 0; + public const uint R_AARCH64_P32_ABS32 = 1; + public const uint R_AARCH64_P32_COPY = 180; + public const uint R_AARCH64_P32_GLOB_DAT = 181; + public const uint R_AARCH64_P32_JUMP_SLOT = 182; + public const uint R_AARCH64_P32_RELATIVE = 183; + public const uint R_AARCH64_P32_TLS_DTPMOD = 184; + public const uint R_AARCH64_P32_TLS_DTPREL = 185; + public const uint R_AARCH64_P32_TLS_TPREL = 186; + public const uint R_AARCH64_P32_TLSDESC = 187; + public const uint R_AARCH64_P32_IRELATIVE = 188; + public const uint R_AARCH64_ABS64 = 257; + public const uint R_AARCH64_ABS32 = 258; + public const uint R_AARCH64_ABS16 = 259; + public const uint R_AARCH64_PREL64 = 260; + public const uint R_AARCH64_PREL32 = 261; + public const uint R_AARCH64_PREL16 = 262; + public const uint R_AARCH64_MOVW_UABS_G0 = 263; + public const uint R_AARCH64_MOVW_UABS_G0_NC = 264; + public const uint R_AARCH64_MOVW_UABS_G1 = 265; + public const uint R_AARCH64_MOVW_UABS_G1_NC = 266; + public const uint R_AARCH64_MOVW_UABS_G2 = 267; + public const uint R_AARCH64_MOVW_UABS_G2_NC = 268; + public const uint R_AARCH64_MOVW_UABS_G3 = 269; + public const uint R_AARCH64_MOVW_SABS_G0 = 270; + public const uint R_AARCH64_MOVW_SABS_G1 = 271; + public const uint R_AARCH64_MOVW_SABS_G2 = 272; + public const uint R_AARCH64_LD_PREL_LO19 = 273; + public const uint R_AARCH64_ADR_PREL_LO21 = 274; + public const uint R_AARCH64_ADR_PREL_PG_HI21 = 275; + public const uint R_AARCH64_ADR_PREL_PG_HI21_NC = 276; + public const uint R_AARCH64_ADD_ABS_LO12_NC = 277; + public const uint R_AARCH64_LDST8_ABS_LO12_NC = 278; + public const uint R_AARCH64_TSTBR14 = 279; + public const uint R_AARCH64_CONDBR19 = 280; + public const uint R_AARCH64_JUMP26 = 282; + public const uint R_AARCH64_CALL26 = 283; + public const uint R_AARCH64_LDST16_ABS_LO12_NC = 284; + public const uint R_AARCH64_LDST32_ABS_LO12_NC = 285; + public const uint R_AARCH64_LDST64_ABS_LO12_NC = 286; + public const uint R_AARCH64_MOVW_PREL_G0 = 287; + public const uint R_AARCH64_MOVW_PREL_G0_NC = 288; + public const uint R_AARCH64_MOVW_PREL_G1 = 289; + public const uint R_AARCH64_MOVW_PREL_G1_NC = 290; + public const uint R_AARCH64_MOVW_PREL_G2 = 291; + public const uint R_AARCH64_MOVW_PREL_G2_NC = 292; + public const uint R_AARCH64_MOVW_PREL_G3 = 293; + public const uint R_AARCH64_LDST128_ABS_LO12_NC = 299; + public const uint R_AARCH64_MOVW_GOTOFF_G0 = 300; + public const uint R_AARCH64_MOVW_GOTOFF_G0_NC = 301; + public const uint R_AARCH64_MOVW_GOTOFF_G1 = 302; + public const uint R_AARCH64_MOVW_GOTOFF_G1_NC = 303; + public const uint R_AARCH64_MOVW_GOTOFF_G2 = 304; + public const uint R_AARCH64_MOVW_GOTOFF_G2_NC = 305; + public const uint R_AARCH64_MOVW_GOTOFF_G3 = 306; + public const uint R_AARCH64_GOTREL64 = 307; + public const uint R_AARCH64_GOTREL32 = 308; + public const uint R_AARCH64_GOT_LD_PREL19 = 309; + public const uint R_AARCH64_LD64_GOTOFF_LO15 = 310; + public const uint R_AARCH64_ADR_GOT_PAGE = 311; + public const uint R_AARCH64_LD64_GOT_LO12_NC = 312; + public const uint R_AARCH64_LD64_GOTPAGE_LO15 = 313; + public const uint R_AARCH64_TLSGD_ADR_PREL21 = 512; + public const uint R_AARCH64_TLSGD_ADR_PAGE21 = 513; + public const uint R_AARCH64_TLSGD_ADD_LO12_NC = 514; + public const uint R_AARCH64_TLSGD_MOVW_G1 = 515; + public const uint R_AARCH64_TLSGD_MOVW_G0_NC = 516; + public const uint R_AARCH64_TLSLD_ADR_PREL21 = 517; + public const uint R_AARCH64_TLSLD_ADR_PAGE21 = 518; + public const uint R_AARCH64_TLSLD_ADD_LO12_NC = 519; + public const uint R_AARCH64_TLSLD_MOVW_G1 = 520; + public const uint R_AARCH64_TLSLD_MOVW_G0_NC = 521; + public const uint R_AARCH64_TLSLD_LD_PREL19 = 522; + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523; + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524; + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525; + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526; + public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527; + public const uint R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528; + public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529; + public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530; + public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531; + public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532; + public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533; + public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534; + public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535; + public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536; + public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537; + public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538; + public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539; + public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540; + public const uint R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541; + public const uint R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542; + public const uint R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543; + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544; + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545; + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546; + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547; + public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548; + public const uint R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549; + public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550; + public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551; + public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552; + public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553; + public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554; + public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555; + public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556; + public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557; + public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558; + public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559; + public const uint R_AARCH64_TLSDESC_LD_PREL19 = 560; + public const uint R_AARCH64_TLSDESC_ADR_PREL21 = 561; + public const uint R_AARCH64_TLSDESC_ADR_PAGE21 = 562; + public const uint R_AARCH64_TLSDESC_LD64_LO12 = 563; + public const uint R_AARCH64_TLSDESC_ADD_LO12 = 564; + public const uint R_AARCH64_TLSDESC_OFF_G1 = 565; + public const uint R_AARCH64_TLSDESC_OFF_G0_NC = 566; + public const uint R_AARCH64_TLSDESC_LDR = 567; + public const uint R_AARCH64_TLSDESC_ADD = 568; + public const uint R_AARCH64_TLSDESC_CALL = 569; + public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570; + public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571; + public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572; + public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573; + public const uint R_AARCH64_COPY = 1024; + public const uint R_AARCH64_GLOB_DAT = 1025; + public const uint R_AARCH64_JUMP_SLOT = 1026; + public const uint R_AARCH64_RELATIVE = 1027; + public const uint R_AARCH64_TLS_DTPMOD = 1028; + public const uint R_AARCH64_TLS_DTPREL = 1029; + public const uint R_AARCH64_TLS_TPREL = 1030; + public const uint R_AARCH64_TLSDESC = 1031; + public const uint R_AARCH64_IRELATIVE = 1032; + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index c361a4f08b9db1..dfb32117b34d03 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -6,126 +6,117 @@ using System.IO; using System.Diagnostics; using System.Buffers.Binary; +using System.Numerics; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; -using LibObjectFile; -using LibObjectFile.Elf; namespace ILCompiler.ObjectWriter { public sealed class ElfObjectWriter : UnixObjectWriter { - private readonly ElfObjectFile _objectFile; - private readonly Dictionary _bssStreams = new(); - private readonly List _sections = new(); - private readonly Dictionary _elfSectionToSectionIndex = new(); - private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); - private readonly Dictionary _sectionToRelocationTable = new(); - private readonly List _debugSections = new(); + private readonly ushort _machine; + private readonly ElfStringTable _stringTable = new(); + private readonly List _sections = new(); + private readonly List _symbols = new(); + private uint _localSymbolCount; + private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); // Symbol table private readonly Dictionary _symbolNameToIndex = new(); - private readonly ElfSymbolTable _symbolTable; private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { - ElfArch arch = factory.Target.Architecture switch + _machine = factory.Target.Architecture switch { - TargetArchitecture.X64 => ElfArch.X86_64, - TargetArchitecture.ARM64 => ElfArch.AARCH64, + TargetArchitecture.X64 => ElfNative.EM_X86_64, + TargetArchitecture.ARM64 => ElfNative.EM_AARCH64, _ => throw new NotSupportedException("Unsupported architecture") }; - _objectFile = new ElfObjectFile(arch); - - var stringSection = new ElfStringTable(); - _symbolTable = new ElfSymbolTable { Link = stringSection }; + // By convention the symbol table starts with empty symbol + _symbols.Add(new ElfSymbol {}); } protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { - ElfSection elfSection; - ElfGroupSection groupSection = null; string sectionName = section.Name == "rdata" ? ".rodata" : (section.Name.StartsWith('_') || section.Name.StartsWith('.') ? section.Name : "." + section.Name); int sectionIndex = _sections.Count; - - if (comdatName is not null && - !_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) - { - groupSection = new ElfGroupSection - { - GroupFlags = 1, // GRP_COMDAT - Link = _symbolTable, - // Info = of the COMDAT symbol, to be filled later - }; - _comdatNameToElfSection.Add(comdatName, groupSection); - } + uint type = 0; + uint flags = 0; + SectionDefinition groupSection = null; if (section.Type == SectionType.Uninitialized) { - elfSection = new ElfBinarySection() - { - Name = sectionName, - Type = ElfSectionType.NoBits, - Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write, - }; - - _bssStreams[sectionIndex] = sectionStream; + type = ElfNative.SHT_NOBITS; + flags = ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE; } else if (section == ObjectNodeSection.TLSSection) { - elfSection = new ElfBinarySection(sectionStream) - { - Name = sectionName, - Type = ElfSectionType.ProgBits, - Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write | ElfSectionFlags.Tls - }; + type = ElfNative.SHT_PROGBITS; + flags = ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE | ElfNative.SHF_TLS; } else { - elfSection = new ElfBinarySection(sectionStream) + type = section.Name == ".eh_frame" && _machine == ElfNative.EM_X86_64 ? ElfNative.SHT_IA_64_UNWIND : ElfNative.SHT_PROGBITS; + flags = section.Type switch { - Name = sectionName, - Type = section.Name == ".eh_frame" && _objectFile.Arch == ElfArch.X86_64 ? - (ElfSectionType)ElfNative.SHT_IA_64_UNWIND : ElfSectionType.ProgBits, - Flags = section.Type switch - { - SectionType.Executable => ElfSectionFlags.Alloc | ElfSectionFlags.Executable, - SectionType.Writeable => ElfSectionFlags.Alloc | ElfSectionFlags.Write, - SectionType.Debug => sectionName == ".debug_str" ? ElfSectionFlags.Merge | ElfSectionFlags.Strings : 0, - _ => ElfSectionFlags.Alloc, - }, - Alignment = 1 + SectionType.Executable => ElfNative.SHF_ALLOC | ElfNative.SHF_EXECINSTR, + SectionType.Writeable => ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE, + SectionType.Debug => sectionName == ".debug_str" ? ElfNative.SHF_MERGE | ElfNative.SHF_STRINGS : 0, + _ => ElfNative.SHF_ALLOC, }; } - if (section.Type == SectionType.Debug) + if (comdatName is not null && + !_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) { - _debugSections.Add(elfSection); + Span tempBuffer = stackalloc byte[sizeof(uint)]; + groupSection = new SectionDefinition + { + Name = ".group", + Type = ElfNative.SHT_GROUP, + Alignment = 4, + Stream = new MemoryStream(5 * sizeof(uint)), + }; + + // Write group flags + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, /*ElfNative.GRP_COMDAT*/1u); + groupSection.Stream.Write(tempBuffer); + + _comdatNameToElfSection.Add(comdatName, groupSection); } - _elfSectionToSectionIndex[elfSection] = sectionIndex; - _sections.Add(elfSection); - groupSection?.AddSection(elfSection); + _sections.Add(new SectionDefinition + { + Name = sectionName, + Type = type, + Flags = flags, + Stream = sectionStream, + GroupSection = groupSection, + }); // Emit section symbol into symbol table (for COMDAT the defining symbol is section symbol) if (comdatName is null) { - _symbolNameToIndex[elfSection.Name] = (uint)_symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() { Type = ElfSymbolType.Section, Section = elfSection }); + _symbolNameToIndex[sectionName] = (uint)_symbols.Count; + _symbols.Add(new ElfSymbol + { + Section = _sections[sectionIndex], + Info = ElfNative.STT_SECTION, + }); } - base.CreateSection(section, comdatName, symbolName ?? elfSection.Name.Value, sectionStream); + base.CreateSection(section, comdatName, symbolName ?? sectionName, sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - ElfSection elfSection = _sections[sectionIndex]; - elfSection.Alignment = Math.Max(elfSection.Alignment, (uint)alignment); + SectionDefinition elfSection = _sections[sectionIndex]; + elfSection.Alignment = Math.Max(elfSection.Alignment, alignment); } protected internal override void EmitRelocation( @@ -180,23 +171,21 @@ protected override void EmitSymbolTable( IDictionary definedSymbols, SortedSet undefinedSymbols) { - uint symbolIndex = (uint)_symbolTable.Entries.Count; - - List sortedSymbols = new(definedSymbols.Count); + List sortedSymbols = new(definedSymbols.Count + undefinedSymbols.Count); foreach ((string name, SymbolDefinition definition) in definedSymbols) { - ElfSection elfSection = _sections[definition.SectionIndex]; + var section = _sections[definition.SectionIndex]; + var type = + (section.Flags & ElfNative.SHF_TLS) == ElfNative.SHF_TLS ? ElfNative.STT_TLS : + definition.Size > 0 ? ElfNative.STT_FUNC : ElfNative.STT_NOTYPE; sortedSymbols.Add(new ElfSymbol { Name = name, - Bind = ElfSymbolBind.Global, - Section = elfSection, Value = (ulong)definition.Value, - Type = - elfSection.Flags.HasFlag(ElfSectionFlags.Tls) ? ElfSymbolType.Tls : - definition.Size > 0 ? ElfSymbolType.Function : 0, Size = (ulong)definition.Size, - Visibility = definition.Global ? ElfSymbolVisibility.Default : ElfSymbolVisibility.Hidden, + Section = _sections[definition.SectionIndex], + Info = (byte)(type | (ElfNative.STB_GLOBAL << 4)), + Other = definition.Global ? ElfNative.STV_DEFAULT : ElfNative.STV_HIDDEN, }); } @@ -207,34 +196,36 @@ protected override void EmitSymbolTable( sortedSymbols.Add(new ElfSymbol { Name = externSymbol, - Bind = ElfSymbolBind.Global, + Info = (ElfNative.STB_GLOBAL << 4), }); } } sortedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); + _localSymbolCount = (uint)_symbols.Count; + _symbols.AddRange(sortedSymbols); + uint symbolIndex = _localSymbolCount; foreach (ElfSymbol definedSymbol in sortedSymbols) { - _symbolTable.Entries.Add(definedSymbol); _symbolNameToIndex[definedSymbol.Name] = symbolIndex; symbolIndex++; } // Update group sections links - foreach ((string comdatName, ElfGroupSection groupSection) in _comdatNameToElfSection) + foreach ((string comdatName, SectionDefinition groupSection) in _comdatNameToElfSection) { - groupSection.Info = new ElfSectionLink(_symbolNameToIndex[comdatName]); + groupSection.Info = (uint)_symbolNameToIndex[comdatName]; } } protected override void EmitRelocations(int sectionIndex, List relocationList) { - switch ((ElfArch)_objectFile.Arch) + switch (_machine) { - case ElfArch.X86_64: + case ElfNative.EM_X86_64: EmitRelocationsX64(sectionIndex, relocationList); break; - case ElfArch.AARCH64: + case ElfNative.EM_AARCH64: EmitRelocationsARM64(sectionIndex, relocationList); break; default: @@ -245,62 +236,57 @@ protected override void EmitRelocations(int sectionIndex, List relocationList) { - ElfSection elfSection = _sections[sectionIndex]; - if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) + if (relocationList.Count > 0) { + Span relocationEntry = stackalloc byte[24]; + var relocationStream = new MemoryStream(24 * relocationList.Count); + _sections[sectionIndex].RelocationStream = relocationStream; foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - - ElfRelocationType type = symbolicRelocation.Type switch + uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_AARCH64_ABS64, - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfRelocationType.R_AARCH64_ABS32, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_AARCH64_PREL32, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfRelocationType.R_AARCH64_CALL26, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfRelocationType.R_AARCH64_ADR_PREL_PG_HI21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfRelocationType.R_AARCH64_ADD_ABS_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfRelocationType.R_AARCH64_TLSLE_ADD_TPREL_HI12, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfRelocationType.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfRelocationType.R_AARCH64_TLSDESC_ADR_PAGE21, - RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfRelocationType.R_AARCH64_TLSDESC_LD64_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfRelocationType.R_AARCH64_TLSDESC_ADD_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfRelocationType.R_AARCH64_TLSDESC_CALL, + RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_AARCH64_ABS64, + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_AARCH64_ABS32, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_AARCH64_PREL32, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfNative.R_AARCH64_CALL26, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfNative.R_AARCH64_ADR_PREL_PG_HI21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfNative.R_AARCH64_ADD_ABS_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21, + RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfNative.R_AARCH64_TLSDESC_LD64_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfNative.R_AARCH64_TLSDESC_ADD_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfNative.R_AARCH64_TLSDESC_CALL, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - relocationTable.Entries.Add(new ElfRelocation - { - SymbolIndex = symbolIndex, - Type = type, - Offset = (ulong)symbolicRelocation.Offset, - Addend = symbolicRelocation.Addend - }); + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry, (ulong)symbolicRelocation.Offset); + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry.Slice(8), ((ulong)symbolIndex << 32) | type); + BinaryPrimitives.WriteInt64LittleEndian(relocationEntry.Slice(16), symbolicRelocation.Addend); + relocationStream.Write(relocationEntry); } } - else - { - Debug.Assert(relocationList.Count == 0); - } } private void EmitRelocationsX64(int sectionIndex, List relocationList) { - ElfSection elfSection = _sections[sectionIndex]; - if (_sectionToRelocationTable.TryGetValue(elfSection, out ElfRelocationTable relocationTable)) + if (relocationList.Count > 0) { + Span relocationEntry = stackalloc byte[24]; + var relocationStream = new MemoryStream(24 * relocationList.Count); + _sections[sectionIndex].RelocationStream = relocationStream; foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - - ElfRelocationType type = symbolicRelocation.Type switch + uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfRelocationType.R_X86_64_32, - RelocType.IMAGE_REL_BASED_DIR64 => ElfRelocationType.R_X86_64_64, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfRelocationType.R_X86_64_PC32, - RelocType.IMAGE_REL_BASED_REL32 => ElfRelocationType.R_X86_64_PLT32, - RelocType.IMAGE_REL_TLSGD => ElfRelocationType.R_X86_64_TLSGD, - RelocType.IMAGE_REL_TPOFF => ElfRelocationType.R_X86_64_TPOFF32, + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_X86_64_32, + RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_X86_64_64, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_X86_64_PC32, + RelocType.IMAGE_REL_BASED_REL32 => ElfNative.R_X86_64_PLT32, + RelocType.IMAGE_REL_TLSGD => ElfNative.R_X86_64_TLSGD, + RelocType.IMAGE_REL_TPOFF => ElfNative.R_X86_64_TPOFF32, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; @@ -310,100 +296,245 @@ private void EmitRelocationsX64(int sectionIndex, List reloc addend -= 4; } - relocationTable.Entries.Add(new ElfRelocation - { - SymbolIndex = symbolIndex, - Type = type, - Offset = (ulong)symbolicRelocation.Offset, - Addend = addend - }); + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry, (ulong)symbolicRelocation.Offset); + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry.Slice(8), ((ulong)symbolIndex << 32) | type); + BinaryPrimitives.WriteInt64LittleEndian(relocationEntry.Slice(16), addend); + relocationStream.Write(relocationEntry); } } - else - { - Debug.Assert(relocationList.Count == 0); - } } - protected override void EmitDebugSections(IDictionary definedSymbols) + protected override void EmitSectionsAndLayout() { - base.EmitDebugSections(definedSymbols); - - foreach (ElfSection debugSection in _debugSections) - { - AddElfSectionWithRelocationsIfNecessary(debugSection); - } } - private void AddElfSectionWithRelocationsIfNecessary(ElfSection elfSection, ElfGroupSection groupSection = null) + protected override void EmitObjectFile(string objectFilePath) { - int sectionIndex = _elfSectionToSectionIndex[elfSection]; - elfSection.Flags |= groupSection is not null ? ElfSectionFlags.Group : 0; - _objectFile.AddSection(elfSection); - - if (SectionHasRelocations(sectionIndex)) + using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) { - var elfRelocationTable = new ElfRelocationTable + ulong sectionHeaderOffset = (ulong)ElfHeader.Size; + uint sectionCount = 1; // NULL section + bool hasSymTabExtendedIndices = false; + Span tempBuffer = stackalloc byte[sizeof(uint)]; + + _sections.AddRange(_comdatNameToElfSection.Values); + _sections.Add(new SectionDefinition + { + Name = ".note.GNU-stack", + Type = ElfNative.SHT_PROGBITS, + Stream = Stream.Null, + }); + + foreach (var section in _sections) + { + _stringTable.ReserveString(section.Name); + section.SectionIndex = (uint)sectionCount; + if (section.Alignment > 0) + { + sectionHeaderOffset = (ulong)((sectionHeaderOffset + (ulong)section.Alignment - 1) & ~(ulong)(section.Alignment - 1)); + } + section.SectionOffset = sectionHeaderOffset; + if (section.Type != ElfNative.SHT_NOBITS) + { + sectionHeaderOffset += (ulong)section.Stream.Length; + } + sectionHeaderOffset += (ulong)section.RelocationStream.Length; + sectionCount++; + if (section.RelocationStream != Stream.Null) + { + _stringTable.ReserveString(".rela" + section.Name); + sectionCount++; + } + + // Write the section index into the section's group. We store all the groups + // at the end so we can modify their contents in this loop safely. + if (section.GroupSection is not null) + { + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, section.SectionIndex); + section.GroupSection.Stream.Write(tempBuffer); + } + } + + // Reserve all symbol names + foreach (var symbol in _symbols) + { + if (symbol.Name is not null) + { + _stringTable.ReserveString(symbol.Name); + } + } + _stringTable.ReserveString(".strtab"); + _stringTable.ReserveString(".symtab"); + if (sectionCount >= ElfNative.SHN_LORESERVE) + { + _stringTable.ReserveString(".symtab_shndx"); + hasSymTabExtendedIndices = true; + } + + uint strTabSectionIndex = sectionCount; + sectionHeaderOffset += _stringTable.Size; + sectionCount++; + uint symTabSectionIndex = sectionCount; + sectionHeaderOffset += (ulong)(_symbols.Count * ElfSymbol.Size64); + sectionCount++; + if (hasSymTabExtendedIndices) { - Name = ".rela" + elfSection.Name, - Link = _symbolTable, - Info = elfSection, - Alignment = 8, - Flags = groupSection is not null ? ElfSectionFlags.Group : 0 + sectionHeaderOffset += (ulong)(_symbols.Count * sizeof(uint)); + sectionCount++; + } + + ElfHeader elfHeader = new ElfHeader + { + Type = ElfNative.ET_REL, + Machine = _machine, + Version = ElfNative.EV_CURRENT, + SegmentHeaderEntrySize = 0x38, + SectionHeaderOffset = sectionHeaderOffset, + SectionHeaderEntrySize = (ushort)ElfSectionHeader.Size, + SectionHeaderEntryCount = sectionCount < ElfNative.SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, + StringTableIndex = strTabSectionIndex < ElfNative.SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)ElfNative.SHN_XINDEX, }; + elfHeader.Write(outputFileStream); - _sectionToRelocationTable[elfSection] = elfRelocationTable; - _objectFile.AddSection(elfRelocationTable); - groupSection?.AddSection(elfRelocationTable); - } - } + foreach (var section in _sections) + { + if (section.Type != ElfNative.SHT_NOBITS) + { + outputFileStream.Position = (long)section.SectionOffset; + section.Stream.Position = 0; + section.Stream.CopyTo(outputFileStream); + if (section.RelocationStream != Stream.Null) + { + section.RelocationStream.Position = 0; + section.RelocationStream.CopyTo(outputFileStream); + } + } + } - protected override void EmitSectionsAndLayout() - { - foreach (ElfGroupSection groupSection in _comdatNameToElfSection.Values) - { - _objectFile.AddSection(groupSection); - for (int i = 0, sectionCount = groupSection.Sections.Count; i < sectionCount; i++) + ulong stringTableOffset = (ulong)outputFileStream.Position; + _stringTable.Write(outputFileStream); + + ulong symbolTableOffset = (ulong)outputFileStream.Position; + foreach (var symbol in _symbols) { - AddElfSectionWithRelocationsIfNecessary(groupSection.Sections[i], groupSection); + symbol.Write64(outputFileStream, _stringTable); } - } - foreach (ElfSection elfSection in _sections) - { - // If the section was not already added as part of COMDAT group, - // add it now. - if (elfSection.Parent is null) + ulong symbolTableExtendedIndicesOffset = (ulong)outputFileStream.Position; + if (hasSymTabExtendedIndices) { - AddElfSectionWithRelocationsIfNecessary(elfSection); + foreach (var symbol in _symbols) + { + uint index = symbol.Section?.SectionIndex ?? 0; + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, index >= ElfNative.SHN_LORESERVE ? index : 0); + outputFileStream.Write(tempBuffer); + } } - } - _objectFile.AddSection(_symbolTable.Link.Section); - _objectFile.AddSection(_symbolTable); - _objectFile.AddSection(new ElfSectionHeaderStringTable()); - foreach ((int bssSectionIndex, Stream bssStream) in _bssStreams) - { - _sections[bssSectionIndex].Size = (ulong)bssStream.Length; - } + // Null section + ElfSectionHeader nullSectionHeader = new ElfSectionHeader + { + NameIndex = 0, + Type = ElfNative.SHT_NULL, + Flags = 0u, + Address = 0u, + Offset = 0u, + SectionSize = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, + Link = strTabSectionIndex >= ElfNative.SHN_LORESERVE ? strTabSectionIndex : 0u, + Info = 0u, + Alignment = 0u, + EntrySize = 0u, + }; + nullSectionHeader.Write(outputFileStream); - _objectFile.AddSection(new ElfBinarySection(Stream.Null) - { - Name = ".note.GNU-stack", - Type = ElfSectionType.ProgBits, - }); + foreach (var section in _sections) + { + uint groupFlag = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u; - if (_objectFile.Sections.Count >= ElfNative.SHN_LORESERVE) - { - _objectFile.AddSection(new ElfSymbolTableSectionHeaderIndices { Link = _symbolTable }); - } - } + ElfSectionHeader sectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(section.Name), + Type = section.Type, + Flags = section.Flags | groupFlag, + Address = 0u, + Offset = section.SectionOffset, + SectionSize = (ulong)section.Stream.Length, + Link = section.Type == ElfNative.SHT_GROUP ? symTabSectionIndex : 0u, + Info = section.Info, + Alignment = (ulong)section.Alignment, + EntrySize = section.Type == ElfNative.SHT_GROUP ? (uint)sizeof(uint) : 0u, + }; + sectionHeader.Write(outputFileStream); - protected override void EmitObjectFile(string objectFilePath) - { - using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) - { - _objectFile.Write(outputFileStream); + if (section.Type != ElfNative.SHT_NOBITS && + section.RelocationStream != Stream.Null) + { + sectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), + Type = ElfNative.SHT_RELA, + Flags = groupFlag, + Address = 0u, + Offset = section.SectionOffset + sectionHeader.SectionSize, + SectionSize = (ulong)section.RelocationStream.Length, + Link = symTabSectionIndex, + Info = section.SectionIndex, + Alignment = 8u, + EntrySize = 24u, + }; + sectionHeader.Write(outputFileStream); + } + } + + // String table section + ElfSectionHeader stringTableSectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".strtab"), + Type = ElfNative.SHT_STRTAB, + Flags = 0u, + Address = 0u, + Offset = stringTableOffset, + SectionSize = _stringTable.Size, + Link = 0u, + Info = 0u, + Alignment = 0u, + EntrySize = 0u, + }; + stringTableSectionHeader.Write(outputFileStream); + + // Symbol table section + ElfSectionHeader symbolTableSectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".symtab"), + Type = ElfNative.SHT_SYMTAB, + Flags = 0u, + Address = 0u, + Offset = symbolTableOffset, + SectionSize = (ulong)(_symbols.Count * ElfSymbol.Size64), + Link = strTabSectionIndex, + Info = _localSymbolCount, + Alignment = 0u, + EntrySize = (uint)ElfSymbol.Size64, + }; + symbolTableSectionHeader.Write(outputFileStream); + + if (hasSymTabExtendedIndices) + { + ElfSectionHeader sectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".symtab_shndx"), + Type = ElfNative.SHT_SYMTAB_SHNDX, + Flags = 0u, + Address = 0u, + Offset = symbolTableExtendedIndicesOffset, + SectionSize = (ulong)(_symbols.Count * sizeof(uint)), + Link = symTabSectionIndex, + Info = 0u, + Alignment = 0u, + EntrySize = (uint)sizeof(uint), + }; + sectionHeader.Write(outputFileStream); + } } } @@ -413,51 +544,179 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection _sections = new(4); + public string Name { get; init; } + public uint Type { get; init; } + public ulong Flags { get; init; } + public int Alignment { get; set; } + public Stream Stream { get; init; } + public Stream RelocationStream { get; set; } = Stream.Null; + public SectionDefinition GroupSection { get; init; } + public uint Info { get; set; } + + // Layout + public uint SectionIndex { get; set; } + public ulong SectionOffset { get; set; } + } - public ElfGroupSection() - { - Name = ".group"; - Type = ElfSectionType.Group; - Alignment = 4; + private sealed class ElfHeader + where T : struct, IBinaryInteger + { + private static ReadOnlySpan Magic => new byte[] { 0x7f, 0x45, 0x4c, 0x46 }; + + public ushort Type { get; set; } + public ushort Machine { get; set; } + public uint Version { get; set; } + public T EntryPoint { get; set; } + public T SegmentHeaderOffset { get; set; } + public T SectionHeaderOffset { get; set; } + public uint Flags { get; set; } + public ushort SegmentHeaderEntrySize { get; set; } + public ushort SegmentHeaderEntryCount { get; set; } + public ushort SectionHeaderEntrySize { get; set; } + public ushort SectionHeaderEntryCount { get; set; } + public ushort StringTableIndex { get; set; } + + private static IBinaryInteger TDefault => default(T); + + public static int Size => + Magic.Length + + 1 + // Class + 1 + // Endianness + 1 + // Header version + 1 + // ABI + 1 + // ABI version + 7 + // Padding + sizeof(ushort) + // Type + sizeof(ushort) + // Machine + sizeof(uint) + // Version + TDefault.GetByteCount() + // Entry point + TDefault.GetByteCount() + // Segment header offset + TDefault.GetByteCount() + // Section header offset + sizeof(uint) + // Flags + sizeof(ushort) + // ELF Header size + sizeof(ushort) + // Segment header entry size + sizeof(ushort) + // Segment header entry count + sizeof(ushort) + // Section header entry size + sizeof(ushort) + // Section header entry count + sizeof(ushort); // String table index + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[Size]; + + buffer.Clear(); + Magic.CopyTo(buffer.Slice(0, Magic.Length)); + buffer[4] = typeof(T) == typeof(uint) ? ElfNative.ELFCLASS32 : ElfNative.ELFCLASS64; + buffer[5] = ElfNative.ELFDATA2LSB; + buffer[6] = 1; + var tempBuffer = buffer.Slice(16); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Type).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Machine).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Version).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(EntryPoint.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(SegmentHeaderOffset.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(SectionHeaderOffset.WriteLittleEndian(tempBuffer)); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, Flags); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(4), (ushort)Size); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(6), SegmentHeaderEntrySize); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(8), SegmentHeaderEntryCount); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(10), SectionHeaderEntrySize); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(12), SectionHeaderEntryCount); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(14), StringTableIndex); + + stream.Write(buffer); } + } - public uint GroupFlags { get; set; } - public IReadOnlyList Sections => _sections; - public override ulong TableEntrySize => 4; + private sealed class ElfSectionHeader + where TSize : struct, IBinaryInteger + { + public uint NameIndex { get; set; } + public uint Type { get; set; } + public TSize Flags { get; set; } + public TSize Address { get; set; } + public TSize Offset { get; set; } + public TSize SectionSize { get; set; } + public uint Link { get; set; } + public uint Info { get; set; } + public TSize Alignment { get; set; } + public TSize EntrySize { get; set; } + + private static IBinaryInteger TSizeDefault => default(TSize); + + public static int Size => + sizeof(uint) + // Name index + sizeof(uint) + // Type + TSizeDefault.GetByteCount() + // Flags + TSizeDefault.GetByteCount() + // Address + TSizeDefault.GetByteCount() + // Offset + TSizeDefault.GetByteCount() + // Size + sizeof(uint) + // Link + sizeof(uint) + // Info + TSizeDefault.GetByteCount() + // Alignment + TSizeDefault.GetByteCount(); // Entry size + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[Size]; + var tempBuffer = buffer; + + tempBuffer = tempBuffer.Slice(((IBinaryInteger)NameIndex).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Type).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(Flags.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(Address.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(Offset.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(SectionSize.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Link).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(((IBinaryInteger)Info).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(Alignment.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(EntrySize.WriteLittleEndian(tempBuffer)); + + stream.Write(buffer); + } + } - public void AddSection(ElfSection section) => _sections.Add(section); + private sealed class ElfSymbol + { + public string Name { get; init; } + public ulong Value { get; init; } + public ulong Size { get; init; } + public SectionDefinition Section { get; init; } + public byte Info { get; init; } + public byte Other { get; init; } - public override void UpdateLayout(DiagnosticBag diagnostics) - { - Size = (ulong)(4u + (_sections.Count * 4u)); - } + public static int Size64 => 24; - public override void Verify(DiagnosticBag diagnostics) + public void Write64(FileStream stream, ElfStringTable stringTable) { - base.Verify(diagnostics); + Span buffer = stackalloc byte[Size64]; - foreach (ElfSection section in _sections) + BinaryPrimitives.WriteUInt32LittleEndian(buffer, Name is not null ? stringTable.GetStringOffset(Name) : 0); + buffer[4] = Info; + buffer[5] = Other; + if (Section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) { - if (section.Parent != Parent) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionInfoParent, $"Invalid parent for grouped section"); - } + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), (ushort)ElfNative.SHN_XINDEX); } - } + else + { + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), Section is not null ? (ushort)Section.SectionIndex : (ushort)0u); + } + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(8), Value); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(16), Size); - protected override void Read(ElfReader reader) => throw new NotImplementedException(); + stream.Write(buffer); + } + } - protected override void Write(ElfWriter writer) + private sealed class ElfStringTable : StringTableBuilder + { + public ElfStringTable() { - writer.Write(GroupFlags); - - foreach (ElfSection section in _sections) - { - writer.Write(section.SectionIndex); - } + // Always start the table with empty string + GetStringOffset(""); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs index b072852a13a266..5da1432ee77819 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs @@ -23,7 +23,14 @@ public void Write(FileStream stream) _stream.CopyTo(stream); } - public uint Size => (uint)_stream.Length; + public uint Size + { + get + { + FlushReservedStrings(); + return (uint)_stream.Length; + } + } public void ReserveString(string text) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 4729885f05339d..9dcf0d46288c5d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -23,7 +23,6 @@ - @@ -610,6 +609,7 @@ + diff --git a/src/coreclr/tools/aot/external/LibObjectFile/changelog.md b/src/coreclr/tools/aot/external/LibObjectFile/changelog.md deleted file mode 100644 index 5eba39943b6e2f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/changelog.md +++ /dev/null @@ -1,32 +0,0 @@ -# Changelog - -## 0.3.5 (11 Feb 2020) -- Fix a bug with bss sections not being correctly handled when trying to write them to a stream -- Add shadow sections between sections even when no-program headers are in the file. - -## 0.3.4 (4 Jan 2020) -- Fix a bug if a program header has an invalid shadow section that does not correspond to a region in the file - -## 0.3.3 (24 Dec 2019) -- Fix an invalid error when a program header size is bigger than expected - -## 0.3.2 (22 Dec 2019) -- Fix a bug when reading ElfObjectFile from an existing ELF where ObjectFile.FileClass/Encoding/Version/OSABI/AbiVersion was not actually deserialized. - -## 0.3.1 (18 Dec 2019) -- Fix creation of DWARF sections from scratch - -## 0.3.0 (18 Dec 2019) -- Add support for DWARF Version 4 (missing only .debug_frame) -- Add support for layouting sections independently of the order defined sections header - -## 0.2.1 (17 Nov 2019) -- Add verify for PT_LOAD segment align requirements - -## 0.2.0 (17 Nov 2019) -- Add support for ElfNoteTable -- Add XML documentation and user manual -- Removed some accessors that should not have been public - -## 0.1.0 (16 Nov 2019) -- Initial version with support for ELF file format \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png b/src/coreclr/tools/aot/external/LibObjectFile/doc/ar_class_diagram.png deleted file mode 100644 index 94017777fbbce96643f6a82b2b37709511591cb7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 37660 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 diff --git a/src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png b/src/coreclr/tools/aot/external/LibObjectFile/doc/elf_class_diagram.png deleted file mode 100644 index c57837fe14afa74cee85b47345fce7643d987dd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 119276 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�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≤yZ1A7 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

YL7u9*yk*NZ??3?c3`@d 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 vB%`-(TlBqz-Z+5;|Kg9|zE=F^ Note: The `ArSymbolTable` instance must be the first entry in the `ArArchiveFile.Files` before other file entries - -```c# -var arFile = new ArArchiveFile(); -// Create Symbol table, added 1st to ArArchiveFile -var symbolTable = new ArSymbolTable(); -arFile.AddFile(symbolTable); -// Create an ELF -var elf = new ElfObjectFile(); -// ... fill elf, add symbols -arFile.AddFile(elf); -// Add a symbol entry -symbolTable.Symbols.Add(new ArSymbol("my_symbol", elf)); -``` -### Links - -- [Archive ar file format (Wikipedia)](https://en.wikipedia.org/wiki/Ar_(Unix)) diff --git a/src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png b/src/coreclr/tools/aot/external/LibObjectFile/img/libobjectfile.png deleted file mode 100644 index 13a891acfcaf4f2c77f4024fb956f4cd22961b70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6489 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 - -LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...) - -> NOTE: Currently LibObjectFile supports only the following file format: -> -> - **ELF** object-file format -> - **DWARF** debugging format (version 4) -> - **Archive `ar`** file format (Common, GNU and BSD variants) -> -> There is a longer term plan to support other file formats (e.g COFF, MACH-O, .lib) but as I don't -> have a need for them right now, it is left as an exercise for PR contributors! ;) - -## Usage - -```C# -// Reads an ELF file -using var inStream = File.OpenRead("helloworld"); -var elf = ElfObjectFile.Read(inStream); -foreach(var section in elf.Sections) -{ - Console.WriteLine(section.Name); -} -// Print the content of the ELF as readelf output -elf.Print(Console.Out); -// Write the ElfObjectFile to another file on the disk -using var outStream = File.OpenWrite("helloworld2"); -elf.Write(outStream); -``` - -## Features -- Full support of Archive `ar` file format including Common, GNU and BSD variants. -- Good support for the ELF file format: - - Read and write from/to a `System.IO.Stream` - - Handling of LSB/MSB - - Support the following sections: - - String Table - - Symbol Table - - Relocation Table: supported I386, X86_64, ARM and AARCH64 relocations (others can be exposed by adding some mappings) - - Note Table - - Other sections fallback to `ElfCustomSection` - - Program headers with or without sections - - Print with `readelf` similar output -- Support for DWARF debugging format: - - Partial support of Version 4 (currently still the default for GCC) - - Support for the sections: `.debug_info`, `.debug_line`, `.debug_aranges`, `.debug_abbrev` and `.debug_str` - - Support for Dwarf expressions - - High level interface, automatic layout/offsets between sections. - - Integration with ELF to support easy reading/writing back - - Support for relocatable sections -- Use of a Diagnostics API to validate file format (on read/before write) -- Library requiring `net7.0` - - If you are looking for `netstandard2.1` support you will need to use `0.4.0` version - -## Documentation - -The [doc/readme.md](doc/readme.md) explains how the library is designed and can be used. - -## Known Issues - -PR Welcome if you are willing to contribute to one of these issues: - -- [ ] Add more unit tests - -### ELF -There are still a few missing implementation of `ElfSection` for completeness: - -- [ ] Dynamic Linking Table (`SHT_DYNAMIC`) -- [ ] Version Symbol Table (`SHT_VERSYM`) -- [ ] Version Needs Table (`SHT_VERNEED`) - -These sections are currently loaded as `ElfCustomSection` but should have their own ElfXXXTable (e.g `ElfDynamicLinkingTable`, `ElfVersionSymbolTable`...) - -### DWARF - -- [ ] Version 4: support for `.debug_types`, `.debug_frame`, `.debug_loc`, `.debug_ranges`, `.debug_pubnames`, `.debug_pubtypes`, `.debug_macinfo` section -- [ ] Version 5 - -### Other file formats -In a future version I would like to implement the following file format: - -- [ ] COFF -- [ ] Mach-O -- [ ] Portable in Memory file format to easily convert between ELF/COFF/Mach-O file formats. - -## Download - -LibObjectFile is available as a NuGet package: [![NuGet](https://img.shields.io/nuget/v/LibObjectFile.svg)](https://www.nuget.org/packages/LibObjectFile/) - -## Build - -In order to build LibObjectFile, you need to have installed the [.NET Core 3.0 SDK](https://www.microsoft.com/net/core). - -Running the tests require Ubuntu 18.04. `dotnet test` will work on Windows (via WSL) and on that version of Ubuntu. -If you're using macOS or another Linux, there's a Dockerfile and a helper script under `src` to run tests in the right OS version. - -## License - -This software is released under the [BSD-Clause 2 license](https://github.com/xoofx/LibObjectFile/blob/master/license.txt). - -## Author - -Alexandre MUTEL aka [xoofx](http://xoofx.com) - -## Supporters - -Supports this project with a monthly donation and help me continue improving it. \[[Become a supporter](https://github.com/sponsors/xoofx)\] - -[bruno-garcia](https://github.com/bruno-garcia) \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore b/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore deleted file mode 100644 index ac752d15f985a8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -Dockerfile -.dockerignore -**/bin/ -**/obj/ \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props b/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props deleted file mode 100644 index 2755547fe39a5d..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/Directory.Build.props +++ /dev/null @@ -1,7 +0,0 @@ - - - True - True - $(NoWarn);CS1591;CS1573;CS1574;CS1734;CS0419 - - \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile b/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile deleted file mode 100644 index 4ae896b1e7059c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM ubuntu:18.04 - -RUN apt-get update && apt-get -y install \ - # .NET Core SDK needs: https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?pivots=os-linux&tabs=netcore31#supported-operating-systems - curl libcurl4 libssl1.0.0 zlib1g libicu60 libkrb5-3 liblttng-ust0 \ - # Tests need: - build-essential gcc - -ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 -RUN curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.0.100 - -ENV PATH="/root/.dotnet:${PATH}" -RUN dotnet --info - -WORKDIR /src - -CMD dotnet test \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj deleted file mode 100644 index 8c186f55fc2799..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/LibObjectFile.CodeGen.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - net7.0 - Exe - false - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - - diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs deleted file mode 100644 index f7a143908e07e9..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.Dwarf.cs +++ /dev/null @@ -1,787 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using CppAst.CodeGen.CSharp; - -namespace LibObjectFile.CodeGen -{ - partial class Program - { - private static void GenerateDwarf() - { - var cppOptions = new CSharpConverterOptions() - { - DefaultClassLib = "DwarfNative", - DefaultNamespace = "LibObjectFile.Dwarf", - DefaultOutputFilePath = "/LibObjectFile.Dwarf.generated.cs", - DefaultDllImportNameAndArguments = "NotUsed", - MappingRules = - { - map => map.MapMacroToConst("^DW_TAG_.*", "unsigned short"), - map => map.MapMacroToConst("^DW_FORM_.*", "unsigned short"), - map => map.MapMacroToConst("^DW_AT_.*", "unsigned short"), - map => map.MapMacroToConst("^DW_LN[ES]_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_IDX_.*", "unsigned short"), - map => map.MapMacroToConst("^DW_LANG_.*", "unsigned short"), - map => map.MapMacroToConst("^DW_ID_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_CC_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_ISA_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_CHILDREN_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_OP_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_ACCESS_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_VIS_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_VIRTUALITY_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_INL_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_ORD_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_DSC_.*", "unsigned char"), - map => map.MapMacroToConst("^DW_UT_.*", "unsigned char"), - } - }; - - cppOptions.GenerateEnumItemAsFields = false; - cppOptions.IncludeFolders.Add(Environment.CurrentDirectory); - - var csCompilation = CSharpConverter.Convert(@"#include ""dwarf.h""", cppOptions); - - AssertCompilation(csCompilation); - - // Add pragma - var csFile = csCompilation.Members.OfType().First(); - var ns = csFile.Members.OfType().First(); - csFile.Members.Insert(csFile.Members.IndexOf(ns), new CSharpLineElement("#pragma warning disable 1591") ); - - ProcessEnum(cppOptions, csCompilation, "DW_AT_", "DwarfAttributeKind"); - ProcessEnum(cppOptions, csCompilation, "DW_FORM_", "DwarfAttributeForm"); - ProcessEnum(cppOptions, csCompilation, "DW_TAG_", "DwarfTag"); - ProcessEnum(cppOptions, csCompilation, "DW_OP_", "DwarfOperationKind"); - ProcessEnum(cppOptions, csCompilation, "DW_LANG_", "DwarfLanguageKind"); - ProcessEnum(cppOptions, csCompilation, "DW_CC_", "DwarfCallingConvention"); - ProcessEnum(cppOptions, csCompilation, "DW_UT_", "DwarfUnitKind"); - - GenerateDwarfAttributes(ns); - GenerateDwarfDIE(ns); - - csCompilation.DumpTo(GetCodeWriter(Path.Combine("LibObjectFile", "generated"))); - } - - private static Dictionary MapAttributeCompactNameToType = new Dictionary(); - - private static void GenerateDwarfAttributes(CSharpNamespace ns) - { - var alreadyDone = new HashSet(); - - var csHelper = new CSharpClass("DwarfHelper") - { - Modifiers = CSharpModifiers.Static | CSharpModifiers.Partial, - Visibility = CSharpVisibility.Public - }; - ns.Members.Add(csHelper); - - var csField = new CSharpField("AttributeToEncoding") - { - Modifiers = CSharpModifiers.Static | CSharpModifiers.ReadOnly, - Visibility = CSharpVisibility.Private, - FieldType = new CSharpArrayType(new CSharpFreeType("DwarfAttributeEncoding")) - }; - csHelper.Members.Add(csField); - - var fieldArrayBuilder = new StringBuilder(); - fieldArrayBuilder.AppendLine("new DwarfAttributeEncoding[] {"); - - int currentAttributeIndex = 0; - - foreach (var attrEncoding in MapAttributeToEncoding) - { - var attrEncodingParts = attrEncoding.Split(' ', StringSplitOptions.RemoveEmptyEntries); - var attributeName = attrEncodingParts[0]; - var attributeIndex = int.Parse(attrEncodingParts[1].Substring(2), System.Globalization.NumberStyles.HexNumber); - var rawName = attributeName.Substring("DW_AT_".Length); - //var csharpName = CSharpifyName(rawName); - - string attrType = "object"; - var kind = AttributeKind.Managed; - - if (attributeName == "DW_AT_accessibility") - { - attrType = "DwarfAccessibility"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_visibility") - { - attrType = "DwarfVisibility"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_virtuality") - { - attrType = "DwarfVirtuality"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_language") - { - attrType = "DwarfLanguageKind"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_identifier_case") - { - attrType = "DwarfIdentifierCaseKind"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_calling_convention") - { - attrType = "DwarfCallingConvention"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_inline") - { - attrType = "DwarfInlineKind"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_ordering") - { - attrType = "DwarfArrayOrderingKind"; - kind = AttributeKind.ValueType; - } - else if (attributeName == "DW_AT_discr_list") - { - attrType = "DwarfDiscriminantListKind"; - kind = AttributeKind.ValueType; - } - else if (attrEncodingParts.Length == 3) - { - switch (attrEncodingParts[2]) - { - case "string": - attrType = "string"; - break; - - case "flag": - attrType = "bool"; - kind = AttributeKind.ValueType; - break; - - case "reference": - attrType = "DwarfDIE"; - break; - - case "address": - attrType = "ulong"; - kind = AttributeKind.ValueType; - break; - - case "constant": - attrType = "DwarfConstant"; - kind = AttributeKind.ValueType; - break; - - case "lineptr": - attrType = "DwarfLineProgramTable"; - break; - - case "exprloc": - attrType = "DwarfExpression"; - break; - - case "loclist": - case "loclistptr": - attrType = "DwarfLocation"; - break; - - case "addrptr": - case "macptr": - case "rnglist": - case "rangelistptr": - case "rnglistsptr": - case "stroffsetsptr": - attrType = "ulong"; - kind = AttributeKind.ValueType; - break; - } - } - else if (attrEncodingParts.Length > 3) - { - var key = string.Join(" ", attrEncodingParts.Skip(2).ToArray()); - alreadyDone.Add(key); - - Console.WriteLine(attrEncoding); - - bool hasConstant = false; - for (int i = 2; i < attrEncodingParts.Length; i++) - { - switch (attrEncodingParts[i]) - { - case "loclist": - case "loclistptr": - attrType = "DwarfLocation"; - kind = AttributeKind.ValueType; - goto next; - case "constant": - hasConstant = true; - break; - } - } - - if (hasConstant) - { - attrType = "DwarfConstant"; - kind = AttributeKind.ValueType; - } - } - - next: - - MapAttributeCompactNameToType.Add(attributeName.Replace("_", string.Empty), new AttributeMapping(rawName, attrType, kind)); - - const int PaddingEncodingName = 50; - - for (; currentAttributeIndex < attributeIndex; currentAttributeIndex++) - { - fieldArrayBuilder.AppendLine($" {"DwarfAttributeEncoding.None",-PaddingEncodingName}, // 0x{currentAttributeIndex:x2} (undefined)"); - } - - for (int i = 2; i < attrEncodingParts.Length; i++) - { - string name; - switch (attrEncodingParts[i]) - { - case "string": - name = "String"; - break; - - case "flag": - name = "Flag"; - break; - - case "block": - name = "Block"; - break; - - case "reference": - name = "Reference"; - break; - - case "address": - name = "Address"; - break; - - case "constant": - name = "Constant"; - break; - - case "lineptr": - name = "LinePointer"; - break; - - case "exprloc": - name = "ExpressionLocation"; - break; - - case "loclist": - name = "LocationList"; - break; - - case "loclistptr": - name = "LocationListPointer"; - break; - - case "loclistsptr": - name = "LocationListsPointer"; - break; - - case "addrptr": - name = "AddressPointer"; - break; - - case "macptr": - name = "MacroPointer"; - break; - - case "rnglist": - name = "RangeList"; - break; - - case "rangelistptr": - name = "RangeListPointer"; - break; - - case "rnglistsptr": - name = "RangeListsPointer"; - break; - - case "stroffsetsptr": - name = "StringOffsetPointer"; - break; - default: - throw new InvalidOperationException($"Unknown encoding {attrEncodingParts[i]}"); - } - - bool isLast = i + 1 == attrEncodingParts.Length; - - fieldArrayBuilder.Append($" {"DwarfAttributeEncoding." + name + (isLast ? "" : " | "),-PaddingEncodingName}"); - - if (isLast) - { - fieldArrayBuilder.Append($", // 0x{currentAttributeIndex:x2} {attributeName} "); - } - fieldArrayBuilder.AppendLine(); - - } - - currentAttributeIndex++; - } - - fieldArrayBuilder.Append(" }"); - csField.InitValue = fieldArrayBuilder.ToString(); - - Console.WriteLine(); - foreach (var key in alreadyDone.ToArray().OrderBy(x => x)) - { - Console.WriteLine(key); - } - } - - struct AttributeMapping - { - public AttributeMapping(string rawName, string attributeType, AttributeKind kind) - { - RawName = rawName; - AttributeType = attributeType; - Kind = kind; - } - - public string RawName { get; set; } - - public string AttributeType { get; set; } - - public AttributeKind Kind { get; set; } - - public override string ToString() - { - return $"{nameof(RawName)}: {RawName}, {nameof(AttributeType)}: {AttributeType}, {nameof(Kind)}: {Kind}"; - } - } - - enum AttributeKind - { - Managed, - - ValueType, - - Link, - } - - private static void GenerateDwarfDIE(CSharpNamespace ns) - { - var file = File.ReadAllLines(@"C:\code\LibObjectFile\ext\dwarf-specs\attributesbytag.tex"); - - var regexDWTag = new Regex(@"^\\(DWTAG\w+)"); - var regexDWAT = new Regex(@"^&\\(DWAT\w+)"); - - int state = 0; - - string currentCompactTagName = null; - CSharpClass currentDIE = null; - - var dieClasses = new List(); - var dieTags = new List(); - - foreach (var line in file) - { - if (state == 0) - { - if (line.StartsWith(@"\begin{longtable}")) - { - continue; - } - else - { - state = 1; - } - } - var match = regexDWTag.Match(line); - if (match.Success) - { - var compactTagName = match.Groups[1].Value; - if (compactTagName == currentCompactTagName) - { - continue; - } - currentCompactTagName = compactTagName; - var fullTagName = MapTagCompactNameToFullName[compactTagName]; - dieTags.Add(fullTagName); - var csDIEName = fullTagName.Substring("DW_TAG_".Length); - csDIEName = CSharpifyName(csDIEName); - currentDIE = new CSharpClass($"DwarfDIE{csDIEName}"); - currentDIE.BaseTypes.Add(new CSharpFreeType("DwarfDIE")); - ns.Members.Add(currentDIE); - - var csConstructor = new CSharpMethod(); - csConstructor.IsConstructor = true; - csConstructor.Body = (writer, element) => writer.WriteLine($"this.Tag = (DwarfTag)DwarfNative.{fullTagName};"); - currentDIE.Members.Add(csConstructor); - - dieClasses.Add(currentDIE); - } - else - { - match = regexDWAT.Match(line); - if (match.Success) - { - var compactAttrName = match.Groups[1].Value; - var csProperty = CreatePropertyFromDwarfAttributeName(compactAttrName); - currentDIE.Members.Add(csProperty); - - // The DW_AT_description attribute can be used on any debugging information - // entry that may have a DW_AT_name attribute. For simplicity, this attribute is - // not explicitly shown. - if (compactAttrName == "DWATname") - { - csProperty = CreatePropertyFromDwarfAttributeName("DWATdescription"); - currentDIE.Members.Add(csProperty); - } - - - } - else if (currentDIE != null && line.Contains("{DECL}")) - { - currentDIE.BaseTypes[0] = new CSharpFreeType("DwarfDIEDeclaration"); - } - } - } - - // Generate the DIEHelper class - var dieHelperClass = new CSharpClass("DIEHelper") - { - Modifiers = CSharpModifiers.Partial | CSharpModifiers.Static, - Visibility = CSharpVisibility.Internal - }; - ns.Members.Add(dieHelperClass); - var dieHelperMethod = new CSharpMethod() - { - Name = "ConvertTagToDwarfDIE", - Modifiers = CSharpModifiers.Static, - Visibility = CSharpVisibility.Public - }; - dieHelperClass.Members.Add(dieHelperMethod); - - dieHelperMethod.Parameters.Add(new CSharpParameter("tag") { ParameterType = CSharpPrimitiveType.UShort() }); - dieHelperMethod.ReturnType = new CSharpFreeType("DwarfDIE"); - - dieHelperMethod.Body = (writer, element) => { - - writer.WriteLine("switch (tag)"); - writer.OpenBraceBlock(); - - for (var i = 0; i < dieClasses.Count; i++) - { - var dieCls = dieClasses[i]; - var dieTag = dieTags[i]; - writer.WriteLine($"case DwarfNative.{dieTag}:"); - writer.Indent(); - writer.WriteLine($"return new {dieCls.Name}();"); - writer.UnIndent(); - } - - writer.CloseBraceBlock(); - writer.WriteLine("return new DwarfDIE();"); - }; - } - - private static CSharpProperty CreatePropertyFromDwarfAttributeName(string compactAttrName) - { - if (compactAttrName == "DWATuseUTFeight") - { - compactAttrName = "DWATuseUTF8"; - } - - var map = MapAttributeCompactNameToType[compactAttrName]; - var rawAttrName = map.RawName; - var attrType = map.AttributeType; - - var propertyName = CSharpifyName(map.RawName); - - var csProperty = new CSharpProperty(propertyName) - { - Visibility = CSharpVisibility.Public, - ReturnType = new CSharpFreeType(map.Kind == AttributeKind.Managed ? attrType : $"{attrType}?"), - }; - - var attrName = CSharpifyName(rawAttrName); - - switch (map.Kind) - { - case AttributeKind.Managed: - csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeValue<{attrType}>(DwarfAttributeKind.{attrName});"); - csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeValue<{attrType}>(DwarfAttributeKind.{attrName}, value);"); - break; - case AttributeKind.ValueType: - if (map.AttributeType == "DwarfConstant") - { - csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeConstantOpt(DwarfAttributeKind.{attrName});"); - csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeConstantOpt(DwarfAttributeKind.{attrName}, value);"); - } - else if (map.AttributeType == "DwarfLocation") - { - csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeLocationOpt(DwarfAttributeKind.{attrName});"); - csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeLocationOpt(DwarfAttributeKind.{attrName}, value);"); - } - else - { - csProperty.GetBody = (writer, element) => writer.WriteLine($"return GetAttributeValueOpt<{attrType}>(DwarfAttributeKind.{attrName});"); - csProperty.SetBody = (writer, element) => writer.WriteLine($"SetAttributeValueOpt<{attrType}>(DwarfAttributeKind.{attrName}, value);"); - } - break; - case AttributeKind.Link: - csProperty.GetBody = (writer, element) => - { - writer.WriteLine($"var attr = FindAttributeByKey(DwarfAttributeKind.{attrName});"); - writer.WriteLine($"return attr == null ? null : new {attrType}(attr.ValueAsU64, attr.ValueAsObject);"); - }; - csProperty.SetBody = (writer, element) => { writer.WriteLine($"SetAttributeLinkValue(DwarfAttributeKind.{attrName}, value);"); }; - break; - default: - throw new ArgumentOutOfRangeException(); - } - - return csProperty; - } - - private static string CSharpifyName(string rawName) - { - if (rawName.EndsWith("_pc")) - { - rawName = rawName.Replace("_pc", "_PC"); - } - - var newName = new StringBuilder(); - bool upperCase = true; - for (var i = 0; i < rawName.Length; i++) - { - var c = rawName[i]; - if (c == '_') - { - upperCase = true; - continue; - } - - if (upperCase) - { - newName.Append(char.ToUpperInvariant(c)); - upperCase = false; - } - else - { - newName.Append(c); - } - } - return newName.ToString(); - } - - - private static Dictionary MapTagCompactNameToFullName = new Dictionary() - { - {"DWTAGaccessdeclaration", "DW_TAG_access_declaration"}, - {"DWTAGarraytype", "DW_TAG_array_type"}, - {"DWTAGatomictype", "DW_TAG_atomic_type"}, - {"DWTAGbasetype", "DW_TAG_base_type"}, - {"DWTAGcallsite", "DW_TAG_call_site"}, - {"DWTAGcallsiteparameter", "DW_TAG_call_site_parameter"}, - {"DWTAGcatchblock", "DW_TAG_catch_block"}, - {"DWTAGclasstype", "DW_TAG_class_type"}, - {"DWTAGcoarraytype", "DW_TAG_coarray_type"}, - {"DWTAGcommonblock", "DW_TAG_common_block"}, - {"DWTAGcommoninclusion", "DW_TAG_common_inclusion"}, - {"DWTAGcompileunit", "DW_TAG_compile_unit"}, - {"DWTAGcondition", "DW_TAG_condition"}, - {"DWTAGconsttype", "DW_TAG_const_type"}, - {"DWTAGconstant", "DW_TAG_constant"}, - {"DWTAGdescriptortype", "DW_TAG_descriptor_type"}, - {"DWTAGdwarfprocedure", "DW_TAG_dwarf_procedure"}, - {"DWTAGdynamictype", "DW_TAG_dynamic_type"}, - {"DWTAGentrypoint", "DW_TAG_entry_point"}, - {"DWTAGenumerationtype", "DW_TAG_enumeration_type"}, - {"DWTAGenumerator", "DW_TAG_enumerator"}, - {"DWTAGfiletype", "DW_TAG_file_type"}, - {"DWTAGformalparameter", "DW_TAG_formal_parameter"}, - {"DWTAGfriend", "DW_TAG_friend"}, - {"DWTAGgenericsubrange", "DW_TAG_generic_subrange"}, - {"DWTAGhiuser", "DW_TAG_hi_user"}, - {"DWTAGimmutabletype", "DW_TAG_immutable_type"}, - {"DWTAGimporteddeclaration", "DW_TAG_imported_declaration"}, - {"DWTAGimportedmodule", "DW_TAG_imported_module"}, - {"DWTAGimportedunit", "DW_TAG_imported_unit"}, - {"DWTAGinheritance", "DW_TAG_inheritance"}, - {"DWTAGinlinedsubroutine", "DW_TAG_inlined_subroutine"}, - {"DWTAGinterfacetype", "DW_TAG_interface_type"}, - {"DWTAGlabel", "DW_TAG_label"}, - {"DWTAGlexicalblock", "DW_TAG_lexical_block"}, - {"DWTAGlouser", "DW_TAG_lo_user"}, - {"DWTAGmember", "DW_TAG_member"}, - {"DWTAGmodule", "DW_TAG_module"}, - {"DWTAGnamelist", "DW_TAG_namelist"}, - {"DWTAGnamelistitem", "DW_TAG_namelist_item"}, - {"DWTAGnamespace", "DW_TAG_namespace"}, - {"DWTAGpackedtype", "DW_TAG_packed_type"}, - {"DWTAGpartialunit", "DW_TAG_partial_unit"}, - {"DWTAGpointertype", "DW_TAG_pointer_type"}, - {"DWTAGptrtomembertype", "DW_TAG_ptr_to_member_type"}, - {"DWTAGreferencetype", "DW_TAG_reference_type"}, - {"DWTAGrestricttype", "DW_TAG_restrict_type"}, - {"DWTAGrvaluereferencetype", "DW_TAG_rvalue_reference_type"}, - {"DWTAGsettype", "DW_TAG_set_type"}, - {"DWTAGsharedtype", "DW_TAG_shared_type"}, - {"DWTAGskeletonunit", "DW_TAG_skeleton_unit"}, - {"DWTAGstringtype", "DW_TAG_string_type"}, - {"DWTAGstructuretype", "DW_TAG_structure_type"}, - {"DWTAGsubprogram", "DW_TAG_subprogram"}, - {"DWTAGsubrangetype", "DW_TAG_subrange_type"}, - {"DWTAGsubroutinetype", "DW_TAG_subroutine_type"}, - {"DWTAGtemplatealias", "DW_TAG_template_alias"}, - {"DWTAGtemplatetypeparameter", "DW_TAG_template_type_parameter"}, - {"DWTAGtemplatevalueparameter", "DW_TAG_template_value_parameter"}, - {"DWTAGthrowntype", "DW_TAG_thrown_type"}, - {"DWTAGtryblock", "DW_TAG_try_block"}, - {"DWTAGtypedef", "DW_TAG_typedef"}, - {"DWTAGtypeunit", "DW_TAG_type_unit"}, - {"DWTAGuniontype", "DW_TAG_union_type"}, - {"DWTAGunspecifiedparameters", "DW_TAG_unspecified_parameters"}, - {"DWTAGunspecifiedtype", "DW_TAG_unspecified_type"}, - {"DWTAGvariable", "DW_TAG_variable"}, - {"DWTAGvariant", "DW_TAG_variant"}, - {"DWTAGvariantpart", "DW_TAG_variant_part"}, - {"DWTAGvolatiletype", "DW_TAG_volatile_type"}, - {"DWTAGwithstmt", "DW_TAG_with_stmt"}, - }; - - // Extract from Dwarf 5 specs - Figure 20, Attribute encodings - private static readonly string[] MapAttributeToEncoding = new string[] - { - "DW_AT_sibling 0x01 reference", - "DW_AT_location 0x02 exprloc loclist", - "DW_AT_name 0x03 string", - "DW_AT_ordering 0x09 constant", - "DW_AT_byte_size 0x0b constant exprloc reference", - "DW_AT_bit_offset 0x0c constant exprloc reference", - "DW_AT_bit_size 0x0d constant exprloc reference", - "DW_AT_stmt_list 0x10 lineptr", - "DW_AT_low_pc 0x11 address", - "DW_AT_high_pc 0x12 address constant", - "DW_AT_language 0x13 constant", - "DW_AT_discr 0x15 reference", - "DW_AT_discr_value 0x16 constant", - "DW_AT_visibility 0x17 constant", - "DW_AT_import 0x18 reference", - "DW_AT_string_length 0x19 exprloc loclistptr", - "DW_AT_common_reference 0x1a reference", - "DW_AT_comp_dir 0x1b string", - "DW_AT_const_value 0x1c block constant string ", - "DW_AT_containing_type 0x1d reference", - "DW_AT_default_value 0x1e reference", - "DW_AT_inline 0x20 constant", - "DW_AT_is_optional 0x21 flag", - "DW_AT_lower_bound 0x22 constant exprloc reference", - "DW_AT_producer 0x25 string", - "DW_AT_prototyped 0x27 flag", - "DW_AT_return_addr 0x2a exprloc loclistptr", - "DW_AT_start_scope 0x2c constant rangelistptr", - "DW_AT_bit_stride 0x2e constant exprloc reference", - "DW_AT_upper_bound 0x2f constant exprloc reference", - "DW_AT_abstract_origin 0x31 reference", - "DW_AT_accessibility 0x32 constant", - "DW_AT_address_class 0x33 constant", - "DW_AT_artificial 0x34 flag", - "DW_AT_base_types 0x35 reference", - "DW_AT_calling_convention 0x36 constant", - "DW_AT_count 0x37 constant exprloc reference", - "DW_AT_data_member_location 0x38 constant exprloc loclistptr", - "DW_AT_decl_column 0x39 constant", - "DW_AT_decl_file 0x3a constant", - "DW_AT_decl_line 0x3b constant", - "DW_AT_declaration 0x3c flag", - "DW_AT_discr_list 0x3d block", - "DW_AT_encoding 0x3e constant", - "DW_AT_external 0x3f flag", - "DW_AT_frame_base 0x40 exprloc loclistptr", - "DW_AT_friend 0x41 reference", - "DW_AT_identifier_case 0x42 constant", - "DW_AT_macro_info 0x43 macptr", - "DW_AT_namelist_item 0x44 reference", - "DW_AT_priority 0x45 reference", - "DW_AT_segment 0x46 exprloc loclistptr", - "DW_AT_specification 0x47 reference", - "DW_AT_static_link 0x48 exprloc loclistptr", - "DW_AT_type 0x49 reference", - "DW_AT_use_location 0x4a exprloc loclistptr", - "DW_AT_variable_parameter 0x4b flag", - "DW_AT_virtuality 0x4c constant", - "DW_AT_vtable_elem_location 0x4d exprloc loclistptr ", - "DW_AT_allocated 0x4e constant exprloc reference", - "DW_AT_associated 0x4f constant exprloc reference", - "DW_AT_data_location 0x50 exprloc", - "DW_AT_byte_stride 0x51 constant exprloc reference", - "DW_AT_entry_pc 0x52 address", - "DW_AT_use_UTF8 0x53 flag", - "DW_AT_extension 0x54 reference", - "DW_AT_ranges 0x55 rangelistptr", - "DW_AT_trampoline 0x56 address flag reference string", - "DW_AT_call_column 0x57 constant", - "DW_AT_call_file 0x58 constant", - "DW_AT_call_line 0x59 constant", - "DW_AT_description 0x5a string", - "DW_AT_binary_scale 0x5b constant", - "DW_AT_decimal_scale 0x5c constant", - "DW_AT_small 0x5d reference", - "DW_AT_decimal_sign 0x5e constant", - "DW_AT_digit_count 0x5f constant", - "DW_AT_picture_string 0x60 string", - "DW_AT_mutable 0x61 flag ", - "DW_AT_threads_scaled 0x62 flag", - "DW_AT_explicit 0x63 flag", - "DW_AT_object_pointer 0x64 reference", - "DW_AT_endianity 0x65 constant", - "DW_AT_elemental 0x66 flag", - "DW_AT_pure 0x67 flag", - "DW_AT_recursive 0x68 flag", - "DW_AT_signature 0x69 reference", - "DW_AT_main_subprogram 0x6a flag", - "DW_AT_data_bit_offset 0x6b constant", - "DW_AT_const_expr 0x6c flag", - "DW_AT_enum_class 0x6d flag", - "DW_AT_linkage_name 0x6e string ", - "DW_AT_string_length_bit_size 0x6f constant", - "DW_AT_string_length_byte_size 0x70 constant", - "DW_AT_rank 0x71 constant exprloc", - "DW_AT_str_offsets_base 0x72 stroffsetsptr", - "DW_AT_addr_base 0x73 addrptr", - "DW_AT_rnglists_base 0x74 rnglistsptr", - "DW_AT_dwo_name 0x76 string", - "DW_AT_reference 0x77 flag", - "DW_AT_rvalue_reference 0x78 flag", - "DW_AT_macros 0x79 macptr", - "DW_AT_call_all_calls 0x7a flag", - "DW_AT_call_all_source_calls 0x7b flag", - "DW_AT_call_all_tail_calls 0x7c flag", - "DW_AT_call_return_pc 0x7d address", - "DW_AT_call_value 0x7e exprloc", - "DW_AT_call_origin 0x7f exprloc", - "DW_AT_call_parameter 0x80 reference", - "DW_AT_call_pc 0x81 address", - "DW_AT_call_tail_call 0x82 flag", - "DW_AT_call_target 0x83 exprloc", - "DW_AT_call_target_clobbered 0x84 exprloc", - "DW_AT_call_data_location 0x85 exprloc", - "DW_AT_call_data_value 0x86 exprloc", - "DW_AT_noreturn 0x87 flag", - "DW_AT_alignment 0x88 constant", - "DW_AT_export_symbols 0x89 flag", - "DW_AT_deleted 0x8a flag", - "DW_AT_defaulted 0x8b constant", - "DW_AT_loclists_base 0x8c loclistsptr", - }; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs deleted file mode 100644 index 992070cc99bf8c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/Program.cs +++ /dev/null @@ -1,327 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using CppAst; -using CppAst.CodeGen.Common; -using CppAst.CodeGen.CSharp; -using Zio.FileSystems; - -namespace LibObjectFile.CodeGen -{ - partial class Program - { - private const string SrcFolderRelative = @"..\..\..\.."; - - static void Main(string[] args) - { - GenerateElf(); - GenerateDwarf(); - } - - private static CodeWriter GetCodeWriter(string subPath) - { - var fs = new PhysicalFileSystem(); - var destFolder = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, SrcFolderRelative, subPath)); - var subfs = new SubFileSystem(fs, fs.ConvertPathFromInternal(destFolder)); - var codeWriter = new CodeWriter(new CodeWriterOptions(subfs)); - return codeWriter; - } - - private static void AssertCompilation(CSharpCompilation csCompilation) - { - if (csCompilation.HasErrors) - { - foreach (var message in csCompilation.Diagnostics.Messages) - { - Console.Error.WriteLine(message); - } - Console.Error.WriteLine("Unexpected parsing errors"); - Environment.Exit(1); - } - } - - private static void GenerateElf() - { - var cppOptions = new CSharpConverterOptions() - { - DefaultClassLib = "ElfNative", - DefaultNamespace = "LibObjectFile.Elf", - DefaultOutputFilePath = "/LibObjectFile.Elf.generated.cs", - DefaultDllImportNameAndArguments = "NotUsed", - MappingRules = - { - map => map.MapMacroToConst("^EI.*", "uint8_t"), - map => map.MapMacroToConst("^ELFMAG\\d", "uint8_t"), - map => map.MapMacroToConst("^ELFCLASS.*", "uint8_t"), - map => map.MapMacroToConst("^ELFDATA.*", "uint8_t"), - map => map.MapMacroToConst("^ELFOSABI.*", "uint8_t"), - map => map.MapMacroToConst("^ET_.*", "uint16_t"), - map => map.MapMacroToConst("^EM_.*", "uint16_t"), - map => map.MapMacroToConst("^EV_.*", "uint8_t"), - map => map.MapMacroToConst("^SHN_.*", "uint32_t"), - map => map.MapMacroToConst("^SHT_.*", "uint32_t"), - map => map.MapMacroToConst("^SHF_.*", "uint32_t"), - map => map.MapMacroToConst("^EF_.*", "uint32_t"), - map => map.MapMacroToConst("^PT_.*", "uint32_t"), - map => map.MapMacroToConst("^PF_.*", "uint32_t"), - map => map.MapMacroToConst("^NT_.*", "uint32_t"), - map => map.MapMacroToConst("^DT_.*", "int32_t"), - map => map.MapMacroToConst("^DF_.*", "uint32_t"), - map => map.MapMacroToConst("^DTF_.*", "uint32_t"), - map => map.MapMacroToConst("^VER_DEF_.*", "uint16_t"), - map => map.MapMacroToConst("^VER_FLG_.*", "uint16_t"), - map => map.MapMacroToConst("^VER_NDX_.*", "uint16_t"), - map => map.MapMacroToConst("^VER_NEED_.*", "uint16_t"), - map => map.MapMacroToConst("^ELFCOMPRESS_.*", "int32_t"), - map => map.MapMacroToConst("^SYMINFO_.*", "uint16_t"), - map => map.MapMacroToConst("^STB_.*", "uint8_t"), - map => map.MapMacroToConst("^STT_.*", "uint8_t"), - map => map.MapMacroToConst("^STN_.*", "uint8_t"), - map => map.MapMacroToConst("^STV_.*", "uint8_t"), - map => map.MapMacroToConst("^R_.*", "uint32_t"), - map => map.MapMacroToConst("ELF_NOTE_OS_.*", "uint32_t"), - } - }; - - cppOptions.ConfigureForWindowsMsvc(CppTargetCpu.X86_64); - cppOptions.Defines.Add("_AMD64_"); - cppOptions.Defines.Add("_TARGET_AMD64_"); - cppOptions.Defines.Add("STARK_NO_ENUM_FLAG"); - cppOptions.GenerateEnumItemAsFields = false; - cppOptions.IncludeFolders.Add(Environment.CurrentDirectory); - - var csCompilation = CSharpConverter.Convert(@"#include ""elf.h""", cppOptions); - - AssertCompilation(csCompilation); - - // Add pragma - var csFile = csCompilation.Members.OfType().First(); - var ns = csFile.Members.OfType().First(); - csFile.Members.Insert(csFile.Members.IndexOf(ns), new CSharpLineElement("#pragma warning disable 1591") ); - - ProcessEnum(cppOptions, csCompilation, "EM_", "ElfArch"); - ProcessEnum(cppOptions, csCompilation, "ELFOSABI_", "ElfOSABI"); - ProcessEnum(cppOptions, csCompilation, "R_", "ElfRelocationType"); - ProcessEnum(cppOptions, csCompilation, "NT_", "ElfNoteType"); - - csCompilation.DumpTo(GetCodeWriter(Path.Combine("LibObjectFile", "generated"))); - } - - private static readonly Dictionary MapRelocMachineToArch = new Dictionary() - { - {"R_386_", "I386"}, - {"R_X86_64_", "X86_64"}, - {"R_ARM_", "ARM"}, - {"R_AARCH64_", "AARCH64"}, - }; - - private static readonly Dictionary MapRelocMachineToMachine = new Dictionary() - { - {"R_386_", "EM_386"}, - {"R_X86_64_", "EM_X86_64"}, - {"R_ARM_", "EM_ARM"}, - {"R_AARCH64_", "EM_AARCH64"}, - }; - - private static void ProcessEnum(CSharpConverterOptions cppOptions, CSharpCompilation csCompilation, string enumPrefix, string enumClassName) - { - var ns = csCompilation.Members.OfType().First().Members.OfType().First(); - - var rawElfClass = ns.Members.OfType().First(); - - var enumRawFields = rawElfClass.Members.OfType().Where(x => (x.Modifiers & CSharpModifiers.Const) != 0 && x.Name.StartsWith(enumPrefix)).ToList(); - - var enumClass = new CSharpStruct(enumClassName) - { - Modifiers = CSharpModifiers.Partial | CSharpModifiers.ReadOnly - }; - ns.Members.Add(enumClass); - - CSharpEnum stdEnum = null; - - var enumItemType = enumRawFields[0].FieldType; - - bool isReloc = enumPrefix == "R_"; - - if (!isReloc) - { - enumClass.Name = enumClass.Name + "Ex"; - stdEnum = new CSharpEnum(enumClassName) - { - Visibility = CSharpVisibility.Public - }; - ns.Members.Add(stdEnum); - stdEnum.BaseTypes.Add(enumItemType); - } - - var filteredFields = new List(); - - foreach (var enumRawField in enumRawFields) - { - var rawName = enumRawField.Name; - - string relocArch = null; - - if (isReloc) - { - foreach (var mapReloc in MapRelocMachineToArch) - { - if (rawName.StartsWith(mapReloc.Key)) - { - relocArch = mapReloc.Value; - break; - } - } - - if (relocArch == null) - { - continue; - } - } - - // skip lo/hi user - if (rawName.StartsWith("DW_") && (rawName.Contains("_lo_") || rawName.Contains("_hi_"))) - { - continue; - } - - // NUM fields - if (rawName.EndsWith("_NUM")) continue; - - filteredFields.Add(enumRawField); - - var csFieldName = isReloc ? rawName : rawName.Substring(enumPrefix.Length); // discard EM_ - if (csFieldName.StartsWith("386")) - { - csFieldName = $"I{csFieldName}"; - } - else - { - switch (csFieldName) - { - case "88K": - csFieldName = "M88K"; - break; - case "860": - csFieldName = "I860"; - break; - case "960": - csFieldName = "I960"; - break; - default: - // assume Motorola - if (csFieldName.StartsWith("68")) - { - csFieldName = $"M{csFieldName}"; - } - - break; - } - } - - if (char.IsDigit(csFieldName[0])) - { - throw new InvalidOperationException($"The enum name `{rawName}` starts with a number and needs to be modified"); - } - - if (rawName.StartsWith("DW_")) - { - csFieldName = CSharpifyName(csFieldName); - } - - csFieldName = CSharpHelper.EscapeName(csFieldName); - - var enumField = new CSharpField(csFieldName) - { - Modifiers = CSharpModifiers.Static | CSharpModifiers.ReadOnly, - FieldType = enumClass, - Visibility = CSharpVisibility.Public, - Comment = enumRawField.Comment, - InitValue = relocArch != null ? - $"new {enumClass.Name}(ElfArch.{relocArch}, {cppOptions.DefaultClassLib}.{rawName})" : - $"new {enumClass.Name}({cppOptions.DefaultClassLib}.{rawName})" - }; - - enumClass.Members.Add(enumField); - - if (!isReloc) - { - var stdEnumField = new CSharpEnumItem(csFieldName, $"{cppOptions.DefaultClassLib}.{rawName}"); - stdEnum.Members.Add(stdEnumField); - } - } - - var toStringInternal = new CSharpMethod() - { - Name = "ToStringInternal", - Visibility = CSharpVisibility.Private, - ReturnType = CSharpPrimitiveType.String() - }; - enumClass.Members.Add(toStringInternal); - - toStringInternal.Body = (writer, element) => - { - var values = new HashSet(); - if (isReloc) - { - writer.WriteLine("switch (((ulong)Value << 16) | (ulong)Arch.Value)"); - } - else - { - writer.WriteLine($"switch (({enumItemType})Value)"); - } - writer.OpenBraceBlock(); - foreach (var rawField in filteredFields) - { - var cppField = ((CppField)rawField.CppElement); - if (isReloc) - { - string relocMachine = null; - foreach (var mapReloc in MapRelocMachineToMachine) - { - if (rawField.Name.StartsWith(mapReloc.Key)) - { - relocMachine = mapReloc.Value; - break; - } - } - - if (relocMachine == null) - { - continue; - } - - if (!values.Add(relocMachine + "$" + cppField.InitValue.Value)) - { - continue; - } - - writer.WriteLine($"case ((ulong){cppOptions.DefaultClassLib}.{rawField.Name} << 16) | {cppOptions.DefaultClassLib}.{relocMachine} : return \"{rawField.Name}\";"); - } - else - { - if (!values.Add(cppField.InitValue.Value)) - { - continue; - } - - string descriptionText = rawField.Name; - //if (cppField.Comment != null) - //{ - // descriptionText += " - " + cppField.Comment.ToString().Replace("\"", "\\\""); - //} - descriptionText = descriptionText.Replace("\r\n", "").Replace("\n", ""); - writer.WriteLine($"case {cppOptions.DefaultClassLib}.{rawField.Name}: return \"{descriptionText}\";"); - } - } - - writer.WriteLine($"default: return null;"); - writer.CloseBraceBlock(); - }; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h deleted file mode 100644 index 3090c557a21174..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/dwarf.h +++ /dev/null @@ -1,1432 +0,0 @@ -/* - Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. - Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved. - Portions Copyright 2007-2017 David Anderson. All rights reserved. - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2.1 of the GNU Lesser General Public License - as published by the Free Software Foundation. - - This program is distributed in the hope that it would be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - Further, this software is distributed without any warranty that it is - free of the rightful claim of any third person regarding infringement - or the like. Any license provided herein, whether implied or - otherwise, applies only to this software file. Patent licenses, if - any, provided herein do not apply to combinations of this program with - other software, or any other product whatsoever. - - You should have received a copy of the GNU Lesser General Public - License along with this program; if not, write the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, - USA. - -*/ - - -#ifndef __DWARF_H -#define __DWARF_H -#ifdef __cplusplus -extern "C" { -#endif - -/* - dwarf.h DWARF debugging information values - $Revision: 1.41 $ $Date: 2006/04/17 00:09:56 $ - - The comment "DWARF3" appears where there are - new entries from DWARF3 as of 2004, "DWARF3f" - where there are new entries as of the November 2005 - public review document and other comments apply - where extension entries appear. - - Extensions part of DWARF4 are marked DWARF4. - - A few extension names have omitted the 'vendor id' - (See chapter 7, "Vendor Extensibility"). Please - always use a 'vendor id' string in extension names. - - Vendors should use a vendor string in names and - whereever possible avoid duplicating values used by - other vendor extensions - - The DWARF1 comments indicate values unused in - DWARF2 and later but used or reserved in DWARF1. -*/ - - -#define DW_TAG_array_type 0x01 -#define DW_TAG_class_type 0x02 -#define DW_TAG_entry_point 0x03 -#define DW_TAG_enumeration_type 0x04 -#define DW_TAG_formal_parameter 0x05 -/* TAG_global_subroutine 0x06 DWARF1 only */ -/* TAG_global_variable 0x07 DWARF1 only */ -#define DW_TAG_imported_declaration 0x08 -/* reserved by DWARF1 0x09 DWARF1 only */ -#define DW_TAG_label 0x0a -#define DW_TAG_lexical_block 0x0b -/* TAG_local_variable 0x0c DWARF1 only. */ -#define DW_TAG_member 0x0d -/* reserved by DWARF1 0x0e DWARF1 only */ -#define DW_TAG_pointer_type 0x0f -#define DW_TAG_reference_type 0x10 -#define DW_TAG_compile_unit 0x11 -#define DW_TAG_string_type 0x12 -#define DW_TAG_structure_type 0x13 -/* TAG_subroutine 0x14 DWARF1 only */ -#define DW_TAG_subroutine_type 0x15 -#define DW_TAG_typedef 0x16 -#define DW_TAG_union_type 0x17 -#define DW_TAG_unspecified_parameters 0x18 -#define DW_TAG_variant 0x19 -#define DW_TAG_common_block 0x1a -#define DW_TAG_common_inclusion 0x1b -#define DW_TAG_inheritance 0x1c -#define DW_TAG_inlined_subroutine 0x1d -#define DW_TAG_module 0x1e -#define DW_TAG_ptr_to_member_type 0x1f -#define DW_TAG_set_type 0x20 -#define DW_TAG_subrange_type 0x21 -#define DW_TAG_with_stmt 0x22 -#define DW_TAG_access_declaration 0x23 -#define DW_TAG_base_type 0x24 -#define DW_TAG_catch_block 0x25 -#define DW_TAG_const_type 0x26 -#define DW_TAG_constant 0x27 -#define DW_TAG_enumerator 0x28 -#define DW_TAG_file_type 0x29 -#define DW_TAG_friend 0x2a -#define DW_TAG_namelist 0x2b - /* Early releases of this header had the following - misspelled with a trailing 's' */ -#define DW_TAG_namelist_item 0x2c /* DWARF3/2 spelling */ -#define DW_TAG_namelist_items 0x2c /* SGI misspelling/typo */ -#define DW_TAG_packed_type 0x2d -#define DW_TAG_subprogram 0x2e - /* The DWARF2 document had two spellings of the following - two TAGs, DWARF3 specifies the longer spelling. */ -#define DW_TAG_template_type_parameter 0x2f /* DWARF3/2 spelling*/ -#define DW_TAG_template_type_param 0x2f /* DWARF2 spelling*/ -#define DW_TAG_template_value_parameter 0x30 /* DWARF3/2 spelling*/ -#define DW_TAG_template_value_param 0x30 /* DWARF2 spelling*/ -#define DW_TAG_thrown_type 0x31 -#define DW_TAG_try_block 0x32 -#define DW_TAG_variant_part 0x33 -#define DW_TAG_variable 0x34 -#define DW_TAG_volatile_type 0x35 -#define DW_TAG_dwarf_procedure 0x36 /* DWARF3 */ -#define DW_TAG_restrict_type 0x37 /* DWARF3 */ -#define DW_TAG_interface_type 0x38 /* DWARF3 */ -#define DW_TAG_namespace 0x39 /* DWARF3 */ -#define DW_TAG_imported_module 0x3a /* DWARF3 */ -#define DW_TAG_unspecified_type 0x3b /* DWARF3 */ -#define DW_TAG_partial_unit 0x3c /* DWARF3 */ -#define DW_TAG_imported_unit 0x3d /* DWARF3 */ - /* Do not use DW_TAG_mutable_type */ -#define DW_TAG_mutable_type 0x3e /* Withdrawn from DWARF3 by DWARF3f. */ -#define DW_TAG_condition 0x3f /* DWARF3f */ -#define DW_TAG_shared_type 0x40 /* DWARF3f */ -#define DW_TAG_type_unit 0x41 /* DWARF4 */ -#define DW_TAG_rvalue_reference_type 0x42 /* DWARF4 */ -#define DW_TAG_template_alias 0x43 /* DWARF4 */ -#define DW_TAG_coarray_type 0x44 /* DWARF5 */ -#define DW_TAG_generic_subrange 0x45 /* DWARF5 */ -#define DW_TAG_dynamic_type 0x46 /* DWARF5 */ -#define DW_TAG_atomic_type 0x47 /* DWARF5 */ -#define DW_TAG_call_site 0x48 /* DWARF5 */ -#define DW_TAG_call_site_parameter 0x49 /* DWARF5 */ -#define DW_TAG_skeleton_unit 0x4a /* DWARF5 */ -#define DW_TAG_immutable_type 0x4b /* DWARF5 */ -#define DW_TAG_lo_user 0x4080 - -#define DW_TAG_MIPS_loop 0x4081 - -/* HP extensions: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz */ -#define DW_TAG_HP_array_descriptor 0x4090 /* HP */ - -/* GNU extensions. The first 3 missing the GNU_. */ -#define DW_TAG_format_label 0x4101 /* GNU. Fortran. */ -#define DW_TAG_function_template 0x4102 /* GNU. For C++ */ -#define DW_TAG_class_template 0x4103 /* GNU. For C++ */ -#define DW_TAG_GNU_BINCL 0x4104 /* GNU */ -#define DW_TAG_GNU_EINCL 0x4105 /* GNU */ - -/* GNU extension. http://gcc.gnu.org/wiki/TemplateParmsDwarf */ -#define DW_TAG_GNU_template_template_parameter 0x4106 /* GNU */ -#define DW_TAG_GNU_template_template_param 0x4106 /* GNU */ -#define DW_TAG_GNU_template_parameter_pack 0x4107 /* GNU */ -#define DW_TAG_GNU_formal_parameter_pack 0x4108 /* GNU */ - -#define DW_TAG_GNU_call_site 0x4109 /* GNU */ -#define DW_TAG_GNU_call_site_parameter 0x410a /* GNU */ - -/* ALTIUM extensions */ - /* DSP-C/Starcore __circ qualifier */ -#define DW_TAG_ALTIUM_circ_type 0x5101 /* ALTIUM */ - /* Starcore __mwa_circ qualifier */ -#define DW_TAG_ALTIUM_mwa_circ_type 0x5102 /* ALTIUM */ - /* Starcore __rev_carry qualifier */ -#define DW_TAG_ALTIUM_rev_carry_type 0x5103 /* ALTIUM */ - /* M16 __rom qualifier */ -#define DW_TAG_ALTIUM_rom 0x5111 /* ALTIUM */ - -/* The following 3 are extensions to support UPC */ -#define DW_TAG_upc_shared_type 0x8765 /* UPC */ -#define DW_TAG_upc_strict_type 0x8766 /* UPC */ -#define DW_TAG_upc_relaxed_type 0x8767 /* UPC */ - -/* PGI (STMicroelectronics) extensions. */ -#define DW_TAG_PGI_kanji_type 0xa000 /* PGI */ -#define DW_TAG_PGI_interface_block 0xa020 /* PGI */ -/* The following are SUN extensions */ -#define DW_TAG_SUN_function_template 0x4201 /* SUN */ -#define DW_TAG_SUN_class_template 0x4202 /* SUN */ -#define DW_TAG_SUN_struct_template 0x4203 /* SUN */ -#define DW_TAG_SUN_union_template 0x4204 /* SUN */ -#define DW_TAG_SUN_indirect_inheritance 0x4205 /* SUN */ -#define DW_TAG_SUN_codeflags 0x4206 /* SUN */ -#define DW_TAG_SUN_memop_info 0x4207 /* SUN */ -#define DW_TAG_SUN_omp_child_func 0x4208 /* SUN */ -#define DW_TAG_SUN_rtti_descriptor 0x4209 /* SUN */ -#define DW_TAG_SUN_dtor_info 0x420a /* SUN */ -#define DW_TAG_SUN_dtor 0x420b /* SUN */ -#define DW_TAG_SUN_f90_interface 0x420c /* SUN */ -#define DW_TAG_SUN_fortran_vax_structure 0x420d /* SUN */ -#define DW_TAG_SUN_hi 0x42ff /* SUN */ - -#define DW_TAG_hi_user 0xffff - -/* The following two are non-standard. Use DW_CHILDREN_yes - and DW_CHILDREN_no instead. These could - probably be deleted, but someone might be using them, - so they remain. */ -#define DW_children_no 0 -#define DW_children_yes 1 - -#define DW_FORM_addr 0x01 -/* FORM_REF 0x02 DWARF1 only */ -#define DW_FORM_block2 0x03 -#define DW_FORM_block4 0x04 -#define DW_FORM_data2 0x05 -#define DW_FORM_data4 0x06 -#define DW_FORM_data8 0x07 -#define DW_FORM_string 0x08 -#define DW_FORM_block 0x09 -#define DW_FORM_block1 0x0a -#define DW_FORM_data1 0x0b -#define DW_FORM_flag 0x0c -#define DW_FORM_sdata 0x0d -#define DW_FORM_strp 0x0e -#define DW_FORM_udata 0x0f -#define DW_FORM_ref_addr 0x10 -#define DW_FORM_ref1 0x11 -#define DW_FORM_ref2 0x12 -#define DW_FORM_ref4 0x13 -#define DW_FORM_ref8 0x14 -#define DW_FORM_ref_udata 0x15 -#define DW_FORM_indirect 0x16 -#define DW_FORM_sec_offset 0x17 /* DWARF4 */ -#define DW_FORM_exprloc 0x18 /* DWARF4 */ -#define DW_FORM_flag_present 0x19 /* DWARF4 */ -#define DW_FORM_strx 0x1a /* DWARF5 */ -#define DW_FORM_addrx 0x1b /* DWARF5 */ -#define DW_FORM_ref_sup4 0x1c /* DWARF5 */ -#define DW_FORM_strp_sup 0x1d /* DWARF5 */ -#define DW_FORM_data16 0x1e /* DWARF5 */ -#define DW_FORM_line_strp 0x1f /* DWARF5 */ -#define DW_FORM_ref_sig8 0x20 /* DWARF4 */ -#define DW_FORM_implicit_const 0x21 /* DWARF5 */ -#define DW_FORM_loclistx 0x22 /* DWARF5 */ -#define DW_FORM_rnglistx 0x23 /* DWARF5 */ -#define DW_FORM_ref_sup8 0x24 /* DWARF5 */ -#define DW_FORM_strx1 0x25 /* DWARF5 */ -#define DW_FORM_strx2 0x26 /* DWARF5 */ -#define DW_FORM_strx3 0x27 /* DWARF5 */ -#define DW_FORM_strx4 0x28 /* DWARF5 */ -#define DW_FORM_addrx1 0x29 /* DWARF5 */ -#define DW_FORM_addrx2 0x2a /* DWARF5 */ -#define DW_FORM_addrx3 0x2b /* DWARF5 */ -#define DW_FORM_addrx4 0x2c /* DWARF5 */ - -#define DW_FORM_GNU_addr_index 0x1f01 /* GNU extension in debug_info.dwo.*/ -#define DW_FORM_GNU_str_index 0x1f02 /* GNU extension, somewhat like DW_FORM_strp */ -#define DW_FORM_GNU_ref_alt 0x1f20 /* GNU extension. Offset in .debug_info. */ -#define DW_FORM_GNU_strp_alt 0x1f21 /* GNU extension. Offset in .debug_str of another object file. */ - -#define DW_AT_sibling 0x01 -#define DW_AT_location 0x02 -#define DW_AT_name 0x03 -/* reserved DWARF1 0x04, DWARF1 only */ -/* AT_fund_type 0x05, DWARF1 only */ -/* AT_mod_fund_type 0x06, DWARF1 only */ -/* AT_user_def_type 0x07, DWARF1 only */ -/* AT_mod_u_d_type 0x08, DWARF1 only */ -#define DW_AT_ordering 0x09 -#define DW_AT_subscr_data 0x0a -#define DW_AT_byte_size 0x0b -#define DW_AT_bit_offset 0x0c -#define DW_AT_bit_size 0x0d -/* reserved DWARF1 0x0d, DWARF1 only */ -#define DW_AT_element_list 0x0f -#define DW_AT_stmt_list 0x10 -#define DW_AT_low_pc 0x11 -#define DW_AT_high_pc 0x12 -#define DW_AT_language 0x13 -#define DW_AT_member 0x14 -#define DW_AT_discr 0x15 -#define DW_AT_discr_value 0x16 -#define DW_AT_visibility 0x17 -#define DW_AT_import 0x18 -#define DW_AT_string_length 0x19 -#define DW_AT_common_reference 0x1a -#define DW_AT_comp_dir 0x1b -#define DW_AT_const_value 0x1c -#define DW_AT_containing_type 0x1d -#define DW_AT_default_value 0x1e -/* reserved 0x1f */ -#define DW_AT_inline 0x20 -#define DW_AT_is_optional 0x21 -#define DW_AT_lower_bound 0x22 -/* reserved 0x23 */ -/* reserved 0x24 */ -#define DW_AT_producer 0x25 -/* reserved 0x26 */ -#define DW_AT_prototyped 0x27 -/* reserved 0x28 */ -/* reserved 0x29 */ -#define DW_AT_return_addr 0x2a -/* reserved 0x2b */ -#define DW_AT_start_scope 0x2c -/* reserved 0x2d */ -#define DW_AT_bit_stride 0x2e /* DWARF3 name */ -#define DW_AT_stride_size 0x2e /* DWARF2 name */ -#define DW_AT_upper_bound 0x2f -/* AT_virtual 0x30, DWARF1 only */ -#define DW_AT_abstract_origin 0x31 -#define DW_AT_accessibility 0x32 -#define DW_AT_address_class 0x33 -#define DW_AT_artificial 0x34 -#define DW_AT_base_types 0x35 -#define DW_AT_calling_convention 0x36 -#define DW_AT_count 0x37 -#define DW_AT_data_member_location 0x38 -#define DW_AT_decl_column 0x39 -#define DW_AT_decl_file 0x3a -#define DW_AT_decl_line 0x3b -#define DW_AT_declaration 0x3c -#define DW_AT_discr_list 0x3d /* DWARF2 */ -#define DW_AT_encoding 0x3e -#define DW_AT_external 0x3f -#define DW_AT_frame_base 0x40 -#define DW_AT_friend 0x41 -#define DW_AT_identifier_case 0x42 -#define DW_AT_macro_info 0x43 /* DWARF{234} not DWARF5 */ -#define DW_AT_namelist_item 0x44 -#define DW_AT_priority 0x45 -#define DW_AT_segment 0x46 -#define DW_AT_specification 0x47 -#define DW_AT_static_link 0x48 -#define DW_AT_type 0x49 -#define DW_AT_use_location 0x4a -#define DW_AT_variable_parameter 0x4b -#define DW_AT_virtuality 0x4c -#define DW_AT_vtable_elem_location 0x4d -#define DW_AT_allocated 0x4e /* DWARF3 */ -#define DW_AT_associated 0x4f /* DWARF3 */ -#define DW_AT_data_location 0x50 /* DWARF3 */ -#define DW_AT_byte_stride 0x51 /* DWARF3f */ -#define DW_AT_stride 0x51 /* DWARF3 (do not use) */ -#define DW_AT_entry_pc 0x52 /* DWARF3 */ -#define DW_AT_use_UTF8 0x53 /* DWARF3 */ -#define DW_AT_extension 0x54 /* DWARF3 */ -#define DW_AT_ranges 0x55 /* DWARF3 */ -#define DW_AT_trampoline 0x56 /* DWARF3 */ -#define DW_AT_call_column 0x57 /* DWARF3 */ -#define DW_AT_call_file 0x58 /* DWARF3 */ -#define DW_AT_call_line 0x59 /* DWARF3 */ -#define DW_AT_description 0x5a /* DWARF3 */ -#define DW_AT_binary_scale 0x5b /* DWARF3f */ -#define DW_AT_decimal_scale 0x5c /* DWARF3f */ -#define DW_AT_small 0x5d /* DWARF3f */ -#define DW_AT_decimal_sign 0x5e /* DWARF3f */ -#define DW_AT_digit_count 0x5f /* DWARF3f */ -#define DW_AT_picture_string 0x60 /* DWARF3f */ -#define DW_AT_mutable 0x61 /* DWARF3f */ -#define DW_AT_threads_scaled 0x62 /* DWARF3f */ -#define DW_AT_explicit 0x63 /* DWARF3f */ -#define DW_AT_object_pointer 0x64 /* DWARF3f */ -#define DW_AT_endianity 0x65 /* DWARF3f */ -#define DW_AT_elemental 0x66 /* DWARF3f */ -#define DW_AT_pure 0x67 /* DWARF3f */ -#define DW_AT_recursive 0x68 /* DWARF3f */ -#define DW_AT_signature 0x69 /* DWARF4 */ -#define DW_AT_main_subprogram 0x6a /* DWARF4 */ -#define DW_AT_data_bit_offset 0x6b /* DWARF4 */ -#define DW_AT_const_expr 0x6c /* DWARF4 */ -#define DW_AT_enum_class 0x6d /* DWARF4 */ -#define DW_AT_linkage_name 0x6e /* DWARF4 */ -#define DW_AT_string_length_bit_size 0x6f /* DWARF5 */ -#define DW_AT_string_length_byte_size 0x70 /* DWARF5 */ -#define DW_AT_rank 0x71 /* DWARF5 */ -#define DW_AT_str_offsets_base 0x72 /* DWARF5 */ -#define DW_AT_addr_base 0x73 /* DWARF5 */ - /* Use DW_AT_rnglists_base, DW_AT_ranges_base is obsolete as */ - /* it was only used in some DWARF5 drafts, not the final DWARF5. */ -#define DW_AT_rnglists_base 0x74 /* DWARF5 */ - /* DW_AT_dwo_id, an experiment in some DWARF4+. Not DWARF5! */ -#define DW_AT_dwo_id 0x75 /* DWARF4!*/ -#define DW_AT_dwo_name 0x76 /* DWARF5 */ -#define DW_AT_reference 0x77 /* DWARF5 */ -#define DW_AT_rvalue_reference 0x78 /* DWARF5 */ -#define DW_AT_macros 0x79 /* DWARF5 */ -#define DW_AT_call_all_calls 0x7a /* DWARF5 */ -#define DW_AT_call_all_source_calls 0x7b /* DWARF5 */ -#define DW_AT_call_all_tail_calls 0x7c /* DWARF5 */ -#define DW_AT_call_return_pc 0x7d /* DWARF5 */ -#define DW_AT_call_value 0x7e /* DWARF5 */ -#define DW_AT_call_origin 0x7f /* DWARF5 */ -#define DW_AT_call_parameter 0x80 /* DWARF5 */ -#define DW_AT_call_pc 0x81 /* DWARF5 */ -#define DW_AT_call_tail_call 0x82 /* DWARF5 */ -#define DW_AT_call_target 0x83 /* DWARF5 */ -#define DW_AT_call_target_clobbered 0x84 /* DWARF5 */ -#define DW_AT_call_data_location 0x85 /* DWARF5 */ -#define DW_AT_call_data_value 0x86 /* DWARF5 */ -#define DW_AT_noreturn 0x87 /* DWARF5 */ -#define DW_AT_alignment 0x88 /* DWARF5 */ -#define DW_AT_export_symbols 0x89 /* DWARF5 */ -#define DW_AT_deleted 0x8a /* DWARF5 */ -#define DW_AT_defaulted 0x8b /* DWARF5 */ -#define DW_AT_loclists_base 0x8c /* DWARF5 */ - -/* In extensions, we attempt to include the vendor extension - in the name even when the vendor leaves it out. */ - -/* HP extensions. */ -#define DW_AT_HP_block_index 0x2000 /* HP */ - -/* Follows extension so dwarfdump prints the most-likely-useful name. */ -#define DW_AT_lo_user 0x2000 - -#define DW_AT_MIPS_fde 0x2001 /* MIPS/SGI */ -#define DW_AT_MIPS_loop_begin 0x2002 /* MIPS/SGI */ -#define DW_AT_MIPS_tail_loop_begin 0x2003 /* MIPS/SGI */ -#define DW_AT_MIPS_epilog_begin 0x2004 /* MIPS/SGI */ -#define DW_AT_MIPS_loop_unroll_factor 0x2005 /* MIPS/SGI */ -#define DW_AT_MIPS_software_pipeline_depth 0x2006 /* MIPS/SGI */ -#define DW_AT_MIPS_linkage_name 0x2007 /* MIPS/SGI, GNU, and others.*/ -#define DW_AT_MIPS_stride 0x2008 /* MIPS/SGI */ -#define DW_AT_MIPS_abstract_name 0x2009 /* MIPS/SGI */ -#define DW_AT_MIPS_clone_origin 0x200a /* MIPS/SGI */ -#define DW_AT_MIPS_has_inlines 0x200b /* MIPS/SGI */ -#define DW_AT_MIPS_stride_byte 0x200c /* MIPS/SGI */ -#define DW_AT_MIPS_stride_elem 0x200d /* MIPS/SGI */ -#define DW_AT_MIPS_ptr_dopetype 0x200e /* MIPS/SGI */ -#define DW_AT_MIPS_allocatable_dopetype 0x200f /* MIPS/SGI */ -#define DW_AT_MIPS_assumed_shape_dopetype 0x2010 /* MIPS/SGI */ -#define DW_AT_MIPS_assumed_size 0x2011 /* MIPS/SGI */ - -/* HP extensions. */ -#define DW_AT_HP_unmodifiable 0x2001 /* conflict: MIPS */ -#define DW_AT_HP_actuals_stmt_list 0x2010 /* conflict: MIPS */ -#define DW_AT_HP_proc_per_section 0x2011 /* conflict: MIPS */ -#define DW_AT_HP_raw_data_ptr 0x2012 /* HP */ -#define DW_AT_HP_pass_by_reference 0x2013 /* HP */ -#define DW_AT_HP_opt_level 0x2014 /* HP */ -#define DW_AT_HP_prof_version_id 0x2015 /* HP */ -#define DW_AT_HP_opt_flags 0x2016 /* HP */ -#define DW_AT_HP_cold_region_low_pc 0x2017 /* HP */ -#define DW_AT_HP_cold_region_high_pc 0x2018 /* HP */ -#define DW_AT_HP_all_variables_modifiable 0x2019 /* HP */ -#define DW_AT_HP_linkage_name 0x201a /* HP */ -#define DW_AT_HP_prof_flags 0x201b /* HP */ - -#define DW_AT_CPQ_discontig_ranges 0x2001 /* COMPAQ/HP */ -#define DW_AT_CPQ_semantic_events 0x2002 /* COMPAQ/HP */ -#define DW_AT_CPQ_split_lifetimes_var 0x2003 /* COMPAQ/HP */ -#define DW_AT_CPQ_split_lifetimes_rtn 0x2004 /* COMPAQ/HP */ -#define DW_AT_CPQ_prologue_length 0x2005 /* COMPAQ/HP */ - -#define DW_AT_INTEL_other_endian 0x2026 /* Intel, 1 if byte swapped. */ - -/* GNU extensions. */ -#define DW_AT_sf_names 0x2101 /* GNU */ -#define DW_AT_src_info 0x2102 /* GNU */ -#define DW_AT_mac_info 0x2103 /* GNU */ -#define DW_AT_src_coords 0x2104 /* GNU */ -#define DW_AT_body_begin 0x2105 /* GNU */ -#define DW_AT_body_end 0x2106 /* GNU */ -#define DW_AT_GNU_vector 0x2107 /* GNU */ - -/* Thread safety, see http://gcc.gnu.org/wiki/ThreadSafetyAnnotation . */ -/* The values here are from gcc-4.6.2 include/dwarf2.h. The - values are not given on the web page at all, nor on web pages - it refers to. */ -#define DW_AT_GNU_guarded_by 0x2108 /* GNU */ -#define DW_AT_GNU_pt_guarded_by 0x2109 /* GNU */ -#define DW_AT_GNU_guarded 0x210a /* GNU */ -#define DW_AT_GNU_pt_guarded 0x210b /* GNU */ -#define DW_AT_GNU_locks_excluded 0x210c /* GNU */ -#define DW_AT_GNU_exclusive_locks_required 0x210d /* GNU */ -#define DW_AT_GNU_shared_locks_required 0x210e /* GNU */ - -/* See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo */ -#define DW_AT_GNU_odr_signature 0x210f /* GNU */ - -/* See See http://gcc.gnu.org/wiki/TemplateParmsDwarf */ -/* The value here is from gcc-4.6.2 include/dwarf2.h. The value is - not consistent with the web page as of December 2011. */ -#define DW_AT_GNU_template_name 0x2110 /* GNU */ -/* The GNU call site extension. - See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . */ -#define DW_AT_GNU_call_site_value 0x2111 /* GNU */ -#define DW_AT_GNU_call_site_data_value 0x2112 /* GNU */ -#define DW_AT_GNU_call_site_target 0x2113 /* GNU */ -#define DW_AT_GNU_call_site_target_clobbered 0x2114 /* GNU */ -#define DW_AT_GNU_tail_call 0x2115 /* GNU */ -#define DW_AT_GNU_all_tail_call_sites 0x2116 /* GNU */ -#define DW_AT_GNU_all_call_sites 0x2117 /* GNU */ -#define DW_AT_GNU_all_source_call_sites 0x2118 /* GNU */ -/* Section offset to .debug_macro section. */ -#define DW_AT_GNU_macros 0x2119 /* GNU */ -/* The GNU DebugFission project: http://gcc.gnu.org/wiki/DebugFission */ -#define DW_AT_GNU_dwo_name 0x2130 /* GNU */ -#define DW_AT_GNU_dwo_id 0x2131 /* GNU */ - -#define DW_AT_GNU_ranges_base 0x2132 /* GNU */ -#define DW_AT_GNU_addr_base 0x2133 /* GNU */ -#define DW_AT_GNU_pubnames 0x2134 /* GNU */ -#define DW_AT_GNU_pubtypes 0x2135 /* GNU */ - -/* To distinguish distinct basic blocks in a single source line. */ -#define DW_AT_GNU_discriminator 0x2136 /* GNU */ -/* Ada GNAT gcc attributes. constant integer forms. */ -#define DW_AT_GNU_numerator 0x2303 /* GNU */ -#define DW_AT_GNU_denominator 0x2304 /* GNU */ -#define DW_AT_GNU_bias 0x2305 /* GNU */ - - - -/* ALTIUM extension: ALTIUM Compliant location lists (flag) */ -#define DW_AT_ALTIUM_loclist 0x2300 /* ALTIUM */ - -/* Sun extensions */ -#define DW_AT_SUN_template 0x2201 /* SUN */ -#define DW_AT_VMS_rtnbeg_pd_address 0x2201 /* VMS */ -#define DW_AT_SUN_alignment 0x2202 /* SUN */ -#define DW_AT_SUN_vtable 0x2203 /* SUN */ -#define DW_AT_SUN_count_guarantee 0x2204 /* SUN */ -#define DW_AT_SUN_command_line 0x2205 /* SUN */ -#define DW_AT_SUN_vbase 0x2206 /* SUN */ -#define DW_AT_SUN_compile_options 0x2207 /* SUN */ -#define DW_AT_SUN_language 0x2208 /* SUN */ -#define DW_AT_SUN_browser_file 0x2209 /* SUN */ -#define DW_AT_SUN_vtable_abi 0x2210 /* SUN */ -#define DW_AT_SUN_func_offsets 0x2211 /* SUN */ -#define DW_AT_SUN_cf_kind 0x2212 /* SUN */ -#define DW_AT_SUN_vtable_index 0x2213 /* SUN */ -#define DW_AT_SUN_omp_tpriv_addr 0x2214 /* SUN */ -#define DW_AT_SUN_omp_child_func 0x2215 /* SUN */ -#define DW_AT_SUN_func_offset 0x2216 /* SUN */ -#define DW_AT_SUN_memop_type_ref 0x2217 /* SUN */ -#define DW_AT_SUN_profile_id 0x2218 /* SUN */ -#define DW_AT_SUN_memop_signature 0x2219 /* SUN */ -#define DW_AT_SUN_obj_dir 0x2220 /* SUN */ -#define DW_AT_SUN_obj_file 0x2221 /* SUN */ -#define DW_AT_SUN_original_name 0x2222 /* SUN */ -#define DW_AT_SUN_hwcprof_signature 0x2223 /* SUN */ -#define DW_AT_SUN_amd64_parmdump 0x2224 /* SUN */ -#define DW_AT_SUN_part_link_name 0x2225 /* SUN */ -#define DW_AT_SUN_link_name 0x2226 /* SUN */ -#define DW_AT_SUN_pass_with_const 0x2227 /* SUN */ -#define DW_AT_SUN_return_with_const 0x2228 /* SUN */ -#define DW_AT_SUN_import_by_name 0x2229 /* SUN */ -#define DW_AT_SUN_f90_pointer 0x222a /* SUN */ -#define DW_AT_SUN_pass_by_ref 0x222b /* SUN */ -#define DW_AT_SUN_f90_allocatable 0x222c /* SUN */ -#define DW_AT_SUN_f90_assumed_shape_array 0x222d /* SUN */ -#define DW_AT_SUN_c_vla 0x222e /* SUN */ -#define DW_AT_SUN_return_value_ptr 0x2230 /* SUN */ -#define DW_AT_SUN_dtor_start 0x2231 /* SUN */ -#define DW_AT_SUN_dtor_length 0x2232 /* SUN */ -#define DW_AT_SUN_dtor_state_initial 0x2233 /* SUN */ -#define DW_AT_SUN_dtor_state_final 0x2234 /* SUN */ -#define DW_AT_SUN_dtor_state_deltas 0x2235 /* SUN */ -#define DW_AT_SUN_import_by_lname 0x2236 /* SUN */ -#define DW_AT_SUN_f90_use_only 0x2237 /* SUN */ -#define DW_AT_SUN_namelist_spec 0x2238 /* SUN */ -#define DW_AT_SUN_is_omp_child_func 0x2239 /* SUN */ -#define DW_AT_SUN_fortran_main_alias 0x223a /* SUN */ -#define DW_AT_SUN_fortran_based 0x223b /* SUN */ - -/* See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ -#define DW_AT_use_GNAT_descriptive_type 0x2301 /* GNAT */ -#define DW_AT_GNAT_descriptive_type 0x2302 /* GNAT */ - -/* UPC extension */ -#define DW_AT_upc_threads_scaled 0x3210 /* UPC */ - -/* PGI (STMicroelectronics) extensions. */ -#define DW_AT_PGI_lbase 0x3a00 /* PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. */ -#define DW_AT_PGI_soffset 0x3a01 /* PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. */ -#define DW_AT_PGI_lstride 0x3a02 /* PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. */ - -/* There are two groups of Apple extensions here, it is - unclear what exactly is correct. */ -#define DW_AT_APPLE_optimized 0x3fe1 /* Apple */ -#define DW_AT_APPLE_flags 0x3fe2 /* Apple */ -#define DW_AT_APPLE_isa 0x3fe3 /* Apple */ -#define DW_AT_APPLE_block 0x3fe4 /* Apple */ -#define DW_AT_APPLE_major_runtime_vers 0x3fe5 /* Apple */ -#define DW_AT_APPLE_runtime_class 0x3fe6 /* Apple */ -#define DW_AT_APPLE_omit_frame_ptr 0x3fe7 /* Apple */ - -/* Apple Extensions for closures */ -#define DW_AT_APPLE_closure 0x3fe4 /* Apple */ - -#define DW_AT_hi_user 0x3fff - -/* OP values 0x01,0x02,0x04,0x05,0x07 are DWARF1 only */ -#define DW_OP_addr 0x03 -#define DW_OP_deref 0x06 -#define DW_OP_const1u 0x08 -#define DW_OP_const1s 0x09 -#define DW_OP_const2u 0x0a -#define DW_OP_const2s 0x0b -#define DW_OP_const4u 0x0c -#define DW_OP_const4s 0x0d -#define DW_OP_const8u 0x0e -#define DW_OP_const8s 0x0f -#define DW_OP_constu 0x10 -#define DW_OP_consts 0x11 -#define DW_OP_dup 0x12 -#define DW_OP_drop 0x13 -#define DW_OP_over 0x14 -#define DW_OP_pick 0x15 -#define DW_OP_swap 0x16 -#define DW_OP_rot 0x17 -#define DW_OP_xderef 0x18 -#define DW_OP_abs 0x19 -#define DW_OP_and 0x1a -#define DW_OP_div 0x1b -#define DW_OP_minus 0x1c -#define DW_OP_mod 0x1d -#define DW_OP_mul 0x1e -#define DW_OP_neg 0x1f -#define DW_OP_not 0x20 -#define DW_OP_or 0x21 -#define DW_OP_plus 0x22 -#define DW_OP_plus_uconst 0x23 -#define DW_OP_shl 0x24 -#define DW_OP_shr 0x25 -#define DW_OP_shra 0x26 -#define DW_OP_xor 0x27 -#define DW_OP_bra 0x28 -#define DW_OP_eq 0x29 -#define DW_OP_ge 0x2a -#define DW_OP_gt 0x2b -#define DW_OP_le 0x2c -#define DW_OP_lt 0x2d -#define DW_OP_ne 0x2e -#define DW_OP_skip 0x2f -#define DW_OP_lit0 0x30 -#define DW_OP_lit1 0x31 -#define DW_OP_lit2 0x32 -#define DW_OP_lit3 0x33 -#define DW_OP_lit4 0x34 -#define DW_OP_lit5 0x35 -#define DW_OP_lit6 0x36 -#define DW_OP_lit7 0x37 -#define DW_OP_lit8 0x38 -#define DW_OP_lit9 0x39 -#define DW_OP_lit10 0x3a -#define DW_OP_lit11 0x3b -#define DW_OP_lit12 0x3c -#define DW_OP_lit13 0x3d -#define DW_OP_lit14 0x3e -#define DW_OP_lit15 0x3f -#define DW_OP_lit16 0x40 -#define DW_OP_lit17 0x41 -#define DW_OP_lit18 0x42 -#define DW_OP_lit19 0x43 -#define DW_OP_lit20 0x44 -#define DW_OP_lit21 0x45 -#define DW_OP_lit22 0x46 -#define DW_OP_lit23 0x47 -#define DW_OP_lit24 0x48 -#define DW_OP_lit25 0x49 -#define DW_OP_lit26 0x4a -#define DW_OP_lit27 0x4b -#define DW_OP_lit28 0x4c -#define DW_OP_lit29 0x4d -#define DW_OP_lit30 0x4e -#define DW_OP_lit31 0x4f -#define DW_OP_reg0 0x50 -#define DW_OP_reg1 0x51 -#define DW_OP_reg2 0x52 -#define DW_OP_reg3 0x53 -#define DW_OP_reg4 0x54 -#define DW_OP_reg5 0x55 -#define DW_OP_reg6 0x56 -#define DW_OP_reg7 0x57 -#define DW_OP_reg8 0x58 -#define DW_OP_reg9 0x59 -#define DW_OP_reg10 0x5a -#define DW_OP_reg11 0x5b -#define DW_OP_reg12 0x5c -#define DW_OP_reg13 0x5d -#define DW_OP_reg14 0x5e -#define DW_OP_reg15 0x5f -#define DW_OP_reg16 0x60 -#define DW_OP_reg17 0x61 -#define DW_OP_reg18 0x62 -#define DW_OP_reg19 0x63 -#define DW_OP_reg20 0x64 -#define DW_OP_reg21 0x65 -#define DW_OP_reg22 0x66 -#define DW_OP_reg23 0x67 -#define DW_OP_reg24 0x68 -#define DW_OP_reg25 0x69 -#define DW_OP_reg26 0x6a -#define DW_OP_reg27 0x6b -#define DW_OP_reg28 0x6c -#define DW_OP_reg29 0x6d -#define DW_OP_reg30 0x6e -#define DW_OP_reg31 0x6f -#define DW_OP_breg0 0x70 -#define DW_OP_breg1 0x71 -#define DW_OP_breg2 0x72 -#define DW_OP_breg3 0x73 -#define DW_OP_breg4 0x74 -#define DW_OP_breg5 0x75 -#define DW_OP_breg6 0x76 -#define DW_OP_breg7 0x77 -#define DW_OP_breg8 0x78 -#define DW_OP_breg9 0x79 -#define DW_OP_breg10 0x7a -#define DW_OP_breg11 0x7b -#define DW_OP_breg12 0x7c -#define DW_OP_breg13 0x7d -#define DW_OP_breg14 0x7e -#define DW_OP_breg15 0x7f -#define DW_OP_breg16 0x80 -#define DW_OP_breg17 0x81 -#define DW_OP_breg18 0x82 -#define DW_OP_breg19 0x83 -#define DW_OP_breg20 0x84 -#define DW_OP_breg21 0x85 -#define DW_OP_breg22 0x86 -#define DW_OP_breg23 0x87 -#define DW_OP_breg24 0x88 -#define DW_OP_breg25 0x89 -#define DW_OP_breg26 0x8a -#define DW_OP_breg27 0x8b -#define DW_OP_breg28 0x8c -#define DW_OP_breg29 0x8d -#define DW_OP_breg30 0x8e -#define DW_OP_breg31 0x8f -#define DW_OP_regx 0x90 -#define DW_OP_fbreg 0x91 -#define DW_OP_bregx 0x92 -#define DW_OP_piece 0x93 -#define DW_OP_deref_size 0x94 -#define DW_OP_xderef_size 0x95 -#define DW_OP_nop 0x96 -#define DW_OP_push_object_address 0x97 /* DWARF3 */ -#define DW_OP_call2 0x98 /* DWARF3 */ -#define DW_OP_call4 0x99 /* DWARF3 */ -#define DW_OP_call_ref 0x9a /* DWARF3 */ -#define DW_OP_form_tls_address 0x9b /* DWARF3f */ -#define DW_OP_call_frame_cfa 0x9c /* DWARF3f */ -#define DW_OP_bit_piece 0x9d /* DWARF3f */ -#define DW_OP_implicit_value 0x9e /* DWARF4 */ -#define DW_OP_stack_value 0x9f /* DWARF4 */ -#define DW_OP_implicit_pointer 0xa0 /* DWARF5 */ -#define DW_OP_addrx 0xa1 /* DWARF5 */ -#define DW_OP_constx 0xa2 /* DWARF5 */ -#define DW_OP_entry_value 0xa3 /* DWARF5 */ -#define DW_OP_const_type 0xa4 /* DWARF5 */ -#define DW_OP_regval_type 0xa5 /* DWARF5 */ -#define DW_OP_deref_type 0xa6 /* DWARF5 */ -#define DW_OP_xderef_type 0xa7 /* DWARF5 */ -#define DW_OP_convert 0xa8 /* DWARF5 */ -#define DW_OP_reinterpret 0xa9 /* DWARF5 */ - - - /* GNU extensions. */ -#define DW_OP_GNU_push_tls_address 0xe0 /* GNU */ - -/* Follows extension so dwarfdump prints the most-likely-useful name. */ -#define DW_OP_lo_user 0xe0 - - -#define DW_OP_GNU_uninit 0xf0 /* GNU */ -#define DW_OP_GNU_encoded_addr 0xf1 /* GNU */ -#define DW_OP_GNU_implicit_pointer 0xf2 /* GNU */ -#define DW_OP_GNU_entry_value 0xf3 /* GNU */ -#define DW_OP_GNU_const_type 0xf4 /* GNU */ -#define DW_OP_GNU_regval_type 0xf5 /* GNU */ -#define DW_OP_GNU_deref_type 0xf6 /* GNU */ -#define DW_OP_GNU_convert 0xf7 /* GNU */ -#define DW_OP_GNU_reinterpret 0xf9 /* GNU */ -#define DW_OP_GNU_parameter_ref 0xfa /* GNU */ -#define DW_OP_GNU_addr_index 0xfb /* GNU DebugFission */ -#define DW_OP_GNU_const_index 0xfc /* GNU DebugFission */ - - /* HP extensions. */ -#define DW_OP_HP_unknown 0xe0 /* HP conflict: GNU */ -#define DW_OP_HP_is_value 0xe1 /* HP */ -#define DW_OP_HP_fltconst4 0xe2 /* HP */ -#define DW_OP_HP_fltconst8 0xe3 /* HP */ -#define DW_OP_HP_mod_range 0xe4 /* HP */ -#define DW_OP_HP_unmod_range 0xe5 /* HP */ -#define DW_OP_HP_tls 0xe6 /* HP */ - -#define DW_OP_INTEL_bit_piece 0xe8 /* Intel: made obsolete by DW_OP_bit_piece above. */ - - /* Apple extension. */ -#define DW_OP_APPLE_uninit 0xf0 /* Apple */ -#define DW_OP_PGI_omp_thread_num 0xf8 /* PGI (STMicroelectronics) */ - -#define DW_OP_hi_user 0xff - -#define DW_ATE_address 0x01 -#define DW_ATE_boolean 0x02 -#define DW_ATE_complex_float 0x03 -#define DW_ATE_float 0x04 -#define DW_ATE_signed 0x05 -#define DW_ATE_signed_char 0x06 -#define DW_ATE_unsigned 0x07 -#define DW_ATE_unsigned_char 0x08 -#define DW_ATE_imaginary_float 0x09 /* DWARF3 */ -#define DW_ATE_packed_decimal 0x0a /* DWARF3f */ -#define DW_ATE_numeric_string 0x0b /* DWARF3f */ -#define DW_ATE_edited 0x0c /* DWARF3f */ -#define DW_ATE_signed_fixed 0x0d /* DWARF3f */ -#define DW_ATE_unsigned_fixed 0x0e /* DWARF3f */ -#define DW_ATE_decimal_float 0x0f /* DWARF3f */ -#define DW_ATE_UTF 0x10 /* DWARF4 */ -#define DW_ATE_UCS 0x11 /* DWARF5 */ -#define DW_ATE_ASCII 0x12 /* DWARF5 */ - - -/* ALTIUM extensions. x80, x81 */ -#define DW_ATE_ALTIUM_fract 0x80 /* ALTIUM __fract type */ - -/* Follows extension so dwarfdump prints the most-likely-useful name. */ -#define DW_ATE_lo_user 0x80 - -/* Shown here to help dwarfdump build script. */ -#define DW_ATE_ALTIUM_accum 0x81 /* ALTIUM __accum type */ - -/* HP Floating point extensions. */ -#define DW_ATE_HP_float80 0x80 /* (80 bit). HP */ - - -#define DW_ATE_HP_complex_float80 0x81 /* Complex (80 bit). HP */ -#define DW_ATE_HP_float128 0x82 /* (128 bit). HP */ -#define DW_ATE_HP_complex_float128 0x83 /* Complex (128 bit). HP */ -#define DW_ATE_HP_floathpintel 0x84 /* (82 bit IA64). HP */ -#define DW_ATE_HP_imaginary_float80 0x85 /* HP */ -#define DW_ATE_HP_imaginary_float128 0x86 /* HP */ - -/* Sun extensions */ -#define DW_ATE_SUN_interval_float 0x91 -#define DW_ATE_SUN_imaginary_float 0x92 /* Obsolete: See DW_ATE_imaginary_float */ - -#define DW_ATE_hi_user 0xff - - -/* DWARF5 Defaulted Member Encodings. */ -#define DW_DEFAULTED_no 0x0 /* DWARF5 */ -#define DW_DEFAULTED_in_class 0x1 /* DWARF5 */ -#define DW_DEFAULTED_out_of_class 0x2 /* DWARF5 */ - - -#define DW_IDX_compile_unit 0x1 /* DWARF5 */ -#define DW_IDX_type_unit 0x2 /* DWARF5 */ -#define DW_IDX_die_offset 0x3 /* DWARF5 */ -#define DW_IDX_parent 0x4 /* DWARF5 */ -#define DW_IDX_type_hash 0x5 /* DWARF5 */ -#define DW_IDX_lo_user 0x2000 /* DWARF5 */ -#define DW_IDX_hi_user 0x0fff /* DWARF5 */ - -/* These with not-quite-the-same-names were used in DWARF4 - and never official and should not be used by anyone. */ -#define DW_LLEX_end_of_list_entry 0x0 /* DWARF4 experimental */ -#define DW_LLEX_base_address_selection_entry 0x01 /* DWARF4 experimental */ -#define DW_LLEX_start_end_entry 0x02 /* DWARF4 experimental */ -#define DW_LLEX_start_length_entry 0x03 /* DWARF4 experimental */ -#define DW_LLEX_offset_pair_entry 0x04 /* DWARF4 experimental */ - -/* DWARF5 Location List Entries in Split Objects */ -#define DW_LLE_end_of_list 0x0 /* DWARF5 */ -#define DW_LLE_base_addressx 0x01 /* DWARF5 */ -#define DW_LLE_startx_endx 0x02 /* DWARF5 */ -#define DW_LLE_startx_length 0x03 /* DWARF5 */ -#define DW_LLE_offset_pair 0x04 /* DWARF5 */ -#define DW_LLE_default_location 0x05 /* DWARF5 */ -#define DW_LLE_base_address 0x06 /* DWARF5 */ -#define DW_LLE_start_end 0x07 /* DWARF5 */ -#define DW_LLE_start_length 0x08 /* DWARF5 */ - -/* DWARF5 Range List Entries */ -#define DW_RLE_end_of_list 0x00 /* DWARF5 */ -#define DW_RLE_base_addressx 0x01 /* DWARF5 */ -#define DW_RLE_startx_endx 0x02 /* DWARF5 */ -#define DW_RLE_startx_length 0x03 /* DWARF5 */ -#define DW_RLE_offset_pair 0x04 /* DWARF5 */ -#define DW_RLE_base_address 0x05 /* DWARF5 */ -#define DW_RLE_start_end 0x06 /* DWARF5 */ -#define DW_RLE_start_length 0x07 /* DWARF5 */ - -/* DWARF5 Unit header unit type encodings */ -#define DW_UT_compile 0x01 /* DWARF5 */ -#define DW_UT_type 0x02 /* DWARF5 */ -#define DW_UT_partial 0x03 /* DWARF5 */ -#define DW_UT_skeleton 0x04 /* DWARF5 */ -#define DW_UT_split_compile 0x05 /* DWARF5 */ -#define DW_UT_split_type 0x06 /* DWARF5 */ -#define DW_UT_lo_user 0x80 /* DWARF5 */ -#define DW_UT_hi_user 0xff /* DWARF5 */ - - -/* DWARF5 DebugFission object section id values - for .dwp object section offsets hash table. - 0 is reserved, not used. - 2 is actually reserved, not used in DWARF5. - But 2 may be seen in some DWARF4 objects. -*/ -#define DW_SECT_INFO 1 /* .debug_info.dwo DWARF5 */ -#define DW_SECT_TYPES 2 /* .debug_types.dwo pre-DWARF5 */ -#define DW_SECT_ABBREV 3 /* .debug_abbrev.dwo DWARF5 */ -#define DW_SECT_LINE 4 /* .debug_line.dwo DWARF5 */ -#define DW_SECT_LOCLISTS 5 /* .debug_loclists.dwo DWARF5 */ -#define DW_SECT_STR_OFFSETS 6 /* .debug_str_offsets.dwo DWARF5 */ -#define DW_SECT_MACRO 7 /* .debug_macro.dwo DWARF5 */ -#define DW_SECT_RNGLISTS 8 /* .debug_rnglists.dwo DWARF5 */ - - -/* Decimal Sign codes. */ -#define DW_DS_unsigned 0x01 /* DWARF3f */ -#define DW_DS_leading_overpunch 0x02 /* DWARF3f */ -#define DW_DS_trailing_overpunch 0x03 /* DWARF3f */ -#define DW_DS_leading_separate 0x04 /* DWARF3f */ -#define DW_DS_trailing_separate 0x05 /* DWARF3f */ - -/* Endian code name. */ -#define DW_END_default 0x00 /* DWARF3f */ -#define DW_END_big 0x01 /* DWARF3f */ -#define DW_END_little 0x02 /* DWARF3f */ - -#define DW_END_lo_user 0x40 /* DWARF3f */ -#define DW_END_hi_user 0xff /* DWARF3f */ - -/* For use with DW_TAG_SUN_codeflags - If DW_TAG_SUN_codeflags is accepted as a dwarf standard, then - standard dwarf ATCF entries start at 0x01 */ -#define DW_ATCF_lo_user 0x40 /* SUN */ -#define DW_ATCF_SUN_mop_bitfield 0x41 /* SUN */ -#define DW_ATCF_SUN_mop_spill 0x42 /* SUN */ -#define DW_ATCF_SUN_mop_scopy 0x43 /* SUN */ -#define DW_ATCF_SUN_func_start 0x44 /* SUN */ -#define DW_ATCF_SUN_end_ctors 0x45 /* SUN */ -#define DW_ATCF_SUN_branch_target 0x46 /* SUN */ -#define DW_ATCF_SUN_mop_stack_probe 0x47 /* SUN */ -#define DW_ATCF_SUN_func_epilog 0x48 /* SUN */ -#define DW_ATCF_hi_user 0xff /* SUN */ - -/* Accessibility code name. */ -#define DW_ACCESS_public 0x01 -#define DW_ACCESS_protected 0x02 -#define DW_ACCESS_private 0x03 - -/* Visibility code name. */ -#define DW_VIS_local 0x01 -#define DW_VIS_exported 0x02 -#define DW_VIS_qualified 0x03 - -/* Virtuality code name. */ -#define DW_VIRTUALITY_none 0x00 -#define DW_VIRTUALITY_virtual 0x01 -#define DW_VIRTUALITY_pure_virtual 0x02 - -#define DW_LANG_C89 0x0001 -#define DW_LANG_C 0x0002 -#define DW_LANG_Ada83 0x0003 -#define DW_LANG_C_plus_plus 0x0004 -#define DW_LANG_Cobol74 0x0005 -#define DW_LANG_Cobol85 0x0006 -#define DW_LANG_Fortran77 0x0007 -#define DW_LANG_Fortran90 0x0008 -#define DW_LANG_Pascal83 0x0009 -#define DW_LANG_Modula2 0x000a -#define DW_LANG_Java 0x000b /* DWARF3 */ -#define DW_LANG_C99 0x000c /* DWARF3 */ -#define DW_LANG_Ada95 0x000d /* DWARF3 */ -#define DW_LANG_Fortran95 0x000e /* DWARF3 */ -#define DW_LANG_PLI 0x000f /* DWARF3 */ -#define DW_LANG_ObjC 0x0010 /* DWARF3f */ -#define DW_LANG_ObjC_plus_plus 0x0011 /* DWARF3f */ -#define DW_LANG_UPC 0x0012 /* DWARF3f */ -#define DW_LANG_D 0x0013 /* DWARF3f */ -#define DW_LANG_Python 0x0014 /* DWARF4 */ -/* The following 2 are not yet formally approved October 2010, but - it seems extremely likely they will be approved as the committee - chair agrees these should be ok and no one on the committee - has objected. */ -#define DW_LANG_OpenCL 0x0015 /* DWARF5 */ -#define DW_LANG_Go 0x0016 /* DWARF5 */ -#define DW_LANG_Modula3 0x0017 /* DWARF5 */ -#define DW_LANG_Haskel 0x0018 /* DWARF5 */ -#define DW_LANG_C_plus_plus_03 0x0019 /* DWARF5 */ -#define DW_LANG_C_plus_plus_11 0x001a /* DWARF5 */ -#define DW_LANG_OCaml 0x001b /* DWARF5 */ -#define DW_LANG_Rust 0x001c /* DWARF5 */ -#define DW_LANG_C11 0x001d /* DWARF5 */ -#define DW_LANG_Swift 0x001e /* DWARF5 */ -#define DW_LANG_Julia 0x001f /* DWARF5 */ -#define DW_LANG_Dylan 0x0020 /* DWARF5 */ -#define DW_LANG_C_plus_plus_14 0x0021 /* DWARF5 */ -#define DW_LANG_Fortran03 0x0022 /* DWARF5 */ -#define DW_LANG_Fortran08 0x0023 /* DWARF5 */ -#define DW_LANG_RenderScript 0x0024 /* DWARF5 */ -#define DW_LANG_BLISS 0x0025 /* DWARF5 */ -#define DW_LANG_lo_user 0x8000 -#define DW_LANG_Mips_Assembler 0x8001 /* MIPS */ -#define DW_LANG_Upc 0x8765 /* UPC, use - DW_LANG_UPC instead. */ -/* ALTIUM extension */ -#define DW_LANG_ALTIUM_Assembler 0x9101 /* ALTIUM */ - -/* Sun extensions */ -#define DW_LANG_SUN_Assembler 0x9001 /* SUN */ - -#define DW_LANG_hi_user 0xffff - -/* Identifier case name. */ -#define DW_ID_case_sensitive 0x00 -#define DW_ID_up_case 0x01 -#define DW_ID_down_case 0x02 -#define DW_ID_case_insensitive 0x03 - -/* Calling Convention Name. */ -#define DW_CC_normal 0x01 -#define DW_CC_program 0x02 -#define DW_CC_nocall 0x03 -#define DW_CC_pass_by_reference 0x04 /* DWARF5 */ -#define DW_CC_pass_by_value 0x05 /* DWARF5 */ -#define DW_CC_lo_user 0x40 - -#define DW_CC_GNU_renesas_sh 0x40 /* GNU */ -#define DW_CC_GNU_borland_fastcall_i386 0x41 /* GNU */ - - - -/* ALTIUM extensions. */ -/* Function is an interrupt handler, return address on system stack. */ -#define DW_CC_ALTIUM_interrupt 0x65 /* ALTIUM*/ - -/* Near function model, return address on system stack. */ -#define DW_CC_ALTIUM_near_system_stack 0x66 /*ALTIUM */ - -/* Near function model, return address on user stack. */ -#define DW_CC_ALTIUM_near_user_stack 0x67 /* ALTIUM */ - -/* Huge function model, return address on user stack. */ -#define DW_CC_ALTIUM_huge_user_stack 0x68 /* ALTIUM */ - - -#define DW_CC_hi_user 0xff - -/* Inline Code Name. */ -#define DW_INL_not_inlined 0x00 -#define DW_INL_inlined 0x01 -#define DW_INL_declared_not_inlined 0x02 -#define DW_INL_declared_inlined 0x03 - -/* Ordering Name. */ -#define DW_ORD_row_major 0x00 -#define DW_ORD_col_major 0x01 - -/* Discriminant Descriptor Name. */ -#define DW_DSC_label 0x00 -#define DW_DSC_range 0x01 - -/* Line number header entry format encodings. DWARF5 */ -#define DW_LNCT_path 0x1 /* DWARF5 */ -#define DW_LNCT_directory_index 0x2 /* DWARF5 */ -#define DW_LNCT_timestamp 0x3 /* DWARF5 */ -#define DW_LNCT_size 0x4 /* DWARF5 */ -#define DW_LNCT_MD5 0x5 /* DWARF5 */ -/* Experimental two-level line tables. Non standard */ -#define DW_LNCT_GNU_subprogram_name 0x6 -#define DW_LNCT_GNU_decl_file 0x7 -#define DW_LNCT_GNU_decl_line 0x8 -#define DW_LNCT_lo_user 0x2000 /* DWARF5 */ -#define DW_LNCT_hi_user 0x3fff /* DWARF5 */ - -/* Line number standard opcode name. */ -#define DW_LNS_copy 0x01 -#define DW_LNS_advance_pc 0x02 -#define DW_LNS_advance_line 0x03 -#define DW_LNS_set_file 0x04 -#define DW_LNS_set_column 0x05 -#define DW_LNS_negate_stmt 0x06 -#define DW_LNS_set_basic_block 0x07 -#define DW_LNS_const_add_pc 0x08 -#define DW_LNS_fixed_advance_pc 0x09 -#define DW_LNS_set_prologue_end 0x0a /* DWARF3 */ -#define DW_LNS_set_epilogue_begin 0x0b /* DWARF3 */ -#define DW_LNS_set_isa 0x0c /* DWARF3 */ - -/* Experimental two-level line tables. NOT STD DWARF5 */ -/* Not saying GNU or anything. There are no - DW_LNS_lo_user or DW_LNS_hi_user values though. - DW_LNS_set_address_from_logical and - DW_LNS_set_subprogram being both 0xd - to avoid using up more space in the special opcode table. - EXPERIMENTAL DW_LNS follow. -*/ -#define DW_LNS_set_address_from_logical 0x0d /* Actuals table only */ -#define DW_LNS_set_subprogram 0x0d /* Logicals table only */ -#define DW_LNS_inlined_call 0x0e /* Logicals table only */ -#define DW_LNS_pop_context 0x0f /* Logicals table only */ - -/* Line number extended opcode name. */ -#define DW_LNE_end_sequence 0x01 -#define DW_LNE_set_address 0x02 -#define DW_LNE_define_file 0x03 /* DWARF4 and earlier only */ -#define DW_LNE_set_discriminator 0x04 /* DWARF4 */ - -/* HP extensions. */ -#define DW_LNE_HP_negate_is_UV_update 0x11 /* 17 HP */ -#define DW_LNE_HP_push_context 0x12 /* 18 HP */ -#define DW_LNE_HP_pop_context 0x13 /* 19 HP */ -#define DW_LNE_HP_set_file_line_column 0x14 /* 20 HP */ -#define DW_LNE_HP_set_routine_name 0x15 /* 21 HP */ -#define DW_LNE_HP_set_sequence 0x16 /* 22 HP */ -#define DW_LNE_HP_negate_post_semantics 0x17 /* 23 HP */ -#define DW_LNE_HP_negate_function_exit 0x18 /* 24 HP */ -#define DW_LNE_HP_negate_front_end_logical 0x19 /* 25 HP */ -#define DW_LNE_HP_define_proc 0x20 /* 32 HP */ - -#define DW_LNE_HP_source_file_correlation 0x80 /* HP */ -#define DW_LNE_lo_user 0x80 /* DWARF3 */ -#define DW_LNE_hi_user 0xff /* DWARF3 */ - -/* These are known values for DW_LNS_set_isa. */ -/* These identifiers are not defined by any DWARFn standard. */ -#define DW_ISA_UNKNOWN 0 -/* The following two are ARM specific. */ -#define DW_ISA_ARM_thumb 1 /* ARM ISA */ -#define DW_ISA_ARM_arm 2 /* ARM ISA */ - - -/* Macro information, DWARF5 */ -#define DW_MACRO_define 0x01 /* DWARF5 */ -#define DW_MACRO_undef 0x02 /* DWARF5 */ -#define DW_MACRO_start_file 0x03 /* DWARF5 */ -#define DW_MACRO_end_file 0x04 /* DWARF5 */ -#define DW_MACRO_define_strp 0x05 /* DWARF5 */ -#define DW_MACRO_undef_strp 0x06 /* DWARF5 */ -#define DW_MACRO_import 0x07 /* DWARF5 */ -#define DW_MACRO_define_sup 0x08 /* DWARF5 */ -#define DW_MACRO_undef_sup 0x09 /* DWARF5 */ -#define DW_MACRO_import_sup 0x0a /* DWARF5 */ -#define DW_MACRO_define_strx 0x0b /* DWARF5 */ -#define DW_MACRO_undef_strx 0x0c /* DWARF5 */ -#define DW_MACRO_lo_user 0xe0 -#define DW_MACRO_hi_user 0xff - -/* Macro information, DWARF2-DWARF4. */ -#define DW_MACINFO_define 0x01 -#define DW_MACINFO_undef 0x02 -#define DW_MACINFO_start_file 0x03 -#define DW_MACINFO_end_file 0x04 -#define DW_MACINFO_vendor_ext 0xff - -/* CFA operator compaction (a space saving measure, see - the DWARF standard) means DW_CFA_extended and DW_CFA_nop - have the same value here. */ -#define DW_CFA_advance_loc 0x40 -#define DW_CFA_offset 0x80 -#define DW_CFA_restore 0xc0 -#define DW_CFA_extended 0 - -#define DW_CFA_nop 0x00 -#define DW_CFA_set_loc 0x01 -#define DW_CFA_advance_loc1 0x02 -#define DW_CFA_advance_loc2 0x03 -#define DW_CFA_advance_loc4 0x04 -#define DW_CFA_offset_extended 0x05 -#define DW_CFA_restore_extended 0x06 -#define DW_CFA_undefined 0x07 -#define DW_CFA_same_value 0x08 -#define DW_CFA_register 0x09 -#define DW_CFA_remember_state 0x0a -#define DW_CFA_restore_state 0x0b -#define DW_CFA_def_cfa 0x0c -#define DW_CFA_def_cfa_register 0x0d -#define DW_CFA_def_cfa_offset 0x0e -#define DW_CFA_def_cfa_expression 0x0f /* DWARF3 */ -#define DW_CFA_expression 0x10 /* DWARF3 */ -#define DW_CFA_offset_extended_sf 0x11 /* DWARF3 */ -#define DW_CFA_def_cfa_sf 0x12 /* DWARF3 */ -#define DW_CFA_def_cfa_offset_sf 0x13 /* DWARF3 */ -#define DW_CFA_val_offset 0x14 /* DWARF3f */ -#define DW_CFA_val_offset_sf 0x15 /* DWARF3f */ -#define DW_CFA_val_expression 0x16 /* DWARF3f */ -#define DW_CFA_lo_user 0x1c -#define DW_CFA_low_user 0x1c /* Incorrect spelling, do not use. */ - -/* SGI/MIPS extension. */ -#define DW_CFA_MIPS_advance_loc8 0x1d /* MIPS */ - -/* GNU extensions. */ -#define DW_CFA_GNU_window_save 0x2d /* GNU */ -#define DW_CFA_GNU_args_size 0x2e /* GNU */ -#define DW_CFA_GNU_negative_offset_extended 0x2f /* GNU */ - -/* Metaware if HC is augmentation, apparently meaning High C - and the op has a single uleb operand. - See http://sourceforge.net/p/elftoolchain/tickets/397/ */ -#define DW_CFA_METAWARE_info 0x34 - -#define DW_CFA_high_user 0x3f - -/* GNU exception header encoding. See the Generic - Elf Specification of the Linux Standard Base (LSB). - http://refspecs.freestandards.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/dwarfext.html - The upper 4 bits indicate how the value is to be applied. - The lower 4 bits indicate the format of the data. - These identifiers are not defined by any DWARFn standard. -*/ -#define DW_EH_PE_absptr 0x00 /* GNU */ -#define DW_EH_PE_uleb128 0x01 /* GNU */ -#define DW_EH_PE_udata2 0x02 /* GNU */ -#define DW_EH_PE_udata4 0x03 /* GNU */ -#define DW_EH_PE_udata8 0x04 /* GNU */ -#define DW_EH_PE_sleb128 0x09 /* GNU */ -#define DW_EH_PE_sdata2 0x0A /* GNU */ -#define DW_EH_PE_sdata4 0x0B /* GNU */ -#define DW_EH_PE_sdata8 0x0C /* GNU */ - -#define DW_EH_PE_pcrel 0x10 /* GNU */ -#define DW_EH_PE_textrel 0x20 /* GNU */ -#define DW_EH_PE_datarel 0x30 /* GNU */ -#define DW_EH_PE_funcrel 0x40 /* GNU */ -#define DW_EH_PE_aligned 0x50 /* GNU */ - -#define DW_EH_PE_omit 0xff /* GNU. Means no value present. */ - - -/* Mapping from machine registers and pseudo-regs into the - .debug_frame table. DW_FRAME entries are machine specific. - These describe MIPS/SGI R3000, R4K, R4400 and all later - MIPS/SGI IRIX machines. They describe a mapping from - hardware register number to the number used in the table - to identify that register. - - The CFA (Canonical Frame Address) described in DWARF is - called the Virtual Frame Pointer on MIPS/SGI machines. - - The DW_FRAME* names here are MIPS/SGI specific. - Libdwarf interfaces defined in 2008 make the - frame definitions here (and the fixed table sizes - they imply) obsolete. They are left here for compatibility. -*/ -/* Default column used for CFA in the libdwarf reader client. - Assumes reg 0 never appears as - a register in DWARF information. Usable for MIPS, - but never a good idea, really. */ -/* These identifiers are not defined by any DWARFn standard. */ -#define DW_FRAME_CFA_COL 0 - -#define DW_FRAME_REG1 1 /* integer reg 1 */ -#define DW_FRAME_REG2 2 /* integer reg 2 */ -#define DW_FRAME_REG3 3 /* integer reg 3 */ -#define DW_FRAME_REG4 4 /* integer reg 4 */ -#define DW_FRAME_REG5 5 /* integer reg 5 */ -#define DW_FRAME_REG6 6 /* integer reg 6 */ -#define DW_FRAME_REG7 7 /* integer reg 7 */ -#define DW_FRAME_REG8 8 /* integer reg 8 */ -#define DW_FRAME_REG9 9 /* integer reg 9 */ -#define DW_FRAME_REG10 10 /* integer reg 10 */ -#define DW_FRAME_REG11 11 /* integer reg 11 */ -#define DW_FRAME_REG12 12 /* integer reg 12 */ -#define DW_FRAME_REG13 13 /* integer reg 13 */ -#define DW_FRAME_REG14 14 /* integer reg 14 */ -#define DW_FRAME_REG15 15 /* integer reg 15 */ -#define DW_FRAME_REG16 16 /* integer reg 16 */ -#define DW_FRAME_REG17 17 /* integer reg 17 */ -#define DW_FRAME_REG18 18 /* integer reg 18 */ -#define DW_FRAME_REG19 19 /* integer reg 19 */ -#define DW_FRAME_REG20 20 /* integer reg 20 */ -#define DW_FRAME_REG21 21 /* integer reg 21 */ -#define DW_FRAME_REG22 22 /* integer reg 22 */ -#define DW_FRAME_REG23 23 /* integer reg 23 */ -#define DW_FRAME_REG24 24 /* integer reg 24 */ -#define DW_FRAME_REG25 25 /* integer reg 25 */ -#define DW_FRAME_REG26 26 /* integer reg 26 */ -#define DW_FRAME_REG27 27 /* integer reg 27 */ -#define DW_FRAME_REG28 28 /* integer reg 28 */ -#define DW_FRAME_REG29 29 /* integer reg 29 */ -#define DW_FRAME_REG30 30 /* integer reg 30 */ -#define DW_FRAME_REG31 31 /* integer reg 31, aka ra */ - - /* MIPS1, 2 have only some of these 64-bit registers. - ** MIPS1 save/restore takes 2 instructions per 64-bit reg, and - ** in that case, the register is considered stored after the second - ** swc1. - */ -#define DW_FRAME_FREG0 32 /* 64-bit floating point reg 0 */ -#define DW_FRAME_FREG1 33 /* 64-bit floating point reg 1 */ -#define DW_FRAME_FREG2 34 /* 64-bit floating point reg 2 */ -#define DW_FRAME_FREG3 35 /* 64-bit floating point reg 3 */ -#define DW_FRAME_FREG4 36 /* 64-bit floating point reg 4 */ -#define DW_FRAME_FREG5 37 /* 64-bit floating point reg 5 */ -#define DW_FRAME_FREG6 38 /* 64-bit floating point reg 6 */ -#define DW_FRAME_FREG7 39 /* 64-bit floating point reg 7 */ -#define DW_FRAME_FREG8 40 /* 64-bit floating point reg 8 */ -#define DW_FRAME_FREG9 41 /* 64-bit floating point reg 9 */ -#define DW_FRAME_FREG10 42 /* 64-bit floating point reg 10 */ -#define DW_FRAME_FREG11 43 /* 64-bit floating point reg 11 */ -#define DW_FRAME_FREG12 44 /* 64-bit floating point reg 12 */ -#define DW_FRAME_FREG13 45 /* 64-bit floating point reg 13 */ -#define DW_FRAME_FREG14 46 /* 64-bit floating point reg 14 */ -#define DW_FRAME_FREG15 47 /* 64-bit floating point reg 15 */ -#define DW_FRAME_FREG16 48 /* 64-bit floating point reg 16 */ -#define DW_FRAME_FREG17 49 /* 64-bit floating point reg 17 */ -#define DW_FRAME_FREG18 50 /* 64-bit floating point reg 18 */ -#define DW_FRAME_FREG19 51 /* 64-bit floating point reg 19 */ -#define DW_FRAME_FREG20 52 /* 64-bit floating point reg 20 */ -#define DW_FRAME_FREG21 53 /* 64-bit floating point reg 21 */ -#define DW_FRAME_FREG22 54 /* 64-bit floating point reg 22 */ -#define DW_FRAME_FREG23 55 /* 64-bit floating point reg 23 */ -#define DW_FRAME_FREG24 56 /* 64-bit floating point reg 24 */ -#define DW_FRAME_FREG25 57 /* 64-bit floating point reg 25 */ -#define DW_FRAME_FREG26 58 /* 64-bit floating point reg 26 */ -#define DW_FRAME_FREG27 59 /* 64-bit floating point reg 27 */ -#define DW_FRAME_FREG28 60 /* 64-bit floating point reg 28 */ -#define DW_FRAME_FREG29 61 /* 64-bit floating point reg 29 */ -#define DW_FRAME_FREG30 62 /* 64-bit floating point reg 30 */ -#define DW_FRAME_FREG31 63 /* 64-bit floating point reg 31 */ - -#define DW_FRAME_FREG32 64 /* 64-bit floating point reg 32 */ -#define DW_FRAME_FREG33 65 /* 64-bit floating point reg 33 */ -#define DW_FRAME_FREG34 66 /* 64-bit floating point reg 34 */ -#define DW_FRAME_FREG35 67 /* 64-bit floating point reg 35 */ -#define DW_FRAME_FREG36 68 /* 64-bit floating point reg 36 */ -#define DW_FRAME_FREG37 69 /* 64-bit floating point reg 37 */ -#define DW_FRAME_FREG38 70 /* 64-bit floating point reg 38 */ -#define DW_FRAME_FREG39 71 /* 64-bit floating point reg 39 */ -#define DW_FRAME_FREG40 72 /* 64-bit floating point reg 40 */ -#define DW_FRAME_FREG41 73 /* 64-bit floating point reg 41 */ -#define DW_FRAME_FREG42 74 /* 64-bit floating point reg 42 */ -#define DW_FRAME_FREG43 75 /* 64-bit floating point reg 43 */ -#define DW_FRAME_FREG44 76 /* 64-bit floating point reg 44 */ -#define DW_FRAME_FREG45 77 /* 64-bit floating point reg 45 */ -#define DW_FRAME_FREG46 78 /* 64-bit floating point reg 46 */ -#define DW_FRAME_FREG47 79 /* 64-bit floating point reg 47 */ -#define DW_FRAME_FREG48 80 /* 64-bit floating point reg 48 */ -#define DW_FRAME_FREG49 81 /* 64-bit floating point reg 49 */ -#define DW_FRAME_FREG50 82 /* 64-bit floating point reg 50 */ -#define DW_FRAME_FREG51 83 /* 64-bit floating point reg 51 */ -#define DW_FRAME_FREG52 84 /* 64-bit floating point reg 52 */ -#define DW_FRAME_FREG53 85 /* 64-bit floating point reg 53 */ -#define DW_FRAME_FREG54 86 /* 64-bit floating point reg 54 */ -#define DW_FRAME_FREG55 87 /* 64-bit floating point reg 55 */ -#define DW_FRAME_FREG56 88 /* 64-bit floating point reg 56 */ -#define DW_FRAME_FREG57 89 /* 64-bit floating point reg 57 */ -#define DW_FRAME_FREG58 90 /* 64-bit floating point reg 58 */ -#define DW_FRAME_FREG59 91 /* 64-bit floating point reg 59 */ -#define DW_FRAME_FREG60 92 /* 64-bit floating point reg 60 */ -#define DW_FRAME_FREG61 93 /* 64-bit floating point reg 61 */ -#define DW_FRAME_FREG62 94 /* 64-bit floating point reg 62 */ -#define DW_FRAME_FREG63 95 /* 64-bit floating point reg 63 */ -#define DW_FRAME_FREG64 96 /* 64-bit floating point reg 64 */ -#define DW_FRAME_FREG65 97 /* 64-bit floating point reg 65 */ -#define DW_FRAME_FREG66 98 /* 64-bit floating point reg 66 */ -#define DW_FRAME_FREG67 99 /* 64-bit floating point reg 67 */ -#define DW_FRAME_FREG68 100 /* 64-bit floating point reg 68 */ -#define DW_FRAME_FREG69 101 /* 64-bit floating point reg 69 */ -#define DW_FRAME_FREG70 102 /* 64-bit floating point reg 70 */ -#define DW_FRAME_FREG71 103 /* 64-bit floating point reg 71 */ -#define DW_FRAME_FREG72 104 /* 64-bit floating point reg 72 */ -#define DW_FRAME_FREG73 105 /* 64-bit floating point reg 73 */ -#define DW_FRAME_FREG74 106 /* 64-bit floating point reg 74 */ -#define DW_FRAME_FREG75 107 /* 64-bit floating point reg 75 */ -#define DW_FRAME_FREG76 108 /* 64-bit floating point reg 76 */ - -/* ***IMPORTANT NOTE, TARGET DEPENDENCY **** - The following 4 #defines are dependent on - the target cpu(s) that you apply libdwarf to. - Ensure that DW_FRAME_UNDEFINED_VAL and DW_FRAME_SAME_VAL - do not conflict with the range [0-DW_FRAME_STATIC_LINK]. - The value 63 works for MIPS cpus at least up to the R16000. - - For a cpu with more than 63 real registers - DW_FRAME_HIGHEST_NORMAL_REGISTER - must be increased for things to work properly! - Also ensure that DW_FRAME_UNDEFINED_VAL DW_FRAME_SAME_VAL - are not in the range [0-DW_FRAME_STATIC_LINK] - - Having DW_FRAME_HIGHEST_NORMAL_REGISTER be higher than - is strictly needed is safe. - -*/ - -#ifndef DW_FRAME_HIGHEST_NORMAL_REGISTER -#define DW_FRAME_HIGHEST_NORMAL_REGISTER 188 -#endif -/* This is the number of columns in the Frame Table. - This constant should - be kept in sync with DW_REG_TABLE_SIZE defined in libdwarf.h - It must also be large enough to be beyond the highest - compiler-defined-register (meaning DW_FRAME_RA_COL DW_FRAME_STATIC_LINK - in the MIPS/IRIX case */ -#ifndef DW_FRAME_LAST_REG_NUM -#define DW_FRAME_LAST_REG_NUM (DW_FRAME_HIGHEST_NORMAL_REGISTER + 3) -#endif - - -/* Column recording ra (return address from a function call). - This is common to many architectures, but as a 'simple register' - is not necessarily adequate for all architectures. - For MIPS/IRIX this register number is actually recorded on disk - in the .debug_frame section. - */ -#define DW_FRAME_RA_COL (DW_FRAME_HIGHEST_NORMAL_REGISTER + 1) - -/* Column recording static link applicable to up-level - addressing, as in IRIX mp code, pascal, etc. - This is common to many architectures but - is not necessarily adequate for all architectures. - For MIPS/IRIX this register number is actually recorded on disk - in the .debug_frame section. -*/ -#define DW_FRAME_STATIC_LINK (DW_FRAME_HIGHEST_NORMAL_REGISTER + 2) - - - -/* - DW_FRAME_UNDEFINED_VAL and DW_FRAME_SAME_VAL are - never on disk, just generated by libdwarf. See libdwarf.h - for their values. -*/ - - - -#define DW_CHILDREN_no 0x00 -#define DW_CHILDREN_yes 0x01 - -#define DW_ADDR_none 0 - -#ifdef __cplusplus -} -#endif -#endif /* __DWARF_H */ diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h deleted file mode 100644 index 2fbb310083636f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.CodeGen/elf.h +++ /dev/null @@ -1,3367 +0,0 @@ -/* This file defines standard ELF types, structures, and macros. - Copyright (C) 1995-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _ELF_H -#define _ELF_H 1 - -/* Standard ELF types. */ - -#include - -/* Type for a 16-bit quantity. */ -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -/* Types for signed and unsigned 32-bit quantities. */ -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -/* Types for signed and unsigned 64-bit quantities. */ -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* Type of addresses. */ -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -/* Type of file offsets. */ -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -/* Type for section indices, which are 16-bit quantities. */ -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -/* Type for version symbol information. */ -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - - -/* The ELF file header. This appears at the start of every ELF file. */ - -#define EI_NIDENT (16) - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf32_Half e_type; /* Object file type */ - Elf32_Half e_machine; /* Architecture */ - Elf32_Word e_version; /* Object file version */ - Elf32_Addr e_entry; /* Entry point virtual address */ - Elf32_Off e_phoff; /* Program header table file offset */ - Elf32_Off e_shoff; /* Section header table file offset */ - Elf32_Word e_flags; /* Processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size in bytes */ - Elf32_Half e_phentsize; /* Program header table entry size */ - Elf32_Half e_phnum; /* Program header table entry count */ - Elf32_Half e_shentsize; /* Section header table entry size */ - Elf32_Half e_shnum; /* Section header table entry count */ - Elf32_Half e_shstrndx; /* Section header string table index */ -} Elf32_Ehdr; - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ -} Elf64_Ehdr; - -/* Fields in the e_ident array. The EI_* macros are indices into the - array. The macros under each EI_* macro are the values the byte - may have. */ - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7f /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -/* Conglomeration of the identification bytes, for easy testing as a word. */ -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 /* File class byte index */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -#define EI_DATA 5 /* Data encoding byte index */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ -#define ELFDATANUM 3 - -#define EI_VERSION 6 /* File version byte index */ - /* Value must be EV_CURRENT */ - -#define EI_OSABI 7 /* OS ABI identification */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ -#define ELFOSABI_HPUX 1 /* HP-UX */ -#define ELFOSABI_NETBSD 2 /* NetBSD. */ -#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */ -#define ELFOSABI_LINUX ELFOSABI_GNU /* Object uses GNU ELF extensions. */ -#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ -#define ELFOSABI_AIX 7 /* IBM AIX. */ -#define ELFOSABI_IRIX 8 /* SGI Irix. */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ -#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ -#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define EI_ABIVERSION 8 /* ABI version */ - -#define EI_PAD 9 /* Byte index of padding bytes */ - -/* Legal values for e_type (object file type). */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 /* Number of defined types */ -#define ET_LOOS 0xfe00 /* OS-specific range start */ -#define ET_HIOS 0xfeff /* OS-specific range end */ -#define ET_LOPROC 0xff00 /* Processor-specific range start */ -#define ET_HIPROC 0xffff /* Processor-specific range end */ - -/* Legal values for e_machine (architecture). */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 big-endian */ -#define EM_S370 9 /* IBM System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ - -#define EM_PARISC 15 /* HPPA */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC 64-bit */ -#define EM_S390 22 /* IBM S390 */ - -#define EM_V800 36 /* NEC V800 series */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* ARM */ -#define EM_FAKE_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ - -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /* Harvard University machine-independent object files */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_ALTERA_NIOS2 113 /* Altera Nios II */ -#define EM_AARCH64 183 /* ARM AARCH64 */ -#define EM_TILEPRO 188 /* Tilera TILEPro */ -#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ -#define EM_TILEGX 191 /* Tilera TILE-Gx */ -#define EM_NUM 192 - -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ - -#define EM_ALPHA 0x9026 - -/* Legal values for e_version (version). */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* Section header. */ - -typedef struct -{ - Elf32_Word sh_name; /* Section name (string tbl index) */ - Elf32_Word sh_type; /* Section type */ - Elf32_Word sh_flags; /* Section flags */ - Elf32_Addr sh_addr; /* Section virtual addr at execution */ - Elf32_Off sh_offset; /* Section file offset */ - Elf32_Word sh_size; /* Section size in bytes */ - Elf32_Word sh_link; /* Link to another section */ - Elf32_Word sh_info; /* Additional section information */ - Elf32_Word sh_addralign; /* Section alignment */ - Elf32_Word sh_entsize; /* Entry size if section holds table */ -} Elf32_Shdr; - -typedef struct -{ - Elf64_Word sh_name; /* Section name (string tbl index) */ - Elf64_Word sh_type; /* Section type */ - Elf64_Xword sh_flags; /* Section flags */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Section size in bytes */ - Elf64_Word sh_link; /* Link to another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -/* Special section indices. */ - -#define SHN_UNDEF 0 /* Undefined section */ -#define SHN_LORESERVE 0xff00 /* Start of reserved indices *k/ -#define SHN_LOPROC 0xff00 /* Start of processor-specific */ -#define SHN_BEFORE 0xff00 /* Order section before all others (Solaris). */ -#define SHN_AFTER 0xff01 /* Order section after all others (Solaris). */ -#define SHN_HIPROC 0xff1f /* End of processor-specific */ -#define SHN_LOOS 0xff20 /* Start of OS-specific */ -#define SHN_HIOS 0xff3f /* End of OS-specific */ -#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ -#define SHN_COMMON 0xfff2 /* Associated symbol is common */ -#define SHN_XINDEX 0xffff /* Index is in extra table. */ -#define SHN_HIRESERVE 0xffff /* End of reserved indices */ - -/* Legal values for sh_type (section type). */ - -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program data */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation entries with addends */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Notes */ -#define SHT_NOBITS 8 /* Program space with no data (bss) */ -#define SHT_REL 9 /* Relocation entries, no addends */ -#define SHT_SHLIB 10 /* Reserved */ -#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ -#define SHT_INIT_ARRAY 14 /* Array of constructors */ -#define SHT_FINI_ARRAY 15 /* Array of destructors */ -#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ -#define SHT_NUM 19 /* Number of defined types. */ -#define SHT_LOOS 0x60000000 /* Start OS-specific. */ -#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */ -#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ -#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ -#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ -#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ -#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ -#define SHT_HIOS 0x6fffffff /* End OS-specific type */ -#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ -#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ -#define SHT_LOUSER 0x80000000 /* Start of application-specific */ -#define SHT_HIUSER 0x8fffffff /* End of application-specific */ - -/* Legal values for sh_flags (section flags). */ - -#define SHF_WRITE (1 << 0) /* Writable */ -#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#define SHF_EXECINSTR (1 << 2) /* Executable */ -#define SHF_MERGE (1 << 4) /* Might be merged */ -#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling required */ -#define SHF_GROUP (1 << 9) /* Section is member of a group. */ -#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ -#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ -#define SHF_ORDERED (1 << 30) /* Special ordering requirement (Solaris). */ -#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless referenced or allocated (Solaris).*/ - -/* Section compression header. Used when SHF_COMPRESSED is set. */ - -typedef struct -{ - Elf32_Word ch_type; /* Compression format. */ - Elf32_Word ch_size; /* Uncompressed data size. */ - Elf32_Word ch_addralign; /* Uncompressed data alignment. */ -} Elf32_Chdr; - -typedef struct -{ - Elf64_Word ch_type; /* Compression format. */ - Elf64_Word ch_reserved; - Elf64_Xword ch_size; /* Uncompressed data size. */ - Elf64_Xword ch_addralign; /* Uncompressed data alignment. */ -} Elf64_Chdr; - -/* Legal values for ch_type (compression algorithm). */ -#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE algorithm. */ -#define ELFCOMPRESS_LOOS 0x60000000 /* Start of OS-specific. */ -#define ELFCOMPRESS_HIOS 0x6fffffff /* End of OS-specific. */ -#define ELFCOMPRESS_LOPROC 0x70000000 /* Start of processor-specific. */ -#define ELFCOMPRESS_HIPROC 0x7fffffff /* End of processor-specific. */ - -/* Section group handling. */ -#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ - -/* Symbol table entry. */ - -typedef struct -{ - Elf32_Word st_name; /* Symbol name (string tbl index) */ - Elf32_Addr st_value; /* Symbol value */ - Elf32_Word st_size; /* Symbol size */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf32_Section st_shndx; /* Section index */ -} Elf32_Sym; - -typedef struct -{ - Elf64_Word st_name; /* Symbol name (string tbl index) */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf64_Section st_shndx; /* Section index */ - Elf64_Addr st_value; /* Symbol value */ - Elf64_Xword st_size; /* Symbol size */ -} Elf64_Sym; - -/* The syminfo section if available contains additional information about - every dynamic symbol. */ - -typedef struct -{ - Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf32_Half si_flags; /* Per symbol flags */ -} Elf32_Syminfo; - -typedef struct -{ - Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf64_Half si_flags; /* Per symbol flags */ -} Elf64_Syminfo; - -/* Possible values for si_boundto. */ -#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ - -/* Possible bitmasks for si_flags. */ -#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ -#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy loaded */ -/* Syminfo version values. */ -#define SYMINFO_NONE 0 -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - - -/* How to extract and insert information held in the st_info field. */ - -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) -#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) - -/* Legal values for ST_BIND subfield of st_info (symbol binding). */ - -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* Weak symbol */ -#define STB_NUM 3 /* Number of defined types. */ -#define STB_LOOS 10 /* Start of OS-specific */ -#define STB_GNU_UNIQUE 10 /* Unique symbol. */ -#define STB_HIOS 12 /* End of OS-specific */ -#define STB_LOPROC 13 /* Start of processor-specific */ -#define STB_HIPROC 15 /* End of processor-specific */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_NOTYPE 0 /* Symbol type is unspecified */ -#define STT_OBJECT 1 /* Symbol is a data object */ -#define STT_FUNC 2 /* Symbol is a code object */ -#define STT_SECTION 3 /* Symbol associated with a section */ -#define STT_FILE 4 /* Symbol's name is file name */ -#define STT_COMMON 5 /* Symbol is a common data object */ -#define STT_TLS 6 /* Symbol is thread-local data object*/ -#define STT_NUM 7 /* Number of defined types. */ -#define STT_LOOS 10 /* Start of OS-specific */ -#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ -#define STT_HIOS 12 /* End of OS-specific */ -#define STT_LOPROC 13 /* Start of processor-specific */ -#define STT_HIPROC 15 /* End of processor-specific */ - - -/* Symbol table indices are found in the hash buckets and chain table - of a symbol hash table section. This special index value indicates - the end of a chain, meaning no further symbols are found in that bucket. */ - -#define STN_UNDEF 0 /* End of a chain. */ - - -/* How to extract and insert information held in the st_other field. */ - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) - -/* For ELF64 the definitions are the same. */ -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) - -/* Symbol visibility specification encoded in the st_other field. */ -#define STV_DEFAULT 0 /* Default symbol visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Sym unavailable in other modules */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - - -/* Relocation table entry without addend (in section of type SHT_REL). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ -} Elf32_Rel; - -/* I have seen two different definitions of the Elf64_Rel and - Elf64_Rela structures, so we'll leave them out until Novell (or - whoever) gets their act together. */ -/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ -} Elf64_Rel; - -/* Relocation table entry with addend (in section of type SHT_RELA). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ - Elf32_Sword r_addend; /* Addend */ -} Elf32_Rela; - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ - Elf64_Sxword r_addend; /* Addend */ -} Elf64_Rela; - -/* How to extract and insert information held in the r_info field. */ - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i) & 0xffffffff) -#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) - -/* Program segment header. */ - -typedef struct -{ - Elf32_Word p_type; /* Segment type */ - Elf32_Off p_offset; /* Segment file offset */ - Elf32_Addr p_vaddr; /* Segment virtual address */ - Elf32_Addr p_paddr; /* Segment physical address */ - Elf32_Word p_filesz; /* Segment size in file */ - Elf32_Word p_memsz; /* Segment size in memory */ - Elf32_Word p_flags; /* Segment flags */ - Elf32_Word p_align; /* Segment alignment */ -} Elf32_Phdr; - -typedef struct -{ - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment */ -} Elf64_Phdr; - -/* Special value for e_phnum. This indicates that the real number of - program headers is too large to fit into e_phnum. Instead the real - value is in the field sh_info of section 0. */ - -#define PN_XNUM 0xffff - -/* Legal values for p_type (segment type). */ - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_TLS 7 /* Thread-local storage segment */ -#define PT_NUM 8 /* Number of defined types */ -#define PT_LOOS 0x60000000 /* Start of OS-specific */ -#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ -#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ -#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* End of OS-specific */ -#define PT_LOPROC 0x70000000 /* Start of processor-specific */ -#define PT_HIPROC 0x7fffffff /* End of processor-specific */ - -/* Legal values for p_flags (segment flags). */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKOS 0x0ff00000 /* OS-specific */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Legal values for note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */ -#define NT_SIGINFO 0x53494749 /* Contains copy of siginfo_t, size might increase */ -#define NT_FILE 0x46494c45 /* Contains information about mapped files */ -#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */ -#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ -#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ -#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ -#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ -#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ -#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ -#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */ -#define NT_S390_TIMER 0x301 /* s390 timer register */ -#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */ -#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */ -#define NT_S390_CTRS 0x304 /* s390 control registers */ -#define NT_S390_PREFIX 0x305 /* s390 prefix register */ -#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ -#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ -#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ -#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ -#define NT_ARM_TLS 0x401 /* ARM TLS register */ -#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ -#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ - - -/* Dynamic section entry. */ - -typedef struct -{ - Elf32_Sword d_tag; /* Dynamic entry type */ - union - { - Elf32_Word d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -typedef struct -{ - Elf64_Sxword d_tag; /* Dynamic entry type */ - union - { - Elf64_Xword d_val; /* Integer value */ - Elf64_Addr d_ptr; /* Address value */ - } d_un; -} Elf64_Dyn; - -/* Legal values for d_tag (dynamic entry type). */ - -#define DT_NULL 0 /* Marks end of dynamic section */ -#define DT_NEEDED 1 /* Name of needed library */ -#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ -#define DT_PLTGOT 3 /* Processor defined value */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocs */ -#define DT_RELASZ 8 /* Total size of Rela relocs */ -#define DT_RELAENT 9 /* Size of one Rela reloc */ -#define DT_STRSZ 10 /* Size of string table */ -#define DT_SYMENT 11 /* Size of one symbol table entry */ -#define DT_INIT 12 /* Address of init function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Name of shared object */ -#define DT_RPATH 15 /* Library search path (deprecated) */ -#define DT_SYMBOLIC 16 /* Start symbol search here */ -#define DT_REL 17 /* Address of Rel relocs */ -#define DT_RELSZ 18 /* Total size of Rel relocs */ -#define DT_RELENT 19 /* Size of one Rel reloc */ -#define DT_PLTREL 20 /* Type of reloc in PLT */ -#define DT_DEBUG 21 /* For debugging; unspecified */ -#define DT_TEXTREL 22 /* Reloc might modify .text */ -#define DT_JMPREL 23 /* Address of PLT relocs */ -#define DT_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ -#define DT_LOOS 0x6000000d /* Start of OS-specific */ -#define DT_HIOS 0x6ffff000 /* End of OS-specific */ -#define DT_LOPROC 0x70000000 /* Start of processor-specific */ -#define DT_HIPROC 0x7fffffff /* End of processor-specific */ -#define DT_PROCNUM 0x36 /* Most used by any processor */ - -/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's - approach. */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ -#define DT_CHECKSUM 0x6ffffdf8 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ -#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting the following DT_* entry. */ -#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ -#define DT_VALRNGHI 0x6ffffdff -#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ -#define DT_VALNUM 12 - -/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - - If any adjustment is made to the ELF object after it has been - built these entries will need to be adjusted. */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */ -#define DT_TLSDESC_PLT 0x6ffffef6 -#define DT_TLSDESC_GOT 0x6ffffef7 -#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ -#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ -#define DT_CONFIG 0x6ffffefa /* Configuration information. */ -#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ -#define DT_AUDIT 0x6ffffefc /* Object auditing. */ -#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ -#define DT_MOVETAB 0x6ffffefe /* Move table. */ -#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ -#define DT_ADDRRNGHI 0x6ffffeff -#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ -#define DT_ADDRNUM 11 - -/* The versioning entry types. The next are defined as part of the GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - -/* Sun added these machine-independent extensions in the "processor-specific" range. Be compatible. */ -#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ -#define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - -/* Values of `d_un.d_val' in the DT_FLAGS entry. */ -#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ -#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ - -/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry in the dynamic section. */ -#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ -#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ -#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ -#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ -#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ -#define DF_1_NODIRECT 0x00020000 /* Object has no-direct binding. */ -#define DF_1_IGNMULDEF 0x00040000 -#define DF_1_NOKSYMS 0x00080000 -#define DF_1_NOHDR 0x00100000 -#define DF_1_EDITED 0x00200000 /* Object is modified after built. */ -#define DF_1_NORELOC 0x00400000 -#define DF_1_SYMINTPOSE 0x00800000 /* Object has individual interposers. */ -#define DF_1_GLOBAUDIT 0x01000000 /* Global auditing required. */ -#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */ - -/* Flags for the feature selection in DT_FEATURE_1. */ -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - -/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ -#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not generally available. */ - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - -/* Auxiliary vector. */ - -/* This vector is normally only used by the program interpreter. The - usual definition in an ABI supplement uses the name auxv_t. The - vector is not usually defined in a standard file, but it - can't hurt. We rename it to avoid conflicts. The sizes of these - types are an arrangement between the exec server and the program - interpreter, so we don't fully specify them here. */ - -typedef struct -{ - uint32_t a_type; /* Entry type */ - union - { - uint32_t a_val; /* Integer value */ - /* We use to have pointer elements added here. We cannot do that, - though, since it does not work when using 32-bit definitions - on 64-bit platforms and vice versa. */ - } a_un; -} Elf32_auxv_t; - -typedef struct -{ - uint64_t a_type; /* Entry type */ - union - { - uint64_t a_val; /* Integer value */ - /* We use to have pointer elements added here. We cannot do that, - though, since it does not work when using 32-bit definitions - on 64-bit platforms and vice versa. */ - } a_un; -} Elf64_auxv_t; - -/* Note section contents. Each entry in the note section begins with - a header of a fixed form. */ - -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; - -/* Known names of notes. */ - -/* Solaris entries in the note section have this name. */ -#define ELF_NOTE_SOLARIS "SUNW Solaris" - -/* Note entries for GNU systems have this name. */ -#define ELF_NOTE_GNU "GNU" - - -/* Defined types of notes for Solaris. */ - -/* Value of descriptor (one word) is desired pagesize for the binary. */ -#define ELF_NOTE_PAGESIZE_HINT 1 - - -/* Defined note types for GNU systems. */ - -/* ABI information. The descriptor consists of words: - word 0: OS descriptor - word 1: major version of the ABI - word 2: minor version of the ABI - word 3: subminor version of the ABI -*/ -#define NT_GNU_ABI_TAG 1 -#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */ - -/* Known OSes. These values can appear in word 0 of an - NT_GNU_ABI_TAG note section entry. */ -#define ELF_NOTE_OS_LINUX 0 -#define ELF_NOTE_OS_GNU 1 -#define ELF_NOTE_OS_SOLARIS2 2 -#define ELF_NOTE_OS_FREEBSD 3 - -/* Synthetic hwcap information. The descriptor begins with two words: - word 0: number of entries - word 1: bitmask of enabled entries - Then follow variable-length entries, one byte followed by a - '\0'-terminated hwcap name string. The byte gives the bit - number to test if enabled, (1U << bit) & bitmask. */ -#define NT_GNU_HWCAP 2 - -/* Build ID bits as generated by ld --build-id. - The descriptor consists of any nonzero number of bytes. */ -#define NT_GNU_BUILD_ID 3 - -/* Version note generated by GNU gold containing a version string. */ -#define NT_GNU_GOLD_VERSION 4 - - -/* Move records. */ -typedef struct -{ - Elf32_Xword m_value; /* Symbol value. */ - Elf32_Word m_info; /* Size and index. */ - Elf32_Word m_poffset; /* Symbol offset. */ - Elf32_Half m_repeat; /* Repeat count. */ - Elf32_Half m_stride; /* Stride info. */ -} Elf32_Move; - -typedef struct -{ - Elf64_Xword m_value; /* Symbol value. */ - Elf64_Xword m_info; /* Size and index. */ - Elf64_Xword m_poffset; /* Symbol offset. */ - Elf64_Half m_repeat; /* Repeat count. */ - Elf64_Half m_stride; /* Stride info. */ -} Elf64_Move; - -/* Macro to construct move records. */ -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((unsigned char) (info)) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) - -#define ELF64_M_SYM(info) ELF32_M_SYM (info) -#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) -#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) - - -/* Motorola 68k specific definitions. */ - -/* Values for Elf32_Ehdr.e_flags. */ -#define EF_CPU32 0x00810000 - -/* m68k relocs. */ - -#define R_68K_NONE 0 /* No reloc */ -#define R_68K_32 1 /* Direct 32 bit */ -#define R_68K_16 2 /* Direct 16 bit */ -#define R_68K_8 3 /* Direct 8 bit */ -#define R_68K_PC32 4 /* PC relative 32 bit */ -#define R_68K_PC16 5 /* PC relative 16 bit */ -#define R_68K_PC8 6 /* PC relative 8 bit */ -#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ -#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ -#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ -#define R_68K_GOT32O 10 /* 32 bit GOT offset */ -#define R_68K_GOT16O 11 /* 16 bit GOT offset */ -#define R_68K_GOT8O 12 /* 8 bit GOT offset */ -#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ -#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ -#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ -#define R_68K_PLT32O 16 /* 32 bit PLT offset */ -#define R_68K_PLT16O 17 /* 16 bit PLT offset */ -#define R_68K_PLT8O 18 /* 8 bit PLT offset */ -#define R_68K_COPY 19 /* Copy symbol at runtime */ -#define R_68K_GLOB_DAT 20 /* Create GOT entry */ -#define R_68K_JMP_SLOT 21 /* Create PLT entry */ -#define R_68K_RELATIVE 22 /* Adjust by program base */ -#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */ -#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */ -#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */ -#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */ -#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */ -#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */ -#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */ -#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */ -#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */ -#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */ -#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */ -#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */ -#define R_68K_TLS_LE32 37 /* 32 bit offset relative to static TLS block */ -#define R_68K_TLS_LE16 38 /* 16 bit offset relative to static TLS block */ -#define R_68K_TLS_LE8 39 /* 8 bit offset relative to static TLS block */ -#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */ -#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */ -#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */ -/* Keep this the last entry. */ -#define R_68K_NUM 43 - -/* Intel 80386 specific definitions. */ - -/* i386 relocs. */ - -#define R_386_NONE 0 /* No reloc */ -#define R_386_32 1 /* Direct 32 bit */ -#define R_386_PC32 2 /* PC relative 32 bit */ -#define R_386_GOT32 3 /* 32 bit GOT entry */ -#define R_386_PLT32 4 /* 32 bit PLT address */ -#define R_386_COPY 5 /* Copy symbol at runtime */ -#define R_386_GLOB_DAT 6 /* Create GOT entry */ -#define R_386_JMP_SLOT 7 /* Create PLT entry */ -#define R_386_RELATIVE 8 /* Adjust by program base */ -#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ -#define R_386_32PLT 11 -#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ -#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS block offset */ -#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block offset */ -#define R_386_TLS_LE 17 /* Offset relative to static TLS block */ -#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of general dynamic thread local data */ -#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of local dynamic thread local data in LE code */ -#define R_386_16 20 -#define R_386_PC16 21 -#define R_386_8 22 -#define R_386_PC8 23 -#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic - thread local data */ -#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ -#define R_386_TLS_GD_CALL 26 /* Relocation for call to - __tls_get_addr() */ -#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ -#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic - thread local data in LE code */ -#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ -#define R_386_TLS_LDM_CALL 30 /* Relocation for call to - __tls_get_addr() in LDM code */ -#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ -#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ -#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS - block offset */ -#define R_386_TLS_LE_32 34 /* Negated offset relative to static - TLS block */ -#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ -#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ -#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ -#define R_386_SIZE32 38 /* 32-bit symbol size */ -#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */ -#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS - descriptor for - relaxation. */ -#define R_386_TLS_DESC 41 /* TLS descriptor containing - pointer to code and to - argument, returning the TLS - offset for the symbol. */ -#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */ -/* Keep this the last entry. */ -#define R_386_NUM 43 - -/* SUN SPARC specific definitions. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ - -/* Values for Elf64_Ehdr.e_flags. */ - -#define EF_SPARCV9_MM 3 -#define EF_SPARCV9_TSO 0 -#define EF_SPARCV9_PSO 1 -#define EF_SPARCV9_RMO 2 -#define EF_SPARC_LEDATA 0x800000 /* little endian data */ -#define EF_SPARC_EXT_MASK 0xFFFF00 -#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ -#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ -#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ -#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ - -/* SPARC relocs. */ - -#define R_SPARC_NONE 0 /* No reloc */ -#define R_SPARC_8 1 /* Direct 8 bit */ -#define R_SPARC_16 2 /* Direct 16 bit */ -#define R_SPARC_32 3 /* Direct 32 bit */ -#define R_SPARC_DISP8 4 /* PC relative 8 bit */ -#define R_SPARC_DISP16 5 /* PC relative 16 bit */ -#define R_SPARC_DISP32 6 /* PC relative 32 bit */ -#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ -#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ -#define R_SPARC_HI22 9 /* High 22 bit */ -#define R_SPARC_22 10 /* Direct 22 bit */ -#define R_SPARC_13 11 /* Direct 13 bit */ -#define R_SPARC_LO10 12 /* Truncated 10 bit */ -#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ -#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ -#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ -#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ -#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ -#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ -#define R_SPARC_COPY 19 /* Copy symbol at runtime */ -#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ -#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ -#define R_SPARC_RELATIVE 22 /* Adjust by program base */ -#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ - -/* Additional Sparc64 relocs. */ - -#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ -#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ -#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ -#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ -#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ -#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ -#define R_SPARC_10 30 /* Direct 10 bit */ -#define R_SPARC_11 31 /* Direct 11 bit */ -#define R_SPARC_64 32 /* Direct 64 bit */ -#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ -#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ -#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ -#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ -#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ -#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ -#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ -#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ -#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ -#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */ -#define R_SPARC_7 43 /* Direct 7 bit */ -#define R_SPARC_5 44 /* Direct 5 bit */ -#define R_SPARC_6 45 /* Direct 6 bit */ -#define R_SPARC_DISP64 46 /* PC relative 64 bit */ -#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ -#define R_SPARC_HIX22 48 /* High 22 bit complemented */ -#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ -#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ -#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ -#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ -#define R_SPARC_REGISTER 53 /* Global register usage */ -#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ -#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 -#define R_SPARC_GOTDATA_HIX22 80 -#define R_SPARC_GOTDATA_LOX10 81 -#define R_SPARC_GOTDATA_OP_HIX22 82 -#define R_SPARC_GOTDATA_OP_LOX10 83 -#define R_SPARC_GOTDATA_OP 84 -#define R_SPARC_H34 85 -#define R_SPARC_SIZE32 86 -#define R_SPARC_SIZE64 87 -#define R_SPARC_WDISP10 88 -#define R_SPARC_JMP_IREL 248 -#define R_SPARC_IRELATIVE 249 -#define R_SPARC_GNU_VTINHERIT 250 -#define R_SPARC_GNU_VTENTRY 251 -#define R_SPARC_REV32 252 -/* Keep this the last entry. */ -#define R_SPARC_NUM 253 - -/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_SPARC_NUM 2 - -/* MIPS R3000 specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used. */ -#define EF_MIPS_PIC 2 /* Contains PIC code. */ -#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence. */ -#define EF_MIPS_XGOT 8 -#define EF_MIPS_64BIT_WHIRL 16 -#define EF_MIPS_ABI2 32 -#define EF_MIPS_ABI_ON32 64 -#define EF_MIPS_FP64 512 /* Uses FP64 (12 callee-saved). */ -#define EF_MIPS_NAN2008 1024 /* Uses IEEE 754-2008 NaN encoding. */ -#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level. */ - -/* Legal values for MIPS architecture level. */ - -#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ -#define EF_MIPS_ARCH_32 0x50000000 /* MIPS32 code. */ -#define EF_MIPS_ARCH_64 0x60000000 /* MIPS64 code. */ -#define EF_MIPS_ARCH_32R2 0x70000000 /* MIPS32r2 code. */ -#define EF_MIPS_ARCH_64R2 0x80000000 /* MIPS64r2 code. */ - -/* The following are unofficial names and should not be used. */ - -#define E_MIPS_ARCH_1 EF_MIPS_ARCH_1 -#define E_MIPS_ARCH_2 EF_MIPS_ARCH_2 -#define E_MIPS_ARCH_3 EF_MIPS_ARCH_3 -#define E_MIPS_ARCH_4 EF_MIPS_ARCH_4 -#define E_MIPS_ARCH_5 EF_MIPS_ARCH_5 -#define E_MIPS_ARCH_32 EF_MIPS_ARCH_32 -#define E_MIPS_ARCH_64 EF_MIPS_ARCH_64 - -/* Special section indices. */ - -#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols. */ -#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ -#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ -#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols. */ -#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols. */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link. */ -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols. */ -#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes. */ -#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ -#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging info. */ -#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information. */ -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ -#define SHT_MIPS_SHDR 0x70000010 -#define SHT_MIPS_FDESC 0x70000011 -#define SHT_MIPS_EXTSYM 0x70000012 -#define SHT_MIPS_DENSE 0x70000013 -#define SHT_MIPS_PDESC 0x70000014 -#define SHT_MIPS_LOCSYM 0x70000015 -#define SHT_MIPS_AUXSYM 0x70000016 -#define SHT_MIPS_OPTSYM 0x70000017 -#define SHT_MIPS_LOCSTR 0x70000018 -#define SHT_MIPS_LINE 0x70000019 -#define SHT_MIPS_RFDESC 0x7000001a -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_MIPS_GPREL 0x10000000 /* Must be in global data area. */ -#define SHF_MIPS_MERGE 0x20000000 -#define SHF_MIPS_ADDR 0x40000000 -#define SHF_MIPS_STRINGS 0x80000000 -#define SHF_MIPS_NOSTRIP 0x08000000 -#define SHF_MIPS_LOCAL 0x04000000 -#define SHF_MIPS_NAMES 0x02000000 -#define SHF_MIPS_NODUPE 0x01000000 - - -/* Symbol tables. */ - -/* MIPS specific values for `st_other'. */ -#define STO_MIPS_DEFAULT 0x0 -#define STO_MIPS_INTERNAL 0x1 -#define STO_MIPS_HIDDEN 0x2 -#define STO_MIPS_PROTECTED 0x3 -#define STO_MIPS_PLT 0x8 -#define STO_MIPS_SC_ALIGN_UNUSED 0xff - -/* MIPS specific values for `st_info'. */ -#define STB_MIPS_SPLIT_COMMON 13 - -/* Entries found in sections of type SHT_MIPS_GPTAB. */ - -typedef union -{ - struct - { - Elf32_Word gt_current_g_value; /* -G value used for compilation. */ - Elf32_Word gt_unused; /* Not used. */ - } gt_header; /* First entry in section. */ - struct - { - Elf32_Word gt_g_value; /* If this value were used for -G. */ - Elf32_Word gt_bytes; /* This many bytes would be used. */ - } gt_entry; /* Subsequent entries in section. */ -} Elf32_gptab; - -/* Entry found in sections of type SHT_MIPS_REGINFO. */ - -typedef struct -{ - Elf32_Word ri_gprmask; /* General registers used. */ - uint32_t ri_cprmask[4]; /* Coprocessor registers used. */ - Elf32_Sword ri_gp_value; /* $gp register value. */ -} Elf32_RegInfo; - -/* Entries found in sections of type SHT_MIPS_OPTIONS. */ - -typedef struct -{ - unsigned char kind; /* Determines interpretation of the - variable part of descriptor. */ - unsigned char size; /* Size of descriptor, including header. */ - Elf32_Section section; /* Section header index of section affected, - 0 for global options. */ - Elf32_Word info; /* Kind-specific information. */ -} Elf_Options; - -/* Values for `kind' field in Elf_Options. */ - -#define ODK_NULL 0 /* Undefined. */ -#define ODK_REGINFO 1 /* Register usage information. */ -#define ODK_EXCEPTIONS 2 /* Exception processing options. */ -#define ODK_PAD 3 /* Section padding options. */ -#define ODK_HWPATCH 4 /* Hardware workarounds performed */ -#define ODK_FILL 5 /* record the fill value used by the linker. */ -#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ -#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ -#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ - -/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ - -#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ -#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ -#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ -#define OEX_SMM 0x20000 /* Force sequential memory mode? */ -#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ -#define OEX_PRECISEFP OEX_FPDBUG -#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ - -#define OEX_FPU_INVAL 0x10 -#define OEX_FPU_DIV0 0x08 -#define OEX_FPU_OFLO 0x04 -#define OEX_FPU_UFLO 0x02 -#define OEX_FPU_INEX 0x01 - -/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ - -#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ -#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ -#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ -#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ - -#define OPAD_PREFIX 0x1 -#define OPAD_POSTFIX 0x2 -#define OPAD_SYMBOL 0x4 - -/* Entry found in `.options' section. */ - -typedef struct -{ - Elf32_Word hwp_flags1; /* Extra flags. */ - Elf32_Word hwp_flags2; /* Extra flags. */ -} Elf_Options_Hw; - -/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ - -#define OHWA0_R4KEOP_CHECKED 0x00000001 -#define OHWA1_R4KEOP_CLEAN 0x00000002 - -/* MIPS relocs. */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ - -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ -#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ -#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ -#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ -#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ -#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ -#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ -#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ -#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ -#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ -#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ -#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ -#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ -#define R_MIPS_GLOB_DAT 51 -#define R_MIPS_COPY 126 -#define R_MIPS_JUMP_SLOT 127 -/* Keep this the last entry. */ -#define R_MIPS_NUM 128 - -/* Legal values for p_type field of Elf32_Phdr. */ - -#define PT_MIPS_REGINFO 0x70000000 /* Register usage information. */ -#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ -#define PT_MIPS_OPTIONS 0x70000002 -#define PT_MIPS_ABIFLAGS 0x70000003 /* FP mode requirement. */ - -/* Special program header types. */ - -#define PF_MIPS_LOCAL 0x10000000 - -/* Legal values for d_tag field of Elf32_Dyn. */ - -#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ -#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ -#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ -#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ -#define DT_MIPS_FLAGS 0x70000005 /* Flags */ -#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ -#define DT_MIPS_MSYM 0x70000007 -#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ -#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ -#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ -#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ -#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ -#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ -#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ -#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ -#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ -#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in - DT_MIPS_DELTA_CLASS. */ -#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in - DT_MIPS_DELTA_INSTANCE. */ -#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in - DT_MIPS_DELTA_RELOC. */ -#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta - relocations refer to. */ -#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in - DT_MIPS_DELTA_SYM. */ -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the - class declaration. */ -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in - DT_MIPS_DELTA_CLASSSYM. */ -#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ -#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve - function stored in GOT. */ -#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added - by rld on dlopen() calls. */ -#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ -#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ -#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ -/* The address of .got.plt in an executable using the new non-PIC ABI. */ -#define DT_MIPS_PLTGOT 0x70000032 -/* The base of the PLT in an executable using the new non-PIC ABI if that - PLT is writable. For a non-writable PLT, this is omitted or has a zero - value. */ -#define DT_MIPS_RWPLT 0x70000034 -/* An alternative description of the classic MIPS RLD_MAP that is usable - in a PIE as it stores a relative offset from the address of the tag - rather than an absolute address. */ -#define DT_MIPS_RLD_MAP_REL 0x70000035 -#define DT_MIPS_NUM 0x36 - -/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ - -#define RHF_NONE 0 /* No flags */ -#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ -#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ -#define RHF_NO_MOVE (1 << 3) -#define RHF_SGI_ONLY (1 << 4) -#define RHF_GUARANTEE_INIT (1 << 5) -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) -#define RHF_GUARANTEE_START_INIT (1 << 7) -#define RHF_PIXIE (1 << 8) -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) -#define RHF_REQUICKSTART (1 << 10) -#define RHF_REQUICKSTARTED (1 << 11) -#define RHF_CORD (1 << 12) -#define RHF_NO_UNRES_UNDEF (1 << 13) -#define RHF_RLD_ORDER_SAFE (1 << 14) - -/* Entries found in sections of type SHT_MIPS_LIBLIST. */ - -typedef struct -{ - Elf32_Word l_name; /* Name (string table index) */ - Elf32_Word l_time_stamp; /* Timestamp */ - Elf32_Word l_checksum; /* Checksum */ - Elf32_Word l_version; /* Interface version */ - Elf32_Word l_flags; /* Flags */ -} Elf32_Lib; - -typedef struct -{ - Elf64_Word l_name; /* Name (string table index) */ - Elf64_Word l_time_stamp; /* Timestamp */ - Elf64_Word l_checksum; /* Checksum */ - Elf64_Word l_version; /* Interface version */ - Elf64_Word l_flags; /* Flags */ -} Elf64_Lib; - - -/* Legal values for l_flags. */ - -#define LL_NONE 0 -#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ -#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ -#define LL_REQUIRE_MINOR (1 << 2) -#define LL_EXPORTS (1 << 3) -#define LL_DELAY_LOAD (1 << 4) -#define LL_DELTA (1 << 5) - -/* Entries found in sections of type SHT_MIPS_CONFLICT. */ - -typedef Elf32_Addr Elf32_Conflict; - -typedef struct -{ - /* Version of flags structure. */ - Elf32_Half version; - /* The level of the ISA: 1-5, 32, 64. */ - unsigned char isa_level; - /* The revision of ISA: 0 for MIPS V and below, 1-n otherwise. */ - unsigned char isa_rev; - /* The size of general purpose registers. */ - unsigned char gpr_size; - /* The size of co-processor 1 registers. */ - unsigned char cpr1_size; - /* The size of co-processor 2 registers. */ - unsigned char cpr2_size; - /* The floating-point ABI. */ - unsigned char fp_abi; - /* Processor-specific extension. */ - Elf32_Word isa_ext; - /* Mask of ASEs used. */ - Elf32_Word ases; - /* Mask of general flags. */ - Elf32_Word flags1; - Elf32_Word flags2; -} Elf_MIPS_ABIFlags_v0; - -/* Values for the register size bytes of an abi flags structure. */ - -#define MIPS_AFL_REG_NONE 0x00 /* No registers. */ -#define MIPS_AFL_REG_32 0x01 /* 32-bit registers. */ -#define MIPS_AFL_REG_64 0x02 /* 64-bit registers. */ -#define MIPS_AFL_REG_128 0x03 /* 128-bit registers. */ - -/* Masks for the ases word of an ABI flags structure. */ - -#define MIPS_AFL_ASE_DSP 0x00000001 /* DSP ASE. */ -#define MIPS_AFL_ASE_DSPR2 0x00000002 /* DSP R2 ASE. */ -#define MIPS_AFL_ASE_EVA 0x00000004 /* Enhanced VA Scheme. */ -#define MIPS_AFL_ASE_MCU 0x00000008 /* MCU (MicroController) ASE. */ -#define MIPS_AFL_ASE_MDMX 0x00000010 /* MDMX ASE. */ -#define MIPS_AFL_ASE_MIPS3D 0x00000020 /* MIPS-3D ASE. */ -#define MIPS_AFL_ASE_MT 0x00000040 /* MT ASE. */ -#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 /* SmartMIPS ASE. */ -#define MIPS_AFL_ASE_VIRT 0x00000100 /* VZ ASE. */ -#define MIPS_AFL_ASE_MSA 0x00000200 /* MSA ASE. */ -#define MIPS_AFL_ASE_MIPS16 0x00000400 /* MIPS16 ASE. */ -#define MIPS_AFL_ASE_MICROMIPS 0x00000800 /* MICROMIPS ASE. */ -#define MIPS_AFL_ASE_XPA 0x00001000 /* XPA ASE. */ -#define MIPS_AFL_ASE_MASK 0x00001fff /* All ASEs. */ - -/* Values for the isa_ext word of an ABI flags structure. */ - -#define MIPS_AFL_EXT_XLR 1 /* RMI Xlr instruction. */ -#define MIPS_AFL_EXT_OCTEON2 2 /* Cavium Networks Octeon2. */ -#define MIPS_AFL_EXT_OCTEONP 3 /* Cavium Networks OcteonP. */ -#define MIPS_AFL_EXT_LOONGSON_3A 4 /* Loongson 3A. */ -#define MIPS_AFL_EXT_OCTEON 5 /* Cavium Networks Octeon. */ -#define MIPS_AFL_EXT_5900 6 /* MIPS R5900 instruction. */ -#define MIPS_AFL_EXT_4650 7 /* MIPS R4650 instruction. */ -#define MIPS_AFL_EXT_4010 8 /* LSI R4010 instruction. */ -#define MIPS_AFL_EXT_4100 9 /* NEC VR4100 instruction. */ -#define MIPS_AFL_EXT_3900 10 /* Toshiba R3900 instruction. */ -#define MIPS_AFL_EXT_10000 11 /* MIPS R10000 instruction. */ -#define MIPS_AFL_EXT_SB1 12 /* Broadcom SB-1 instruction. */ -#define MIPS_AFL_EXT_4111 13 /* NEC VR4111/VR4181 instruction. */ -#define MIPS_AFL_EXT_4120 14 /* NEC VR4120 instruction. */ -#define MIPS_AFL_EXT_5400 15 /* NEC VR5400 instruction. */ -#define MIPS_AFL_EXT_5500 16 /* NEC VR5500 instruction. */ -#define MIPS_AFL_EXT_LOONGSON_2E 17 /* ST Microelectronics Loongson 2E. */ -#define MIPS_AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */ - -/* Masks for the flags1 word of an ABI flags structure. */ -#define MIPS_AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */ - -/* HPPA specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ -#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ -#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ -#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ -#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch - prediction. */ -#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ -#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ - -/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ - -#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ -#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ -#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ - -/* Additional section indeces. */ - -#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared - symbols in ANSI C. */ -#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ -#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ -#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ -#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ -#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ - -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#define STT_HP_STUB (STT_LOOS + 0x2) - -/* HPPA relocs. */ - -#define R_PARISC_NONE 0 /* No reloc. */ -#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ -#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ -#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ -#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ -#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ -#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ -#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ -#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ -#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ -#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ -#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ -#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ -#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ -#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ -#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ -#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ -#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ -#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ -#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ -#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ -#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ -#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ -#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ -#define R_PARISC_FPTR64 64 /* 64 bits function address. */ -#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ -#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */ -#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */ -#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ -#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ -#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ -#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ -#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ -#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ -#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ -#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ -#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ -#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ -#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ -#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ -#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ -#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ -#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ -#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ -#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ -#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ -#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LORESERVE 128 -#define R_PARISC_COPY 128 /* Copy relocation. */ -#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ -#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ -#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ -#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ -#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ -#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ -#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ -#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ -#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_GNU_VTENTRY 232 -#define R_PARISC_GNU_VTINHERIT 233 -#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */ -#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */ -#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */ -#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */ -#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */ -#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */ -#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */ -#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */ -#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */ -#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */ -#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */ -#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */ -#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L -#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R -#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L -#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R -#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 -#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 -#define R_PARISC_HIRESERVE 255 - -/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ - -#define PT_HP_TLS (PT_LOOS + 0x0) -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#define PT_HP_STACK (PT_LOOS + 0x14) - -#define PT_PARISC_ARCHEXT 0x70000000 -#define PT_PARISC_UNWIND 0x70000001 - -/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ - -#define PF_PARISC_SBP 0x08000000 - -#define PF_HP_PAGE_SIZE 0x00100000 -#define PF_HP_FAR_SHARED 0x00200000 -#define PF_HP_NEAR_SHARED 0x00400000 -#define PF_HP_CODE 0x01000000 -#define PF_HP_MODIFY 0x02000000 -#define PF_HP_LAZYSWAP 0x04000000 -#define PF_HP_SBP 0x08000000 - - -/* Alpha specific definitions. */ - -/* Legal values for e_flags field of Elf64_Ehdr. */ - -#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ -#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ - -/* Legal values for sh_type field of Elf64_Shdr. */ - -/* These two are primerily concerned with ECOFF debugging info. */ -#define SHT_ALPHA_DEBUG 0x70000001 -#define SHT_ALPHA_REGINFO 0x70000002 - -/* Legal values for sh_flags field of Elf64_Shdr. */ - -#define SHF_ALPHA_GPREL 0x10000000 - -/* Legal values for st_other field of Elf64_Sym. */ -#define STO_ALPHA_NOPV 0x80 /* No PV required. */ -#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ - -/* Alpha relocs. */ - -#define R_ALPHA_NONE 0 /* No reloc */ -#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ -#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ -#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ -#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ -#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ -#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ -#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ -#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ -#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ -#define R_ALPHA_TLS_GD_HI 28 -#define R_ALPHA_TLSGD 29 -#define R_ALPHA_TLS_LDM 30 -#define R_ALPHA_DTPMOD64 31 -#define R_ALPHA_GOTDTPREL 32 -#define R_ALPHA_DTPREL64 33 -#define R_ALPHA_DTPRELHI 34 -#define R_ALPHA_DTPRELLO 35 -#define R_ALPHA_DTPREL16 36 -#define R_ALPHA_GOTTPREL 37 -#define R_ALPHA_TPREL64 38 -#define R_ALPHA_TPRELHI 39 -#define R_ALPHA_TPRELLO 40 -#define R_ALPHA_TPREL16 41 -/* Keep this the last entry. */ -#define R_ALPHA_NUM 46 - -/* Magic values of the LITUSE relocation addend. */ -#define LITUSE_ALPHA_ADDR 0 -#define LITUSE_ALPHA_BASE 1 -#define LITUSE_ALPHA_BYTOFF 2 -#define LITUSE_ALPHA_JSR 3 -#define LITUSE_ALPHA_TLS_GD 4 -#define LITUSE_ALPHA_TLS_LDM 5 - -/* Legal values for d_tag of Elf64_Dyn. */ -#define DT_ALPHA_PLTRO (DT_LOPROC + 0) -#define DT_ALPHA_NUM 1 - -/* PowerPC specific declarations */ - -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ - -/* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib - flag */ - -/* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - -/* PowerPC relocations defined for the TLS access ABI. */ -#define R_PPC_TLS 67 /* none (sym+add)@tls */ -#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ -#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ -#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ -#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ -#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ -#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ -#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ -#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ -#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ -#define R_PPC_TLSGD 95 /* none (sym+add)@tlsgd */ -#define R_PPC_TLSLD 96 /* none (sym+add)@tlsld */ - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* GNU extension to support local ifunc. */ -#define R_PPC_IRELATIVE 248 - -/* GNU relocs used in PIC code sequences. */ -#define R_PPC_REL16 249 /* half16 (sym+add-.) */ -#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */ -#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */ -#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 - -/* PowerPC specific values for the Dyn d_tag field. */ -#define DT_PPC_GOT (DT_LOPROC + 0) -#define DT_PPC_OPT (DT_LOPROC + 1) -#define DT_PPC_NUM 2 - -/* PowerPC specific values for the DT_PPC_OPT Dyn entry. */ -#define PPC_OPT_TLS 1 - -/* PowerPC64 relocations defined by the ABIs */ -#define R_PPC64_NONE R_PPC_NONE -#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ -#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ -#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ -#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ -#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ -#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ -#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ -#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN -#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN -#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ -#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ -#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN -#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN -#define R_PPC64_GOT16 R_PPC_GOT16 -#define R_PPC64_GOT16_LO R_PPC_GOT16_LO -#define R_PPC64_GOT16_HI R_PPC_GOT16_HI -#define R_PPC64_GOT16_HA R_PPC_GOT16_HA - -#define R_PPC64_COPY R_PPC_COPY -#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT -#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT -#define R_PPC64_RELATIVE R_PPC_RELATIVE - -#define R_PPC64_UADDR32 R_PPC_UADDR32 -#define R_PPC64_UADDR16 R_PPC_UADDR16 -#define R_PPC64_REL32 R_PPC_REL32 -#define R_PPC64_PLT32 R_PPC_PLT32 -#define R_PPC64_PLTREL32 R_PPC_PLTREL32 -#define R_PPC64_PLT16_LO R_PPC_PLT16_LO -#define R_PPC64_PLT16_HI R_PPC_PLT16_HI -#define R_PPC64_PLT16_HA R_PPC_PLT16_HA - -#define R_PPC64_SECTOFF R_PPC_SECTOFF -#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO -#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI -#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA -#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ -#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ -#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ -#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ -#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ -#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ -#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ -#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ -#define R_PPC64_PLT64 45 /* doubleword64 L + A */ -#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ -#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ -#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ -#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ -#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ -#define R_PPC64_TOC 51 /* doubleword64 .TOC */ -#define R_PPC64_PLTGOT16 52 /* half16* M + A */ -#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ -#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ -#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ - -#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ -#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ -#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ -#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ -#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ -#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ -#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ -#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ -#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ -#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ -#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ - -/* PowerPC64 relocations defined for the TLS access ABI. */ -#define R_PPC64_TLS 67 /* none (sym+add)@tls */ -#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ -#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ -#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ -#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ -#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ -#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ -#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ -#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ -#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ -#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ -#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ -#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ -#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ -#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ -#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ -#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ -#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ -#define R_PPC64_TLSGD 107 /* none (sym+add)@tlsgd */ -#define R_PPC64_TLSLD 108 /* none (sym+add)@tlsld */ -#define R_PPC64_TOCSAVE 109 /* none */ - -/* Added when HA and HI relocs were changed to report overflows. */ -#define R_PPC64_ADDR16_HIGH 110 -#define R_PPC64_ADDR16_HIGHA 111 -#define R_PPC64_TPREL16_HIGH 112 -#define R_PPC64_TPREL16_HIGHA 113 -#define R_PPC64_DTPREL16_HIGH 114 -#define R_PPC64_DTPREL16_HIGHA 115 - -/* GNU extension to support local ifunc. */ -#define R_PPC64_JMP_IREL 247 -#define R_PPC64_IRELATIVE 248 -#define R_PPC64_REL16 249 /* half16 (sym+add-.) */ -#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */ -#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */ -#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */ - -/* e_flags bits specifying ABI. - 1 for original function descriptor using ABI, - 2 for revised ABI without function descriptors, - 0 for unspecified or not using any features affected by the differences. */ -#define EF_PPC64_ABI 3 - -/* PowerPC64 specific values for the Dyn d_tag field. */ -#define DT_PPC64_GLINK (DT_LOPROC + 0) -#define DT_PPC64_OPD (DT_LOPROC + 1) -#define DT_PPC64_OPDSZ (DT_LOPROC + 2) -#define DT_PPC64_OPT (DT_LOPROC + 3) -#define DT_PPC64_NUM 4 - -/* PowerPC64 specific values for the DT_PPC64_OPT Dyn entry. */ -#define PPC64_OPT_TLS 1 -#define PPC64_OPT_MULTI_TOC 2 - -/* PowerPC64 specific values for the Elf64_Sym st_other field. */ -#define STO_PPC64_LOCAL_BIT 5 -#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT) -#define PPC64_LOCAL_ENTRY_OFFSET(other) \ - (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2) - - -/* ARM specific declarations */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_ARM_NEW_ABI 0x80 -#define EF_ARM_OLD_ABI 0x100 -#define EF_ARM_SOFT_FLOAT 0x200 -#define EF_ARM_VFP_FLOAT 0x400 -#define EF_ARM_MAVERICK_FLOAT 0x800 - -#define EF_ARM_ABI_FLOAT_SOFT 0x200 /* NB conflicts with EF_ARM_SOFT_FLOAT */ -#define EF_ARM_ABI_FLOAT_HARD 0x400 /* NB conflicts with EF_ARM_VFP_FLOAT */ - - -/* Other constants defined in the ARM ELF spec. version B-01. */ -/* NB. These conflict with values defined above. */ -#define EF_ARM_SYMSARESORTED 0x04 -#define EF_ARM_DYNSYMSUSESEGIDX 0x08 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_EABIMASK 0XFF000000 - -/* Constants defined in AAELF. */ -#define EF_ARM_BE8 0x00800000 -#define EF_ARM_LE8 0x00400000 - -#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 -#define EF_ARM_EABI_VER3 0x03000000 -#define EF_ARM_EABI_VER4 0x04000000 -#define EF_ARM_EABI_VER5 0x05000000 - -/* Additional symbol types for Thumb. */ -#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ -#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ - -/* ARM-specific values for sh_flags */ -#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ -#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined - in the input to a link step. */ - -/* ARM-specific program header flags */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location - addressed by the static base. */ -#define PF_ARM_PI 0x20000000 /* Position-independent segment. */ -#define PF_ARM_ABS 0x40000000 /* Absolute segment. */ - -/* Processor specific values for the Phdr p_type field. */ -#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */ - -/* Processor specific values for the Shdr sh_type field. */ -#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */ -#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */ -#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */ - - -/* AArch64 relocs. */ - -#define R_AARCH64_NONE 0 /* No relocation. */ - -/* ILP32 AArch64 relocs. */ -#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */ -#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */ -#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */ -#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */ -#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */ -#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */ -#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */ -#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */ -#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */ -#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */ - -/* LP64 AArch64 relocs. */ -#define R_AARCH64_ABS64 257 /* Direct 64 bit. */ -#define R_AARCH64_ABS32 258 /* Direct 32 bit. */ -#define R_AARCH64_ABS16 259 /* Direct 16-bit. */ -#define R_AARCH64_PREL64 260 /* PC-relative 64-bit. */ -#define R_AARCH64_PREL32 261 /* PC-relative 32-bit. */ -#define R_AARCH64_PREL16 262 /* PC-relative 16-bit. */ -#define R_AARCH64_MOVW_UABS_G0 263 /* Dir. MOVZ imm. from bits 15:0. */ -#define R_AARCH64_MOVW_UABS_G0_NC 264 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_UABS_G1 265 /* Dir. MOVZ imm. from bits 31:16. */ -#define R_AARCH64_MOVW_UABS_G1_NC 266 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_UABS_G2 267 /* Dir. MOVZ imm. from bits 47:32. */ -#define R_AARCH64_MOVW_UABS_G2_NC 268 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_UABS_G3 269 /* Dir. MOV{K,Z} imm. from 63:48. */ -#define R_AARCH64_MOVW_SABS_G0 270 /* Dir. MOV{N,Z} imm. from 15:0. */ -#define R_AARCH64_MOVW_SABS_G1 271 /* Dir. MOV{N,Z} imm. from 31:16. */ -#define R_AARCH64_MOVW_SABS_G2 272 /* Dir. MOV{N,Z} imm. from 47:32. */ -#define R_AARCH64_LD_PREL_LO19 273 /* PC-rel. LD imm. from bits 20:2. */ -#define R_AARCH64_ADR_PREL_LO21 274 /* PC-rel. ADR imm. from bits 20:0. */ -#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page-rel. ADRP imm. from 32:12. */ -#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 /* Likewise; no overflow check. */ -#define R_AARCH64_ADD_ABS_LO12_NC 277 /* Dir. ADD imm. from bits 11:0. */ -#define R_AARCH64_LDST8_ABS_LO12_NC 278 /* Likewise for LD/ST; no check. */ -#define R_AARCH64_TSTBR14 279 /* PC-rel. TBZ/TBNZ imm. from 15:2. */ -#define R_AARCH64_CONDBR19 280 /* PC-rel. cond. br. imm. from 20:2. */ -#define R_AARCH64_JUMP26 282 /* PC-rel. B imm. from bits 27:2. */ -#define R_AARCH64_CALL26 283 /* Likewise for CALL. */ -#define R_AARCH64_LDST16_ABS_LO12_NC 284 /* Dir. ADD imm. from bits 11:1. */ -#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* Likewise for bits 11:2. */ -#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* Likewise for bits 11:3. */ -#define R_AARCH64_MOVW_PREL_G0 287 /* PC-rel. MOV{N,Z} imm. from 15:0. */ -#define R_AARCH64_MOVW_PREL_G0_NC 288 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_PREL_G1 289 /* PC-rel. MOV{N,Z} imm. from 31:16. */ -#define R_AARCH64_MOVW_PREL_G1_NC 290 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_PREL_G2 291 /* PC-rel. MOV{N,Z} imm. from 47:32. */ -#define R_AARCH64_MOVW_PREL_G2_NC 292 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_PREL_G3 293 /* PC-rel. MOV{N,Z} imm. from 63:48. */ -#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* Dir. ADD imm. from bits 11:4. */ -#define R_AARCH64_MOVW_GOTOFF_G0 300 /* GOT-rel. off. MOV{N,Z} imm. 15:0. */ -#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_GOTOFF_G1 302 /* GOT-rel. o. MOV{N,Z} imm. 31:16. */ -#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_GOTOFF_G2 304 /* GOT-rel. o. MOV{N,Z} imm. 47:32. */ -#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* Likewise for MOVK; no check. */ -#define R_AARCH64_MOVW_GOTOFF_G3 306 /* GOT-rel. o. MOV{N,Z} imm. 63:48. */ -#define R_AARCH64_GOTREL64 307 /* GOT-relative 64-bit. */ -#define R_AARCH64_GOTREL32 308 /* GOT-relative 32-bit. */ -#define R_AARCH64_GOT_LD_PREL19 309 /* PC-rel. GOT off. load imm. 20:2. */ -#define R_AARCH64_LD64_GOTOFF_LO15 310 /* GOT-rel. off. LD/ST imm. 14:3. */ -#define R_AARCH64_ADR_GOT_PAGE 311 /* P-page-rel. GOT off. ADRP 32:12. */ -#define R_AARCH64_LD64_GOT_LO12_NC 312 /* Dir. GOT off. LD/ST imm. 11:3. */ -#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* GOT-page-rel. GOT off. LD/ST 14:3 */ -#define R_AARCH64_TLSGD_ADR_PREL21 512 /* PC-relative ADR imm. 20:0. */ -#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* page-rel. ADRP imm. 32:12. */ -#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* direct ADD imm. from 11:0. */ -#define R_AARCH64_TLSGD_MOVW_G1 515 /* GOT-rel. MOV{N,Z} 31:16. */ -#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* GOT-rel. MOVK imm. 15:0. */ -#define R_AARCH64_TLSLD_ADR_PREL21 517 /* Like 512; local dynamic model. */ -#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Like 513; local dynamic model. */ -#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* Like 514; local dynamic model. */ -#define R_AARCH64_TLSLD_MOVW_G1 520 /* Like 515; local dynamic model. */ -#define R_AARCH64_TLSLD_MOVW_G0_NC 521 /* Like 516; local dynamic model. */ -#define R_AARCH64_TLSLD_LD_PREL19 522 /* TLS PC-rel. load imm. 20:2. */ -#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 /* TLS DTP-rel. MOV{N,Z} 47:32. */ -#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 /* TLS DTP-rel. MOV{N,Z} 31:16. */ -#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 /* Likewise; MOVK; no check. */ -#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 /* TLS DTP-rel. MOV{N,Z} 15:0. */ -#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 /* Likewise; MOVK; no check. */ -#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 /* DTP-rel. ADD imm. from 23:12. */ -#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 /* DTP-rel. ADD imm. from 11:0. */ -#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 /* Likewise; no ovfl. check. */ -#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 /* DTP-rel. LD/ST imm. 11:0. */ -#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 /* Likewise; no check. */ -#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 /* DTP-rel. LD/ST imm. 11:1. */ -#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 /* Likewise; no check. */ -#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 /* DTP-rel. LD/ST imm. 11:2. */ -#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* Likewise; no check. */ -#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTP-rel. LD/ST imm. 11:3. */ -#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* Likewise; no check. */ -#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* GOT-rel. MOV{N,Z} 31:16. */ -#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* GOT-rel. MOVK 15:0. */ -#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page-rel. ADRP 32:12. */ -#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* Direct LD off. 11:3. */ -#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* PC-rel. load imm. 20:2. */ -#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TLS TP-rel. MOV{N,Z} 47:32. */ -#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TLS TP-rel. MOV{N,Z} 31:16. */ -#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* Likewise; MOVK; no check. */ -#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 /* TLS TP-rel. MOV{N,Z} 15:0. */ -#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 /* Likewise; MOVK; no check. */ -#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 /* TP-rel. ADD imm. 23:12. */ -#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 /* TP-rel. ADD imm. 11:0. */ -#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 /* Likewise; no ovfl. check. */ -#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 /* TP-rel. LD/ST off. 11:0. */ -#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 /* Likewise; no ovfl. check. */ -#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 /* TP-rel. LD/ST off. 11:1. */ -#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 /* Likewise; no check. */ -#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 /* TP-rel. LD/ST off. 11:2. */ -#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 /* Likewise; no check. */ -#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TP-rel. LD/ST off. 11:3. */ -#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* Likewise; no check. */ -#define R_AARCH64_TLSDESC_LD_PREL19 560 /* PC-rel. load immediate 20:2. */ -#define R_AARCH64_TLSDESC_ADR_PREL21 561 /* PC-rel. ADR immediate 20:0. */ -#define R_AARCH64_TLSDESC_ADR_PAGE21 562 /* Page-rel. ADRP imm. 32:12. */ -#define R_AARCH64_TLSDESC_LD64_LO12 563 /* Direct LD off. from 11:3. */ -#define R_AARCH64_TLSDESC_ADD_LO12 564 /* Direct ADD imm. from 11:0. */ -#define R_AARCH64_TLSDESC_OFF_G1 565 /* GOT-rel. MOV{N,Z} imm. 31:16. */ -#define R_AARCH64_TLSDESC_OFF_G0_NC 566 /* GOT-rel. MOVK imm. 15:0; no ck. */ -#define R_AARCH64_TLSDESC_LDR 567 /* Relax LDR. */ -#define R_AARCH64_TLSDESC_ADD 568 /* Relax ADD. */ -#define R_AARCH64_TLSDESC_CALL 569 /* Relax BLR. */ -#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 /* TP-rel. LD/ST off. 11:4. */ -#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 /* Likewise; no check. */ -#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 /* DTP-rel. LD/ST imm. 11:4. */ -#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 /* Likewise; no check. */ -#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ -#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */ -#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */ -#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */ -#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */ -#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */ -#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */ -#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */ -#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */ - -/* ARM relocs. */ - -#define R_ARM_NONE 0 /* No reloc */ -#define R_ARM_PC24 1 /* Deprecated PC relative 26 bit branch. */ -#define R_ARM_ABS32 2 /* Direct 32 bit */ -#define R_ARM_REL32 3 /* PC relative 32 bit */ -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 /* Direct 16 bit */ -#define R_ARM_ABS12 6 /* Direct 12 bit */ -#define R_ARM_THM_ABS5 7 /* Direct & 0x7C (LDR, STR). */ -#define R_ARM_ABS8 8 /* Direct 8 bit */ -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 /* PC relative 24 bit (Thumb32 BL). */ -#define R_ARM_THM_PC8 11 /* PC relative & 0x3FC (Thumb16 LDR, ADD, ADR). */ -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 /* Obsolete static relocation. */ -#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */ -#define R_ARM_THM_SWI8 14 /* Reserved. */ -#define R_ARM_XPC25 15 /* Reserved. */ -#define R_ARM_THM_XPC22 16 /* Reserved. */ -#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ -#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ -#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ -#define R_ARM_COPY 20 /* Copy symbol at runtime */ -#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ -#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ -#define R_ARM_RELATIVE 23 /* Adjust by program base */ -#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ -#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ -#define R_ARM_GOT32 26 /* 32 bit GOT entry */ -#define R_ARM_PLT32 27 /* Deprecated, 32 bit PLT address. */ -#define R_ARM_CALL 28 /* PC relative 24 bit (BL, BLX). */ -#define R_ARM_JUMP24 29 /* PC relative 24 bit (B, BL). */ -#define R_ARM_THM_JUMP24 30 /* PC relative 24 bit (Thumb32 B.W). */ -#define R_ARM_BASE_ABS 31 /* Adjust by program base. */ -#define R_ARM_ALU_PCREL_7_0 32 /* Obsolete. */ -#define R_ARM_ALU_PCREL_15_8 33 /* Obsolete. */ -#define R_ARM_ALU_PCREL_23_15 34 /* Obsolete. */ -#define R_ARM_LDR_SBREL_11_0 35 /* Deprecated, prog. base relative. */ -#define R_ARM_ALU_SBREL_19_12 36 /* Deprecated, prog. base relative. */ -#define R_ARM_ALU_SBREL_27_20 37 /* Deprecated, prog. base relative. */ -#define R_ARM_TARGET1 38 -#define R_ARM_SBREL31 39 /* Program base relative. */ -#define R_ARM_V4BX 40 -#define R_ARM_TARGET2 41 -#define R_ARM_PREL31 42 /* 32 bit PC relative. */ -#define R_ARM_MOVW_ABS_NC 43 /* Direct 16-bit (MOVW). */ -#define R_ARM_MOVT_ABS 44 /* Direct high 16-bit (MOVT). */ -#define R_ARM_MOVW_PREL_NC 45 /* PC relative 16-bit (MOVW). */ -#define R_ARM_MOVT_PREL 46 /* PC relative (MOVT). */ -#define R_ARM_THM_MOVW_ABS_NC 47 /* Direct 16 bit (Thumb32 MOVW). */ -#define R_ARM_THM_MOVT_ABS 48 /* Direct high 16 bit (Thumb32 MOVT). */ -#define R_ARM_THM_MOVW_PREL_NC 49 /* PC relative 16 bit (Thumb32 MOVW). */ -#define R_ARM_THM_MOVT_PREL 50 /* PC relative high 16 bit (Thumb32 MOVT). */ -#define R_ARM_THM_JUMP19 51 /* PC relative 20 bit (Thumb32 B.W). */ -#define R_ARM_THM_JUMP6 52 /* PC relative X & 0x7E (Thumb16 CBZ, CBNZ). */ -#define R_ARM_THM_ALU_PREL_11_0 53 /* PC relative 12 bit (Thumb32 ADR.W). */ -#define R_ARM_THM_PC12 54 /* PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). */ -#define R_ARM_ABS32_NOI 55 /* Direct 32-bit. */ -#define R_ARM_REL32_NOI 56 /* PC relative 32-bit. */ -#define R_ARM_ALU_PC_G0_NC 57 /* PC relative (ADD, SUB). */ -#define R_ARM_ALU_PC_G0 58 /* PC relative (ADD, SUB). */ -#define R_ARM_ALU_PC_G1_NC 59 /* PC relative (ADD, SUB). */ -#define R_ARM_ALU_PC_G1 60 /* PC relative (ADD, SUB). */ -#define R_ARM_ALU_PC_G2 61 /* PC relative (ADD, SUB). */ -#define R_ARM_LDR_PC_G1 62 /* PC relative (LDR,STR,LDRB,STRB). */ -#define R_ARM_LDR_PC_G2 63 /* PC relative (LDR,STR,LDRB,STRB). */ -#define R_ARM_LDRS_PC_G0 64 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ -#define R_ARM_LDRS_PC_G1 65 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ -#define R_ARM_LDRS_PC_G2 66 /* PC relative (STR{D,H}, LDR{D,SB,H,SH}). */ -#define R_ARM_LDC_PC_G0 67 /* PC relative (LDC, STC). */ -#define R_ARM_LDC_PC_G1 68 /* PC relative (LDC, STC). */ -#define R_ARM_LDC_PC_G2 69 /* PC relative (LDC, STC). */ -#define R_ARM_ALU_SB_G0_NC 70 /* Program base relative (ADD,SUB). */ -#define R_ARM_ALU_SB_G0 71 /* Program base relative (ADD,SUB). */ -#define R_ARM_ALU_SB_G1_NC 72 /* Program base relative (ADD,SUB). */ -#define R_ARM_ALU_SB_G1 73 /* Program base relative (ADD,SUB). */ -#define R_ARM_ALU_SB_G2 74 /* Program base relative (ADD,SUB). */ -#define R_ARM_LDR_SB_G0 75 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDR_SB_G1 76 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDR_SB_G2 77 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDRS_SB_G0 78 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDRS_SB_G1 79 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDRS_SB_G2 80 /* Program base relative (LDR, STR, LDRB, STRB). */ -#define R_ARM_LDC_SB_G0 81 /* Program base relative (LDC,STC). */ -#define R_ARM_LDC_SB_G1 82 /* Program base relative (LDC,STC). */ -#define R_ARM_LDC_SB_G2 83 /* Program base relative (LDC,STC). */ -#define R_ARM_MOVW_BREL_NC 84 /* Program base relative 16 bit (MOVW). */ -#define R_ARM_MOVT_BREL 85 /* Program base relative high 16 bit (MOVT). */ -#define R_ARM_MOVW_BREL 86 /* Program base relative 16 bit (MOVW). */ -#define R_ARM_THM_MOVW_BREL_NC 87 /* Program base relative 16 bit (Thumb32 MOVW). */ -#define R_ARM_THM_MOVT_BREL 88 /* Program base relative high 16 bit (Thumb32 MOVT). */ -#define R_ARM_THM_MOVW_BREL 89 /* Program base relative 16 bit (Thumb32 MOVW). */ -#define R_ARM_TLS_GOTDESC 90 -#define R_ARM_TLS_CALL 91 -#define R_ARM_TLS_DESCSEQ 92 /* TLS relaxation. */ -#define R_ARM_THM_TLS_CALL 93 -#define R_ARM_PLT32_ABS 94 -#define R_ARM_GOT_ABS 95 /* GOT entry. */ -#define R_ARM_GOT_PREL 96 /* PC relative GOT entry. */ -#define R_ARM_GOT_BREL12 97 /* GOT entry relative to GOT origin (LDR). */ -#define R_ARM_GOTOFF12 98 /* 12 bit, GOT entry relative to GOT origin (LDR, STR). */ -#define R_ARM_GOTRELAX 99 -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_PC11 102 /* PC relative & 0xFFE (Thumb16 B). */ -#define R_ARM_THM_PC9 103 /* PC relative & 0x1FE (Thumb16 B/B). */ -#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic thread local data */ -#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic thread local data */ -#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS block */ -#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of static TLS block offset */ -#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static TLS block */ -#define R_ARM_TLS_LDO12 109 /* 12 bit relative to TLS block (LDR, STR). */ -#define R_ARM_TLS_LE12 110 /* 12 bit relative to static TLS block (LDR, STR). */ -#define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative to GOT origin (LDR). */ -#define R_ARM_ME_TOO 128 /* Obsolete. */ -#define R_ARM_THM_TLS_DESCSEQ 129 -#define R_ARM_THM_TLS_DESCSEQ16 129 -#define R_ARM_THM_TLS_DESCSEQ32 130 -#define R_ARM_THM_GOT_BREL12 131 /* GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). */ -#define R_ARM_IRELATIVE 160 -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS22 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 -/* Keep this the last entry. */ -#define R_ARM_NUM 256 - -/* IA-64 specific declarations. */ - -/* Processor specific flags for the Ehdr e_flags field. */ -#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ -#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ -#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ - -/* Processor specific values for the Phdr p_type field. */ -#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ -#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ -#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) -#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) -#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) - -/* Processor specific flags for the Phdr p_flags field. */ -#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Shdr sh_type field. */ -#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ - -/* Processor specific flags for the Shdr sh_flags field. */ -#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ -#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Dyn d_tag field. */ -#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) -#define DT_IA_64_NUM 1 - -/* IA-64 relocations. */ -#define R_IA64_NONE 0x00 /* none */ -#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ -#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ -#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ -#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ -#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ -#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ -#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ -#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ -#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ -#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ -#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ -#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ -#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ -#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ -#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ -#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ -#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ -#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ -#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ -#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ -#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ -#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ -#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ -#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ -#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ -#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ -#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ -#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ -#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ -#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ -#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ -#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ -#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ -#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ -#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ -#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ -#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ -#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ -#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ -#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ -#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ -#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ -#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ -#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ -#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ -#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ -#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ -#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ -#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ -#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ -#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ -#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ -#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ -#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ -#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ -#define R_IA64_COPY 0x84 /* copy relocation */ -#define R_IA64_SUB 0x85 /* Addend and symbol difference */ -#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ -#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ -#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ -#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ -#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ -#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ -#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ -#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ -#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ -#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ -#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ -#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ -#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ -#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ -#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ -#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ - -/* SH specific declarations */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_SH_MACH_MASK 0x1f -#define EF_SH_UNKNOWN 0x0 -#define EF_SH1 0x1 -#define EF_SH2 0x2 -#define EF_SH3 0x3 -#define EF_SH_DSP 0x4 -#define EF_SH3_DSP 0x5 -#define EF_SH4AL_DSP 0x6 -#define EF_SH3E 0x8 -#define EF_SH4 0x9 -#define EF_SH2E 0xb -#define EF_SH4A 0xc -#define EF_SH2A 0xd -#define EF_SH4_NOFPU 0x10 -#define EF_SH4A_NOFPU 0x11 -#define EF_SH4_NOMMU_NOFPU 0x12 -#define EF_SH2A_NOFPU 0x13 -#define EF_SH3_NOMMU 0x14 -#define EF_SH2A_SH4_NOFPU 0x15 -#define EF_SH2A_SH3_NOFPU 0x16 -#define EF_SH2A_SH4 0x17 -#define EF_SH2A_SH3E 0x18 - -/* SH relocs. */ -#define R_SH_NONE 0 -#define R_SH_DIR32 1 -#define R_SH_REL32 2 -#define R_SH_DIR8WPN 3 -#define R_SH_IND12W 4 -#define R_SH_DIR8WPL 5 -#define R_SH_DIR8WPZ 6 -#define R_SH_DIR8BP 7 -#define R_SH_DIR8W 8 -#define R_SH_DIR8L 9 -#define R_SH_SWITCH16 25 -#define R_SH_SWITCH32 26 -#define R_SH_USES 27 -#define R_SH_COUNT 28 -#define R_SH_ALIGN 29 -#define R_SH_CODE 30 -#define R_SH_DATA 31 -#define R_SH_LABEL 32 -#define R_SH_SWITCH8 33 -#define R_SH_GNU_VTINHERIT 34 -#define R_SH_GNU_VTENTRY 35 -#define R_SH_TLS_GD_32 144 -#define R_SH_TLS_LD_32 145 -#define R_SH_TLS_LDO_32 146 -#define R_SH_TLS_IE_32 147 -#define R_SH_TLS_LE_32 148 -#define R_SH_TLS_DTPMOD32 149 -#define R_SH_TLS_DTPOFF32 150 -#define R_SH_TLS_TPOFF32 151 -#define R_SH_GOT32 160 -#define R_SH_PLT32 161 -#define R_SH_COPY 162 -#define R_SH_GLOB_DAT 163 -#define R_SH_JMP_SLOT 164 -#define R_SH_RELATIVE 165 -#define R_SH_GOTOFF 166 -#define R_SH_GOTPC 167 -/* Keep this the last entry. */ -#define R_SH_NUM 256 - -/* S/390 specific definitions. */ - -/* Valid values for the e_flags field. */ - -#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */ - -/* Additional s390 relocs */ - -#define R_390_NONE 0 /* No reloc. */ -#define R_390_8 1 /* Direct 8 bit. */ -#define R_390_12 2 /* Direct 12 bit. */ -#define R_390_16 3 /* Direct 16 bit. */ -#define R_390_32 4 /* Direct 32 bit. */ -#define R_390_PC32 5 /* PC relative 32 bit. */ -#define R_390_GOT12 6 /* 12 bit GOT offset. */ -#define R_390_GOT32 7 /* 32 bit GOT offset. */ -#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ -#define R_390_COPY 9 /* Copy symbol at runtime. */ -#define R_390_GLOB_DAT 10 /* Create GOT entry. */ -#define R_390_JMP_SLOT 11 /* Create PLT entry. */ -#define R_390_RELATIVE 12 /* Adjust by program base. */ -#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ -#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ -#define R_390_GOT16 15 /* 16 bit GOT offset. */ -#define R_390_PC16 16 /* PC relative 16 bit. */ -#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ -#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ -#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ -#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ -#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ -#define R_390_64 22 /* Direct 64 bit. */ -#define R_390_PC64 23 /* PC relative 64 bit. */ -#define R_390_GOT64 24 /* 64 bit GOT offset. */ -#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ -#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ -#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ -#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ -#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ -#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ -#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ -#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ -#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ -#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ -#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ -#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ -#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ -#define R_390_TLS_GDCALL 38 /* Tag for function call in general dynamic TLS code. */ -#define R_390_TLS_LDCALL 39 /* Tag for function call in local dynamic TLS code. */ -#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic thread local data. */ -#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic thread local data. */ -#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS block offset. */ -#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS block offset. */ -#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS block offset. */ -#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic thread local data in LE code. */ -#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic thread local data in LE code. */ -#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for negated static TLS block offset. */ -#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for negated static TLS block offset. */ -#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for negated static TLS block offset. */ -#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to static TLS block. */ -#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to static TLS block. */ -#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS block. */ -#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS block. */ -#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ -#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ -#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS block. */ -#define R_390_20 57 /* Direct 20 bit. */ -#define R_390_GOT20 58 /* 20 bit GOT offset. */ -#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ -#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS block offset. */ -#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */ -/* Keep this the last entry. */ -#define R_390_NUM 62 - - -/* CRIS relocations. */ -#define R_CRIS_NONE 0 -#define R_CRIS_8 1 -#define R_CRIS_16 2 -#define R_CRIS_32 3 -#define R_CRIS_8_PCREL 4 -#define R_CRIS_16_PCREL 5 -#define R_CRIS_32_PCREL 6 -#define R_CRIS_GNU_VTINHERIT 7 -#define R_CRIS_GNU_VTENTRY 8 -#define R_CRIS_COPY 9 -#define R_CRIS_GLOB_DAT 10 -#define R_CRIS_JUMP_SLOT 11 -#define R_CRIS_RELATIVE 12 -#define R_CRIS_16_GOT 13 -#define R_CRIS_32_GOT 14 -#define R_CRIS_16_GOTPLT 15 -#define R_CRIS_32_GOTPLT 16 -#define R_CRIS_32_GOTREL 17 -#define R_CRIS_32_PLT_GOTREL 18 -#define R_CRIS_32_PLT_PCREL 19 - -#define R_CRIS_NUM 20 - - -/* AMD x86-64 relocations. */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */ -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ -#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ -#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ -#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ -#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset to two GOT entries for GD symbol */ -#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset to two GOT entries for LD symbol */ -#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ -#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset to GOT entry for IE symbol */ -#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ -#define R_X86_64_PC64 24 /* PC relative 64 bit */ -#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */ -#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative offset to GOT */ -#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */ -#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset to GOT entry */ -#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */ -#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */ -#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset to PLT entry */ -#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */ -#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */ -#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */ -#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS descriptor. */ -#define R_X86_64_TLSDESC 36 /* TLS descriptor. */ -#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */ -#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */ - -#define R_X86_64_NUM 39 - - -/* AM33 relocations. */ -#define R_MN10300_NONE 0 /* No reloc. */ -#define R_MN10300_32 1 /* Direct 32 bit. */ -#define R_MN10300_16 2 /* Direct 16 bit. */ -#define R_MN10300_8 3 /* Direct 8 bit. */ -#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ -#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ -#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ -#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ -#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ -#define R_MN10300_24 9 /* Direct 24 bit. */ -#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ -#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ -#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ -#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ -#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ -#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ -#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ -#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ -#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ -#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ -#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ -#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ -#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ -#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ -#define R_MN10300_TLS_GD 24 /* 32-bit offset for global dynamic. */ -#define R_MN10300_TLS_LD 25 /* 32-bit offset for local dynamic. */ -#define R_MN10300_TLS_LDO 26 /* Module-relative offset. */ -#define R_MN10300_TLS_GOTIE 27 /* GOT offset for static TLS block offset. */ -#define R_MN10300_TLS_IE 28 /* GOT address for static TLS block offset. */ -#define R_MN10300_TLS_LE 29 /* Offset relative to static TLS block. */ -#define R_MN10300_TLS_DTPMOD 30 /* ID of module containing symbol. */ -#define R_MN10300_TLS_DTPOFF 31 /* Offset in module TLS block. */ -#define R_MN10300_TLS_TPOFF 32 /* Offset in static TLS block. */ -#define R_MN10300_SYM_DIFF 33 /* Adjustment for next reloc as needed by linker relaxation. */ -#define R_MN10300_ALIGN 34 /* Alignment requirement for linker relaxation. */ -#define R_MN10300_NUM 35 - - -/* M32R relocs. */ -#define R_M32R_NONE 0 /* No reloc. */ -#define R_M32R_16 1 /* Direct 16 bit. */ -#define R_M32R_32 2 /* Direct 32 bit. */ -#define R_M32R_24 3 /* Direct 24 bit. */ -#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ -#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ -#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ -#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ -#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ -#define R_M32R_LO16 9 /* Low 16 bit. */ -#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ -#define R_M32R_GNU_VTINHERIT 11 -#define R_M32R_GNU_VTENTRY 12 -/* M32R relocs use SHT_RELA. */ -#define R_M32R_16_RELA 33 /* Direct 16 bit. */ -#define R_M32R_32_RELA 34 /* Direct 32 bit. */ -#define R_M32R_24_RELA 35 /* Direct 24 bit. */ -#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ -#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ -#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ -#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ -#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ -#define R_M32R_LO16_RELA 41 /* Low 16 bit */ -#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ -#define R_M32R_RELA_GNU_VTINHERIT 43 -#define R_M32R_RELA_GNU_VTENTRY 44 -#define R_M32R_REL32 45 /* PC relative 32 bit. */ - -#define R_M32R_GOT24 48 /* 24 bit GOT entry */ -#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ -#define R_M32R_COPY 50 /* Copy symbol at runtime */ -#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ -#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ -#define R_M32R_RELATIVE 53 /* Adjust by program base */ -#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ -#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ -#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned low */ -#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed low */ -#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ -#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to GOT with unsigned low */ -#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to GOT with signed low */ -#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to GOT */ -#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT with unsigned low */ -#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT with signed low */ -#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ -#define R_M32R_NUM 256 /* Keep this the last entry. */ - -/* MicroBlaze relocations */ -#define R_MICROBLAZE_NONE 0 /* No reloc. */ -#define R_MICROBLAZE_32 1 /* Direct 32 bit. */ -#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */ -#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */ -#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */ -#define R_MICROBLAZE_64 5 /* Direct 64 bit. */ -#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */ -#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */ -#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */ -#define R_MICROBLAZE_64_NONE 9 /* No reloc. */ -#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */ -#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */ -#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */ -#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */ -#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */ -#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */ -#define R_MICROBLAZE_REL 16 /* Adjust by program base. */ -#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */ -#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */ -#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */ -#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */ -#define R_MICROBLAZE_COPY 21 /* Runtime copy. */ -#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */ -#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */ -#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */ -#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */ -#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */ -#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */ -#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */ -#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */ - -/* Legal values for d_tag (dynamic entry type). */ -#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */ - -/* Nios II relocations. */ -#define R_NIOS2_NONE 0 /* No reloc. */ -#define R_NIOS2_S16 1 /* Direct signed 16 bit. */ -#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */ -#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */ -#define R_NIOS2_CALL26 4 /* Direct call. */ -#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */ -#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */ -#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */ -#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */ -#define R_NIOS2_HI16 9 /* High 16 bit. */ -#define R_NIOS2_LO16 10 /* Low 16 bit. */ -#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */ -#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */ -#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */ -#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */ -#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */ -#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */ -#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */ -#define R_NIOS2_UJMP 18 /* Unconditional branch. */ -#define R_NIOS2_CJMP 19 /* Conditional branch. */ -#define R_NIOS2_CALLR 20 /* Indirect call through register. */ -#define R_NIOS2_ALIGN 21 /* Alignment requirement for linker relaxation. */ -#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */ -#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */ -#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */ -#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */ -#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */ -#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */ -#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */ -#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */ -#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */ -#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */ -#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */ -#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */ -#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */ -#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */ -#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */ -#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */ -#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */ -#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */ -#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */ -#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */ -#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */ -#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */ -#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */ -#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */ - -/* TILEPro relocations. */ -#define R_TILEPRO_NONE 0 /* No reloc */ -#define R_TILEPRO_32 1 /* Direct 32 bit */ -#define R_TILEPRO_16 2 /* Direct 16 bit */ -#define R_TILEPRO_8 3 /* Direct 8 bit */ -#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */ -#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */ -#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */ -#define R_TILEPRO_LO16 7 /* Low 16 bit */ -#define R_TILEPRO_HI16 8 /* High 16 bit */ -#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */ -#define R_TILEPRO_COPY 10 /* Copy relocation */ -#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */ -#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */ -#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */ -#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */ -#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */ -#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */ -#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */ -#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */ -#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */ -#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */ -#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */ -#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */ -#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */ -#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */ -#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */ -#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */ -#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */ -#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */ -#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */ -#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */ -#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */ -#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */ -#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */ -#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */ -#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */ -#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */ -#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */ -#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */ -#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */ -#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */ -#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */ -#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */ -#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */ -#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */ -#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */ -#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */ -#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */ -#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */ -#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */ -/* Relocs 56-59 are currently not defined. */ -#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */ -#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */ -#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */ -#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */ -#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */ -#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */ -#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */ -#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */ -#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */ -#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */ -#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */ -#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */ -#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */ -#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */ - -#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ -#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ - -#define R_TILEPRO_NUM 130 - - -/* TILE-Gx relocations. */ -#define R_TILEGX_NONE 0 /* No reloc */ -#define R_TILEGX_64 1 /* Direct 64 bit */ -#define R_TILEGX_32 2 /* Direct 32 bit */ -#define R_TILEGX_16 3 /* Direct 16 bit */ -#define R_TILEGX_8 4 /* Direct 8 bit */ -#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */ -#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */ -#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */ -#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */ -#define R_TILEGX_HW0 9 /* hword 0 16-bit */ -#define R_TILEGX_HW1 10 /* hword 1 16-bit */ -#define R_TILEGX_HW2 11 /* hword 2 16-bit */ -#define R_TILEGX_HW3 12 /* hword 3 16-bit */ -#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */ -#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */ -#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */ -#define R_TILEGX_COPY 16 /* Copy relocation */ -#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */ -#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */ -#define R_TILEGX_RELATIVE 19 /* Adjust by program base */ -#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */ -#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */ -#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */ -#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */ -#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */ -#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */ -#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */ -#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */ -#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */ -#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */ -#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */ -#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */ -#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */ -#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */ -#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */ -#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */ -#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */ -#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */ -#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */ -#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */ -#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */ -#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */ -#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */ -#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */ -#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */ -#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */ -#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */ -#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */ -#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */ -#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */ -#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */ -#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */ -#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */ -#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */ -#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */ -#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */ -#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */ -#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */ -#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */ -#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */ -#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */ -#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */ -#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */ -#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */ -#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */ -#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */ -#define R_TILEGX_IMM16_X0_HW0_PLT_PCREL 66 /* X0 pipe PC-rel PLT hword 0 */ -#define R_TILEGX_IMM16_X1_HW0_PLT_PCREL 67 /* X1 pipe PC-rel PLT hword 0 */ -#define R_TILEGX_IMM16_X0_HW1_PLT_PCREL 68 /* X0 pipe PC-rel PLT hword 1 */ -#define R_TILEGX_IMM16_X1_HW1_PLT_PCREL 69 /* X1 pipe PC-rel PLT hword 1 */ -#define R_TILEGX_IMM16_X0_HW2_PLT_PCREL 70 /* X0 pipe PC-rel PLT hword 2 */ -#define R_TILEGX_IMM16_X1_HW2_PLT_PCREL 71 /* X1 pipe PC-rel PLT hword 2 */ -#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */ -#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */ -#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */ -#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */ -#define R_TILEGX_IMM16_X0_HW3_PLT_PCREL 76 /* X0 pipe PC-rel PLT hword 3 */ -#define R_TILEGX_IMM16_X1_HW3_PLT_PCREL 77 /* X1 pipe PC-rel PLT hword 3 */ -#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */ -#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */ -#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */ -#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */ -#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */ -#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */ -#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */ -#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */ -#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */ -#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */ -#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */ -#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */ -/* Relocs 90-91 are currently not defined. */ -#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */ -#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */ -#define R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL 94 /* X0 pipe PC-rel PLT last hword 0 */ -#define R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL 95 /* X1 pipe PC-rel PLT last hword 0 */ -#define R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL 96 /* X0 pipe PC-rel PLT last hword 1 */ -#define R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL 97 /* X1 pipe PC-rel PLT last hword 1 */ -#define R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL 98 /* X0 pipe PC-rel PLT last hword 2 */ -#define R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL 99 /* X1 pipe PC-rel PLT last hword 2 */ -#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */ -#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */ -#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */ -#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */ -/* Relocs 104-105 are currently not defined. */ -#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */ -#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */ -#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */ -#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */ -#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */ -#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */ -#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */ -#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */ -#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */ -#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */ -#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */ -#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */ -#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */ -#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */ -#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */ -#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */ - -#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ -#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ - -#define R_TILEGX_NUM 130 - -#endif /* elf.h */ diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs deleted file mode 100644 index 1a318e98cefe47..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTestBase.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using NUnit.Framework; - -namespace LibObjectFile.Tests.Ar -{ - public abstract class ArTestBase - { - protected static void ExpectNoDiagnostics(DiagnosticBag diagnostics) - { - if (diagnostics.Messages.Count != 0) - { - Console.WriteLine(diagnostics); - Assert.AreEqual(0, diagnostics.Messages.Count, $"Invalid number of diagnostics found, expecting no diagnostics"); - } - } - - protected static void ExpectDiagnostics(DiagnosticBag diagnostics, params DiagnosticId[] ids) - { - if (diagnostics.Messages.Count != ids.Length) - { - Console.WriteLine(diagnostics); - Assert.AreEqual(ids.Length, diagnostics.Messages.Count, $"Invalid number of diagnostics found, expecting {ids.Length} entries [{string.Join(", ", ids)}]"); - } - - for (var i = 0; i < diagnostics.Messages.Count; i++) - { - var diagnosticsMessage = diagnostics.Messages[i]; - var expectedId = ids[i]; - - if (expectedId != diagnosticsMessage.Id) - { - Console.WriteLine(diagnostics); - Assert.AreEqual(expectedId, diagnosticsMessage.Id, $"Invalid Id {diagnosticsMessage.Id} found for diagnostics [{i}] while expecting {expectedId} from entries [{string.Join(", ", ids)}]"); - } - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs deleted file mode 100644 index 9cbc9bee83f0e0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Ar/ArTests.cs +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Linq; -using System.Text; -using LibObjectFile.Ar; -using NUnit.Framework; - -namespace LibObjectFile.Tests.Ar -{ - public class ArTests : ArTestBase - { - [Test] - public void CheckInvalidHeader() - { - // Incorrect magic length - { - var stream = new MemoryStream(new byte[] { 1, 2, 3, 4 }); - Assert.False(ArArchiveFile.IsAr(stream, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidMagicLength); - } - - // Correct length, magic invalid - { - var stream = new MemoryStream(new byte[] - { - (byte)'!', - (byte)'<', - (byte)'a', - (byte)'r', - (byte)'c', - (byte)'h', - (byte)'>', - (byte)'?', - }); - Assert.False(ArArchiveFile.IsAr(stream, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_MagicNotFound); - } - - // Valid - { - var stream = new MemoryStream(new byte[] - { - (byte)'!', - (byte)'<', - (byte)'a', - (byte)'r', - (byte)'c', - (byte)'h', - (byte)'>', - (byte)'\n', - }); - Assert.True(ArArchiveFile.IsAr(stream, out var diagnostics)); - ExpectNoDiagnostics(diagnostics); - } - } - - [Test] - public void CheckInvalidFileEntry() - { - // Incorrect entry length - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - stream.Write(new byte[] {(byte)'a', (byte)'b'}); - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidFileEntryLength); - } - - // Input invalid non-numeric characters into decimal/octal fields in file entry - { - var offsets = new int[] - { - ArFile.FieldTimestampOffset, - ArFile.FieldOwnerIdOffset, - ArFile.FieldGroupIdOffset, - ArFile.FieldFileModeOffset, - ArFile.FieldFileSizeOffset, - ArFile.FieldEndCharactersOffset - }; - foreach (var offset in offsets) - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[offset] = (byte)'a'; - stream.Write(entry); - - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry); - } - } - - // Input name with `/` - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[0] = (byte)'a'; - entry[1] = (byte)'b'; - entry[2] = (byte)'/'; - entry[3] = (byte)'c'; - - entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; - entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; - - stream.Write(entry); - - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterInFileEntryName); - } - - // Input length of content - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[0] = (byte)'a'; - entry[ArFile.FieldFileSizeOffset] = (byte)'2'; - entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; - entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; - - stream.Write(entry); - - var continuePosition = stream.Position; - - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); - - stream.Position = continuePosition; - - stream.WriteByte(0); - stream.WriteByte(1); - - stream.Position = 0; - - // Check that we can actually read the content - - var result = ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out var arFile, out diagnostics); - ExpectNoDiagnostics(diagnostics); - Assert.True(result, $"Error while reading file: {diagnostics}"); - Assert.AreEqual(1, arFile.Files.Count, "Invalid number of file entries found"); - Assert.AreEqual("a", arFile.Files[0].Name, "Invalid name of file entry[0] found"); - Assert.AreEqual(2, arFile.Files[0].Size, "Invalid size of file entry[0] found"); - Assert.IsInstanceOf(arFile.Files[0], "Invalid instance of of file entry[0] "); - - var fileStream = ((ArBinaryFile) arFile.Files[0]).Stream; - var read = new byte[] - { - (byte)fileStream.ReadByte(), - (byte)fileStream.ReadByte() - }; - Assert.AreEqual(new byte[] { 0, 1}, read, "Invalid content of of file entry[0] "); - - Assert.Null(arFile.SymbolTable, "Invalid non-null symbol table found"); - - } - - // Input length of content - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[0] = (byte)'a'; - entry[ArFile.FieldFileSizeOffset] = (byte)'1'; - entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; - entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; - - stream.Write(entry); - stream.WriteByte(0); - - var continuePosition = stream.Position; - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); - - stream.Position = continuePosition; - stream.WriteByte(0); - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_ExpectingNewLineCharacter); - - stream.Position = continuePosition; - stream.WriteByte((byte)'\n'); - stream.Position = 0; - - Assert.True(ArArchiveFile.TryRead(stream, ArArchiveKind.GNU, out _, out diagnostics)); - ExpectNoDiagnostics(diagnostics); - } - } - - [Test] - public void CheckInvalidBSDFileEntry() - { - // Input invalid BSD Length - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[0] = (byte)'#'; - entry[1] = (byte)'1'; - entry[2] = (byte)'/'; - entry[3] = (byte)'a'; - - stream.Write(entry); - - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry); - } - - // Input invalid BSD Length - { - var stream = new MemoryStream(); - stream.Write(ArArchiveFile.Magic); - var entry = new Span(new byte[ArFile.FileEntrySizeInBytes]); - entry.Fill((byte)' '); - entry[0] = (byte)'#'; - entry[1] = (byte)'1'; - entry[2] = (byte)'/'; - entry[3] = (byte)'2'; // it will try to read 2 bytes for the name but won't find it - - entry[ArFile.FieldEndCharactersOffset] = (byte)'`'; - entry[ArFile.FieldEndCharactersOffset + 1] = (byte)'\n'; - - stream.Write(entry); - - var continuePosition = stream.Position; - - stream.Position = 0; - - Assert.False(ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out _, out var diagnostics)); - ExpectDiagnostics(diagnostics, DiagnosticId.CMN_ERR_UnexpectedEndOfFile); - - // Check validity of BSD name - - stream.Position = continuePosition; - stream.WriteByte((byte)'a'); - stream.WriteByte((byte)'b'); - - stream.Position = 0; - - var result = ArArchiveFile.TryRead(stream, ArArchiveKind.BSD, out var arFile, out diagnostics); - Assert.True(result, $"Error while reading file: {diagnostics}"); - Assert.AreEqual(1, arFile.Files.Count, "Invalid number of file entries found"); - Assert.AreEqual("ab", arFile.Files[0].Name, "Invalid name of file entry[0] found"); - Assert.Null(arFile.SymbolTable, "Invalid non-null symbol table found"); - } - } - - [Test] - public void CheckLibraryWithELF() - { - var cppName = "helloworld"; - var cppObj = $"{cppName}.o"; - var cppLib = $"lib{cppName}.a"; - File.Delete(cppObj); - File.Delete(cppLib); - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -c -o {cppObj}"); - LinuxUtil.RunLinuxExe("ar", $"rcs {cppLib} {cppObj}"); - - using (var stream = new FileStream(cppLib, FileMode.Open, FileAccess.Read)) - { - Assert.True(ArArchiveFile.IsAr(stream)); - - var arFile = ArArchiveFile.Read(stream, new ArArchiveFileReaderOptions(ArArchiveKind.GNU) {ProcessObjectFiles = false}); - - var elfFile = arFile.Files.FirstOrDefault(x => x.Name == cppObj); - - Assert.NotNull(elfFile, $"Unable to find {cppObj} file in {cppLib}"); - - Assert.NotNull(arFile.SymbolTable, $"Unable to find symbol table in {cppLib}"); - - Assert.AreEqual(1, arFile.SymbolTable.Symbols.Count, "Invalid number of symbols in Symbol table"); - Assert.AreEqual("main", arFile.SymbolTable.Symbols[0].Name, "Invalid symbol found"); - Assert.AreEqual(elfFile, arFile.SymbolTable.Symbols[0].File, "Invalid symbol to file found"); - - var outStream = new MemoryStream(); - arFile.Write(outStream); - var newArray = outStream.ToArray(); - outStream.Position = 0; - - var cppLibCopy = $"lib{cppName}_copy.a"; - using (var copyStream = new FileStream(cppLibCopy, FileMode.Create, FileAccess.Write)) - { - outStream.CopyTo(copyStream); - } - - var originalStream = new MemoryStream(); - stream.Position = 0; - stream.CopyTo(originalStream); - var originalArray = originalStream.ToArray(); - - Assert.AreEqual(originalArray, newArray, $"Non binary matching between file {cppLib} and {cppLibCopy}"); - } - } - - [Test] - public void CheckCreateArLibrary() - { - var libName = "libcustom.a"; - - var file = new ArArchiveFile(); - using (var stream = new FileStream(libName, FileMode.Create, FileAccess.Write)) - { - var symbolTable = new ArSymbolTable(); - file.AddFile(symbolTable); - - file.AddFile(new ArBinaryFile() { Name = "file2.txt", OwnerId = 0666, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file")) }); - - file.AddFile(new ArBinaryFile() { Name = "file3.txt", OwnerId = 0777, GroupId = 0744, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file3")) }); - - file.AddFile(new ArBinaryFile() { Name = "file4.txt", OwnerId = 0777, GroupId = 0744, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file4")) }); - - file.AddFile(new ArBinaryFile() { Name = "file5.txt", OwnerId = 0706, GroupId = 0705, FileMode = 0x123456, Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file5")) }); - - file.AddFile(new ArBinaryFile() { Name = "long_file_name_large_file6.txt", Timestamp = DateTimeOffset.UtcNow.AddSeconds(-2), Stream = new MemoryStream(Encoding.UTF8.GetBytes("this is file6 yoyo")) }); - - symbolTable.Symbols.Add(new ArSymbol() { File = file.Files[1], Name = "my_symbol" }); - - file.Write(stream); - stream.Flush(); - } - - // Check that AR is able to read back what we just serialized - { - var fileNameBuilder = new StringBuilder(); - foreach (var fileEntry in file.Files) - { - if (fileEntry.IsSystem) continue; - fileNameBuilder.Append($"{fileEntry.Name}\n"); - } - - var fileNameList = fileNameBuilder.ToString().Trim(); - var fileNameListFromAr = LinuxUtil.RunLinuxExe("ar", $"t {libName}").Trim(); - Assert.AreEqual(fileNameListFromAr, fileNameList); - } - - // Display the content of each file via AR - { - var contentBuilder = new StringBuilder(); - foreach (var fileEntry in file.Files) - { - if (!(fileEntry is ArBinaryFile arBinary)) continue; - - arBinary.Stream.Position = 0; - contentBuilder.Append(Encoding.UTF8.GetString(((MemoryStream) arBinary.Stream).ToArray())); - } - - var content = contentBuilder.ToString().Trim(); - var contentFromAr = LinuxUtil.RunLinuxExe("ar", $"p {libName}").Trim(); - Assert.AreEqual(contentFromAr, content); - } - - ArArchiveFile file2; - using (var stream = new FileStream(libName, FileMode.Open, FileAccess.Read)) - { - file2 = ArArchiveFile.Read(stream, ArArchiveKind.GNU); - } - - Assert.NotNull(file2.SymbolTable); - CompareArFiles(file, file2); - - var libNameBsd = "libcustom_bsd.a"; - file.Kind = ArArchiveKind.BSD; - using (var stream = new FileStream(libNameBsd, FileMode.Create, FileAccess.Write)) - { - file.Write(stream); - stream.Flush(); - } - - ArArchiveFile archiveFileBsd; - using (var stream = new FileStream(libNameBsd, FileMode.Open, FileAccess.Read)) - { - archiveFileBsd = ArArchiveFile.Read(stream, ArArchiveKind.BSD); - } - - CompareArFiles(file, archiveFileBsd); - } - - private static void CompareArFiles(ArArchiveFile archiveFile, ArArchiveFile file2) - { - Assert.AreEqual(archiveFile.Files.Count, file2.Files.Count, "File entries count don't match"); - for (var i = 0; i < archiveFile.Files.Count; i++) - { - var fileEntry = archiveFile.Files[i]; - var file2Entry = file2.Files[i]; - Assert.AreEqual(fileEntry.GetType(), file2Entry.GetType(), $"File entry [{i}] for {archiveFile} type don't match "); - Assert.AreEqual(fileEntry.Name, file2Entry.Name, $"File entry Name [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.Timestamp, file2Entry.Timestamp, $"File entry Timestamp [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.OwnerId, file2Entry.OwnerId, $"File entry Timestamp [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.GroupId, file2Entry.GroupId, $"File entry Timestamp [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.FileMode, file2Entry.FileMode, $"File entry Timestamp [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.Size, file2Entry.Size, $"File entry Size [{i}] for {archiveFile}"); - Assert.AreEqual(fileEntry.ToString(), file2Entry.ToString(), $"File entry ToString() [{i}] for {archiveFile}"); - - if (fileEntry is ArSymbolTable fileSymbolTable) - { - var file2SymbolTable = (ArSymbolTable) (file2Entry); - for (var j = 0; j < fileSymbolTable.Symbols.Count; j++) - { - var fileSymbol = fileSymbolTable.Symbols[j]; - var file2Symbol = file2SymbolTable.Symbols[j]; - - Assert.AreEqual(fileSymbol.ToString(), file2Symbol.ToString(), $"Invalid symbol [{j}]"); - } - } - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs deleted file mode 100644 index 1793215c6da971..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Dwarf/DwarfTests.cs +++ /dev/null @@ -1,546 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using LibObjectFile.Dwarf; -using LibObjectFile.Elf; -using NUnit.Framework; - -namespace LibObjectFile.Tests.Dwarf -{ - public class DwarfTests - { - [TestCase(0UL)] - [TestCase(1UL)] - [TestCase(50UL)] - [TestCase(0x7fUL)] - [TestCase(0x80UL)] - [TestCase(0x81UL)] - [TestCase(0x12345UL)] - [TestCase(2147483647UL)] // int.MaxValue - [TestCase(4294967295UL)] // uint.MaxValue - [TestCase(ulong.MaxValue)] - public void TestLEB128(ulong value) - { - var stream = new MemoryStream(); - - stream.WriteULEB128(value); - - Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfULEB128(value)); - - stream.Position = 0; - var readbackValue = stream.ReadULEB128(); - - Assert.AreEqual(value, readbackValue); - } - - [TestCase(0L)] - [TestCase(1L)] - [TestCase(50L)] - [TestCase(0x7fL)] - [TestCase(0x80L)] - [TestCase(0x81L)] - [TestCase(0x12345L)] - [TestCase(2147483647L)] // int.MaxValue - [TestCase(4294967295L)] // uint.MaxValue - [TestCase(long.MinValue)] - [TestCase(long.MaxValue)] - public void TestSignedLEB128(long value) - { - var stream = new MemoryStream(); - - { - // check positive - stream.WriteILEB128(value); - Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfILEB128(value)); - - stream.Position = 0; - var readbackValue = stream.ReadSignedLEB128(); - Assert.AreEqual(value, readbackValue); - } - - { - stream.Position = 0; - // Check negative - value = -value; - stream.WriteILEB128(value); - Assert.AreEqual((uint)stream.Position, DwarfHelper.SizeOfILEB128(value)); - - stream.Position = 0; - var readbackValue = stream.ReadSignedLEB128(); - Assert.AreEqual(value, readbackValue); - } - } - - - [Test] - public void TestDebugLineHelloWorld() - { - var cppName = "helloworld"; - var cppExe = $"{cppName}_debug"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -o {cppExe}"); - - ElfObjectFile elf; - using (var inStream = File.OpenRead(cppExe)) - { - Console.WriteLine($"ReadBack from {cppExe}"); - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - var elfContext = new DwarfElfContext(elf); - var inputContext = new DwarfReaderContext(elfContext); - inputContext.DebugLinePrinter = Console.Out; - var dwarf = DwarfFile.Read(inputContext); - - inputContext.DebugLineStream.Position = 0; - - var copyInputDebugLineStream = new MemoryStream(); - inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); - inputContext.DebugLineStream.Position = 0; - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = inputContext.IsLittleEndian, - EnableRelocation = false, - AddressSize = inputContext.AddressSize, - DebugLineStream = new MemoryStream() - }; - dwarf.Write(outputContext); - - Console.WriteLine(); - Console.WriteLine("====================================================="); - Console.WriteLine("Readback"); - Console.WriteLine("====================================================="); - Console.WriteLine(); - - var reloadContext = new DwarfReaderContext() - { - IsLittleEndian = outputContext.IsLittleEndian, - AddressSize = outputContext.AddressSize, - DebugLineStream = outputContext.DebugLineStream - }; - - reloadContext.DebugLineStream.Position = 0; - reloadContext.DebugLineStream = outputContext.DebugLineStream; - reloadContext.DebugLinePrinter = Console.Out; - - var dwarf2 = DwarfFile.Read(reloadContext); - - var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); - var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); - Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); - } - - [Test] - public void TestDebugLineLibMultipleObjs() - { - var cppName = "lib"; - var libShared = $"{cppName}_debug.so"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}_a.cpp {cppName}_b.cpp -gdwarf-4 -shared -o {libShared}"); - - ElfObjectFile elf; - using (var inStream = File.OpenRead(libShared)) - { - Console.WriteLine($"ReadBack from {libShared}"); - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - var elfContext = new DwarfElfContext(elf); - var inputContext = new DwarfReaderContext(elfContext); - inputContext.DebugLinePrinter = Console.Out; - var dwarf = DwarfFile.Read(inputContext); - - inputContext.DebugLineStream.Position = 0; - - var copyInputDebugLineStream = new MemoryStream(); - inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); - inputContext.DebugLineStream.Position = 0; - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = inputContext.IsLittleEndian, - EnableRelocation = false, - AddressSize = inputContext.AddressSize, - DebugLineStream = new MemoryStream() - }; - dwarf.Write(outputContext); - - Console.WriteLine(); - Console.WriteLine("====================================================="); - Console.WriteLine("Readback"); - Console.WriteLine("====================================================="); - Console.WriteLine(); - - var reloadContext = new DwarfReaderContext() - { - IsLittleEndian = outputContext.IsLittleEndian, - AddressSize = outputContext.AddressSize, - DebugLineStream = outputContext.DebugLineStream - }; - - reloadContext.DebugLineStream.Position = 0; - reloadContext.DebugLineStream = outputContext.DebugLineStream; - reloadContext.DebugLinePrinter = Console.Out; - - var dwarf2 = DwarfFile.Read(reloadContext); - - var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); - var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); - Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); - } - - [Test] - public void TestDebugLineSmall() - { - var cppName = "small"; - var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); - ElfObjectFile elf; - using (var inStream = File.OpenRead(cppObj)) - { - Console.WriteLine($"ReadBack from {cppObj}"); - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - var elfContext = new DwarfElfContext(elf); - var inputContext = new DwarfReaderContext(elfContext); - inputContext.DebugLinePrinter = Console.Out; - var dwarf = DwarfFile.Read(inputContext); - - inputContext.DebugLineStream.Position = 0; - var copyInputDebugLineStream = new MemoryStream(); - inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); - inputContext.DebugLineStream.Position = 0; - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = inputContext.IsLittleEndian, - AddressSize = inputContext.AddressSize, - DebugLineStream = new MemoryStream() - }; - dwarf.Write(outputContext); - - Console.WriteLine(); - Console.WriteLine("====================================================="); - Console.WriteLine("Readback"); - Console.WriteLine("====================================================="); - Console.WriteLine(); - - var reloadContext = new DwarfReaderContext() - { - IsLittleEndian = outputContext.IsLittleEndian, - AddressSize = outputContext.AddressSize, - DebugLineStream = outputContext.DebugLineStream - }; - - reloadContext.DebugLineStream.Position = 0; - reloadContext.DebugLineStream = outputContext.DebugLineStream; - reloadContext.DebugLinePrinter = Console.Out; - - var dwarf2 = DwarfFile.Read(reloadContext); - - var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); - var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); - Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); - } - - - - [Test] - public void TestDebugLineMultipleFunctions() - { - var cppName = "multiple_functions"; - var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); - - ElfObjectFile elf; - using (var inStream = File.OpenRead(cppObj)) - { - Console.WriteLine($"ReadBack from {cppObj}"); - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - var elfContext = new DwarfElfContext(elf); - var inputContext = new DwarfReaderContext(elfContext); - inputContext.DebugLinePrinter = Console.Out; - var dwarf = DwarfFile.Read(inputContext); - - inputContext.DebugLineStream.Position = 0; - var copyInputDebugLineStream = new MemoryStream(); - inputContext.DebugLineStream.CopyTo(copyInputDebugLineStream); - inputContext.DebugLineStream.Position = 0; - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = inputContext.IsLittleEndian, - AddressSize = inputContext.AddressSize, - DebugLineStream = new MemoryStream() - }; - dwarf.Write(outputContext); - - Console.WriteLine(); - Console.WriteLine("====================================================="); - Console.WriteLine("Readback"); - Console.WriteLine("====================================================="); - Console.WriteLine(); - - var reloadContext = new DwarfReaderContext() - { - IsLittleEndian = outputContext.IsLittleEndian, - AddressSize = outputContext.AddressSize, - DebugLineStream = outputContext.DebugLineStream - }; - - reloadContext.DebugLineStream.Position = 0; - reloadContext.DebugLineStream = outputContext.DebugLineStream; - reloadContext.DebugLinePrinter = Console.Out; - - var dwarf2 = DwarfFile.Read(reloadContext); - - var inputDebugLineBuffer = copyInputDebugLineStream.ToArray(); - var outputDebugLineBuffer = ((MemoryStream)reloadContext.DebugLineStream).ToArray(); - Assert.AreEqual(inputDebugLineBuffer, outputDebugLineBuffer); - } - - - [Test] - public void TestDebugInfoSmall() - { - var cppName = "small"; - var cppObj = $"{cppName}_debug.o"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -gdwarf-4 -c -o {cppObj}"); - - ElfObjectFile elf; - using (var inStream = File.OpenRead(cppObj)) - { - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - var elfContext = new DwarfElfContext(elf); - var inputContext = new DwarfReaderContext(elfContext); - var dwarf = DwarfFile.Read(inputContext); - - dwarf.AbbreviationTable.Print(Console.Out); - dwarf.InfoSection.Print(Console.Out); - dwarf.AddressRangeTable.Print(Console.Out); - - PrintStreamLength(inputContext); - - Console.WriteLine(); - Console.WriteLine("===================================================================="); - Console.WriteLine("Write Back"); - Console.WriteLine("===================================================================="); - - var outputContext = new DwarfWriterContext - { - IsLittleEndian = inputContext.IsLittleEndian, - AddressSize = inputContext.AddressSize, - DebugAbbrevStream = new MemoryStream(), - DebugLineStream = new MemoryStream(), - DebugInfoStream = new MemoryStream(), - DebugStringStream = new MemoryStream(), - DebugAddressRangeStream = new MemoryStream() - }; - dwarf.Write(outputContext); - - dwarf.AbbreviationTable.Print(Console.Out); - dwarf.InfoSection.Print(Console.Out); - dwarf.InfoSection.PrintRelocations(Console.Out); - dwarf.AddressRangeTable.Print(Console.Out); - dwarf.AddressRangeTable.PrintRelocations(Console.Out); - - dwarf.WriteToElf(elfContext); - - var cppObj2 = $"{cppName}_debug2.o"; - using (var outStream = new FileStream(cppObj2, FileMode.Create)) - { - elf.Write(outStream); - } - - PrintStreamLength(outputContext); - } - - - [Test] - public void CreateDwarf() - { - // Create ELF object - var elf = new ElfObjectFile(ElfArch.X86_64); - - var codeSection = new ElfBinarySection(new MemoryStream(new byte[0x64])).ConfigureAs(ElfSectionSpecialType.Text); - elf.AddSection(codeSection); - var stringSection = new ElfStringTable(); - elf.AddSection(stringSection); - elf.AddSection(new ElfSymbolTable() { Link = stringSection }); - elf.AddSection(new ElfSectionHeaderStringTable()); - - var elfDiagnostics = new DiagnosticBag(); - elf.UpdateLayout(elfDiagnostics); - Assert.False(elfDiagnostics.HasErrors); - - // Create DWARF Object - var dwarfFile = new DwarfFile(); - - // Create .debug_line information - var fileName = new DwarfFileName() - { - Name = "check1.cpp", - Directory = Environment.CurrentDirectory, - }; - var fileName2 = new DwarfFileName() - { - Name = "check2.cpp", - Directory = Environment.CurrentDirectory, - }; - - // First line table - for (int i = 0; i < 2; i++) - { - var lineTable = new DwarfLineProgramTable(); - dwarfFile.LineSection.AddLineProgramTable(lineTable); - - lineTable.AddressSize = DwarfAddressSize.Bit64; - lineTable.FileNames.Add(fileName); - lineTable.FileNames.Add(fileName2); - lineTable.AddLineSequence(new DwarfLineSequence() - { - - new DwarfLine() - { - File = fileName, - Address = 0, - Column = 1, - Line = 1, - }, - new DwarfLine() - { - File = fileName, - Address = 1, - Column = 1, - Line = 2, - } - } - ); - // NOTE: doesn't seem to be generated by regular GCC - // (it seems that only one line sequence is usually used) - lineTable.AddLineSequence(new DwarfLineSequence() - { - - new DwarfLine() - { - File = fileName2, - Address = 0, - Column = 1, - Line = 1, - }, - } - ); - } - - // Create .debug_info - var rootDIE = new DwarfDIECompileUnit() - { - Name = fileName.Name, - LowPC = 0, // 0 relative to base virtual address - HighPC = (int)codeSection.Size, // default is offset/length after LowPC - CompDir = fileName.Directory, - StmtList = dwarfFile.LineSection.LineTables[0], - }; - var subProgram = new DwarfDIESubprogram() - { - Name = "MyFunction", - }; - rootDIE.AddChild(subProgram); - - var locationList = new DwarfLocationList(); - var regExpression = new DwarfExpression(); - regExpression.AddOperation(new DwarfOperation { Kind = DwarfOperationKindEx.Reg0 }); - var regExpression2 = new DwarfExpression(); - regExpression2.AddOperation(new DwarfOperation { Kind = DwarfOperationKindEx.Reg2 }); - locationList.AddLocationListEntry(new DwarfLocationListEntry - { - Start = 0, - End = 0x10, - Expression = regExpression, - }); - locationList.AddLocationListEntry(new DwarfLocationListEntry - { - Start = 0x10, - End = 0x20, - Expression = regExpression2, - }); - var variable = new DwarfDIEVariable() - { - Name = "a", - Location = locationList, - }; - dwarfFile.LocationSection.AddLocationList(locationList); - subProgram.AddChild(variable); - - var cu = new DwarfCompilationUnit() - { - AddressSize = DwarfAddressSize.Bit64, - Root = rootDIE - }; - dwarfFile.InfoSection.AddUnit(cu); - - // AddressRange table - dwarfFile.AddressRangeTable.AddressSize = DwarfAddressSize.Bit64; - dwarfFile.AddressRangeTable.Unit = cu; - dwarfFile.AddressRangeTable.Ranges.Add(new DwarfAddressRange(0, 0, codeSection.Size)); - - // Transfer DWARF To ELF - var dwarfElfContext = new DwarfElfContext(elf); - dwarfFile.WriteToElf(dwarfElfContext); - - var outputFileName = "create_dwarf.o"; - using (var output = new FileStream(outputFileName, FileMode.Create)) - { - elf.Write(output); - } - - elf.Print(Console.Out); - Console.WriteLine(); - dwarfFile.AbbreviationTable.Print(Console.Out); - Console.WriteLine(); - dwarfFile.AddressRangeTable.Print(Console.Out); - Console.WriteLine(); - dwarfFile.InfoSection.Print(Console.Out); - - Console.WriteLine("ReadBack --debug-dump=rawline"); - var readelf = LinuxUtil.ReadElf(outputFileName, "--debug-dump=rawline").TrimEnd(); - Console.WriteLine(readelf); - } - - private static void PrintStreamLength(DwarfReaderWriterContext context) - { - if (context.DebugInfoStream != null) - { - Console.WriteLine($".debug_info {context.DebugInfoStream.Length}"); - } - if (context.DebugAbbrevStream != null) - { - Console.WriteLine($".debug_abbrev {context.DebugAbbrevStream.Length}"); - } - if (context.DebugAddressRangeStream != null) - { - Console.WriteLine($".debug_aranges {context.DebugAddressRangeStream.Length}"); - } - if (context.DebugStringStream != null) - { - Console.WriteLine($".debug_str {context.DebugStringStream.Length}"); - } - if (context.DebugLineStream != null) - { - Console.WriteLine($".debug_line {context.DebugLineStream.Length}"); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs deleted file mode 100644 index 75e36f51dd220a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfSimpleTests.cs +++ /dev/null @@ -1,482 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using LibObjectFile.Elf; -using NUnit.Framework; - -namespace LibObjectFile.Tests.Elf -{ - public class ElfSimpleTests : ElfTestBase - { - [Test] - public void TryReadThrows() - { - static void CheckInvalidLib(bool isReadOnly) - { - using var stream = File.OpenRead("TestFiles/cmnlib.b00"); - Assert.False(ElfObjectFile.TryRead(stream, out var elf, out var diagnostics, new ElfReaderOptions() { ReadOnly = isReadOnly })); - Assert.NotNull(elf); - Assert.AreEqual(4, diagnostics.Messages.Count, "Invalid number of error messages found"); - Assert.AreEqual(DiagnosticId.ELF_ERR_IncompleteProgramHeader32Size, diagnostics.Messages[0].Id); - for (int i = 1; i < diagnostics.Messages.Count; i++) - { - Assert.AreEqual(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, diagnostics.Messages[i].Id); - } - } - - CheckInvalidLib(false); - CheckInvalidLib(true); - } - - [Test] - public void TryReadFailed() - { - using var stream = File.OpenRead(typeof(ElfSimpleTests).Assembly.Location); - - Assert.False(ElfObjectFile.TryRead(stream, out var elfObjectFile, out var diagnostics)); - Assert.True(diagnostics.HasErrors); - Assert.AreEqual(1, diagnostics.Messages.Count); - Assert.AreEqual(DiagnosticId.ELF_ERR_InvalidHeaderMagic, diagnostics.Messages[0].Id); - } - - - [Test] - public void SimpleEmptyWithDefaultSections() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - AssertReadElf(elf, "empty_default.elf"); - } - - [Test] - public void SimpleEmpty() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - for (int i = elf.Sections.Count - 1; i >= 0; i--) - { - elf.RemoveSectionAt(i); - } - AssertReadElf(elf, "empty.elf"); - } - - [Test] - public void SimpleCodeSection() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - var codeStream = new MemoryStream(); - codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); - codeStream.Position = 0; - - var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); - elf.AddSection(codeSection); - elf.AddSection(new ElfSectionHeaderStringTable()); - - AssertReadElf(elf, "test.elf"); - } - - [Test] - public void TestBss() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - var stream = new MemoryStream(); - stream.Write(new byte[] { 1, 2, 3, 4 }); - stream.Position = 0; - var codeSection = new ElfBinarySection(stream).ConfigureAs(ElfSectionSpecialType.Text); - elf.AddSection(codeSection); - - elf.AddSection(new ElfAlignedShadowSection(1024)); - - var bssSection = new ElfBinarySection().ConfigureAs(ElfSectionSpecialType.Bss); - elf.AddSection(bssSection); - - elf.AddSection(new ElfSectionHeaderStringTable()); - - var diagnostics = new DiagnosticBag(); - elf.UpdateLayout(diagnostics); - Assert.False(diagnostics.HasErrors); - - Assert.AreEqual(1024, bssSection.Offset); - - AssertReadElf(elf, "test_bss.elf"); - } - - [Test] - public void SimpleCodeSectionAndSymbolSection() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - var codeStream = new MemoryStream(); - codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); - codeStream.Position = 0; - - var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); - elf.AddSection(codeSection); - - var stringSection = new ElfStringTable(); - elf.AddSection(stringSection); - - var symbolSection = new ElfSymbolTable() - { - Link = stringSection, - - Entries = - { - new ElfSymbol() - { - Name = "local_symbol", - Bind = ElfSymbolBind.Local, - Section = codeSection, - Size = 16, - Type = ElfSymbolType.Function, - Visibility = ElfSymbolVisibility.Protected, - Value = 0x7896 - }, - new ElfSymbol() - { - Name = "GlobalSymbol", - Bind = ElfSymbolBind.Global, - Section = codeSection, - Size = 4, - Type = ElfSymbolType.Function, - Value = 0x12345 - } - } - }; - elf.AddSection(symbolSection); - elf.AddSection(new ElfSectionHeaderStringTable()); - - AssertReadElf(elf, "test2.elf"); - } - - [Test] - public void SimpleProgramHeaderAndCodeSectionAndSymbolSection() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - var codeStream = new MemoryStream(); - codeStream.Write(new byte[4096]); - - var codeSection = elf.AddSection( - new ElfBinarySection(codeStream) - { - VirtualAddress = 0x1000, - Alignment = 4096 - }.ConfigureAs(ElfSectionSpecialType.Text) - ); - - var dataStream = new MemoryStream(); - dataStream.Write(new byte[1024]); - - var dataSection = elf.AddSection( - new ElfBinarySection(dataStream) - { - VirtualAddress = 0x2000, - Alignment = 4096 - }.ConfigureAs(ElfSectionSpecialType.ReadOnlyData) - ); - - var stringSection = elf.AddSection(new ElfStringTable()); - - var symbolSection = elf.AddSection( - new ElfSymbolTable() - { - Link = stringSection, - - Entries = - { - new ElfSymbol() - { - Name = "local_symbol", - Bind = ElfSymbolBind.Local, - Section = codeSection, - Size = 16, - Type = ElfSymbolType.Function, - Visibility = ElfSymbolVisibility.Protected, - Value = 0x7896 - }, - new ElfSymbol() - { - Name = "GlobalSymbol", - Bind = ElfSymbolBind.Global, - Section = codeSection, - Size = 4, - Type = ElfSymbolType.Function, - Value = 0x12345 - } - } - } - ); - elf.AddSection(new ElfSectionHeaderStringTable()); - - elf.AddSegment(new ElfSegment() - { - Type = ElfSegmentTypeCore.Load, - Range = codeSection, - VirtualAddress = 0x1000, - PhysicalAddress = 0x1000, - Flags = ElfSegmentFlagsCore.Readable|ElfSegmentFlagsCore.Executable, - Size = 4096, - SizeInMemory = 4096, - Alignment = 4096, - }); - - elf.AddSegment(new ElfSegment() - { - Type = ElfSegmentTypeCore.Load, - Range = dataSection, - VirtualAddress = 0x2000, - PhysicalAddress = 0x2000, - Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Writable, - Size = 1024, - SizeInMemory = 1024, - Alignment = 4096, - }); - - AssertReadElf(elf, "test3.elf"); - } - - - [Test] - public void SimpleProgramHeaderAndCodeSectionAndSymbolSectionAndRelocation() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - var codeStream = new MemoryStream(); - codeStream.Write(new byte[4096]); - - var codeSection = elf.AddSection( - new ElfBinarySection(codeStream) - { - VirtualAddress = 0x1000, - Alignment = 4096 - }.ConfigureAs(ElfSectionSpecialType.Text) - ); - - - var dataStream = new MemoryStream(); - dataStream.Write(new byte[1024]); - - var dataSection = elf.AddSection( - new ElfBinarySection(dataStream) - { - VirtualAddress = 0x2000, - Alignment = 4096 - }.ConfigureAs(ElfSectionSpecialType.ReadOnlyData) - ); - - var stringSection = elf.AddSection(new ElfStringTable()); - - var symbolSection = elf.AddSection( - new ElfSymbolTable() - { - Link = stringSection, - - Entries = - { - new ElfSymbol() - { - Name = "local_symbol", - Bind = ElfSymbolBind.Local, - Section = codeSection, - Size = 16, - Type = ElfSymbolType.Function, - Visibility = ElfSymbolVisibility.Protected, - Value = 0x7896 - }, - new ElfSymbol() - { - Name = "GlobalSymbol", - Bind = ElfSymbolBind.Global, - Section = codeSection, - Size = 4, - Type = ElfSymbolType.Function, - Value = 0x12345 - } - } - } - ); - - elf.AddSegment( - new ElfSegment() - { - Type = ElfSegmentTypeCore.Load, - Range = codeSection, - VirtualAddress = 0x1000, - PhysicalAddress = 0x1000, - Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Executable, - Size = 4096, - SizeInMemory = 4096, - Alignment = 4096, - } - ); - - elf.AddSegment( - new ElfSegment() - { - Type = ElfSegmentTypeCore.Load, - Range = dataSection, - VirtualAddress = 0x2000, - PhysicalAddress = 0x2000, - Flags = ElfSegmentFlagsCore.Readable | ElfSegmentFlagsCore.Writable, - Size = 1024, - SizeInMemory = 1024, - Alignment = 4096, - } - ); - - var relocTable = elf.AddSection( - new ElfRelocationTable - { - Name = ".rela.text", - Link = symbolSection, - Info = codeSection, - Entries = - { - new ElfRelocation() - { - SymbolIndex = 1, - Type = ElfRelocationType.R_X86_64_32, - Offset = 0 - }, - new ElfRelocation() - { - SymbolIndex = 2, - Type = ElfRelocationType.R_X86_64_8, - Offset = 0 - } - } - } - ); - - elf.AddSection(new ElfSectionHeaderStringTable()); - - AssertReadElf(elf, "test4.elf"); - } - - - [Test] - public void TestHelloWorld() - { - var cppName = "helloworld"; - LinuxUtil.RunLinuxExe("gcc", $"{cppName}.cpp -o {cppName}"); - - ElfObjectFile elf; - using (var inStream = File.OpenRead(cppName)) - { - Console.WriteLine($"ReadBack from {cppName}"); - elf = ElfObjectFile.Read(inStream); - elf.Print(Console.Out); - } - - using (var outStream = File.OpenWrite($"{cppName}_copy")) - { - elf.Write(outStream); - outStream.Flush(); - } - - var expected = LinuxUtil.ReadElf(cppName); - var result = LinuxUtil.ReadElf($"{cppName}_copy"); - if (expected != result) - { - Console.WriteLine("=== Result:"); - Console.WriteLine(result); - - Console.WriteLine("=== Expected:"); - Console.WriteLine(expected); - - Assert.AreEqual(expected, result); - } - } - - [Test] - public void TestAlignedSection() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - - // By default 0x1000 - var alignedSection = new ElfAlignedShadowSection(); - elf.AddSection(alignedSection); - - var codeStream = new MemoryStream(); - codeStream.Write(Encoding.UTF8.GetBytes("This is a text")); - codeStream.Position = 0; - - var codeSection = new ElfBinarySection(codeStream).ConfigureAs(ElfSectionSpecialType.Text); - elf.AddSection(codeSection); - - elf.AddSection(new ElfSectionHeaderStringTable()); - - var diagnostics = elf.Verify(); - Assert.False(diagnostics.HasErrors); - - elf.UpdateLayout(diagnostics); - Assert.False(diagnostics.HasErrors); - - elf.Print(Console.Out); - - Assert.AreEqual(alignedSection.UpperAlignment, codeSection.Offset, "Invalid alignment"); - } - - [Test] - public void TestManySections() - { - var elf = new ElfObjectFile(ElfArch.X86_64); - var stringTable = new ElfStringTable(); - var symbolTable = new ElfSymbolTable { Link = stringTable }; - - for (int i = 0; i < ushort.MaxValue; i++) - { - var section = new ElfBinarySection { Name = $".section{i}" }; - elf.AddSection(section); - symbolTable.Entries.Add(new ElfSymbol { Type = ElfSymbolType.Section, Section = section }); - } - - elf.AddSection(stringTable); - elf.AddSection(symbolTable); - elf.AddSection(new ElfSectionHeaderStringTable()); - - var diagnostics = elf.Verify(); - Assert.True(diagnostics.HasErrors); - Assert.AreEqual(DiagnosticId.ELF_ERR_MissingSectionHeaderIndices, diagnostics.Messages[0].Id); - - elf.AddSection(new ElfSymbolTableSectionHeaderIndices { Link = symbolTable }); - diagnostics = elf.Verify(); - Assert.False(diagnostics.HasErrors); - - uint visibleSectionCount = elf.VisibleSectionCount; - - using (var outStream = File.OpenWrite("manysections")) - { - elf.Write(outStream); - outStream.Flush(); - } - - using (var inStream = File.OpenRead("manysections")) - { - elf = ElfObjectFile.Read(inStream); - } - - Assert.AreEqual(visibleSectionCount, elf.VisibleSectionCount); - Assert.True(elf.Sections[0] is ElfNullSection); - Assert.True(elf.Sections[1] is ElfProgramHeaderTable); - - for (int i = 0; i < ushort.MaxValue; i++) - { - Assert.True(elf.Sections[i + 2] is ElfBinarySection); - Assert.AreEqual($".section{i}", elf.Sections[i + 2].Name.Value); - } - - Assert.True(elf.Sections[ushort.MaxValue + 3] is ElfSymbolTable); - symbolTable = (ElfSymbolTable)elf.Sections[ushort.MaxValue + 3]; - for (int i = 0; i < ushort.MaxValue; i++) - { - Assert.AreEqual($".section{i}", symbolTable.Entries[i + 1].Section.Section.Name.Value); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs deleted file mode 100644 index 7377d9a3bfc8e1..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/Elf/ElfTestBase.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using LibObjectFile.Elf; -using NUnit.Framework; - -namespace LibObjectFile.Tests.Elf -{ - public abstract class ElfTestBase - { - protected static void AssertReadElf(ElfObjectFile elf, string fileName) - { - AssertReadElfInternal(elf, fileName); - AssertReadBack(elf, fileName, readAsReadOnly: false); - AssertReadBack(elf, fileName, readAsReadOnly: true); - AssertLsbMsb(elf, fileName); - } - - private static void AssertReadElfInternal(ElfObjectFile elf, string fileName, bool writeFile = true, string context = null) - { - if (writeFile) - { - using (var stream = new FileStream(Path.Combine(Environment.CurrentDirectory, fileName), FileMode.Create)) - { - elf.Write(stream); - stream.Flush(); - Assert.AreEqual(stream.Length, (long)elf.Layout.TotalSize); - } - } - - var stringWriter = new StringWriter(); - elf.Print(stringWriter); - - var result = stringWriter.ToString().Replace("\r\n", "\n").TrimEnd(); - Console.WriteLine(result); - var readelf = LinuxUtil.ReadElf(fileName).TrimEnd(); - if (readelf != result) - { - Console.WriteLine("=== Expected:"); - Console.WriteLine(readelf); - Console.WriteLine("=== Result:"); - Console.WriteLine(result); - if (context != null) - { - Assert.AreEqual(readelf, result, context); - } - else - { - Assert.AreEqual(readelf, result); - } - } - } - - private static void AssertReadBack(ElfObjectFile elf, string fileName, bool readAsReadOnly) - { - ElfObjectFile newObjectFile; - - var filePath = Path.Combine(Environment.CurrentDirectory, fileName); - using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) - { - newObjectFile = ElfObjectFile.Read(stream, new ElfReaderOptions() {ReadOnly = readAsReadOnly}); - - Console.WriteLine(); - Console.WriteLine("============================================================================="); - Console.WriteLine($"readback {(readAsReadOnly ? "as readonly" : "as readwrite")}"); - Console.WriteLine("============================================================================="); - Console.WriteLine(); - - AssertReadElfInternal(newObjectFile, fileName, false, $"Unexpected error while reading back {fileName}"); - - var originalBuffer = File.ReadAllBytes(filePath); - var memoryStream = new MemoryStream(); - newObjectFile.Write(memoryStream); - var newBuffer = memoryStream.ToArray(); - - Assert.AreEqual(originalBuffer, newBuffer, "Invalid binary diff between write -> (original) -> read -> write -> (new)"); - } - } - - private static void AssertLsbMsb(ElfObjectFile elf, string fileName) - { - Console.WriteLine(); - Console.WriteLine("*****************************************************************************"); - Console.WriteLine("LSB to MSB"); - Console.WriteLine("*****************************************************************************"); - Console.WriteLine(); - - elf.Encoding = ElfEncoding.Msb; - var newFileName = Path.GetFileNameWithoutExtension(fileName) + "_msb.elf"; - AssertReadElfInternal(elf, newFileName); - AssertReadBack(elf, newFileName, readAsReadOnly: false); - AssertReadBack(elf, newFileName, readAsReadOnly: true); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj deleted file mode 100644 index 924e41dbe0e5d6..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LibObjectFile.Tests.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - net7.0 - true - false - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs deleted file mode 100644 index 06205fcb0d3562..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/LinuxUtil.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; - -namespace LibObjectFile.Tests -{ - public static class LinuxUtil - { - public static string ReadElf(string file, string arguments = "-W -a") - { - return RunLinuxExe("readelf", $"{file} {arguments}"); - } - - public static string RunLinuxExe(string exe, string arguments, string distribution = "Ubuntu") - { - if (exe == null) throw new ArgumentNullException(nameof(exe)); - if (arguments == null) throw new ArgumentNullException(nameof(arguments)); - if (distribution == null) throw new ArgumentNullException(nameof(distribution)); - - // redirect to a file the output as there is a bug reading back stdout with WSL - var wslOut = $"wsl_stdout_{Guid.NewGuid()}.txt"; - - bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - if (isWindows) - { - arguments = $"-d {distribution} {exe} {arguments} > {wslOut}"; - exe = "wsl.exe"; - } - - StringBuilder errorBuilder = null; - StringBuilder outputBuilder = new StringBuilder(); - - using (var process = new Process() - { - StartInfo = new ProcessStartInfo(exe, arguments) - { - UseShellExecute = false, - RedirectStandardOutput = !isWindows, - CreateNoWindow = true, - RedirectStandardError = true, - }, - }) - { - - process.ErrorDataReceived += (sender, args) => - { - if (errorBuilder == null) - { - errorBuilder = new StringBuilder(); - } - - errorBuilder.Append(args.Data).Append('\n'); - }; - - if (!isWindows) - { - process.OutputDataReceived += (sender, args) => { outputBuilder.Append(args.Data).Append('\n'); }; - } - - process.Start(); - process.BeginErrorReadLine(); - - if (!isWindows) - { - process.BeginOutputReadLine(); - } - - process.WaitForExit(); - - if (process.ExitCode != 0) - { - throw new InvalidOperationException($"Error while running command `{exe} {arguments}`: {errorBuilder}"); - } - - if (isWindows) - { - var generated = Path.Combine(Environment.CurrentDirectory, wslOut); - var result = File.ReadAllText(generated); - try - { - File.Delete(generated); - } - catch - { - // ignore - } - - return result; - } - } - - return outputBuilder.ToString(); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/TestFiles/cmnlib.b00 deleted file mode 100644 index 39ee3f3b288e087e123e0061ad4ffb4a0bf98519..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmb<-^>JflWMqH=CI$@#7|#SM$i%?FYQmtvzyg%R2DTss*+EROegPn31CRy8Cfq -int main(int argc, char** argv) -{ - printf("HelloWorld!\n"); -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp deleted file mode 100644 index feeda9f1c11445..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_a.cpp +++ /dev/null @@ -1,4 +0,0 @@ -int process_add(int a, int b) -{ - return a + b; -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp deleted file mode 100644 index a48e8274cb0768..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/lib_b.cpp +++ /dev/null @@ -1,4 +0,0 @@ -float process_add2(float a, float b) -{ - return a + b; -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp deleted file mode 100644 index dea924723f9d12..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/multiple_functions.cpp +++ /dev/null @@ -1,14 +0,0 @@ -int process_add(int a, int b) -{ - return a + b; -} - -float process_add2(float a, float b) -{ - return a + b; -} - -float process_both(int a, float b) -{ - return (float)process_add(a, (int)b) + process_add2((float)a, b); -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp deleted file mode 100644 index b614c4e53730ac..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.Tests/small.cpp +++ /dev/null @@ -1,22 +0,0 @@ -struct MyStruct -{ - unsigned char* str; - - int count; -}; - -typedef char (*TransformCharDelegate)(char); - -int ProcessStructs(MyStruct* input, MyStruct* output, TransformCharDelegate transform) -{ - int acc = 0; - for(int i = 0; i < input->count; i++) - { - auto value1 = input->str[i]; - auto value2 = output->str[i]; - auto value3 = transform(value1) + transform(value2); - - acc += value1 + value2 + value3; - } - return acc; -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln deleted file mode 100644 index 91e14458030749..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln +++ /dev/null @@ -1,59 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.32210.238 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile", "LibObjectFile\LibObjectFile.csproj", "{4395EB77-43C4-4292-8449-D7B03D479313}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile.Tests", "LibObjectFile.Tests\LibObjectFile.Tests.csproj", "{DE76269F-077C-4F8D-8DEF-A2EB5764996D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibObjectFile.CodeGen", "LibObjectFile.CodeGen\LibObjectFile.CodeGen.csproj", "{A42D56D8-B0D1-4809-9210-B1285F1C4409}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D117A3-A530-46EE-A873-4FE18DCA6841}" - ProjectSection(SolutionItems) = preProject - ..\.gitignore = ..\.gitignore - ..\changelog.md = ..\changelog.md - Directory.Build.props = Directory.Build.props - ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml - dotnet-releaser.toml = dotnet-releaser.toml - ..\license.txt = ..\license.txt - ..\readme.md = ..\readme.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{BD580DD4-4E27-4FE6-8E3B-E773BE9555E0}" - ProjectSection(SolutionItems) = preProject - ..\doc\readme.md = ..\doc\readme.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "objdasm", "objdasm\objdasm.csproj", "{056AA737-6B5F-47A6-8426-E7918D930C5C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4395EB77-43C4-4292-8449-D7B03D479313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4395EB77-43C4-4292-8449-D7B03D479313}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4395EB77-43C4-4292-8449-D7B03D479313}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4395EB77-43C4-4292-8449-D7B03D479313}.Release|Any CPU.Build.0 = Release|Any CPU - {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE76269F-077C-4F8D-8DEF-A2EB5764996D}.Release|Any CPU.Build.0 = Release|Any CPU - {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A42D56D8-B0D1-4809-9210-B1285F1C4409}.Release|Any CPU.Build.0 = Release|Any CPU - {056AA737-6B5F-47A6-8426-E7918D930C5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {056AA737-6B5F-47A6-8426-E7918D930C5C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {056AA737-6B5F-47A6-8426-E7918D930C5C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {056AA737-6B5F-47A6-8426-E7918D930C5C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1137A8C0-B13F-4D49-ACC2-425BBA1B193C} - EndGlobalSection -EndGlobal diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings deleted file mode 100644 index 446dc7e29ccc57..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile.sln.DotSettings +++ /dev/null @@ -1,16 +0,0 @@ - - Copyright (c) Alexandre Mutel. All rights reserved. -This file is licensed under the BSD-Clause 2 license. -See the license.txt file in the project root for more information. - BSD - DIE - GNU - LEB - True - True - True - True - True - True - True - True \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd deleted file mode 100644 index a3f7e9725a7dc9..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/Ar.cd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - AABAEACAAABAAQKAAAAQAAAwgAAAAACAAAAAAAMAEIA= - Ar\ArArchiveFile.cs - - - - - - - - - - - - EgAAIAAMAAAAEFIFAkACAAQgEEAAEIQAAAGRAIEEgAA= - Ar\ArFile.cs - - - - - - AAgIAAAAAABAAQAFAAAAAAQgEAAAAAAAAAAAIAEAAAA= - Ar\ArSymbolTable.cs - - - - - - - - - AAAAAAAAAAAAAAAAAAAAAAAgAAAIAAAAAAAAIAEAAAA= - Ar\ArBinaryFile.cs - - - - - - AAAAAAAAAAAAQAAAAAAAAAAgAAAAAAAAAAAAIAEAAAA= - Ar\ArElfFile.cs - - - - - - - - - IIAMBgAQAAAEAYGAAAAEHAAggCAoQAkIEUgAiAUBACA= - Elf\ElfObjectFile.cs - - - - - - AAAAAAAAAAAQAAAEAAAQAAQAAAAEAAAAAAAAAAAAAAA= - Ar\ArSymbol.cs - - - - \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs deleted file mode 100644 index a95b5b2bfaf17c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFile.cs +++ /dev/null @@ -1,381 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace LibObjectFile.Ar -{ - /// - /// An 'ar' archive file. - /// - public sealed class ArArchiveFile : ObjectFileNode - { - private readonly List _files; - - /// - /// Gets the bytes !<arch>\n involved in the magic file header of an archive - /// - public static ReadOnlySpan Magic => new ReadOnlySpan(new byte[] - { - (byte)'!', - (byte)'<', - (byte)'a', - (byte)'r', - (byte)'c', - (byte)'h', - (byte)'>', - (byte)'\n', - }); - - /// - /// Initializes a new instance. - /// - public ArArchiveFile() - { - _files = new List(); - Kind = ArArchiveKind.GNU; - } - - /// - /// Gets or sets the type of this archive file. - /// - public ArArchiveKind Kind { get; set; } - - /// - /// Gets the associated to this instance. Must be first entry in - /// - public ArSymbolTable SymbolTable { get; private set; } - - /// - /// Internal extended file names used for GNU entries. - /// - internal ArLongNamesTable LongNamesTable { get; set; } - - /// - /// Gets the file entries. Use or to manipulate the entries. - /// - public IReadOnlyList Files => _files; - - /// - /// Adds a file to . - /// - /// A file - public void AddFile(ArFile file) - { - if (file == null) throw new ArgumentNullException(nameof(file)); - if (file.Parent != null) - { - if (file.Parent == this) throw new InvalidOperationException("Cannot add the file as it is already added"); - if (file.Parent != this) throw new InvalidOperationException($"Cannot add the file as it is already added to another {nameof(ArArchiveFile)} instance"); - } - - if (file is ArSymbolTable symbolTable) - { - InsertFileAt(0, file); - return; - } - - file.Parent = this; - file.Index = (uint)_files.Count; - _files.Add(file); - } - - /// - /// Inserts a file into at the specified index. - /// - /// Index into to insert the specified file - /// The file to insert - public void InsertFileAt(int index, ArFile file) - { - if (index < 0 || index > _files.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_files.Count}"); - if (file == null) throw new ArgumentNullException(nameof(file)); - if (file.Parent != null) - { - if (file.Parent == this) throw new InvalidOperationException("Cannot add the file as it is already added"); - if (file.Parent != this) throw new InvalidOperationException($"Cannot add the file as it is already added to another {nameof(ArArchiveFile)} instance"); - } - - if (file is ArSymbolTable symbolTable) - { - if (SymbolTable == null) - { - if (index != 0) - { - throw new ArgumentException($"Cannot only add a symbol table at index 0", nameof(file)); - } - SymbolTable = symbolTable; - } - else - { - throw new ArgumentException($"Cannot add this symbol table as an existing symbol table is already present in the file entries of {this}", nameof(file)); - } - } - else - { - if (SymbolTable != null && index == 0) - { - throw new ArgumentException($"Cannot add the entry {file} at index 0 because a symbol table is already set and must be the first entry in the list of files", nameof(file)); - } - } - - file.Index = (uint)index; - _files.Insert(index, file); - file.Parent = this; - - // Update the index of following files - for (int i = index + 1; i < _files.Count; i++) - { - var nextFile = _files[i]; - nextFile.Index++; - } - } - - /// - /// Removes a file from - /// - /// The file to remove - public void RemoveFile(ArFile file) - { - if (file == null) throw new ArgumentNullException(nameof(file)); - if (file.Parent != this) - { - throw new InvalidOperationException($"Cannot remove this file as it is not part of this {nameof(ArArchiveFile)} instance"); - } - - // If we are removing the SymbolTable - if (file == SymbolTable) - { - SymbolTable = null; - } - - var i = (int)file.Index; - _files.RemoveAt(i); - file.Index = 0; - - // Update indices for other sections - for (int j = i + 1; j < _files.Count; j++) - { - var nextEntry = _files[j]; - nextEntry.Index--; - } - - file.Parent = null; - } - - /// - /// Removes a file from at the specified index. - /// - /// Index into to remove the specified file - public ArFile RemoveFileAt(int index) - { - if (index < 0 || index > _files.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_files.Count}"); - var file = _files[index]; - RemoveFile(file); - return file; - } - - public override void Verify(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - for (var i = 0; i < Files.Count; i++) - { - var item = Files[i]; - if (item.Name == null) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullFileEntryName, $"Invalid null FileName for file entry [{i}] in {this}"); - } - else if (Kind == ArArchiveKind.Common) - { - var count = Encoding.UTF8.GetByteCount(item.Name); - if (count > ArFile.FieldNameLength) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileEntryNameTooLong, $"Invalid length ({count} bytes) for file entry [{i}] {item.Name} in {this}. Must be <= {ArFile.FieldNameLength} for {Kind} ar file"); - } - } - - item.Verify(diagnostics); - } - } - - /// - /// Detects from the specified stream if there is an 'ar' archive file header. - /// - /// The stream to detect the presence of an 'ar' archive file header. - /// true if an 'ar' archive file header was detected. false otherwise. - public static bool IsAr(Stream stream) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - var startPosition = stream.Position; - var result = ArArchiveFileReader.IsAr(stream, null); - stream.Position = startPosition; - return result; - } - - /// - /// Detects from the specified stream if there is an 'ar' archive file header. - /// - /// The stream to detect the presence of an 'ar' archive file header. - /// The diagnostics - /// true if an 'ar' archive file header was detected. false otherwise. - public static bool IsAr(Stream stream, out DiagnosticBag diagnostics) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - var startPosition = stream.Position; - diagnostics = new DiagnosticBag(); - var result = ArArchiveFileReader.IsAr(stream, diagnostics); - stream.Position = startPosition; - return result; - } - - /// - /// Reads an 'ar' archive file from the specified stream. - /// - /// The stream to read 'ar' a archive file from. - /// The type of 'ar' archive to read. - /// An instance of if the read was successful. - /// In case of an invalid file. - public static ArArchiveFile Read(Stream stream, ArArchiveKind archiveKind) - { - return Read(stream, new ArArchiveFileReaderOptions(archiveKind)); - } - - /// - /// Reads an 'ar' archive file from the specified stream. - /// - /// The stream to read 'ar' a archive file from. - /// The options used for reading this 'ar' file. - /// An instance of if the read was successful. - /// In case of an invalid file. - public static ArArchiveFile Read(Stream stream, ArArchiveFileReaderOptions options) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - if (options == null) throw new ArgumentNullException(nameof(options)); - - if (!TryRead(stream, options, out var arFile, out var diagnostics)) - { - throw new ObjectFileException("Invalid ar file", diagnostics); - } - - return arFile; - } - - /// - /// Tries to reads an 'ar' archive file from the specified stream. - /// - /// The stream to read 'ar' a archive file from. - /// The type of 'ar' archive to read. - /// The output 'ar' archive file if the read was successful. - /// The output associated diagnostics after reading the archive. - /// true An instance of if the read was successful. - public static bool TryRead(Stream stream, ArArchiveKind archiveKind, out ArArchiveFile arArchiveFile, out DiagnosticBag diagnostics) - { - return TryRead(stream, new ArArchiveFileReaderOptions(archiveKind), out arArchiveFile, out diagnostics); - } - - /// - /// Tries to reads an 'ar' archive file from the specified stream. - /// - /// The stream to read 'ar' a archive file from. - /// The options used for reading this 'ar' file. - /// The output 'ar' archive file if the read was successful. - /// The output associated diagnostics after reading the archive. - /// true An instance of if the read was successful. - public static bool TryRead(Stream stream, ArArchiveFileReaderOptions options, out ArArchiveFile arArchiveFile, out DiagnosticBag diagnostics) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - if (options == null) throw new ArgumentNullException(nameof(options)); - - arArchiveFile = new ArArchiveFile { Kind = options.ArchiveKind }; - var reader = new ArArchiveFileReader(arArchiveFile, stream, options); - diagnostics = reader.Diagnostics; - reader.Read(); - - return !reader.Diagnostics.HasErrors; - } - - /// - /// Writes this 'ar' archive file to the specified stream. - /// - /// The stream to write to. - public void Write(Stream stream) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - var writer = new ArArchiveFileWriter(this, stream); - writer.Write(); - } - - public void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - Size = 0; - - if (Kind == ArArchiveKind.GNU) - { - if (LongNamesTable == null) - { - LongNamesTable = new ArLongNamesTable - { - Parent = this - }; - } - - if (SymbolTable != null && SymbolTable.Index == 0) - { - LongNamesTable.Index = 1; - } - else - { - LongNamesTable.Index = 1; - } - } - else - { - // Don't use headers - LongNamesTable = null; - } - - ulong size = (ulong)Magic.Length; - - // Clear the internal names - foreach (var entry in Files) - { - entry.InternalName = null; - } - - for (var i = 0; i < Files.Count; i++) - { - var entry = Files[i]; - - entry.UpdateLayout(diagnostics); - if (diagnostics.HasErrors) return; - - // If we have a GNU headers and they are required, add them to the offset and size - if (LongNamesTable != null && LongNamesTable.Index == i) - { - LongNamesTable.UpdateLayout(diagnostics); - if (diagnostics.HasErrors) return; - - var headerSize = LongNamesTable.Size; - if (headerSize > 0) - { - LongNamesTable.Offset = size; - size += ArFile.FileEntrySizeInBytes + LongNamesTable.Size; - if ((size & 1) != 0) size++; - } - } - - entry.Offset = size; - size += ArFile.FileEntrySizeInBytes + entry.Size; - if ((size & 1) != 0) size++; - } - - Size = size; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs deleted file mode 100644 index 557d7946e4b00f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReader.cs +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Diagnostics; -using System.IO; -using System.Text; -using LibObjectFile.Elf; - -namespace LibObjectFile.Ar -{ - /// - /// Class for reading and building an from a . - /// - public class ArArchiveFileReader : ObjectFileReaderWriter - { - private ArLongNamesTable _futureHeaders; - - internal ArArchiveFileReader(ArArchiveFile arArchiveFile, Stream stream, ArArchiveFileReaderOptions options) : base(stream) - { - ArArchiveFile = arArchiveFile; - Options = options; - IsReadOnly = options.IsReadOnly; - } - - public ArArchiveFileReaderOptions Options { get; } - - public override bool IsReadOnly { get; } - - internal ArArchiveFile ArArchiveFile { get; } - - internal static bool IsAr(Stream stream, DiagnosticBag diagnostics) - { - Span magic = stackalloc byte[ArArchiveFile.Magic.Length]; - int magicLength = stream.Read(magic); - if (magicLength != magic.Length) - { - if (diagnostics != null) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidMagicLength, $"Invalid length {magicLength} while trying to read ! from stream while expecting at least {magic.Length} bytes"); - } - return false; - } - - if (!magic.SequenceEqual(ArArchiveFile.Magic)) - { - if (diagnostics != null) - { - diagnostics.Error(DiagnosticId.AR_ERR_MagicNotFound, $"Magic !\\n not found"); - } - return false; - } - - return true; - } - - internal void Read() - { - if (!IsAr(Stream, Diagnostics)) - { - return; - } - - Span entryBuffer = stackalloc byte[ArFile.FileEntrySizeInBytes]; - - _futureHeaders = null; - - while (TryReadFileEntry(entryBuffer, out var fileEntry)) - { - if (fileEntry is ArLongNamesTable arGnuFutureHeaders) - { - if (_futureHeaders != null) - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidDuplicatedFutureHeadersTable, $"Invalid duplicated future headers table found at offset {fileEntry.Offset} while another table was already found at offset {_futureHeaders.Offset}. This file is invalid."); - break; - } - - _futureHeaders = arGnuFutureHeaders; - } - else - { - ArArchiveFile.AddFile(fileEntry); - } - } - - if (Diagnostics.HasErrors) return; - - // Perform a pass after all entries have been read - foreach (var arFileEntry in ArArchiveFile.Files) - { - arFileEntry.AfterReadInternal(this.Diagnostics); - } - } - - private bool TryReadFileEntry(Span buffer, out ArFile entry) - { - entry = null; - - Debug.Assert((Stream.Position & 1) == 0); - - long entryOffset = Stream.Position; - int length = Stream.Read(buffer); - if (length == 0) - { - return false; - } - - if (length < buffer.Length) - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileEntryLength, $"Invalid length {length} while trying to read a file entry from stream at offset {entryOffset}. Expecting {buffer.Length} bytes"); - return false; - } - // 0 16 File identifier ASCII - // discard right padding characters - int idLength = 16; - while (idLength > 0) - { - if (buffer[idLength - 1] != ' ') - { - break; - } - idLength--; - } - - string name = null; - ulong? bsdNameLength = null; - - if (idLength > 3 && ArArchiveFile.Kind == ArArchiveKind.BSD) - { - if (buffer[0] == '#' && buffer[1] == '1' && buffer[2] == '/') - { - // If we have a future header table, we are using it and expecting only numbers - if (!TryDecodeDecimal(entryOffset, buffer, 3, ArFile.FieldNameLength - 3, $"BSD Name length following #1/ at offset {entryOffset}", out ulong bsdNameLengthDecoded)) - { - // Don't try to process more entries, the archive might be corrupted - return false; - } - - bsdNameLength = bsdNameLengthDecoded; - } - } - - // If the last char is `/` - // Keep file names with / or // - // But remove trailing `/`for regular file names - if (!bsdNameLength.HasValue && ArArchiveFile.Kind != ArArchiveKind.Common && idLength > 0 && buffer[idLength - 1] == '/') - { - if (!(idLength == 1 || idLength == 2 && buffer[idLength - 2] == '/')) - { - idLength--; - } - } - - if (_futureHeaders != null && buffer[0] == (byte)'/') - { - // If we have a future header table, we are using it and expecting only numbers - if (!TryDecodeDecimal(entryOffset, buffer, 1, ArFile.FieldNameLength - 1, $"Name with offset to Future Headers Table at file offset {entryOffset}", out ulong offsetInFutureHeaders)) - { - // Don't try to process more entries, the archive might be corrupted - return false; - } - - // If the number is ok, check that we have actually a string for this offset - if (!_futureHeaders.FileNames.TryGetValue((int)offsetInFutureHeaders, out name)) - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidReferenceToFutureHeadersTable, $"Invalid reference {offsetInFutureHeaders} found at file offset {entryOffset}. This file is invalid."); - } - } - - if (!bsdNameLength.HasValue && name == null) - { - name = idLength == 0 ? string.Empty : Encoding.UTF8.GetString(buffer.Slice(0, idLength)); - } - - // 16 12 File modification timestamp Decimal - if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldTimestampOffset, ArFile.FieldTimestampLength, "File modification timestamp Decimal", out ulong timestamp)) - { - return false; - } - - // 28 6 Owner ID Decimal - if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldOwnerIdOffset, ArFile.FieldOwnerIdLength, "Owner ID", out ulong ownerId)) - { - return false; - } - - // 34 6 Group ID Decimal - if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldGroupIdOffset, ArFile.FieldGroupIdLength, "Group ID", out ulong groupId)) - { - return false; - } - - // 40 8 File mode Octal - if (!TryDecodeOctal(entryOffset, buffer, ArFile.FieldFileModeOffset, ArFile.FieldFileModeLength, "File mode", out uint fileMode)) - { - return false; - } - - // 48 10 File size in bytes Decimal - if (!TryDecodeDecimal(entryOffset, buffer, ArFile.FieldFileSizeOffset, ArFile.FieldFileSizeLength, "File size in bytes", out ulong fileSize)) - { - return false; - } - - // 58 2 Ending characters 0x60 0x0A - if (buffer[ArFile.FieldEndCharactersOffset] != 0x60 || buffer[ArFile.FieldEndCharactersOffset + 1] != '\n') - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII characters found 0x{buffer[ArFile.FieldEndCharactersOffset]:x} 0x{buffer[ArFile.FieldEndCharactersOffset+1]:x} instead of `\\n at the end of file entry at offset {entryOffset + ArFile.FieldEndCharactersOffset}"); - return false; - } - - entry = CreateFileEntryFromName(name); - entry.Timestamp = DateTimeOffset.FromUnixTimeSeconds((long)timestamp); - entry.OwnerId = (uint)ownerId; - entry.GroupId = (uint)groupId; - entry.FileMode = fileMode; - entry.Offset = (ulong)entryOffset; - entry.Size = fileSize; - - // Read the BSD name if necessary - if (bsdNameLength.HasValue) - { - var nameLength = (int) bsdNameLength.Value; - var bufferForName = ArrayPool.Shared.Rent(nameLength); - var streamPosition = Stream.Position; - var dataReadCount = Stream.Read(bufferForName, 0, nameLength); - if (dataReadCount != nameLength) - { - Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file while trying to read the filename from the data section of the file entry at offset of {streamPosition}. Expecting {nameLength} bytes while only {dataReadCount} bytes were read from the stream."); - return false; - } - name = Encoding.UTF8.GetString(bufferForName, 0, nameLength); - } - - if (!entry.IsSystem) - { - if (name.Contains('/')) - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterInFileEntryName, $"The character `/` was found in the entry `{name}` while it is invalid."); - return false; - } - entry.Name = name; - } - - entry.ReadInternal(this); - - // The end of an entry is always aligned - if ((Stream.Position & 1) != 0) - { - long padOffset = Stream.Position; - int pad = Stream.ReadByte(); - if (pad < 0) - { - Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file while trying to Invalid character 0x{pad:x} found at offset {padOffset} while expecting \\n 0xa"); - return false; - } - if (pad != '\n') - { - Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Invalid character 0x{pad:x} found at offset {padOffset} while expecting \\n 0xa"); - return false; - } - } - - return true; - } - - private bool TryDecodeDecimal(long entryOffset, Span buffer, int offset, int length, string fieldName, out ulong value) - { - value = 0; - // == 0, expect number or space - // == 1, expect space - int state = 0; - for (int i = 0; i < length; i++) - { - var c = buffer[offset + i]; - if (state == 0 && c >= '0' && c <= '9') - { - value = value * 10 + (ulong) (c - '0'); - } - else if (state >= 0 && c == ' ') - { - state = 1; - } - else - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII character 0x{c:x} found instead of {state switch { 0 => "' '/space or decimal 0-9", _ => "' '/space" }} in file entry at file offset {entryOffset + i} while decoding field entry `{fieldName}`"); - return false; - } - } - return true; - } - - private bool TryDecodeOctal(long entryOffset, Span buffer, int offset, int length, string fieldName, out uint value) - { - value = 0; - // == 0, expect number or space - // == 1, expect space - int state = 0; - for (int i = 0; i < length; i++) - { - var c = buffer[offset + i]; - if (state == 0 && c >= '0' && c <= '7') - { - value = value * 8 + (uint)(c - '0'); - } - else if (state >= 0 && c == ' ') - { - state = 1; - } - else - { - Diagnostics.Error(DiagnosticId.AR_ERR_InvalidCharacterFoundInFileEntry, $"Invalid ASCII character 0x{c:x} found instead of {state switch { 0 => "' '/space or octal 0-7", _ => "' '/space" }} in file entry at file offset {entryOffset + i} while decoding field entry `{fieldName}`"); - return false; - } - } - return true; - } - - private ArFile CreateFileEntryFromName(string name) - { - if (ArArchiveFile.Kind == ArArchiveKind.GNU) - { - switch (name) - { - case ArSymbolTable.DefaultGNUSymbolTableName: - return new ArSymbolTable(); - case ArLongNamesTable.DefaultName: - return new ArLongNamesTable(); - } - } - else if (ArArchiveFile.Kind == ArArchiveKind.BSD) - { - if (name == ArSymbolTable.DefaultBSDSymbolTableName) - { - return new ArSymbolTable(); - } - } - - if (Options.ProcessObjectFiles) - { - if (ElfObjectFile.IsElf(Stream)) - { - return new ArElfFile(); - } - } - - return new ArBinaryFile(); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs deleted file mode 100644 index 5c476839a48c36..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileReaderOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Ar -{ - /// - /// Reader options used by and other methods. - /// - public class ArArchiveFileReaderOptions - { - /// - /// Initializes a new instance. - /// - /// Type of the 'ar' file to load (GNU, BSD...) - public ArArchiveFileReaderOptions(ArArchiveKind archiveKind) - { - ArchiveKind = archiveKind; - ProcessObjectFiles = true; - } - - /// - /// Gets or sets a boolean indicating if the file entries must keep a readonly view - /// on the original stream for the content of the file entries, or it should copy - /// them to modifiable . - /// - public bool IsReadOnly { get; set; } - - /// - /// Gets or sets the type of file to load - /// - public ArArchiveKind ArchiveKind { get; set; } - - /// - /// Gets or sets a boolean indicating if object files are being processed to return - /// typed entries () instead of generic binary file entry (). - /// Default is true - /// - public bool ProcessObjectFiles { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs deleted file mode 100644 index f0181cc47499e9..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveFileWriter.cs +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace LibObjectFile.Ar -{ - /// - /// Class for writing an to a . - /// - public class ArArchiveFileWriter: ObjectFileReaderWriter - { - private long _startStreamOffset; - - internal ArArchiveFileWriter(ArArchiveFile archiveFile, Stream stream) : base(stream) - { - ArArchiveFile = archiveFile; - IsReadOnly = false; - } - - private ArArchiveFile ArArchiveFile { get; } - - public override bool IsReadOnly { get; } - - internal void Write() - { - var localDiagnostics = new DiagnosticBag(); - ArArchiveFile.UpdateLayout(localDiagnostics); - if (localDiagnostics.HasErrors) - { - throw new ObjectFileException("Invalid ar file", localDiagnostics); - } - // Copy for warnings - localDiagnostics.CopyTo(Diagnostics); - - _startStreamOffset = Stream.Position; - - Stream.Write(ArArchiveFile.Magic); - Span entryBuffer = stackalloc byte[ArFile.FileEntrySizeInBytes]; - - var headers = ArArchiveFile.LongNamesTable; - - // Serialize all file entries - for (var i = 0; i < ArArchiveFile.Files.Count; i++) - { - var file = ArArchiveFile.Files[i]; - - // Serialize the headers at the correct position only if they are required - if (headers != null && headers.Index == i && headers.Size > 0) - { - WriteFileEntry(entryBuffer, headers); - if (Diagnostics.HasErrors) break; - } - - WriteFileEntry(entryBuffer, file); - if (Diagnostics.HasErrors) break; - } - - if (Diagnostics.HasErrors) - { - throw new ObjectFileException("Unexpected error while writing ar file", Diagnostics); - } - } - - private void WriteFileEntry(Span buffer, ArFile file) - { - Debug.Assert((ulong)(Stream.Position - _startStreamOffset) == file.Offset); - buffer.Fill((byte)' '); - - var name = file.InternalName; - - bool postFixSlash = false; - - if (name == null) - { - name = file.Name; - if (ArArchiveFile.Kind != ArArchiveKind.Common && !name.EndsWith("/")) - { - postFixSlash = true; - } - } - - uint? bsdNameLength = null; - - if (ArArchiveFile.Kind == ArArchiveKind.BSD) - { - var nameLength = Encoding.UTF8.GetByteCount(name); - if (nameLength > ArFile.FieldNameLength) - { - name = $"#1/{nameLength}"; - bsdNameLength = (uint)nameLength; - postFixSlash = false; - } - } - - // Encode Length - int length = Encoding.UTF8.GetBytes(name, buffer.Slice(0, ArFile.FieldNameLength)); - if (postFixSlash) - { - buffer[length] = (byte) '/'; - } - - if (!(file is ArLongNamesTable)) - { - // 16 12 File modification timestamp Decimal - EncodeDecimal(buffer, ArFile.FieldTimestampOffset, ArFile.FieldTimestampLength, (ulong)file.Timestamp.ToUnixTimeSeconds()); - // 28 6 Owner ID Decimal - EncodeDecimal(buffer, ArFile.FieldOwnerIdOffset, ArFile.FieldOwnerIdLength, file.OwnerId); - // 34 6 Group ID Decimal - EncodeDecimal(buffer, ArFile.FieldGroupIdOffset, ArFile.FieldGroupIdLength, file.GroupId); - // 40 8 File mode Octal - EncodeOctal(buffer, ArFile.FieldFileModeOffset, ArFile.FieldFileModeLength, file.FileMode); - } - // 48 10 File size in bytes Decimal - EncodeDecimal(buffer, ArFile.FieldFileSizeOffset, ArFile.FieldFileSizeLength, file.Size); - - buffer[ArFile.FieldEndCharactersOffset] = 0x60; - buffer[ArFile.FieldEndCharactersOffset + 1] = (byte) '\n'; - - // Write the entry - Stream.Write(buffer); - - // Handle BSD file name by serializing the name before the data if it is required - if (bsdNameLength.HasValue) - { - uint nameLength = bsdNameLength.Value; - var bufferName = ArrayPool.Shared.Rent((int) nameLength); - Encoding.UTF8.GetBytes(file.Name, 0, file.Name.Length, bufferName, 0); - try - { - Stream.Write(bufferName, 0, (int)nameLength); - } - finally - { - ArrayPool.Shared.Return(bufferName); - } - } - - // Write the content following the entry - file.WriteInternal(this); - - // Align to even byte - if ((Stream.Position & 1) != 0) - { - Stream.WriteByte((byte)'\n'); - } - } - - private void EncodeDecimal(in Span buffer, int offset, int size, ulong value) - { - int count = value == 0 ? 1 : 0; - var check = value; - while (check > 0) - { - check /= 10; - count++; - } - - if (count > size) - { - Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Cannot encode decimal `{value}` as the size is exceeding the available size {size}"); - return; - } - - check = value; - for (int i = 0; i < count; i++) - { - var dec = check % 10; - buffer[offset + count - i - 1] = (byte)((byte) '0' + dec); - check = check / 10; - } - } - - private void EncodeOctal(in Span buffer, int offset, int size, ulong value) - { - int count = value == 0 ? 1 : 0; - var check = value; - while (check > 0) - { - check /= 8; - count++; - } - - if (count > size) - { - Diagnostics.Error(DiagnosticId.AR_ERR_ExpectingNewLineCharacter, $"Cannot encode octal `{value}` as the size is exceeding the available size {size}"); - } - - check = value; - for (int i = 0; i < count; i++) - { - var dec = check % 8; - buffer[offset + count - i - 1] = (byte)((byte)'0' + dec); - check = check / 8; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs deleted file mode 100644 index 6887e3fea5f672..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArArchiveKind.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Ar -{ - /// - /// The type of archive. - /// - public enum ArArchiveKind - { - /// - /// The common variant, used for example by 'deb' package files. - /// Supports only file names up to 16 characters. - /// - Common, - - /// - /// The GNU variant, used by the `ar` utility on GNU and other systems (including Windows) - /// Based on file format, but using a different strategy - /// for storing long file names, incompatible with format. - /// - GNU, - - /// - /// The BSD variant, used by the `ar` utility on BSD systems (including MacOS) - /// Based on file format and backward compatible with it, - /// but allows to store longer file names and file names containing space. - /// - BSD, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs deleted file mode 100644 index c85c7d9b08796f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArBinaryFile.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Ar -{ - /// - /// An binary stream . - /// - public sealed class ArBinaryFile : ArFile - { - /// - /// Gets or sets the stream associated to this entry. - /// - public Stream Stream { get; set; } - - protected override void Read(ArArchiveFileReader reader) - { - Stream = reader.ReadAsStream(Size); - } - - protected override void Write(ArArchiveFileWriter writer) - { - if (Stream != null) - { - writer.Write(Stream); - } - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - Size = Stream != null ? (ulong) Stream.Length : 0; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs deleted file mode 100644 index 4a496ebaf6664e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArElfFile.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using LibObjectFile.Elf; -using LibObjectFile.Utils; - -namespace LibObjectFile.Ar -{ - /// - /// An ELF file entry. - /// - public sealed class ArElfFile : ArFile - { - public ArElfFile() - { - } - - public ArElfFile(ElfObjectFile elfObjectFile) - { - ElfObjectFile = elfObjectFile; - } - - /// - /// Gets or sets the ELF object file. - /// - public ElfObjectFile ElfObjectFile { get; set; } - - protected override void Read(ArArchiveFileReader reader) - { - var startPosition = reader.Stream.Position; - var endPosition = startPosition + (long) Size; - ElfObjectFile = ElfObjectFile.Read(new SliceStream(reader.Stream, reader.Stream.Position, (long)Size)); - reader.Stream.Position = endPosition; - } - - protected override void Write(ArArchiveFileWriter writer) - { - if (ElfObjectFile != null) - { - ElfObjectFile.TryWrite(writer.Stream, out var diagnostics); - diagnostics.CopyTo(writer.Diagnostics); - } - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - Size = 0; - - if (ElfObjectFile != null) - { - ElfObjectFile.UpdateLayout(diagnostics); - if (!diagnostics.HasErrors) - { - Size = ElfObjectFile.Layout.TotalSize; - } - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs deleted file mode 100644 index 3977b5c589d594..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFile.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Ar -{ - /// - /// Base class for a file entry in - /// - public abstract partial class ArFile : ArObject - { - private string _name; - private DateTimeOffset _timestamp; - - protected ArFile() - { - Timestamp = DateTimeOffset.UtcNow; - } - - /// - /// Gets or sets the name of the file in the archive entry. - /// - public virtual string Name - { - get => _name; - set - { - if (IsSystem) - { - throw CannotModifyProperty(nameof(Name)); - } - - if (value != null && value.Contains('/')) - { - throw new ArgumentException("The character `/` is not allowed in a file name entry"); - } - - _name = value; - } - } - - /// - /// Gets or sets the real (internal) name used for storing this entry (used by ) - /// - internal string InternalName { get; set; } - - /// - /// Gets or sets the timestamp of this file (clamped to seconds since 1970/01/01) - /// - public DateTimeOffset Timestamp - { - get => _timestamp; - - // We clamp the timestamp to the precision supported by the system - set => _timestamp = DateTimeOffset.FromUnixTimeSeconds(value.ToUnixTimeSeconds()); - } - - /// - /// Gets or sets the owner id. - /// - public uint OwnerId { get; set; } - - /// - /// Gets or sets the group id. - /// - public uint GroupId { get; set; } - - /// - /// Gets or sets the file mode. - /// - public uint FileMode { get; set; } - - /// - /// Gets a boolean indicating if this entry is a system entry (symbol table, header references) - /// and so does not respect naming (that should exclude for example `/`) - /// - public virtual bool IsSystem => false; - - internal void AfterReadInternal(DiagnosticBag diagnostics) - { - AfterRead(diagnostics); - } - - internal void ReadInternal(ArArchiveFileReader reader) - { - var expectedSize = (long)Size; - var beforePosition = reader.Stream.Position; - Read(reader); - var afterPosition = reader.Stream.Position; - var size = afterPosition - beforePosition; - // Verifies that the Size property is actually valid with what is being read - if (size != expectedSize) - { - reader.Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected EOF / size (expected: {expectedSize} != read: {size}) while trying to read file entry {Name}"); - } - } - - internal void WriteInternal(ArArchiveFileWriter writer) - { - var expectedSize = (long)Size; - var beforePosition = writer.Stream.Position; - Write(writer); - var afterPosition = writer.Stream.Position; - var size = afterPosition - beforePosition; - - // Verifies that the Size property is actually valid with what is being written - if (size != expectedSize) - { - // In that case, we don't log a diagnostics but throw an error, as it is an implementation problem. - throw new InvalidOperationException($"Invalid implementation of {GetType()}.{nameof(Write)} method. The Size written to the disk doesn't match (expected: {expectedSize} != written: {size}) while trying to write file entry {Name}"); - } - } - - /// - /// Reads this entry from a stream. - /// - /// The reader associated with the stream to read from. - protected abstract void Read(ArArchiveFileReader reader); - - /// - /// Performs after-read operation after all the other entries have been loaded. - /// - /// A diagnostic bag - protected virtual void AfterRead(DiagnosticBag diagnostics) { } - - /// - /// Writes this entry to a stream. - /// - /// The writer associated with the stream to write to. - protected abstract void Write(ArArchiveFileWriter writer); - - protected InvalidOperationException CannotModifyProperty(string propertyName) - { - return new InvalidOperationException($"Cannot modify the property {propertyName} for this {GetType()} file entry instance"); - } - - public override string ToString() - { - return $"{this.GetType().Name} [{Index}] `{Name}`"; - } - - public override void Verify(DiagnosticBag diagnostics) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs deleted file mode 100644 index 4338152e671bdb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArFileEntry.Constants.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Ar -{ - public abstract partial class ArFile - { - /// - /// Size in bytes of an AR file entry - /// - public const int FileEntrySizeInBytes = 60; - - /// - /// Offset of the filename in the entry - /// - public const int FieldNameOffset = 0; - - /// - /// Length in bytes of the filename in the entry - /// - public const int FieldNameLength = 16; - - /// - /// Offset of the timestamp in the entry - /// - public const int FieldTimestampOffset = 16; - - /// - /// Length in bytes of the timestamp in the entry - /// - public const int FieldTimestampLength = 12; - - /// - /// Offset of the owner ID in the entry - /// - public const int FieldOwnerIdOffset = 28; - - /// - /// Length in bytes of the timestamp in the entry - /// - public const int FieldOwnerIdLength = 6; - - /// - /// Offset of the group ID in the entry - /// - public const int FieldGroupIdOffset = 34; - - /// - /// Length in bytes of the timestamp in the entry - /// - public const int FieldGroupIdLength = 6; - - /// - /// Offset of the file mode in the entry - /// - public const int FieldFileModeOffset = 40; - - /// - /// Length in bytes of the timestamp in the entry - /// - public const int FieldFileModeLength = 8; - - /// - /// Offset of the file size in the entry - /// - public const int FieldFileSizeOffset = 48; - - /// - /// Length in bytes of the timestamp in the entry - /// - public const int FieldFileSizeLength = 10; - - /// - /// Offset of the end characters in the entry - /// - public const int FieldEndCharactersOffset = 58; - - /// - /// Length in bytes of the end characters in the entry - /// - public const int FieldEndCharactersLength = 2; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs deleted file mode 100644 index c6ef19773bbd6c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArLongNamesTable.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Text; - -namespace LibObjectFile.Ar -{ - /// - /// Internal class used for loading long file names for GNU `ar` and Windows `lib` archives. - /// - internal class ArLongNamesTable : ArFile - { - public const string DefaultName = "//"; - - public ArLongNamesTable() - { - } - - public override string Name - { - get => DefaultName; - set => base.Name = value; - } - - public Dictionary FileNames { get; private set; } - - public override bool IsSystem => true; - - protected override void Read(ArArchiveFileReader reader) - { - FileNames = new Dictionary(); - - var buffer = ArrayPool.Shared.Rent((int)Size); - int readCount = reader.Stream.Read(buffer, 0, (int)Size); - int startFileIndex = 0; - for (int i = 0; i < readCount; i++) - { - if (buffer[i] == '\n') - { - var fileNameLength = i - startFileIndex; - if (fileNameLength > 0) - { - // Discard trailing `/` - if (buffer[startFileIndex + fileNameLength - 1] == '/') - { - fileNameLength--; - } - - // TODO: Is it UTF8 or ASCII? - FileNames.Add(startFileIndex, Encoding.UTF8.GetString(buffer, startFileIndex, fileNameLength)); - } - startFileIndex = i + 1; - } - } - ArrayPool.Shared.Return(buffer); - } - - protected override void Write(ArArchiveFileWriter writer) - { - var buffer = ArrayPool.Shared.Rent((int)Size); - uint offset = 0; - for (var i = (int)Index; i < Parent.Files.Count; i++) - { - var file = Parent.Files[i]; - - if (file is ArLongNamesTable) break; - - var fileName = file.Name; - if (fileName == null || fileName.StartsWith("/")) - { - continue; - } - - // byte count + `/` - var fileNameLength = Encoding.UTF8.GetByteCount(fileName) + 1; - if (fileNameLength <= FieldNameLength) - { - file.InternalName = null; - continue; - } - - // Add `\n` - fileNameLength++; - - if (fileNameLength > buffer.Length) - { - ArrayPool.Shared.Return(buffer); - buffer = ArrayPool.Shared.Rent(fileNameLength); - } - - file.InternalName = $"/{offset}"; - - Encoding.UTF8.GetBytes(fileName, 0, fileName.Length, buffer, 0); - buffer[fileNameLength - 2] = (byte)'/'; - buffer[fileNameLength - 1] = (byte)'\n'; - - writer.Write(buffer, 0, fileNameLength); - offset += (uint)fileNameLength; - } - - if ((offset & 1) != 0) - { - writer.Stream.WriteByte((byte)'\n'); - } - ArrayPool.Shared.Return(buffer); - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - Size = 0; - - if (Parent == null) return; - - ulong size = 0; - for (var i = (int)Index; i < Parent.Files.Count; i++) - { - var file = Parent.Files[i]; - if (file is ArLongNamesTable) break; - - if (file.Name == null || file.Name.StartsWith("/")) - { - continue; - } - - var byteCount = Encoding.UTF8.GetByteCount(file.Name); - // byte count + `/` - if (byteCount + 1 > FieldNameLength) - { - // byte count + `/` + `\n` - size += (ulong)byteCount + 2; - } - } - - if ((size & 1) != 0) - { - size++; - } - - // Once it is calculated freeze it - Size = size; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs deleted file mode 100644 index 33d92f0d80013f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArObject.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; -using LibObjectFile.Elf; - -namespace LibObjectFile.Ar -{ - public abstract class ArObject : ObjectFileNode - { - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is ArArchiveFile)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(ArArchiveFile)}"); - } - } - - - /// - /// Gets the containing . Might be null if this section or segment - /// does not belong to an existing . - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - public new ArArchiveFile Parent - { - get => (ArArchiveFile)base.Parent; - internal set => base.Parent = value; - } - - public abstract void UpdateLayout(DiagnosticBag diagnostics); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs deleted file mode 100644 index a5750d9ae722eb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbol.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Ar -{ - /// - /// A symbol stored in a - /// - public struct ArSymbol - { - /// - /// Initializes a new instance. - /// - /// The name of the symbol. - /// The associated file entry this symbol is coming from . - public ArSymbol(string name, ArFile file) : this() - { - Name = name; - File = file; - } - - /// - /// Gets or sets the name of this symbol. - /// - public string Name { get; set; } - - /// - /// Internal offset for the name (used for reading) - /// - internal uint NameOffset { get; set; } - - /// - /// Gets or sets the associated file entry this symbol is coming from . - /// - public ArFile File { get; set; } - - /// - /// Internal offset of the file (used for reading) - /// - internal ulong FileOffset { get; set; } - - public override string ToString() - { - return $"Symbol: {Name} => {nameof(File)}: {File}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs deleted file mode 100644 index 716da0a1bc8614..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Ar/ArSymbolTable.cs +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace LibObjectFile.Ar -{ - /// - /// The symbol table. When used it must be the first entry in . - /// - public sealed class ArSymbolTable : ArFile - { - public const string DefaultBSDSymbolTableName = "__.SYMDEF"; - public const string DefaultGNUSymbolTableName = "/"; - - public ArSymbolTable() - { - Symbols = new List(); - } - - public override string Name - { - get - { - if (Parent == null) return ""; - - return Parent.Kind == ArArchiveKind.BSD ? DefaultBSDSymbolTableName : DefaultGNUSymbolTableName; - } - set => base.Name = value; - } - - public override bool IsSystem => true; - - /// - /// Gets the symbols associated to this table. - /// - public List Symbols { get; } - - protected override void Read(ArArchiveFileReader reader) - { - long startOffset = reader.Stream.Position; - - bool isBSD = reader.ArArchiveFile.Kind == ArArchiveKind.BSD; - - // A 32-bit big endian integer, giving the number of entries in the table. - uint entryCount = reader.Stream.ReadU32(false); - - // A set of 32-bit big endian integers. One for each symbol, recording the position within the archive of the header for the file containing this symbol. - for (uint i = 0; i < entryCount; i++) - { - uint stringOffset = 0; - - if (isBSD) - { - stringOffset = reader.Stream.ReadU32(false); - } - - uint offsetOfFile = reader.Stream.ReadU32(false); - - var symbol = new ArSymbol - { - NameOffset = stringOffset, - FileOffset = offsetOfFile, - }; - Symbols.Add(symbol); - } - - // A set of Zero-terminated strings. Each is a symbol name, and occurs in the same order as the list of positions in part 2. - var startStringTableOffset = isBSD ? reader.Stream.Position : 0; - - for (uint i = 0; i < entryCount; i++) - { - bool hasError = false; - var symbol = Symbols[(int)i]; - - var absoluteStringOffset = startStringTableOffset + symbol.NameOffset; - - if (isBSD && absoluteStringOffset >= startOffset + (long)Size) - { - hasError = true; - } - else - { - // Only BSD requires to position correctly - if (isBSD) - { - reader.Stream.Position = absoluteStringOffset; - } - - var text = reader.ReadStringUTF8NullTerminated(); - symbol.Name = text; - Symbols[(int)i] = symbol; - } - - if (hasError) - { - reader.Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected EOF while trying to read the string name [{i}] at file offset {absoluteStringOffset} in {this}"); - return; - } - } - - var sizeRead = (ulong) (reader.Stream.Position - startOffset); - if ((sizeRead & 1) != 0) - { - if (reader.Stream.ReadByte() >= 0) - { - sizeRead++; - } - } - Debug.Assert(Size == sizeRead); - } - - protected override void AfterRead(DiagnosticBag diagnostics) - { - var offsets = new Dictionary(); - foreach (var fileEntry in Parent.Files) - { - offsets[fileEntry.Offset] = fileEntry; - } - - for (var i = 0; i < Symbols.Count; i++) - { - var symbol = Symbols[i]; - if (offsets.TryGetValue(symbol.FileOffset, out var fileEntry)) - { - symbol.File = fileEntry; - Symbols[i] = symbol; - } - else - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidFileOffsetInSystemVSymbolLookupTable, $"Unable to find file at offset {symbol.FileOffset} for symbol entry [{i}] in {this}"); - } - } - } - - protected override void Write(ArArchiveFileWriter writer) - { - long startOffset = writer.Stream.Position; - writer.Stream.WriteU32(false, (uint)Symbols.Count); - - uint stringOffset = 0; - bool isBSD = Parent.Kind == ArArchiveKind.BSD; - foreach (var symbol in Symbols) - { - if (isBSD) - { - writer.Stream.WriteU32(false, stringOffset); - } - - writer.Stream.WriteU32(false, (uint)symbol.File.Offset); - - if (isBSD) - { - stringOffset += (uint) Encoding.UTF8.GetByteCount(symbol.Name) + 1; - } - } - - foreach (var symbol in Symbols) - { - writer.WriteStringUTF8NullTerminated(symbol.Name); - } - - var sizeWritten = writer.Stream.Position - startOffset; - if ((sizeWritten & 1) != 0) - { - writer.Stream.WriteByte(0); - sizeWritten++; - } - - // Double check that the size is actually matching what we have been serializing - Debug.Assert(sizeWritten == (long)Size); - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - for (var i = 0; i < Symbols.Count; i++) - { - var symbol = Symbols[i]; - if (string.IsNullOrEmpty(symbol.Name)) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullOrEmptySymbolName, $"Invalid null or empty symbol name [{i}] in {this}"); - } - - if (symbol.File == null) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullFileForSymbol, $"Invalid null file for symbol `{symbol.Name}` [{i}] in {this}"); - } - else if (symbol.File.Parent == null) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidNullParentFileForSymbol, $"Invalid null Parent for file `{symbol.File}` for symbol `{symbol.Name}` [{i}] in {this}"); - } - else if (symbol.File.Parent != Parent) - { - diagnostics.Error(DiagnosticId.AR_ERR_InvalidParentFileForSymbol, $"Invalid parent for file `{symbol.File}` for symbol `{symbol.Name}` [{i}] in {this}. The parent {nameof(ArArchiveFile)} is not the same instance as this symbol table"); - } - } - } - - public override string ToString() - { - return $"{base.ToString()}, {nameof(Symbols)} Count: {Symbols.Count}"; - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - if (Parent == null) return; - - // number of entries (both for BSD and GNU) - ulong sizeOfTable = sizeof(uint); - - foreach (var symbol in Symbols) - { - if (symbol.Name != null) - { - sizeOfTable += (ulong)Encoding.UTF8.GetByteCount(symbol.Name) + 1; - - // uint file_offset - sizeOfTable += sizeof(uint); - - if (Parent.Kind == ArArchiveKind.BSD) - { - // uint string_offset - sizeOfTable += sizeof(uint); - } - } - } - - if ((sizeOfTable & 1) != 0) - { - sizeOfTable++; - } - - Size = sizeOfTable; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs deleted file mode 100644 index 75e6ed0b575928..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticBag.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace LibObjectFile -{ - /// - /// A container for used for error reporting while reading/writing object files. - /// - [DebuggerDisplay("Count = {Messages.Count}, HasErrors = {" + nameof(HasErrors) + "}")] - public class DiagnosticBag - { - private readonly List _messages; - - public DiagnosticBag() - { - _messages = new List(); - } - - /// - /// List of messages. - /// - public IReadOnlyList Messages => _messages; - - /// - /// If this instance contains error messages. - /// - public bool HasErrors { get; private set; } - - /// - /// Clear all messages. - /// - public void Clear() - { - _messages.Clear(); - HasErrors = false; - } - - /// - /// Copy all the in this bag to another bag. - /// - /// The diagnostics receiving the copy of the - public void CopyTo(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - foreach (var diagnosticMessage in Messages) - { - diagnostics.Log(diagnosticMessage); - } - } - - /// - /// Logs the specified . - /// - /// The diagnostic message - public void Log(DiagnosticMessage message) - { - if (message.Message == null) throw new InvalidOperationException($"{nameof(DiagnosticMessage)}.{nameof(DiagnosticMessage.Message)} cannot be null"); - _messages.Add(message); - if (message.Kind == DiagnosticKind.Error) - { - HasErrors = true; - } - } - - /// - /// Log an error . - /// - /// The identifier of the diagnostic. - /// The text of the message - /// An optional context - public void Error(DiagnosticId id, string message, object context = null) - { - if (message == null) throw new ArgumentNullException(nameof(message)); - Log(new DiagnosticMessage(DiagnosticKind.Error, id, message, context)); - } - - /// - /// Log an error . - /// - /// The identifier of the diagnostic. - /// The text of the message - /// An optional context - public void Warning(DiagnosticId id, string message, object context = null) - { - if (message == null) throw new ArgumentNullException(nameof(message)); - Log(new DiagnosticMessage(DiagnosticKind.Warning, id, message, context)); - } - - public override string ToString() - { - var builder = new StringBuilder(); - foreach (var diagnosticMessage in Messages) - { - builder.AppendLine(diagnosticMessage.ToString()); - } - - return builder.ToString(); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs deleted file mode 100644 index 170dd8443015ba..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticId.cs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - /// - /// Defines the various diagnostic message ids. - /// - public enum DiagnosticId - { - CMN_ERR_UnexpectedEndOfFile = 1, - - // Elf - ELF_ERR_LinkOrInfoSectionNull = 102, - ELF_ERR_LinkOrInfoInvalidSectionType = 103, - ELF_ERR_LinkOrInfoInvalidSectionInstance = 104, - ELF_ERR_InvalidHeaderFileClassNone = 105, - ELF_ERR_InvalidHeaderIdentLength = 106, - ELF_ERR_InvalidHeaderMagic = 107, - //ELF_ERR_InvalidHeaderFileClass = 8, - //ELF_ERR_InvalidHeaderEncoding = 9, - ELF_ERR_MissingProgramHeaderTableSection = 110, - ELF_ERR_InvalidSectionHeaderCount = 111, - ELF_ERR_IncompleteHeader32Size = 112, - ELF_ERR_IncompleteHeader64Size = 113, - ELF_ERR_InvalidZeroProgramHeaderTableEntrySize = 114, - ELF_ERR_InvalidProgramHeaderStreamOffset = 115, - ELF_ERR_IncompleteProgramHeader32Size = 116, - ELF_ERR_IncompleteProgramHeader64Size = 117, - ELF_ERR_InvalidZeroSectionHeaderTableEntrySize = 118, - ELF_ERR_InvalidSectionHeaderStreamOffset = 119, - ELF_ERR_IncompleteSectionHeader32Size = 120, - ELF_ERR_IncompleteSectionHeader64Size = 121, - ELF_ERR_InvalidResolvedLink = 122, - ELF_ERR_InvalidFirstSectionExpectingUndefined = 123, - ELF_ERR_InvalidStringIndexMissingStringHeaderTable = 124, - ELF_ERR_InvalidStringIndex = 125, - ELF_ERR_InvalidOverlappingSections = 126, - ELF_ERR_InvalidSegmentRange = 127, - ELF_ERR_InvalidSectionSizeKind = 128, - ELF_ERR_InvalidSectionLinkParent = 129, - ELF_ERR_InvalidSectionInfoParent = 130, - ELF_ERR_InvalidSegmentRangeBeginSectionParent = 131, - ELF_ERR_InvalidSegmentRangeEndSectionParent = 132, - ELF_ERR_InvalidSegmentRangeBeginOffset = 133, - ELF_ERR_InvalidSegmentRangeEndOffset = 134, - ELF_ERR_InvalidSegmentRangeIndices = 135, - ELF_ERR_IncompleteRelocationAddendsEntry32Size = 136, - ELF_ERR_IncompleteRelocationEntry32Size = 137, - ELF_ERR_IncompleteRelocationAddendsEntry64Size = 138, - ELF_ERR_IncompleteRelocationEntry64Size = 139, - ELF_WRN_InvalidRelocationTablePrefixName = 140, - ELF_WRN_InvalidRelocationTablePrefixTargetName = 141, - ELF_ERR_InvalidRelocationInfoParent = 142, - ELF_ERR_InvalidRelocationEntryAddend = 143, - ELF_ERR_InvalidRelocationEntryArch = 144, - ELF_ERR_InvalidRelocationSymbolIndex = 145, - ELF_ERR_IncompleteSymbolEntry32Size = 146, - ELF_ERR_IncompleteSymbolEntry64Size = 147, - ELF_ERR_InvalidFirstSymbolEntryNonNull = 148, - ELF_ERR_InvalidSymbolEntryNameIndex = 149, - ELF_ERR_InvalidSymbolEntrySectionParent = 150, - ELF_ERR_InvalidSymbolEntryLocalPosition = 151, - ELF_ERR_IncompleteNoteEntrySize = 152, - ELF_ERR_IncompleNoteGnuAbiTag = 153, - ELF_ERR_InvalidSegmentVirtualAddressOrOffset = 154, - ELF_ERR_InvalidSegmentAlignmentForLoad = 155, - ELF_ERR_InvalidStreamForSectionNoBits = 156, - ELF_ERR_InvalidNullSection = 157, - ELF_ERR_InvalidAlignmentOutOfRange = 158, - ELF_ERR_MissingSectionHeaderIndices = 159, - ELF_ERR_MissingNullSection = 159, - - AR_ERR_InvalidMagicLength = 1000, - AR_ERR_MagicNotFound = 1001, - AR_ERR_ExpectingNewLineCharacter = 1002, - //AR_ERR_UnexpectedEndOfFile = 1003, - AR_ERR_InvalidFileEntryLength = 1004, - AR_ERR_InvalidNonPrintableASCIIFoundInFileEntry = 1005, - AR_ERR_InvalidCharacterFoundInFileEntry = 1006, - AR_ERR_InvalidNullFileEntryName = 1007, - AR_ERR_InvalidFileOffsetInSystemVSymbolLookupTable = 1008, - AR_ERR_InvalidDuplicatedFutureHeadersTable = 1009, - AR_ERR_InvalidReferenceToFutureHeadersTable = 1010, - AR_ERR_InvalidFileEntryNameTooLong = 1011, - AR_ERR_InvalidCharacterInFileEntryName = 1012, - AR_ERR_InvalidNullOrEmptySymbolName = 1013, - AR_ERR_InvalidNullFileForSymbol = 1014, - AR_ERR_InvalidNullParentFileForSymbol = 1015, - AR_ERR_InvalidParentFileForSymbol = 1016, - AR_ERR_InvalidFileEntrySize = 1017, - - - DWARF_ERR_AttributeLEB128OutOfRange = 2000, - DWARF_ERR_VersionNotSupported = 2001, - DWARF_ERR_InvalidData = 2002, - DWARF_WRN_UnsupportedLineExtendedCode = 2003, - DWARF_ERR_InvalidReference = 2004, - DWARF_ERR_MissingStringTable = 2005, - DWARF_ERR_InvalidNumberOfStandardOpCodeLengths = 2006, - DWARF_ERR_InvalidStandardOpCodeLength = 2007, - DWARF_WRN_CannotEncodeAddressIncrement = 2008, - DWARF_ERR_InvalidNullFileNameEntry = 2009, - DWARF_ERR_InvalidFileName = 2010, - DWARF_ERR_InvalidMaximumOperationsPerInstruction = 2011, - DWARF_ERR_InvalidNegativeAddressDelta = 2012, - DWARF_ERR_InvalidOperationIndex = 2013, - DWARF_ERR_InvalidAddressSize = 2014, - DWARF_ERR_UnsupportedUnitType = 2015, - DWARF_ERR_InvalidNullUnitForAddressRangeTable = 2016, - DWARF_ERR_InvalidParentUnitForAddressRangeTable = 2017, - DWARF_ERR_InvalidParentForDIE = 2018, - DWARF_WRN_InvalidExtendedOpCodeLength = 2019, - DWARF_ERR_InvalidParentForLocationList = 2020, - - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs deleted file mode 100644 index 2ec742585f4a7e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticKind.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - /// - /// Defines the kind of a - /// - public enum DiagnosticKind - { - /// - /// A warning message. - /// - Warning, - - /// - /// An error message. - /// - Error, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs deleted file mode 100644 index 52633fde11564a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/DiagnosticMessage.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - /// - /// A diagnostic message. - /// - public readonly struct DiagnosticMessage - { - public DiagnosticMessage(DiagnosticKind kind, DiagnosticId id, string message) - { - Kind = kind; - Id = id; - Context = null; - Message = message; - } - - public DiagnosticMessage(DiagnosticKind kind, DiagnosticId id, string message, object context) - { - Kind = kind; - Id = id; - Context = context; - Message = message; - } - - /// - /// Gets the kind of this message. - /// - public DiagnosticKind Kind { get; } - - /// - /// Gets the id of this message. - /// - public DiagnosticId Id { get; } - - /// - /// Gets the context of this message. - /// - public object Context { get; } - - /// - /// Gets the associated text of this message. - /// - public string Message { get; } - - public override string ToString() - { - return $"{Kind} LB{(uint)Id:0000}: {Message}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs deleted file mode 100644 index 593b0150581c77..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviation.cs +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] - public sealed class DwarfAbbreviation : DwarfObject - { - private readonly List _items; - private readonly Dictionary _mapItems; // Only used if code are non contiguous - private readonly Dictionary _mapKeyToItem; - private ulong _nextCode; - - public DwarfAbbreviation() - { - _items = new List(); - _mapItems = new Dictionary(); - _mapKeyToItem = new Dictionary(); - _nextCode = 1; - } - - public void Reset() - { - // Reset parent dependency - foreach (var dwarfAbbreviationItem in _items) - { - dwarfAbbreviationItem.Parent = null; - } - - if (_mapItems.Count > 0) - { - foreach (var keyPair in _mapItems) - { - keyPair.Value.Parent = null; - } - } - - _items.Clear(); - _mapItems.Clear(); - _mapKeyToItem.Clear(); - _nextCode = 1; - } - - public IEnumerable Items => _mapItems.Count > 0 ? GetMapItems() : _items; - - private IEnumerable GetMapItems() - { - foreach (var item in _mapItems.Values) - { - yield return item; - } - } - - public DwarfAbbreviationItem GetOrCreate(DwarfAbbreviationItemKey itemKey) - { - if (!_mapKeyToItem.TryGetValue(itemKey, out var item)) - { - item = new DwarfAbbreviationItem(_nextCode, itemKey.Tag, itemKey.HasChildren, itemKey.Descriptors) - { - Parent = this - }; - - if (_mapItems.Count > 0) - { - - _mapItems[_nextCode] = item; - } - else - { - _items.Add(item); - } - - _mapKeyToItem[itemKey] = item; - - _nextCode++; - } - - return item; - } - - public bool TryFindByCode(ulong code, out DwarfAbbreviationItem item) - { - item = null; - if (code == 0) - { - return false; - } - - code--; - - if (_mapItems.Count > 0) - { - return _mapItems.TryGetValue(code, out item); - } - - if (code < int.MaxValue && (int)code < _items.Count) - { - item = _items[(int) code]; - return true; - } - - item = null; - return false; - } - - private string DebuggerDisplay => $"Count = {(_mapItems.Count > 0 ? _mapItems.Count : _items.Count)}"; - - private bool TryReadNext(DwarfReader reader) - { - var startOffset = (ulong)reader.Offset; - var code = reader.ReadULEB128(); - if (code == 0) - { - return false; - } - - var item = new DwarfAbbreviationItem - { - Offset = startOffset, - Code = code - }; - - var index = code - 1; - bool canAddToList = _mapItems.Count == 0 && index < int.MaxValue && _items.Count == (int)index; - - item.ReadInternal(reader); - - if (canAddToList) - { - _items.Add(item); - _nextCode++; - } - else - { - if (_mapItems.Count == 0) - { - for (var i = 0; i < _items.Count; i++) - { - var previousItem = _items[i]; - _mapItems.Add((ulong)i + 1, previousItem); - } - _items.Clear(); - } - - // TODO: check collisions - if (_mapItems.ContainsKey(code)) - { - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"Invalid code {code} found while another code already exists in this abbreviation."); - return false; - } - _mapItems.Add(code, item); - - _nextCode = Math.Max(code, _nextCode) + 1; - } - - var key = new DwarfAbbreviationItemKey(item.Tag, item.HasChildren, item.Descriptors); - _mapKeyToItem.Add(key, item); - - return true; - } - - protected override void Read(DwarfReader reader) - { - Offset = reader.Offset; - while (TryReadNext(reader)) - { - } - - Size = (ulong)reader.Offset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - Debug.Assert(startOffset == Offset); - if (_mapItems.Count > 0) - { - foreach (var itemPair in _mapItems) - { - var item = itemPair.Value; - item.WriteInternal(writer); - } - - } - else - { - if (_items.Count > 0) - { - foreach (var item in _items) - { - item.WriteInternal(writer); - } - } - } - - // End of abbreviation item - writer.WriteULEB128(0); - - Debug.Assert(writer.Offset - startOffset == Size); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var endOffset = Offset; - - if (_mapItems.Count > 0) - { - foreach (var itemPair in _mapItems) - { - var item = itemPair.Value; - item.Offset = endOffset; - item.UpdateLayoutInternal(layoutContext); - endOffset += item.Size; - } - - } - else - { - if (_items.Count > 0) - { - foreach (var item in _items) - { - item.Offset = endOffset; - item.UpdateLayoutInternal(layoutContext); - endOffset += item.Size; - } - } - } - - endOffset += DwarfHelper.SizeOfULEB128(0); - - Size = endOffset - Offset; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs deleted file mode 100644 index 32d1df7e121946..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItem.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfAbbreviationItem : DwarfObject - { - internal DwarfAbbreviationItem() - { - } - - internal DwarfAbbreviationItem(ulong code, DwarfTagEx tag, bool hasChildren, DwarfAttributeDescriptors descriptors) - { - Code = code; - Tag = tag; - HasChildren = hasChildren; - Descriptors = descriptors; - } - - public ulong Code { get; internal set; } - - public DwarfTagEx Tag { get; private set; } - - public bool HasChildren { get; private set; } - - public DwarfAttributeDescriptors Descriptors { get; private set; } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var endOffset = Offset; - - // Code - endOffset += DwarfHelper.SizeOfULEB128(Code); - - // Tag - endOffset += DwarfHelper.SizeOfULEB128((uint)Tag.Value); - - // HasChildren - endOffset += 1; - - var descriptors = Descriptors; - for (int i = 0; i < descriptors.Length; i++) - { - var descriptor = descriptors[i]; - endOffset += DwarfHelper.SizeOfULEB128((uint)descriptor.Kind.Value); - endOffset += DwarfHelper.SizeOfULEB128((uint)descriptor.Form.Value); - } - - // Null Kind and Form - endOffset += DwarfHelper.SizeOfULEB128(0) * 2; - - Size = endOffset - Offset; - } - - protected override void Read(DwarfReader reader) - { - var itemTag = new DwarfTagEx(reader.ReadULEB128AsU32()); - Tag = itemTag; - var hasChildrenRaw = reader.ReadU8(); - bool hasChildren = false; - if (hasChildrenRaw == DwarfNative.DW_CHILDREN_yes) - { - hasChildren = true; - } - else if (hasChildrenRaw != DwarfNative.DW_CHILDREN_no) - { - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"Invalid children {hasChildrenRaw}. Must be either {DwarfNative.DW_CHILDREN_yes} or {DwarfNative.DW_CHILDREN_no}"); - return; - } - - HasChildren = hasChildren; - - List descriptors = null; - - while (true) - { - var attributeName = new DwarfAttributeKindEx(reader.ReadULEB128AsU32()); - var attributeForm = new DwarfAttributeFormEx(reader.ReadULEB128AsU32()); - - if (attributeForm.Value == 0 && attributeForm.Value == 0) - { - break; - } - - if (descriptors == null) descriptors = new List(1); - descriptors.Add(new DwarfAttributeDescriptor(attributeName, attributeForm)); - } - - Descriptors = descriptors != null ? new DwarfAttributeDescriptors(descriptors.ToArray()) : new DwarfAttributeDescriptors(); - - Size = reader.Offset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - Debug.Assert(startOffset == Offset); - - // Code - writer.WriteULEB128(Code); - - // Tag - writer.WriteULEB128((uint)Tag.Value); - - // HasChildren - writer.WriteU8(HasChildren ? DwarfNative.DW_CHILDREN_yes : DwarfNative.DW_CHILDREN_no); - - var descriptors = Descriptors; - for (int i = 0; i < descriptors.Length; i++) - { - var descriptor = descriptors[i]; - writer.WriteULEB128((uint)descriptor.Kind.Value); - writer.WriteULEB128((uint)descriptor.Form.Value); - } - writer.WriteULEB128(0); - writer.WriteULEB128(0); - - Debug.Assert(writer.Offset - startOffset == Size); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs deleted file mode 100644 index a94024abbc4814..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationItemKey.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public readonly struct DwarfAbbreviationItemKey : IEquatable - { - public DwarfAbbreviationItemKey(DwarfTagEx tag, bool hasChildren, DwarfAttributeDescriptors descriptors) - { - Tag = tag; - HasChildren = hasChildren; - Descriptors = descriptors; - } - - - public readonly DwarfTagEx Tag; - - public readonly bool HasChildren; - - public readonly DwarfAttributeDescriptors Descriptors; - - public bool Equals(DwarfAbbreviationItemKey other) - { - return Tag == other.Tag && HasChildren == other.HasChildren && Descriptors.Equals(other.Descriptors); - } - - public override bool Equals(object obj) - { - return obj is DwarfAbbreviationItemKey other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - var hashCode = Tag.GetHashCode(); - hashCode = (hashCode * 397) ^ HasChildren.GetHashCode(); - hashCode = (hashCode * 397) ^ Descriptors.GetHashCode(); - return hashCode; - } - } - - public static bool operator ==(DwarfAbbreviationItemKey left, DwarfAbbreviationItemKey right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfAbbreviationItemKey left, DwarfAbbreviationItemKey right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return $"{nameof(Tag)}: {Tag}, {nameof(HasChildren)}: {HasChildren}, {nameof(Descriptors)}: {Descriptors}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs deleted file mode 100644 index dc607b201fcfcd..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAbbreviationTable.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public class DwarfAbbreviationTable : DwarfSection - { - private readonly List _abbreviations; - - public DwarfAbbreviationTable() - { - _abbreviations = new List(); - } - - public IReadOnlyList Abbreviations => _abbreviations; - - internal void AddAbbreviation(DwarfAbbreviation abbreviation) - { - _abbreviations.Add(this, abbreviation); - } - - internal void RemoveAbbreviation(DwarfAbbreviation abbreviation) - { - _abbreviations.Remove(this, abbreviation); - } - - internal DwarfAbbreviation RemoveAbbreviationAt(int index) - { - return _abbreviations.RemoveAt(this, index); - } - - internal void Reset() - { - foreach(var abbreviation in _abbreviations) - { - abbreviation.Reset(); - } - _abbreviations.Clear(); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - ulong endOffset = Offset; - foreach (var abbreviation in _abbreviations) - { - abbreviation.Offset = endOffset; - abbreviation.UpdateLayoutInternal(layoutContext); - endOffset += abbreviation.Size; - } - - Size = endOffset - Offset; - } - - protected override void Read(DwarfReader reader) - { - var endOffset = reader.Offset; - while (reader.Offset < reader.Length) - { - var abbreviation = new DwarfAbbreviation - { - Offset = endOffset - }; - abbreviation.ReadInternal(reader); - endOffset += abbreviation.Size; - AddAbbreviation(abbreviation); - } - - Size = endOffset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - foreach (var abbreviation in _abbreviations) - { - abbreviation.WriteInternal(writer); - } - - Debug.Assert(writer.Offset - startOffset == Size); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs deleted file mode 100644 index 67f3271f9e0d6f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAccessibility.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfAccessibility : byte - { - Public = DwarfNative.DW_ACCESS_public, - - Private = DwarfNative.DW_ACCESS_private, - - Protected = DwarfNative.DW_ACCESS_protected, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs deleted file mode 100644 index 6a9e9d12bc9ba5..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRange.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public struct DwarfAddressRange - { - public DwarfAddressRange(ulong segment, ulong address, ulong length) - { - Segment = segment; - Address = address; - Length = length; - } - - public ulong Segment { get; set; } - - public ulong Address { get; set; } - - public ulong Length { get; set; } - - public override string ToString() - { - return $"{nameof(Segment)}: 0x{Segment:x16}, {nameof(Address)}: 0x{Address:x16}, {nameof(Length)}: 0x{Length:x16}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs deleted file mode 100644 index 8bc3a3d22771cf..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressRangeTable.cs +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using LibObjectFile.Utils; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("Count = {Ranges.Count,nq}")] - public class DwarfAddressRangeTable : DwarfRelocatableSection - { - public DwarfAddressRangeTable() - { - Ranges = new List(); - Version = 2; - } - - public ushort Version { get; set; } - - public bool Is64BitEncoding { get; set; } - - public DwarfAddressSize AddressSize { get; set; } - - public DwarfAddressSize SegmentSelectorSize { get; set; } - - public ulong DebugInfoOffset { get; private set; } - - public DwarfUnit Unit { get; set; } - - public List Ranges { get; } - - public ulong HeaderLength => Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding); - - protected override void Read(DwarfReader reader) - { - Offset = reader.Offset; - var unitLength = reader.ReadUnitLength(); - Is64BitEncoding = reader.Is64BitEncoding; - Version = reader.ReadU16(); - - if (Version != 2) - { - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version {Version} for .debug_aranges not supported"); - return; - } - - DebugInfoOffset = reader.ReadUIntFromEncoding(); - - AddressSize = reader.ReadAddressSize(); - - var segment_selector_size = (DwarfAddressSize)reader.ReadU8(); - SegmentSelectorSize = segment_selector_size; - - var align = (ulong)segment_selector_size + (ulong)AddressSize * 2; - - // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple - reader.Offset = AlignHelper.AlignToUpper(reader.Offset, align); - - while (true) - { - ulong segment = 0; - switch (segment_selector_size) - { - case DwarfAddressSize.Bit8: - segment = reader.ReadU8(); - break; - - case DwarfAddressSize.Bit16: - segment = reader.ReadU16(); - break; - - case DwarfAddressSize.Bit32: - segment = reader.ReadU32(); - break; - - case DwarfAddressSize.Bit64: - segment = reader.ReadU64(); - break; - - case DwarfAddressSize.None: - break; - } - - ulong address = 0; - ulong length = 0; - switch (AddressSize) - { - case DwarfAddressSize.Bit8: - address = reader.ReadU8(); - length = reader.ReadU8(); - break; - case DwarfAddressSize.Bit16: - address = reader.ReadU16(); - length = reader.ReadU16(); - break; - case DwarfAddressSize.Bit32: - address = reader.ReadU32(); - length = reader.ReadU32(); - break; - case DwarfAddressSize.Bit64: - address = reader.ReadU64(); - length = reader.ReadU64(); - break; - } - - if (segment == 0 && address == 0 && length == 0) - { - break; - } - - Ranges.Add(new DwarfAddressRange(segment, address, length)); - } - - Size = reader.Offset - Offset; - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - if (Version != 2) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Non supported version {Version} for .debug_aranges"); - } - - if (Unit == null) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNullUnitForAddressRangeTable, $"Invalid {nameof(Unit)} for .debug_aranges that cannot be null"); - } - else - { - var parentFile = Unit.GetParentFile(); - if (this.Parent != parentFile) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentUnitForAddressRangeTable, $"Invalid parent {nameof(DwarfFile)} of {nameof(Unit)} for .debug_aranges that doesn't match the parent of instance"); - } - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - ulong sizeOf = 0; - // unit_length - sizeOf += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); - - // version - sizeOf += 2; - - // debug_info_offset - sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); - - // Address size - sizeOf += 1; - - // segment selector size - sizeOf += 1; - - var align = (ulong)SegmentSelectorSize + (ulong)AddressSize * 2; - - // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple - sizeOf = AlignHelper.AlignToUpper(sizeOf, align); - - // SizeOf ranges + 1 (for last 0 entry) - sizeOf += ((ulong)Ranges.Count + 1UL) * align; - - Size = sizeOf; - - if (Unit != null) - { - DebugInfoOffset = Unit.Offset; - } - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - - // unit_length - writer.WriteUnitLength(Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding)); - - // version - writer.WriteU16(Version); - - // debug_info_offset - var debugInfoOffset = DebugInfoOffset; - if (writer.EnableRelocation) - { - writer.RecordRelocation(DwarfRelocationTarget.DebugInfo, writer.SizeOfUIntEncoding(), debugInfoOffset); - debugInfoOffset = 0; - } - writer.WriteUIntFromEncoding(debugInfoOffset); - - // address_size - writer.AddressSize = AddressSize; - writer.WriteU8((byte)AddressSize); - - writer.WriteU8((byte)SegmentSelectorSize); - - var align = (ulong)SegmentSelectorSize + (ulong)AddressSize * 2; - - // SPECS 7.21: The first tuple following the header in each set begins at an offset that is a multiple of the size of a single tuple - var nextOffset = AlignHelper.AlignToUpper(writer.Offset, align); - for (ulong offset = writer.Offset; offset < nextOffset; offset++) - { - writer.WriteU8(0); - } - Debug.Assert(writer.Offset == nextOffset); - - foreach (var range in Ranges) - { - if (SegmentSelectorSize != 0) - { - switch (SegmentSelectorSize) - { - case DwarfAddressSize.Bit8: - writer.WriteU8((byte)range.Segment); - break; - case DwarfAddressSize.Bit16: - writer.WriteU16((ushort)range.Segment); - break; - case DwarfAddressSize.Bit32: - writer.WriteU32((uint)range.Segment); - break; - case DwarfAddressSize.Bit64: - writer.WriteU64((ulong)range.Segment); - break; - } - } - - writer.WriteAddress(DwarfRelocationTarget.Code, range.Address); - writer.WriteUInt(range.Length); - } - - if (SegmentSelectorSize != 0) - { - switch (SegmentSelectorSize) - { - case DwarfAddressSize.Bit8: - writer.WriteU8(0); - break; - case DwarfAddressSize.Bit16: - writer.WriteU16(0); - break; - case DwarfAddressSize.Bit32: - writer.WriteU32(0); - break; - case DwarfAddressSize.Bit64: - writer.WriteU64(0); - break; - } - } - - switch (AddressSize) - { - case DwarfAddressSize.Bit8: - writer.WriteU16(0); - break; - case DwarfAddressSize.Bit16: - writer.WriteU32(0); - break; - case DwarfAddressSize.Bit32: - writer.WriteU64(0); - break; - case DwarfAddressSize.Bit64: - writer.WriteU64(0); - writer.WriteU64(0); - break; - } - - Debug.Assert(writer.Offset - startOffset == Size); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs deleted file mode 100644 index c2f072e8c30064..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAddressSize.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfAddressSize : byte - { - None = 0, - - Bit8 = 1, - - Bit16 = 2, - - Bit32 = 4, - - Bit64 = 8, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs deleted file mode 100644 index 8464d0c6d521c0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfArrayOrderingKind.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfArrayOrderingKind : byte - { - RowMajor = DwarfNative.DW_ORD_row_major, - - ColumnMajor = DwarfNative.DW_ORD_col_major, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs deleted file mode 100644 index db0c381574bbd8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttribute.cs +++ /dev/null @@ -1,1001 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfAttribute : DwarfObject, IComparable - { - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private ulong _valueAsU64; - - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private object _valueAsObject; - - public DwarfAttributeKindEx Kind { get; set; } - - public bool ValueAsBoolean - { - get => _valueAsU64 != 0; - set => _valueAsU64 = value ? 1U : 0; - } - - public int ValueAsI32 - { - get => (int)_valueAsU64; - set => _valueAsU64 = (ulong)(long)value; - } - - public uint ValueAsU32 - { - get => (uint)_valueAsU64; - set => _valueAsU64 = value; - } - - public long ValueAsI64 - { - get => (long)_valueAsU64; - set => _valueAsU64 = (ulong)value; - } - - public ulong ValueAsU64 - { - get => _valueAsU64; - set => _valueAsU64 = value; - } - - /// - /// Gets or sets the encoding used for this attribute. Default is null meaning that the encoding - /// is detected automatically. Some attributes may require to explicitly set this encoding to disambiguate - /// between different encoding form (e.g boolean => instead of ) - /// - public DwarfAttributeEncoding? Encoding { get; set; } - - public DwarfAttributeFormEx Form { get; internal set; } - - public object ValueAsObject - { - get => _valueAsObject; - set - { - if (_valueAsObject is DwarfExpression oldExpression) - { - oldExpression.Parent = null; - } - _valueAsObject = value; - - if (value is DwarfExpression newExpression) - { - if (newExpression.Parent != null) throw new InvalidOperationException($"Cannot set the {newExpression.GetType()} as it already belongs to another {newExpression.Parent.GetType()} instance"); - newExpression.Parent = this; - } - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - // Check DwarfDIE reference - if (ValueAsObject is DwarfDIE attrDIE) - { - var thisSection = this.GetParentSection(); - var attrSection = attrDIE.GetParentSection(); - - if (thisSection != attrSection) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForDIE, $"Invalid parent for the DIE {attrDIE} referenced by the attribute {this}. It must be within the same parent {thisSection.GetType()}."); - } - } - else if (ValueAsObject is DwarfExpression expr) - { - expr.Verify(diagnostics); - } - else if (ValueAsObject is DwarfLocationList locationList) - { - var thisSection = this.GetParentFile(); - var locationListSection = locationList.GetParentFile(); - - if (thisSection != locationListSection) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidParentForLocationList, $"Invalid parent for the LocationList {locationList} referenced by the attribute {this}. It must be within the same parent {thisSection.GetType()}."); - } - } - } - - public int CompareTo(DwarfAttribute other) - { - return ((uint)Kind).CompareTo((uint)other.Kind); - } - - public override string ToString() - { - if (ValueAsObject != null) - { - return ValueAsU64 != 0 ? $"{nameof(Kind)}: {Kind}, Value: {ValueAsObject} Offset: {ValueAsU64}" : $"{nameof(Kind)}: {Kind}, Value: {ValueAsObject}"; - } - else - { - return $"{nameof(Kind)}: {Kind}, Value: {ValueAsU64}"; - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var addressSize = layoutContext.CurrentUnit.AddressSize; - var is64BitEncoding = layoutContext.CurrentUnit.Is64BitEncoding; - - var endOffset = Offset; - switch (Form.Value) - { - case DwarfAttributeForm.Addr: - endOffset += DwarfHelper.SizeOfUInt(addressSize); // WriteUInt(ValueAsU64); - break; - case DwarfAttributeForm.Data1: - endOffset += 1; // WriteU8((byte)ValueAsU64); - break; - case DwarfAttributeForm.Data2: - endOffset += 2; // WriteU16((ushort)ValueAsU64); - break; - case DwarfAttributeForm.Data4: - endOffset += 4; // WriteU32((uint)ValueAsU64); - break; - case DwarfAttributeForm.Data8: - endOffset += 8; // WriteU64(ValueAsU64); - break; - case DwarfAttributeForm.String: - endOffset += DwarfHelper.SizeOfStringUTF8NullTerminated((string)ValueAsObject); - break; - case DwarfAttributeForm.Block: - { - var stream = (Stream)ValueAsObject; - endOffset += DwarfHelper.SizeOfULEB128((ulong)stream.Length); - endOffset += (ulong)stream.Length; - break; - } - case DwarfAttributeForm.Block1: - { - var stream = (Stream)ValueAsObject; - endOffset += 1; - endOffset += (ulong)stream.Length; - break; - } - case DwarfAttributeForm.Block2: - { - var stream = (Stream)ValueAsObject; - endOffset += 2; - endOffset += (ulong)stream.Length; - break; - } - case DwarfAttributeForm.Block4: - { - var stream = (Stream)ValueAsObject; - endOffset += 4; - endOffset += (ulong)stream.Length; - break; - } - case DwarfAttributeForm.Flag: - endOffset += 1; // WriteU8((byte)(ValueAsU64 != 0 ? 1 : 0)); - break; - case DwarfAttributeForm.Sdata: - endOffset += DwarfHelper.SizeOfILEB128(ValueAsI64); // WriteILEB128(ValueAsI64); - break; - case DwarfAttributeForm.Strp: - endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); // WriteUIntFromEncoding(offset); - break; - case DwarfAttributeForm.Udata: - endOffset += DwarfHelper.SizeOfULEB128(ValueAsU64); // ReadULEB128(); - break; - case DwarfAttributeForm.RefAddr: - endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); // WriteUIntFromEncoding(dieRef.Offset); - break; - case DwarfAttributeForm.Ref1: - endOffset += 1; // WriteU8((byte)(dieRef.Offset - _currentUnit.Offset)); - break; - case DwarfAttributeForm.Ref2: - endOffset += 2; // WriteU16((ushort)(dieRef.Offset - _currentUnit.Offset)); - break; - case DwarfAttributeForm.Ref4: - endOffset += 4; // WriteU32((uint)(dieRef.Offset - _currentUnit.Offset)); - break; - case DwarfAttributeForm.Ref8: - endOffset += 8; // WriteU64((dieRef.Offset - _currentUnit.Offset)); - break; - case DwarfAttributeForm.RefUdata: - { - var dieRef = (DwarfDIE)ValueAsObject; - endOffset += DwarfHelper.SizeOfULEB128(dieRef.Offset - layoutContext.CurrentUnit.Offset); // WriteULEB128((dieRef.Offset - _currentUnit.Offset)); - break; - } - - //case DwarfAttributeForm.indirect: - //{ - // attributeForm = ReadLEB128As(); - // goto indirect; - //} - - // addptr - // lineptr - // loclist - // loclistptr - // macptr - // rnglist - // rngrlistptr - // stroffsetsptr - case DwarfAttributeForm.SecOffset: - endOffset += DwarfHelper.SizeOfUInt(is64BitEncoding); - break; - - case DwarfAttributeForm.Exprloc: - var expr = (DwarfExpression)ValueAsObject; - expr.Offset = endOffset; - expr.UpdateLayoutInternal(layoutContext); - endOffset += expr.Size; - break; - - case DwarfAttributeForm.FlagPresent: - break; - - case DwarfAttributeForm.RefSig8: - endOffset += 8; // WriteU64(ValueAsU64); - break; - - case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); - case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); - case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); - case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); - case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); - case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); - case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); - case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); - case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); - case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); - case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); - case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); - case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); - case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); - case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); - case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); - case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); - case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); - case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); - case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); - case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); - case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); - default: - throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {Form}"); - } - - Size = endOffset - Offset; - } - - protected override void Read(DwarfReader reader) - { - var descriptor = reader.CurrentAttributeDescriptor; - - Kind = descriptor.Kind; - Form = descriptor.Form; - - ReadAttributeFormRawValue(reader); - - Size = reader.Offset - Offset; - - ResolveAttributeValue(reader); - } - - private void ResolveAttributeValue(DwarfReader reader) - { - switch (Kind.Value) - { - case DwarfAttributeKind.DeclFile: - { - var currentLineProgramTable = reader.CurrentLineProgramTable; - if (currentLineProgramTable == null) - { - // Log and error - } - else - { - var file = currentLineProgramTable.FileNames[ValueAsI32 - 1]; - ValueAsU64 = 0; - ValueAsObject = file; - } - break; - } - - case DwarfAttributeKind.StmtList: - { - if (ValueAsU64 == 0) return; - - if (reader.File.LineSection != null) - { - if (reader.OffsetToLineProgramTable.TryGetValue(ValueAsU64, out var lineProgramTable)) - { - ValueAsU64 = 0; - ValueAsObject = lineProgramTable; - reader.PushLineProgramTable(lineProgramTable); - } - else - { - // Log and error - } - } - else - { - - // Log an error - } - - break; - - } - - case DwarfAttributeKind.Location: - { - if (Form == DwarfAttributeFormEx.SecOffset) - { - if (reader.OffsetToLocationList.TryGetValue(ValueAsU64, out var locationList)) - { - ValueAsU64 = 0; - ValueAsObject = locationList; - } - else - { - // Log and error - } - } - break; - } - } - } - - - private void ReadAttributeFormRawValue(DwarfReader reader) - { - var attributeForm = Form; - - indirect: - switch (attributeForm.Value) - { - case DwarfAttributeForm.Addr: - { - ValueAsU64 = reader.ReadUInt(); - break; - } - - case DwarfAttributeForm.Data1: - { - ValueAsU64 = reader.ReadU8(); - break; - } - case DwarfAttributeForm.Data2: - { - ValueAsU64 = reader.ReadU16(); - break; - } - case DwarfAttributeForm.Data4: - { - ValueAsU64 = reader.ReadU32(); - break; - } - case DwarfAttributeForm.Data8: - { - ValueAsU64 = reader.ReadU64(); - break; - } - - case DwarfAttributeForm.String: - { - ValueAsObject = reader.ReadStringUTF8NullTerminated(); - break; - } - - case DwarfAttributeForm.Block: - { - var length = reader.ReadULEB128(); - ValueAsObject = reader.ReadAsStream(length); - break; - } - case DwarfAttributeForm.Block1: - { - var length = reader.ReadU8(); - ValueAsObject = reader.ReadAsStream(length); - break; - } - case DwarfAttributeForm.Block2: - { - var length = reader.ReadU16(); - ValueAsObject = reader.ReadAsStream(length); - break; - } - case DwarfAttributeForm.Block4: - { - var length = reader.ReadU32(); - ValueAsObject = reader.ReadAsStream(length); - break; - } - - case DwarfAttributeForm.Flag: - { - ValueAsBoolean = reader.ReadU8() != 0; - break; - } - case DwarfAttributeForm.Sdata: - { - ValueAsI64 = reader.ReadILEB128(); - break; - } - case DwarfAttributeForm.Strp: - { - var offset = reader.ReadUIntFromEncoding(); - ValueAsObject = reader.File.StringTable.GetStringFromOffset(offset); - break; - } - case DwarfAttributeForm.Udata: - { - ValueAsU64 = reader.ReadULEB128(); - break; - } - case DwarfAttributeForm.RefAddr: - { - ValueAsU64 = reader.ReadUIntFromEncoding(); - reader.ResolveAttributeReferenceWithinSection(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.Ref1: - { - ValueAsU64 = reader.ReadU8(); - reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.Ref2: - { - ValueAsU64 = reader.ReadU16(); - reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.Ref4: - { - ValueAsU64 = reader.ReadU32(); - reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.Ref8: - { - ValueAsU64 = reader.ReadU64(); - reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.RefUdata: - { - ValueAsU64 = reader.ReadULEB128(); - reader.ResolveAttributeReferenceWithinCompilationUnit(AttributeToDIERef(this), false); - break; - } - case DwarfAttributeForm.Indirect: - { - attributeForm = new DwarfAttributeFormEx(reader.ReadULEB128AsU32()); - goto indirect; - } - - // addptr - // lineptr - // loclist - // loclistptr - // macptr - // rnglist - // rngrlistptr - // stroffsetsptr - case DwarfAttributeForm.SecOffset: - { - ValueAsU64 = reader.ReadUIntFromEncoding(); - //Console.WriteLine($"attribute {Key} offset: {ValueAsU64}"); - break; - } - - case DwarfAttributeForm.Exprloc: - { - var expression = new DwarfExpression(); - expression.ReadInternal(reader); - ValueAsObject = expression; - break; - } - - case DwarfAttributeForm.FlagPresent: - { - ValueAsBoolean = true; - break; - } - - case DwarfAttributeForm.RefSig8: - { - var offset = reader.ReadU64(); - ValueAsU64 = offset; - break; - } - - case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); - case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); - case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); - case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); - case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); - case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); - case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); - case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); - case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); - case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); - case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); - case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); - case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); - case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); - case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); - case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); - case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); - case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); - case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); - case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); - case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); - case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); - default: - throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {attributeForm.Value}"); - } - } - - internal void UpdateAttributeForm(DwarfLayoutContext context) - { - Form = ComputeAttributeForm(context); - } - - private DwarfAttributeForm ComputeAttributeForm(DwarfLayoutContext context) - { - var key = Kind; - var encoding = DwarfHelper.GetAttributeEncoding(key); - - if (encoding == DwarfAttributeEncoding.None) - { - switch (Kind.Value) - { - case DwarfAttributeKind.GNUAllCallSites: - case DwarfAttributeKind.GNUAllTailCallSites: - encoding = DwarfAttributeEncoding.Flag; - break; - case DwarfAttributeKind.GNUCallSiteTarget: - case DwarfAttributeKind.GNUCallSiteValue: - encoding = DwarfAttributeEncoding.ExpressionLocation | DwarfAttributeEncoding.LocationList; - break; - - default: - // TODO: Add pluggable support for requesting attribute encoding here - throw new InvalidOperationException($"Unsupported attribute {this} with unknown encoding"); - } - } - - // If the attribute has a requested encoding - if (Encoding.HasValue) - { - var requestedEncoding = Encoding.Value; - if ((encoding & requestedEncoding) == 0) - { - throw new InvalidOperationException($"Requested encoding {requestedEncoding} for {this} doesn't match supported encoding {encoding} for this attribute"); - } - - // Replace encoding with requested encoding - encoding = requestedEncoding; - } - - // Do we still have a complex encoding? - if ((((uint)encoding) & ((uint)encoding - 1)) != 0U) - { - // if we have, try to detect which one we should select - if (ValueAsObject is DwarfDIE) - { - if ((encoding & DwarfAttributeEncoding.Reference) == 0) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The DIE value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Reference."); - } - - encoding = DwarfAttributeEncoding.Reference; - } - else if (this.ValueAsObject is Stream) - { - if ((encoding & DwarfAttributeEncoding.Block) == 0) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The Stream value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Block."); - } - - encoding = DwarfAttributeEncoding.Block; - } - else if (this.ValueAsObject is string) - { - if ((encoding & DwarfAttributeEncoding.String) == 0) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The string value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting String."); - } - - encoding = DwarfAttributeEncoding.String; - } - else if (this.ValueAsObject is DwarfExpression) - { - if ((encoding & DwarfAttributeEncoding.ExpressionLocation) == 0) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The expression value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting ExpressionLocation."); - } - - encoding = DwarfAttributeEncoding.ExpressionLocation; - } - else if (this.ValueAsObject is DwarfLocationList) - { - if ((encoding & DwarfAttributeEncoding.LocationList) == 0) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The expression value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting LocationList."); - } - - encoding = DwarfAttributeEncoding.LocationList; - } - else if ((encoding & DwarfAttributeEncoding.Address) != 0) - { - if (this.ValueAsObject != null) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The {this.ValueAsObject.GetType()} value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Address."); - } - - // If not specified explicitly, We consider HighPC as a constant (delta from LowPC) - if (this.Kind == DwarfAttributeKindEx.HighPC) - { - encoding = DwarfAttributeEncoding.Constant; - } - else - { - encoding = DwarfAttributeEncoding.Address; - } - } - else if ((encoding & DwarfAttributeEncoding.Constant) != 0) - { - if (this.ValueAsObject != null) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The {this.ValueAsObject.GetType()} value of attribute {this} from DIE {this.Parent} is not valid for supported attribute encoding {encoding}. Expecting Constant."); - } - - encoding = DwarfAttributeEncoding.Constant; - } - } - - switch (encoding) - { - case DwarfAttributeEncoding.Address: - return DwarfAttributeForm.Addr; - - case DwarfAttributeEncoding.Block: - VerifyAttributeValueNotNull(context); - - if (!(this.ValueAsObject is Stream)) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a System.IO.Stream"); - } - - return DwarfAttributeForm.Block; - - case DwarfAttributeEncoding.Constant: - - if (this.ValueAsU64 <= byte.MaxValue) - { - return DwarfAttributeForm.Data1; - } - - if (this.ValueAsU64 <= ushort.MaxValue) - { - return DwarfAttributeForm.Data2; - } - - if (this.ValueAsU64 <= uint.MaxValue) - { - return DwarfAttributeForm.Data4; - } - - return DwarfAttributeForm.Data8; - - case DwarfAttributeEncoding.ExpressionLocation: - VerifyAttributeValueNotNull(context); - - if (!(this.ValueAsObject is DwarfExpression)) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfExpression)}"); - } - - return DwarfAttributeForm.Exprloc; - - case DwarfAttributeEncoding.Flag: - return this.ValueAsBoolean ? DwarfAttributeForm.FlagPresent : DwarfAttributeForm.Flag; - - case DwarfAttributeEncoding.LinePointer: - bool canHaveNull = this.Kind.Value == DwarfAttributeKind.StmtList; - if (!canHaveNull) - { - VerifyAttributeValueNotNull(context); - - if (!(this.ValueAsObject is DwarfLine)) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfLine)}"); - } - } - - return DwarfAttributeForm.SecOffset; - - - case DwarfAttributeEncoding.Reference: - VerifyAttributeValueNotNull(context); - - if (this.ValueAsObject is DwarfDIE die) - { - var dieParentUnit = die.GetParentUnit(); - // If we are not from the same unit - if (dieParentUnit != context.CurrentUnit) - { - return DwarfAttributeForm.RefAddr; - } - } - else - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a {nameof(DwarfDIE)}"); - } - - return context.Config.DefaultAttributeFormForReference; - - case DwarfAttributeEncoding.String: - VerifyAttributeValueNotNull(context); - - if (this.ValueAsObject is string str) - { - // Create string offset - if (context.File.StringTable.Contains(str)) - { - return DwarfAttributeForm.Strp; - } - } - else - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The value of attribute {this} from DIE {this.Parent} must be a string."); - } - - return DwarfAttributeForm.String; - - case DwarfAttributeEncoding.RangeList: - case DwarfAttributeEncoding.LocationList: - case DwarfAttributeEncoding.Indirect: - case DwarfAttributeEncoding.AddressPointer: - case DwarfAttributeEncoding.LocationListsPointer: - case DwarfAttributeEncoding.RangeListsPointer: - case DwarfAttributeEncoding.StringOffsetPointer: - case DwarfAttributeEncoding.LocationListPointer: - case DwarfAttributeEncoding.MacroPointer: - case DwarfAttributeEncoding.RangeListPointer: - return DwarfAttributeForm.SecOffset; - } - - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The encoding {encoding} of attribute {this} from DIE {this.Parent} is not supported."); - return DwarfAttributeForm.Data8; - } - - private void VerifyAttributeValueNotNull(DwarfLayoutContext context) - { - if (ValueAsObject == null) - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object value of attribute {this} from DIE {this.Parent} cannot be null"); - } - } - - protected override void Write(DwarfWriter writer) - { - var startAttributeOffset = Offset; - Debug.Assert(Offset == startAttributeOffset); - - switch (Form.Value) - { - case DwarfAttributeForm.Addr: - { - writer.WriteAddress(DwarfRelocationTarget.Code, ValueAsU64); - break; - } - case DwarfAttributeForm.Data1: - { - writer.WriteU8((byte) ValueAsU64); - break; - } - case DwarfAttributeForm.Data2: - { - writer.WriteU16((ushort) ValueAsU64); - break; - } - case DwarfAttributeForm.Data4: - { - writer.WriteU32((uint) ValueAsU64); - break; - } - case DwarfAttributeForm.Data8: - { - writer.WriteU64(ValueAsU64); - break; - } - case DwarfAttributeForm.String: - { - writer.WriteStringUTF8NullTerminated((string) ValueAsObject); - break; - } - case DwarfAttributeForm.Block: - { - var stream = (Stream) ValueAsObject; - writer.WriteULEB128((ulong) stream.Length); - writer.Write(stream); - break; - } - case DwarfAttributeForm.Block1: - { - var stream = (Stream) ValueAsObject; - writer.WriteU8((byte) stream.Length); - writer.Write(stream); - break; - } - case DwarfAttributeForm.Block2: - { - var stream = (Stream) ValueAsObject; - writer.WriteU16((ushort) stream.Length); - writer.Write(stream); - break; - } - case DwarfAttributeForm.Block4: - { - var stream = (Stream) ValueAsObject; - writer.WriteU32((uint) stream.Length); - writer.Write(stream); - break; - } - case DwarfAttributeForm.Flag: - { - writer.WriteU8((byte) (ValueAsU64 != 0 ? 1 : 0)); - break; - } - case DwarfAttributeForm.Sdata: - { - writer.WriteILEB128(ValueAsI64); - break; - } - case DwarfAttributeForm.Strp: - { - var offset = writer.File.StringTable.GetOrCreateString((string) ValueAsObject); - if (writer.EnableRelocation) - { - writer.RecordRelocation(DwarfRelocationTarget.DebugString, writer.SizeOfUIntEncoding(), offset); - offset = 0; - } - writer.WriteUIntFromEncoding(offset); - break; - } - case DwarfAttributeForm.Udata: - { - writer.WriteULEB128(ValueAsU64); - break; - } - case DwarfAttributeForm.RefAddr: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteUIntFromEncoding(dieRef.Offset); - break; - } - case DwarfAttributeForm.Ref1: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteU8((byte) (dieRef.Offset - writer.CurrentUnit.Offset)); - break; - } - case DwarfAttributeForm.Ref2: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteU16((ushort) (dieRef.Offset - writer.CurrentUnit.Offset)); - break; - } - case DwarfAttributeForm.Ref4: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteU32((uint) (dieRef.Offset - writer.CurrentUnit.Offset)); - break; - } - case DwarfAttributeForm.Ref8: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteU64((dieRef.Offset - writer.CurrentUnit.Offset)); - break; - } - case DwarfAttributeForm.RefUdata: - { - var dieRef = (DwarfDIE) ValueAsObject; - writer.WriteULEB128((dieRef.Offset - writer.CurrentUnit.Offset)); - break; - } - - //case DwarfAttributeForm.indirect: - //{ - // attributeForm = reader.ReadLEB128As(); - // goto indirect; - //} - - // addptr - // lineptr - // loclist - // loclistptr - // macptr - // rnglist - // rngrlistptr - // stroffsetsptr - case DwarfAttributeForm.SecOffset: - { - if (ValueAsObject != null) - { - writer.WriteUIntFromEncoding(((DwarfObject) ValueAsObject).Offset); - } - else - { - writer.WriteUIntFromEncoding(ValueAsU64); - } - break; - } - - case DwarfAttributeForm.Exprloc: - ((DwarfExpression) ValueAsObject).WriteInternal(writer); - break; - - case DwarfAttributeForm.FlagPresent: - Debug.Assert(ValueAsBoolean); - break; - - case DwarfAttributeForm.RefSig8: - writer.WriteU64(ValueAsU64); - break; - - case DwarfAttributeForm.Strx: throw new NotSupportedException("DW_FORM_strx - DWARF5"); - case DwarfAttributeForm.Addrx: throw new NotSupportedException("DW_FORM_addrx - DWARF5"); - case DwarfAttributeForm.RefSup4: throw new NotSupportedException("DW_FORM_ref_sup4 - DWARF5"); - case DwarfAttributeForm.StrpSup: throw new NotSupportedException("DW_FORM_strp_sup - DWARF5"); - case DwarfAttributeForm.Data16: throw new NotSupportedException("DW_FORM_data16 - DWARF5"); - case DwarfAttributeForm.LineStrp: throw new NotSupportedException("DW_FORM_line_strp - DWARF5"); - case DwarfAttributeForm.ImplicitConst: throw new NotSupportedException("DW_FORM_implicit_const - DWARF5"); - case DwarfAttributeForm.Loclistx: throw new NotSupportedException("DW_FORM_loclistx - DWARF5"); - case DwarfAttributeForm.Rnglistx: throw new NotSupportedException("DW_FORM_rnglistx - DWARF5"); - case DwarfAttributeForm.RefSup8: throw new NotSupportedException("DW_FORM_ref_sup8 - DWARF5"); - case DwarfAttributeForm.Strx1: throw new NotSupportedException("DW_FORM_strx1 - DWARF5"); - case DwarfAttributeForm.Strx2: throw new NotSupportedException("DW_FORM_strx2 - DWARF5"); - case DwarfAttributeForm.Strx3: throw new NotSupportedException("DW_FORM_strx3 - DWARF5"); - case DwarfAttributeForm.Strx4: throw new NotSupportedException("DW_FORM_strx4 - DWARF5"); - case DwarfAttributeForm.Addrx1: throw new NotSupportedException("DW_FORM_addrx1 - DWARF5"); - case DwarfAttributeForm.Addrx2: throw new NotSupportedException("DW_FORM_addrx2 - DWARF5"); - case DwarfAttributeForm.Addrx3: throw new NotSupportedException("DW_FORM_addrx3 - DWARF5"); - case DwarfAttributeForm.Addrx4: throw new NotSupportedException("DW_FORM_addrx4 - DWARF5"); - case DwarfAttributeForm.GNUAddrIndex: throw new NotSupportedException("DW_FORM_GNU_addr_index - GNU extension in debug_info.dwo."); - case DwarfAttributeForm.GNUStrIndex: throw new NotSupportedException("DW_FORM_GNU_str_index - GNU extension, somewhat like DW_FORM_strp"); - case DwarfAttributeForm.GNURefAlt: throw new NotSupportedException("DW_FORM_GNU_ref_alt - GNU extension. Offset in .debug_info."); - case DwarfAttributeForm.GNUStrpAlt: throw new NotSupportedException("DW_FORM_GNU_strp_alt - GNU extension. Offset in .debug_str of another object file."); - default: - throw new NotSupportedException($"Unknown {nameof(DwarfAttributeForm)}: {Form}"); - } - - Debug.Assert(writer.Offset - startAttributeOffset == Size); - } - - private static readonly DwarfReader.DwarfDIEReferenceResolver DwarfAttributeDIEReferenceResolverInstance = DwarfAttributeDIEReferenceResolver; - - private static DwarfReader.DwarfDIEReference AttributeToDIERef(DwarfAttribute attr) - { - return new DwarfReader.DwarfDIEReference(attr.ValueAsU64, attr, DwarfAttributeDIEReferenceResolverInstance); - } - - private static void DwarfAttributeDIEReferenceResolver(ref DwarfReader.DwarfDIEReference dieRef) - { - var attr = (DwarfAttribute)dieRef.DwarfObject; - attr.ValueAsU64 = 0; - attr.ValueAsObject = dieRef.Resolved; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs deleted file mode 100644 index 8add13ebb6f564..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptor.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("{Kind} {Form}")] - public readonly struct DwarfAttributeDescriptor : IEquatable - { - public static readonly DwarfAttributeDescriptor Empty = new DwarfAttributeDescriptor(); - - public DwarfAttributeDescriptor(DwarfAttributeKindEx kind, DwarfAttributeFormEx form) - { - Kind = kind; - Form = form; - } - - public readonly DwarfAttributeKindEx Kind; - - public readonly DwarfAttributeFormEx Form; - - public bool IsNull => Kind.Value == 0 && Form.Value == 0; - - public bool Equals(DwarfAttributeDescriptor other) - { - return Kind.Equals(other.Kind) && Form.Equals(other.Form); - } - - public override bool Equals(object obj) - { - return obj is DwarfAttributeDescriptor other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return (Kind.GetHashCode() * 397) ^ Form.GetHashCode(); - } - } - - public static bool operator ==(DwarfAttributeDescriptor left, DwarfAttributeDescriptor right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfAttributeDescriptor left, DwarfAttributeDescriptor right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs deleted file mode 100644 index 50ffe430b2d428..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeDescriptors.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] - public readonly struct DwarfAttributeDescriptors : IEquatable - { - private readonly DwarfAttributeDescriptor[] _descriptors; - - public DwarfAttributeDescriptors(DwarfAttributeDescriptor[] descriptors) - { - _descriptors = descriptors ?? throw new ArgumentNullException(nameof(descriptors)); - } - - public int Length => _descriptors?.Length ?? 0; - - public DwarfAttributeDescriptor this[int index] - { - get - { - if (_descriptors == null) throw new ArgumentException("This descriptors instance is not initialized"); - return _descriptors[index]; - } - } - - public bool Equals(DwarfAttributeDescriptors other) - { - if (ReferenceEquals(_descriptors, other._descriptors)) return true; - if (_descriptors == null || other._descriptors == null) return false; - if (_descriptors.Length != other._descriptors.Length) return false; - - for (int i = 0; i < _descriptors.Length; i++) - { - if (_descriptors[i] != other._descriptors[i]) - { - return false; - } - } - return true; - } - - - public override bool Equals(object obj) - { - return obj is DwarfAttributeDescriptors other && Equals(other); - } - - public override int GetHashCode() - { - int hashCode = _descriptors == null ? 0 : _descriptors.Length; - if (hashCode == 0) return hashCode; - foreach (var descriptor in _descriptors) - { - hashCode = (hashCode * 397) ^ descriptor.GetHashCode(); - } - return hashCode; - } - - private string DebuggerDisplay => ToString(); - - public static bool operator ==(DwarfAttributeDescriptors left, DwarfAttributeDescriptors right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfAttributeDescriptors left, DwarfAttributeDescriptors right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return $"Count = {_descriptors.Length}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs deleted file mode 100644 index f722ab38d57b5a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeEncoding.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - [Flags] - public enum DwarfAttributeEncoding - { - None, - - Address = 1, - - Block = 1 << 1, - - Constant = 1 << 2, - - ExpressionLocation = 1 << 3, - - Flag = 1 << 4, - - LinePointer = 1 << 5, - - LocationListPointer = 1 << 6, - - MacroPointer = 1 << 7, - - RangeListPointer = 1 << 8, - - Reference = 1 << 9, - - String = 1 << 10, - - RangeList = 1 << 11, - - Indirect = 1 << 12, - - LocationList = 1 << 13, - - AddressPointer = 1 << 14, - - LocationListsPointer = 1 << 15, - - RangeListsPointer = 1 << 16, - - StringOffsetPointer = 1 << 17, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs deleted file mode 100644 index fa00158fca37de..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeFormEx.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - /// - /// Defines the kind of an . - /// This is the value seen in - /// - [DebuggerDisplay("{ToString(),nq}")] - public readonly partial struct DwarfAttributeFormEx : IEquatable - { - public DwarfAttributeFormEx(uint value) - { - Value = (DwarfAttributeForm)value; - } - public DwarfAttributeFormEx(DwarfAttributeForm value) - { - Value = value; - } - - public readonly DwarfAttributeForm Value; - - public bool Equals(DwarfAttributeFormEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfAttributeFormEx other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(DwarfAttributeFormEx left, DwarfAttributeFormEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfAttributeFormEx left, DwarfAttributeFormEx right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfAttributeFormEx)} (0x{Value:X4})"; - } - - public static explicit operator uint(DwarfAttributeFormEx form) => (uint)form.Value; - - public static implicit operator DwarfAttributeFormEx(DwarfAttributeForm kind) => new DwarfAttributeFormEx(kind); - - public static implicit operator DwarfAttributeForm(DwarfAttributeFormEx kind) => kind.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs deleted file mode 100644 index eb12ac9f8109fe..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeKindEx.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - /// - /// Defines the kind of an . - /// This is the value seen in - /// - [DebuggerDisplay("{ToString(),nq}")] - public readonly partial struct DwarfAttributeKindEx : IEquatable - { - public DwarfAttributeKindEx(uint value) - { - Value = (DwarfAttributeKind)value; - } - - public DwarfAttributeKindEx(DwarfAttributeKind value) - { - Value = value; - } - - public readonly DwarfAttributeKind Value; - - - public bool Equals(DwarfAttributeKindEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfAttributeKindEx other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(DwarfAttributeKindEx left, DwarfAttributeKindEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfAttributeKindEx left, DwarfAttributeKindEx right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfAttributeKindEx)} (0x{Value:X4})"; - } - - public static explicit operator uint(DwarfAttributeKindEx kind) => (uint)kind.Value; - - public static implicit operator DwarfAttributeKindEx(DwarfAttributeKind kind) => new DwarfAttributeKindEx(kind); - - public static implicit operator DwarfAttributeKind(DwarfAttributeKindEx kind) => kind.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs deleted file mode 100644 index b68406fcc583cc..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfAttributeValue.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public class DwarfAttributeValue - { - public DwarfAttributeValue(object value) - { - Value = value; - } - - public object Value { get; set; } - - public override string ToString() - { - return $"{nameof(Value)}: {Value}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs deleted file mode 100644 index ce84db351ca3ac..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCallingConventionEx.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public readonly partial struct DwarfCallingConventionEx : IEquatable - { - public DwarfCallingConventionEx(byte value) - { - Value = (DwarfCallingConvention)value; - } - - public DwarfCallingConventionEx(DwarfCallingConvention value) - { - Value = value; - } - - public readonly DwarfCallingConvention Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfCallingConvention)} (0x{Value:x2})"; - } - - public bool Equals(DwarfCallingConventionEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfCallingConventionEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(DwarfCallingConventionEx left, DwarfCallingConventionEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfCallingConventionEx left, DwarfCallingConventionEx right) - { - return !left.Equals(right); - } - - public static explicit operator uint(DwarfCallingConventionEx callConv) => (uint)callConv.Value; - - public static implicit operator DwarfCallingConventionEx(DwarfCallingConvention callConv) => new DwarfCallingConventionEx(callConv); - - public static implicit operator DwarfCallingConvention(DwarfCallingConventionEx callConv) => callConv.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs deleted file mode 100644 index 86603c49c493cd..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfCompilationUnit.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public class DwarfCompilationUnit : DwarfUnit - { - public DwarfCompilationUnit() - { - Kind = DwarfUnitKind.Compile; - // Default to version 4 - Version = 4; - } - - protected override void ReadHeader(DwarfReader reader) - { - if (Version < 5) - { - // 3. debug_abbrev_offset (section offset) - DebugAbbreviationOffset = reader.ReadUIntFromEncoding(); - - // 4. address_size (ubyte) - AddressSize = reader.ReadAddressSize(); - reader.AddressSize = AddressSize; - } - else - { - // NOTE: order of address_size/debug_abbrev_offset are different from Dwarf 4 - - // 4. address_size (ubyte) - AddressSize = reader.ReadAddressSize(); - reader.AddressSize = AddressSize; - - // 5. debug_abbrev_offset (section offset) - DebugAbbreviationOffset = reader.ReadUIntFromEncoding(); - } - } - - protected override void WriteHeader(DwarfWriter writer) - { - if (Version < 5) - { - // 3. debug_abbrev_offset (section offset) - var abbrevOffset = Abbreviation.Offset; - if (writer.EnableRelocation) - { - writer.RecordRelocation(DwarfRelocationTarget.DebugAbbrev, writer.SizeOfUIntEncoding(), abbrevOffset); - abbrevOffset = 0; - } - writer.WriteUIntFromEncoding(abbrevOffset); - - // 4. address_size (ubyte) - writer.WriteAddressSize(AddressSize); - } - else - { - // NOTE: order of address_size/debug_abbrev_offset are different from Dwarf 4 - - // 4. address_size (ubyte) - writer.WriteAddressSize(AddressSize); - - // 5. debug_abbrev_offset (section offset) - var abbrevOffset = Abbreviation.Offset; - if (writer.EnableRelocation) - { - writer.RecordRelocation(DwarfRelocationTarget.DebugAbbrev, writer.SizeOfUIntEncoding(), abbrevOffset); - abbrevOffset = 0; - } - writer.WriteUIntFromEncoding(abbrevOffset); - } - } - - protected override ulong GetLayoutHeaderSize() - { - // 3. debug_abbrev_offset (section offset) - // 4. address_size (ubyte) - return DwarfHelper.SizeOfUInt(Is64BitEncoding) + 1; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs deleted file mode 100644 index 8c83fa06656967..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfConstant.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public struct DwarfConstant - { - public DwarfConstant(int value) - { - AsValue = new DwarfInteger() {I64 = value}; - AsObject = null; - } - - public DwarfConstant(DwarfExpression expression) - { - AsValue = default; - AsObject = expression; - } - - public DwarfConstant(DwarfDIE dieRef) - { - AsValue = default; - AsObject = dieRef; - } - - public DwarfConstant(Stream stream) - { - AsValue = default; - AsObject = stream; - } - - public DwarfInteger AsValue; - - public object AsObject; - - public DwarfExpression AsExpression => AsObject as DwarfExpression; - - public DwarfDIE AsReference => AsObject as DwarfDIE; - - public Stream AsStream => AsObject as Stream; - - public string AsString => AsObject as string; - - public override string ToString() - { - if (AsExpression != null) return $"Constant Expression: {AsExpression}"; - if (AsReference != null) return $"Constant Reference: {AsReference}"; - if (AsStream != null) return $"Constant Block: Length = {AsStream.Length}"; - if (AsString != null) return $"Constant String: {AsString}"; - return $"Constant Value: {AsValue}"; - } - - public static implicit operator DwarfConstant(int value) - { - return new DwarfConstant(value); - } - - public static implicit operator DwarfConstant(DwarfExpression value) - { - return new DwarfConstant(value); - } - - public static implicit operator DwarfConstant(DwarfDIE value) - { - return new DwarfConstant(value); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs deleted file mode 100644 index 83940ffffff356..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfContainer.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfContainer : DwarfObject - { - public override void Verify(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs deleted file mode 100644 index 2c739980d5df02..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIE.cs +++ /dev/null @@ -1,516 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This attribute is licensed under the BSD-Clause 2 license. -// See the license.txt attribute in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public class DwarfDIE : DwarfContainer - { - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private readonly List _attributes; - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private readonly List _children; - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private DwarfTagEx _tag; - - /// - /// The current line program table when reading. - /// - internal DwarfLineProgramTable CurrentLineProgramTable; - - public DwarfDIE() - { - _attributes = new List(); - _children = new List(); - } - - protected DwarfDIE(DwarfTagEx tag) - { - _tag = tag; - } - - public virtual DwarfTagEx Tag - { - get => _tag; - set => _tag = value; - } - - public IReadOnlyList Attributes => _attributes; - - public IReadOnlyList Children => _children; - - public DwarfAbbreviationItem Abbrev { get; internal set; } - - /// - /// Adds a child to . - /// - /// A child - public void AddChild(DwarfDIE child) - { - _children.Add(this, child); - } - - /// - /// Inserts a child into at the specified index. - /// - /// Index into to insert the specified child - /// The child to insert - public void InsertChildAt(int index, DwarfDIE child) - { - _children.InsertAt(this, index, child); - } - - /// - /// Removes a child from - /// - /// The child to remove - public void RemoveChild(DwarfDIE child) - { - _children.Remove(this, child); - } - - /// - /// Removes a child from at the specified index. - /// - /// Index into to remove the specified child - public DwarfDIE RemoveChildAt(int index) - { - return _children.RemoveAt(this, index); - } - - /// - /// Adds an attribute to . - /// - /// A attribute - public void AddAttribute(DwarfAttribute attribute) - { - _attributes.AddSorted(this, attribute, true); - } - - /// - /// Removes an attribute from - /// - /// The attribute to remove - public void RemoveAttribute(DwarfAttribute attribute) - { - _attributes.Remove(this, attribute); - } - - /// - /// Removes an attribute from at the specified index. - /// - /// Index into to remove the specified attribute - public DwarfAttribute RemoveAttributeAt(int index) - { - return _attributes.RemoveAt(this, index); - } - - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - foreach (var attr in _attributes) - { - attr.Verify(diagnostics); - } - - foreach (var child in _children) - { - child.Verify(diagnostics); - } - } - - public override string ToString() - { - return $"{nameof(Tag)}: {Tag}, {nameof(Attributes)}: {Attributes.Count}, {nameof(Children)}: {Children.Count}"; - } - - protected TValue GetAttributeValue(DwarfAttributeKind kind) - { - foreach (var attr in _attributes) - { - if (attr.Kind == kind) - { - return (TValue)attr.ValueAsObject; - } - } - - return default; - } - - protected unsafe TValue? GetAttributeValueOpt(DwarfAttributeKind kind) where TValue : unmanaged - { - Debug.Assert(sizeof(TValue) <= sizeof(ulong)); - - foreach (var attr in _attributes) - { - if (attr.Kind == kind) - { - ulong localU64 = attr.ValueAsU64; - return *(TValue*) &localU64; - } - } - - return default; - } - - protected DwarfConstant? GetAttributeConstantOpt(DwarfAttributeKind kind) - { - foreach (var attr in _attributes) - { - if (attr.Kind == kind) - { - return new DwarfConstant - { - AsValue = - { - U64 = attr.ValueAsU64 - }, - AsObject = attr.ValueAsObject - }; - } - } - - return null; - } - - protected void SetAttributeConstantOpt(DwarfAttributeKind kind, DwarfConstant? cst) - { - for (int i = 0; i < _attributes.Count; i++) - { - var attr = _attributes[i]; - if (attr.Kind == kind) - { - if (!cst.HasValue) - { - RemoveAttributeAt(i); - } - else - { - var value = cst.Value; - attr.ValueAsU64 = value.AsValue.U64; - attr.ValueAsObject = value.AsExpression; - } - return; - } - } - - if (cst.HasValue) - { - var value = cst.Value; - AddAttribute(new DwarfAttribute() - { - Kind = kind, - ValueAsU64 = value.AsValue.U64, - ValueAsObject = value.AsExpression - }); - } - } - - protected DwarfLocation? GetAttributeLocationOpt(DwarfAttributeKind kind) - { - foreach (var attr in _attributes) - { - if (attr.Kind == kind) - { - return new DwarfLocation - { - AsValue = - { - U64 = attr.ValueAsU64 - }, - AsObject = attr.ValueAsObject - }; - } - } - - return null; - } - - protected void SetAttributeLocationOpt(DwarfAttributeKind kind, DwarfLocation? cst) - { - for (int i = 0; i < _attributes.Count; i++) - { - var attr = _attributes[i]; - if (attr.Kind == kind) - { - if (!cst.HasValue) - { - RemoveAttributeAt(i); - } - else - { - var value = cst.Value; - attr.ValueAsU64 = value.AsValue.U64; - attr.ValueAsObject = value.AsObject; - } - return; - } - } - - if (cst.HasValue) - { - var value = cst.Value; - AddAttribute(new DwarfAttribute() - { - Kind = kind, - ValueAsU64 = value.AsValue.U64, - ValueAsObject = value.AsObject - }); - } - } - - public DwarfAttribute FindAttributeByKey(DwarfAttributeKind kind) - { - foreach (var attr in _attributes) - { - if (attr.Kind == kind) - { - return attr; - } - } - - return null; - } - - protected unsafe void SetAttributeValue(DwarfAttributeKind kind, TValue value) - { - for (int i = 0; i < _attributes.Count; i++) - { - var attr = _attributes[i]; - if (attr.Kind == kind) - { - if (value == null) - { - RemoveAttributeAt(i); - } - else - { - attr.ValueAsObject = value; - } - return; - } - } - - if (value == null) return; - AddAttribute(new DwarfAttribute() { Kind = kind, ValueAsObject = value}); - } - - protected void SetAttributeLinkValue(DwarfAttributeKind kind, TLink link) where TLink : IObjectFileNodeLink - { - for (int i = 0; i < _attributes.Count; i++) - { - var attr = _attributes[i]; - if (attr.Kind == kind) - { - if (link == null) - { - RemoveAttributeAt(i); - } - else - { - attr.ValueAsU64 = link.GetRelativeOffset(); - attr.ValueAsObject = link.GetObjectFileNode(); - } - return; - } - } - - AddAttribute(new DwarfAttribute() - { - Kind = kind, - ValueAsU64 = link.GetRelativeOffset(), - ValueAsObject = link.GetObjectFileNode() - }); - } - - protected unsafe void SetAttributeValueOpt(DwarfAttributeKind kind, TValue? value) where TValue : unmanaged - { - Debug.Assert(sizeof(TValue) <= sizeof(ulong)); - - for (int i = 0; i < _attributes.Count; i++) - { - var attr = _attributes[i]; - if (attr.Kind == kind) - { - if (!value.HasValue) - { - RemoveAttributeAt(i); - } - else - { - ulong valueU64 = 0; - *((TValue*) &valueU64) = value.Value; - attr.ValueAsU64 = valueU64; - attr.ValueAsObject = null; - } - return; - } - } - - if (value.HasValue) - { - var attr = new DwarfAttribute() {Kind = kind}; - ulong valueU64 = 0; - *((TValue*)&valueU64) = value.Value; - attr.ValueAsU64 = valueU64; - AddAttribute(attr); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var abbrev = Abbrev; - - var endOffset = Offset; - endOffset += DwarfHelper.SizeOfULEB128(abbrev.Code); // WriteULEB128(abbreviationItem.Code); - - foreach (var attr in _attributes) - { - attr.Offset = endOffset; - attr.UpdateLayoutInternal(layoutContext); - endOffset += attr.Size; - } - - if (abbrev.HasChildren) - { - foreach (var child in _children) - { - child.Offset = endOffset; - child.UpdateLayout(layoutContext); - endOffset += child.Size; - } - - // Encode abbreviation 0 code - endOffset += DwarfHelper.SizeOfULEB128(0); - } - - Size = endOffset - Offset; - } - - protected override void Read(DwarfReader reader) - { - // Store map offset to DIE to resolve references - reader.PushDIE(this); - - // Console.WriteLine($" <{level}><{die.Offset:x}> Abbrev Number: {abbreviationCode} ({die.Tag})"); - - var descriptors = Abbrev.Descriptors; - if (descriptors.Length > 0) - { - for (int i = 0; i < descriptors.Length; i++) - { - reader.CurrentAttributeDescriptor = descriptors[i]; - - var attribute = new DwarfAttribute() - { - Offset = reader.Offset, - }; - - attribute.ReadInternal(reader); - - AddAttribute(attribute); - } - } - - if (Abbrev.HasChildren) - { - while (true) - { - reader.DIELevel++; - var child = ReadInstance(reader); - reader.DIELevel--; - if (child == null) break; - - AddChild(child); - } - } - - reader.PopDIE(); - - Size = reader.Offset - Offset; - } - - internal static DwarfDIE ReadInstance(DwarfReader reader) - { - var startDIEOffset = reader.Offset; - var abbreviationCode = reader.ReadULEB128(); - DwarfDIE die = null; - - if (abbreviationCode != 0) - { - - if (!reader.CurrentUnit.Abbreviation.TryFindByCode(abbreviationCode, out var abbreviationItem)) - { - throw new InvalidOperationException($"Invalid abbreviation code {abbreviationCode}"); - } - - die = DIEHelper.ConvertTagToDwarfDIE((ushort) abbreviationItem.Tag); - die.Offset = startDIEOffset; - die.Abbrev = abbreviationItem; - die.Tag = abbreviationItem.Tag; - die.ReadInternal(reader); - } - - return die; - } - - internal void UpdateAbbreviationItem(DwarfLayoutContext context) - { - // Initialize the offset of DIE to ulong.MaxValue to make sure that when we have a reference - // to it, we can detect if it is a forward or backward reference. - // If it is a backward reference, we will be able to encode the offset - // otherwise we will have to pad the encoding with NOP (for DwarfOperation in expressions) - Offset = ulong.MaxValue; - - // TODO: pool if not used by GetOrCreate below - var descriptorArray = new DwarfAttributeDescriptor[Attributes.Count]; - - for (var i = 0; i < Attributes.Count; i++) - { - var attr = Attributes[i]; - attr.UpdateAttributeForm(context); - descriptorArray[i] = new DwarfAttributeDescriptor(attr.Kind, attr.Form); - } - - var key = new DwarfAbbreviationItemKey(Tag, Children.Count > 0, new DwarfAttributeDescriptors(descriptorArray)); - var item = context.CurrentUnit.Abbreviation.GetOrCreate(key); - - Abbrev = item; - - foreach (var children in Children) - { - children.UpdateAbbreviationItem(context); - } - } - - protected override void Write(DwarfWriter writer) - { - var startDIEOffset = Offset; - Debug.Assert(Offset == startDIEOffset); - var abbrev = Abbrev; - writer.WriteULEB128(abbrev.Code); - - foreach (var attr in _attributes) - { - attr.WriteInternal(writer); - } - - if (abbrev.HasChildren) - { - foreach (var child in _children) - { - child.Write(writer); - } - writer.WriteULEB128(0); - } - - Debug.Assert(Size == writer.Offset - startDIEOffset); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs deleted file mode 100644 index 179a1c00badd0e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDIEDeclaration.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfDIEDeclaration : DwarfDIE - { - // DW_AT_decl_column, DW_AT_decl_file, and DW_AT_decl_line - public ulong? DeclColumn - { - get => GetAttributeValueOpt(DwarfAttributeKind.DeclColumn); - set => SetAttributeValueOpt(DwarfAttributeKind.DeclColumn, value); - } - - public DwarfFileName DeclFile - { - get => GetAttributeValue(DwarfAttributeKind.DeclFile); - set => SetAttributeValue(DwarfAttributeKind.DeclFile, value); - } - - public ulong? DeclLine - { - get => GetAttributeValueOpt(DwarfAttributeKind.DeclLine); - set => SetAttributeValueOpt(DwarfAttributeKind.DeclLine, value); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs deleted file mode 100644 index b059ae44e3aee0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfDiscriminantListKind.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfDiscriminantListKind : byte - { - Label = DwarfNative.DW_DSC_label, - - Range = DwarfNative.DW_DSC_range, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs deleted file mode 100644 index a8bf8953c6f574..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfElfContext.cs +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using LibObjectFile.Elf; - -namespace LibObjectFile.Dwarf -{ - public class DwarfElfContext - { - private readonly int _codeSectionSymbolIndex; - private int _infoSectionSymbolIndex; - private int _abbreviationTableSymbolIndex; - private int _lineTableSymbolIndex; - private int _stringTableSymbolIndex; - private int _locationSectionSymbolIndex; - private readonly ElfSymbolTable _symbolTable; - - public DwarfElfContext(ElfObjectFile elf) - { - Elf = elf ?? throw new ArgumentNullException(nameof(elf)); - - var relocContext = new ElfRelocationContext(); - - var codeSection = elf.Sections.OfType().FirstOrDefault(s => s.Name == ".text"); - - _symbolTable = elf.Sections.OfType().FirstOrDefault(); - var mapSectionToSymbolIndex = new Dictionary(); - if (_symbolTable != null) - { - for (var i = 0; i < _symbolTable.Entries.Count; i++) - { - var entry = _symbolTable.Entries[i]; - - if (entry.Type == ElfSymbolType.Section && entry.Section.Section != null) - { - mapSectionToSymbolIndex[entry.Section.Section] = i; - } - } - - if (codeSection != null) - { - if (!mapSectionToSymbolIndex.TryGetValue(codeSection, out _codeSectionSymbolIndex)) - { - _codeSectionSymbolIndex = _symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() - { - Type = ElfSymbolType.Section, - Section = codeSection, - }); - } - } - } - - foreach (var section in elf.Sections) - { - switch (section.Name.Value) - { - case ".debug_info": - InfoSection = ((ElfBinarySection)section); - mapSectionToSymbolIndex.TryGetValue(InfoSection, out _infoSectionSymbolIndex); - break; - case ".debug_abbrev": - AbbreviationTable = ((ElfBinarySection)section); - mapSectionToSymbolIndex.TryGetValue(AbbreviationTable, out _abbreviationTableSymbolIndex); - break; - case ".debug_aranges": - AddressRangeTable = ((ElfBinarySection)section); - break; - case ".debug_str": - StringTable = ((ElfBinarySection)section); - mapSectionToSymbolIndex.TryGetValue(StringTable, out _stringTableSymbolIndex); - break; - case ".debug_line": - LineTable = ((ElfBinarySection)section); - mapSectionToSymbolIndex.TryGetValue(LineTable, out _lineTableSymbolIndex); - break; - case ".debug_loc": - LocationSection = ((ElfBinarySection)section); - mapSectionToSymbolIndex.TryGetValue(LocationSection, out _locationSectionSymbolIndex); - break; - - case ".rela.debug_aranges": - case ".rel.debug_aranges": - RelocAddressRangeTable = (ElfRelocationTable)section; - RelocAddressRangeTable.Relocate(relocContext); - break; - - case ".rela.debug_line": - case ".rel.debug_line": - RelocLineTable = (ElfRelocationTable)section; - RelocLineTable.Relocate(relocContext); - break; - - case ".rela.debug_info": - case ".rel.debug_info": - RelocInfoSection = (ElfRelocationTable)section; - RelocInfoSection.Relocate(relocContext); - break; - - case ".rela.debug_loc": - case ".rel.debug_loc": - RelocLocationSection = (ElfRelocationTable)section; - RelocLocationSection.Relocate(relocContext); - break; - } - } - } - - public ElfObjectFile Elf { get; } - - public bool IsLittleEndian => Elf.Encoding == ElfEncoding.Lsb; - - public DwarfAddressSize AddressSize => Elf.FileClass == ElfFileClass.Is64 ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; - - public ElfBinarySection InfoSection { get; private set; } - - public ElfRelocationTable RelocInfoSection { get; set; } - - public ElfBinarySection AbbreviationTable { get; set; } - - public ElfBinarySection AddressRangeTable { get; private set; } - - public ElfRelocationTable RelocAddressRangeTable { get; set; } - - public ElfBinarySection StringTable { get; set; } - - public ElfBinarySection LineTable { get; set; } - - public ElfRelocationTable RelocLineTable { get; set; } - - public ElfBinarySection LocationSection { get; private set; } - - public ElfRelocationTable RelocLocationSection { get; set; } - - public int CodeSectionSymbolIndex => _codeSectionSymbolIndex; - - public int InfoSectionSymbolIndex => _infoSectionSymbolIndex; - - public int StringTableSymbolIndex => _stringTableSymbolIndex; - - public int AbbreviationTableSymbolIndex => _abbreviationTableSymbolIndex; - - public int LineTableSymbolIndex => _lineTableSymbolIndex; - - public int LocationSectionSymbolIndex => _locationSectionSymbolIndex; - - public ElfBinarySection GetOrCreateInfoSection() - { - return InfoSection ??= GetOrCreateDebugSection(".debug_info", true, out _infoSectionSymbolIndex); - } - - public ElfRelocationTable GetOrCreateRelocInfoSection() - { - return RelocInfoSection ??= GetOrCreateRelocationTable(InfoSection); - } - - public ElfBinarySection GetOrCreateAbbreviationTable() - { - return AbbreviationTable ??= GetOrCreateDebugSection(".debug_abbrev", true, out _abbreviationTableSymbolIndex); - } - - public ElfBinarySection GetOrCreateAddressRangeTable() - { - return AddressRangeTable ??= GetOrCreateDebugSection(".debug_aranges", false, out _); - } - - public ElfRelocationTable GetOrCreateRelocAddressRangeTable() - { - return RelocAddressRangeTable ??= GetOrCreateRelocationTable(AddressRangeTable); - } - - public ElfBinarySection GetOrCreateLineSection() - { - return LineTable ??= GetOrCreateDebugSection(".debug_line", true, out _lineTableSymbolIndex); - } - - public ElfRelocationTable GetOrCreateRelocLineSection() - { - return RelocLineTable ??= GetOrCreateRelocationTable(LineTable); - } - - public ElfBinarySection GetOrCreateStringTable() - { - return StringTable ??= GetOrCreateDebugSection(".debug_str", true, out _stringTableSymbolIndex); - } - - public ElfBinarySection GetOrCreateLocationSection() - { - return LocationSection ??= GetOrCreateDebugSection(".debug_loc", true, out _locationSectionSymbolIndex); - } - - public ElfRelocationTable GetOrCreateRelocLocationSection() - { - return RelocLocationSection ??= GetOrCreateRelocationTable(LocationSection); - } - - public void RemoveStringTable() - { - if (StringTable != null) - { - Elf.RemoveSection(StringTable); - StringTable = null; - } - } - - public void RemoveAbbreviationTable() - { - if (AbbreviationTable != null) - { - Elf.RemoveSection(AbbreviationTable); - AbbreviationTable = null; - } - } - - public void RemoveLineTable() - { - if (LineTable != null) - { - Elf.RemoveSection(LineTable); - LineTable = null; - } - - RemoveRelocLineTable(); - } - - public void RemoveRelocLineTable() - { - if (RelocLineTable != null) - { - Elf.RemoveSection(RelocLineTable); - RelocLineTable = null; - } - } - - public void RemoveAddressRangeTable() - { - if (AddressRangeTable != null) - { - Elf.RemoveSection(AddressRangeTable); - AddressRangeTable = null; - } - - RemoveRelocAddressRangeTable(); - } - - public void RemoveRelocAddressRangeTable() - { - if (RelocAddressRangeTable != null) - { - Elf.RemoveSection(RelocAddressRangeTable); - RelocAddressRangeTable = null; - } - } - - public void RemoveInfoSection() - { - if (InfoSection != null) - { - Elf.RemoveSection(InfoSection); - InfoSection = null; - } - - RemoveRelocInfoSection(); - } - - public void RemoveRelocInfoSection() - { - if (RelocInfoSection != null) - { - Elf.RemoveSection(RelocInfoSection); - RelocInfoSection = null; - } - } - - public void RemoveLocationSection() - { - if (LocationSection != null) - { - Elf.RemoveSection(LocationSection); - LocationSection = null; - } - - RemoveRelocLocationSection(); - } - - public void RemoveRelocLocationSection() - { - if (RelocLocationSection != null) - { - Elf.RemoveSection(RelocLocationSection); - RelocLocationSection = null; - } - } - - private ElfBinarySection GetOrCreateDebugSection(string name, bool createSymbol, out int symbolIndex) - { - var newSection = new ElfBinarySection() - { - Name = name, - Alignment = 1, - Type = ElfSectionType.ProgBits, - Stream = new MemoryStream(), - }; - - Elf.AddSection(newSection); - symbolIndex = 0; - - if (createSymbol && _symbolTable != null) - { - symbolIndex = _symbolTable.Entries.Count; - _symbolTable.Entries.Add(new ElfSymbol() - { - Type = ElfSymbolType.Section, - Section = newSection, - }); - } - - return newSection; - } - - private ElfRelocationTable GetOrCreateRelocationTable(ElfBinarySection section) - { - var newSection = new ElfRelocationTable() - { - Name = $".rela{section.Name}", - Alignment = (ulong)AddressSize, - Flags = ElfSectionFlags.InfoLink, - Type = ElfSectionType.RelocationAddends, - Info = section, - Link = _symbolTable, - }; - Elf.AddSection(newSection); - return newSection; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs deleted file mode 100644 index 9dbe2aad16cd6b..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfExpression.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("Count = {Operations.Count,nq}")] - public class DwarfExpression : DwarfObject - { - private readonly List _operations; - - public DwarfExpression() - { - _operations = new List(); - } - - public IReadOnlyList Operations => _operations; - - internal List InternalOperations => _operations; - - public ulong OperationLengthInBytes { get; internal set; } - - public void AddOperation(DwarfOperation operation) - { - if (operation == null) throw new ArgumentNullException(nameof(operation)); - _operations.Add(this, operation); - } - - public void RemoveOperation(DwarfOperation operation) - { - if (operation == null) throw new ArgumentNullException(nameof(operation)); - _operations.Remove(this, operation); - } - - public DwarfOperation RemoveOperationAt(int index) - { - return _operations.RemoveAt(this, index); - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - foreach (var op in _operations) - { - op.Verify(diagnostics); - } - } - - internal void ReadInternal(DwarfReader reader, bool inLocationSection = false) - { - Offset = reader.Offset; - var size = inLocationSection ? reader.ReadU16() : reader.ReadULEB128(); - OperationLengthInBytes = size; - var endPosition = reader.Offset + size; - - while (reader.Offset < endPosition) - { - var op = new DwarfOperation() {Offset = reader.Offset}; - op.ReadInternal(reader); - AddOperation(op); - } - - Size = reader.Offset - Offset; - } - - internal void WriteInternal(DwarfWriter writer, bool inLocationSection = false) - { - Debug.Assert(Offset == writer.Offset); - Debug.Assert(!inLocationSection || OperationLengthInBytes <= ushort.MaxValue); - - var startExpressionOffset = writer.Offset; - if (inLocationSection) - { - writer.WriteU16((ushort)OperationLengthInBytes); - } - else - { - writer.WriteULEB128(OperationLengthInBytes); - } - - foreach (var op in Operations) - { - op.WriteInternal(writer); - } - - Debug.Assert(writer.Offset - startExpressionOffset == Size); - } - - internal void UpdateLayoutInternal(DwarfLayoutContext layoutContext, bool inLocationSection = false) - { - var endOffset = Offset; - foreach (var op in _operations) - { - op.Offset = endOffset; - op.UpdateLayoutInternal(layoutContext); - endOffset += op.Size; - } - - OperationLengthInBytes = endOffset - Offset; - - // We need to shift the expression which is prefixed by its size encoded in LEB128, - // or fixed-size U2 in .debug_loc section - var deltaLength = inLocationSection ? sizeof(ushort) : DwarfHelper.SizeOfULEB128(Size); - foreach (var op in InternalOperations) - { - op.Offset += deltaLength; - } - - Size = OperationLengthInBytes + deltaLength; - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - UpdateLayoutInternal(layoutContext, inLocationSection: false); - } - - protected override void Read(DwarfReader reader) - { - ReadInternal(reader, inLocationSection: false); - } - - protected override void Write(DwarfWriter writer) - { - WriteInternal(writer, inLocationSection: false); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs deleted file mode 100644 index 0d37d0deab81f4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFile.cs +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using LibObjectFile.Elf; - -namespace LibObjectFile.Dwarf -{ - public class DwarfFile : DwarfContainer - { - private DwarfAbbreviationTable _abbreviationTable; - private DwarfStringTable _stringTable; - private DwarfLineSection _lineSection; - private DwarfInfoSection _infoSection; - private DwarfAddressRangeTable _addressRangeTable; - private DwarfLocationSection _locationSection; - - public DwarfFile() - { - AbbreviationTable = new DwarfAbbreviationTable(); - StringTable = new DwarfStringTable(); - LineSection = new DwarfLineSection(); - InfoSection = new DwarfInfoSection(); - LocationSection = new DwarfLocationSection(); - AddressRangeTable = new DwarfAddressRangeTable(); - } - - public DwarfAbbreviationTable AbbreviationTable - { - get => _abbreviationTable; - set => AttachChild(this, value, ref _abbreviationTable, false); - } - - public DwarfStringTable StringTable - { - get => _stringTable; - set => AttachChild(this, value, ref _stringTable, false); - } - - public DwarfLineSection LineSection - { - get => _lineSection; - set => AttachChild(this, value, ref _lineSection, false); - } - - public DwarfAddressRangeTable AddressRangeTable - { - get => _addressRangeTable; - set => AttachChild(this, value, ref _addressRangeTable, false); - } - - public DwarfInfoSection InfoSection - { - get => _infoSection; - set => AttachChild(this, value, ref _infoSection, false); - } - - public DwarfLocationSection LocationSection - { - get => _locationSection; - set => AttachChild(this, value, ref _locationSection, false); - } - - protected override void Read(DwarfReader reader) - { - throw new NotImplementedException(); - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - LineSection.Verify(diagnostics); - AbbreviationTable.Verify(diagnostics); - AddressRangeTable.Verify(diagnostics); - StringTable.Verify(diagnostics); - InfoSection.Verify(diagnostics); - } - - public void UpdateLayout(DwarfLayoutConfig config, DiagnosticBag diagnostics) - { - if (config == null) throw new ArgumentNullException(nameof(config)); - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - var layoutContext = new DwarfLayoutContext(this, config, diagnostics); - - LineSection.Offset = 0; - LineSection.UpdateLayoutInternal(layoutContext); - if (layoutContext.HasErrors) - { - return; - } - - // Reset the abbreviation table - // TODO: Make this configurable via the DwarfWriterContext - AbbreviationTable.Offset = 0; - AbbreviationTable.Reset(); - - InfoSection.Offset = 0; - InfoSection.UpdateLayoutInternal(layoutContext); - if (layoutContext.HasErrors) - { - return; - } - - // Update AddressRangeTable layout after Info - AddressRangeTable.Offset = 0; - AddressRangeTable.UpdateLayoutInternal(layoutContext); - if (layoutContext.HasErrors) - { - return; - } - - // Update string table right after updating the layout of Info - StringTable.Offset = 0; - StringTable.UpdateLayoutInternal(layoutContext); - if (layoutContext.HasErrors) - { - return; - } - - // Update the abbrev table right after we have computed the entire layout of Info - AbbreviationTable.Offset = 0; - AbbreviationTable.UpdateLayoutInternal(layoutContext); - - LocationSection.Offset = 0; - LocationSection.UpdateLayoutInternal(layoutContext); - } - - public void Write(DwarfWriterContext writerContext) - { - if (writerContext == null) throw new ArgumentNullException(nameof(writerContext)); - - var diagnostics = new DiagnosticBag(); - - // Verify correctness - Verify(diagnostics); - CheckErrors(diagnostics); - - // Update the layout of all section and tables - UpdateLayout(writerContext.LayoutConfig, diagnostics); - CheckErrors(diagnostics); - - // Write all section and stables - var writer = new DwarfWriter(this, writerContext.IsLittleEndian, diagnostics); - writer.AddressSize = writerContext.AddressSize; - writer.EnableRelocation = writerContext.EnableRelocation; - - writer.Log = writerContext.DebugLinePrinter; - writer.Stream = writerContext.DebugLineStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = LineSection; - LineSection.Relocations.Clear(); - LineSection.WriteInternal(writer); - } - - writer.Log = null; - writer.Stream = writerContext.DebugAbbrevStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = AbbreviationTable; - AbbreviationTable.WriteInternal(writer); - } - - writer.Stream = writerContext.DebugAddressRangeStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = AddressRangeTable; - AddressRangeTable.Relocations.Clear(); - AddressRangeTable.WriteInternal(writer); - } - - writer.Stream = writerContext.DebugStringStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = StringTable; - StringTable.WriteInternal(writer); - } - - writer.Stream = writerContext.DebugInfoStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = InfoSection; - InfoSection.Relocations.Clear(); - InfoSection.WriteInternal(writer); - } - - writer.Stream = writerContext.DebugLocationStream; - if (writer.Stream != null) - { - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = LocationSection; - LocationSection.Relocations.Clear(); - LocationSection.WriteInternal(writer); - } - - CheckErrors(diagnostics); - } - - public void WriteToElf(DwarfElfContext elfContext, DwarfLayoutConfig layoutConfig = null) - { - if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); - - var diagnostics = new DiagnosticBag(); - - layoutConfig ??= new DwarfLayoutConfig(); - - // Verify correctness - Verify(diagnostics); - CheckErrors(diagnostics); - - // Update the layout of all section and tables - UpdateLayout(layoutConfig, diagnostics); - CheckErrors(diagnostics); - - // Setup the output based on actual content of Dwarf infos - var writer = new DwarfWriter(this, elfContext.IsLittleEndian, diagnostics) - { - AddressSize = elfContext.AddressSize, - EnableRelocation = elfContext.Elf.FileType == ElfFileType.Relocatable - }; - - // Pre-create table/sections to create symbols as well - if (StringTable.Size > 0) elfContext.GetOrCreateStringTable(); - if (AbbreviationTable.Size > 0) elfContext.GetOrCreateAbbreviationTable(); - if (LineSection.Size > 0) elfContext.GetOrCreateLineSection(); - if (AddressRangeTable.Size > 0) elfContext.GetOrCreateAddressRangeTable(); - if (InfoSection.Size > 0) elfContext.GetOrCreateInfoSection(); - - // String table - if (StringTable.Size > 0) - { - writer.Stream = elfContext.GetOrCreateStringTable().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = StringTable; - StringTable.WriteInternal(writer); - } - else - { - elfContext.RemoveStringTable(); - } - - // Abbreviation table - if (AbbreviationTable.Size > 0) - { - writer.Stream = elfContext.GetOrCreateAbbreviationTable().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = AbbreviationTable; - AbbreviationTable.WriteInternal(writer); - } - else - { - elfContext.RemoveAbbreviationTable(); - } - - // Line table - if (LineSection.Size > 0) - { - writer.Stream = elfContext.GetOrCreateLineSection().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = LineSection; - LineSection.Relocations.Clear(); - LineSection.WriteInternal(writer); - if (writer.EnableRelocation && LineSection.Relocations.Count > 0) - { - LineSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocLineSection()); - } - else - { - elfContext.RemoveRelocLineTable(); - } - } - else - { - elfContext.RemoveLineTable(); - } - - // AddressRange table - if (AddressRangeTable.Size > 0) - { - writer.Stream = elfContext.GetOrCreateAddressRangeTable().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = AddressRangeTable; - AddressRangeTable.Relocations.Clear(); - AddressRangeTable.WriteInternal(writer); - - if (writer.EnableRelocation && AddressRangeTable.Relocations.Count > 0) - { - AddressRangeTable.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocAddressRangeTable()); - } - else - { - elfContext.RemoveAddressRangeTable(); - } - } - else - { - elfContext.RemoveAddressRangeTable(); - } - - // InfoSection - if (InfoSection.Size > 0) - { - writer.Stream = elfContext.GetOrCreateInfoSection().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = InfoSection; - InfoSection.Relocations.Clear(); - InfoSection.WriteInternal(writer); - - if (writer.EnableRelocation && InfoSection.Relocations.Count > 0) - { - InfoSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocInfoSection()); - } - else - { - elfContext.RemoveRelocInfoSection(); - } - } - else - { - elfContext.RemoveInfoSection(); - } - - // LocationSection - if (LocationSection.Size > 0) - { - writer.Stream = elfContext.GetOrCreateLocationSection().Stream; - writer.Stream.Position = 0; - writer.Stream.SetLength(0); - writer.CurrentSection = LocationSection; - LocationSection.Relocations.Clear(); - LocationSection.WriteInternal(writer); - - if (writer.EnableRelocation && LocationSection.Relocations.Count > 0) - { - LocationSection.CopyRelocationsTo(elfContext, elfContext.GetOrCreateRelocLocationSection()); - } - else - { - elfContext.RemoveRelocLocationSection(); - } - } - else - { - elfContext.RemoveLocationSection(); - } - - CheckErrors(diagnostics); - } - - public static DwarfFile Read(DwarfReaderContext readerContext) - { - if (readerContext == null) throw new ArgumentNullException(nameof(readerContext)); - - var dwarf = new DwarfFile(); - var reader = new DwarfReader(readerContext, dwarf, new DiagnosticBag()); - - reader.Log = null; - reader.Stream = readerContext.DebugAbbrevStream; - if (reader.Stream != null) - { - reader.CurrentSection = dwarf.AbbreviationTable; - dwarf.AbbreviationTable.ReadInternal(reader); - } - - reader.Stream = readerContext.DebugStringStream; - if (reader.Stream != null) - { - reader.CurrentSection = dwarf.StringTable; - dwarf.StringTable.ReadInternal(reader); - } - - reader.Log = readerContext.DebugLinePrinter; - reader.Stream = readerContext.DebugLineStream; - if (reader.Stream != null) - { - reader.CurrentSection = dwarf.LineSection; - dwarf.LineSection.ReadInternal(reader); - } - - reader.Log = null; - reader.Stream = readerContext.DebugAddressRangeStream; - if (reader.Stream != null) - { - reader.CurrentSection = dwarf.AddressRangeTable; - dwarf.AddressRangeTable.ReadInternal(reader); - } - - reader.Log = null; - reader.Stream = readerContext.DebugLocationStream; - if (reader.Stream != null) - { - reader.CurrentSection = dwarf.LocationSection; - dwarf.LocationSection.ReadInternal(reader); - } - - reader.Log = null; - reader.Stream = readerContext.DebugInfoStream; - if (reader.Stream != null) - { - reader.DefaultUnitKind = DwarfUnitKind.Compile; - reader.CurrentSection = dwarf.InfoSection; - dwarf.InfoSection.ReadInternal(reader); - } - - CheckErrors(reader.Diagnostics); - - return dwarf; - } - - public static DwarfFile ReadFromElf(DwarfElfContext elfContext) - { - if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); - return Read(new DwarfReaderContext(elfContext)); - } - - public static DwarfFile ReadFromElf(ElfObjectFile elf) - { - return ReadFromElf(new DwarfElfContext(elf)); - } - - private static void CheckErrors(DiagnosticBag diagnostics) - { - if (diagnostics.HasErrors) - { - throw new ObjectFileException("Unexpected errors while verifying and updating the layout", diagnostics); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - } - - protected override void Write(DwarfWriter writer) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs deleted file mode 100644 index ece43bc820f493..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfFileName.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfFileName - { - public string Name { get; set; } - - public string Directory { get; set; } - - public ulong Time { get; set; } - - public ulong Size { get; set; } - - public override string ToString() - { - if (string.IsNullOrEmpty(Name)) return ""; - if (Directory != null) - { - return Directory.Contains(Path.AltDirectorySeparatorChar) ? $"{Directory}{Path.AltDirectorySeparatorChar}{Name}" : $"{Directory}{Path.DirectorySeparatorChar}{Name}"; - } - - return Name; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs deleted file mode 100644 index daad1a95ae35e2..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfHelper.cs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Text; -using System.Numerics; - -namespace LibObjectFile.Dwarf -{ - public static partial class DwarfHelper - { - public static ulong SizeOfStringUTF8NullTerminated(string text) - { - if (text == null) return 0; - return (ulong)Encoding.UTF8.GetByteCount(text) + 1; - } - - public static uint SizeOfUnitLength(bool is64Bit) - { - return is64Bit ? 12U : 4U; - } - - public static uint SizeOfUInt(bool is64Bit) - { - return is64Bit ? 8U : 4U; - } - - public static uint SizeOfUInt(DwarfAddressSize addressSize) - { - return (uint)(addressSize); - } - - public static uint SizeOfULEB128(ulong value) - { - // bits_to_encode = (data != 0) ? 64 - CLZ(x) : 1 = 64 - CLZ(data | 1) - // bytes = ceil(bits_to_encode / 7.0); = (6 + bits_to_encode) / 7 - uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); - - // Division by 7 is done by (x * 37) >> 8 where 37 = ceil(256 / 7). - // This works for 0 <= x < 256 / (7 * 37 - 256), i.e. 0 <= x <= 85. - return (x * 37) >> 8; - } - - public static uint SizeOfILEB128(long value) - { - // The same as SizeOfULEB128 calculation but we have to account for the sign bit. - value ^= value >> 63; - uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)value | 1UL); - return (x * 37) >> 8; - } - - public static DwarfAttributeEncoding GetAttributeEncoding(DwarfAttributeKindEx kind) - { - if ((uint)kind.Value >= AttributeToEncoding.Length) return DwarfAttributeEncoding.None; - return AttributeToEncoding[(int) kind.Value]; - } - - private static readonly DwarfAttributeEncoding[] Encodings = new DwarfAttributeEncoding[] - { - DwarfAttributeEncoding.None , // 0 - DwarfAttributeEncoding.Address , // DW_FORM_addr 0x01 - DwarfAttributeEncoding.None , // Reserved 0x02 - DwarfAttributeEncoding.Block , // DW_FORM_block2 0x03 - DwarfAttributeEncoding.Block , // DW_FORM_block4 0x04 - DwarfAttributeEncoding.Constant , // DW_FORM_data2 0x05 - DwarfAttributeEncoding.Constant , // DW_FORM_data4 0x06 - DwarfAttributeEncoding.Constant , // DW_FORM_data8 0x07 - DwarfAttributeEncoding.String , // DW_FORM_string 0x08 - DwarfAttributeEncoding.Block , // DW_FORM_block 0x09 - DwarfAttributeEncoding.Block , // DW_FORM_block1 0x0a - DwarfAttributeEncoding.Constant , // DW_FORM_data1 0x0b - DwarfAttributeEncoding.Flag , // DW_FORM_flag 0x0c - DwarfAttributeEncoding.Constant , // DW_FORM_sdata 0x0d - DwarfAttributeEncoding.String , // DW_FORM_strp 0x0e - DwarfAttributeEncoding.Constant , // DW_FORM_udata 0x0f - DwarfAttributeEncoding.Reference , // DW_FORM_ref_addr 0x10 - DwarfAttributeEncoding.Reference , // DW_FORM_ref1 0x11 - DwarfAttributeEncoding.Reference , // DW_FORM_ref2 0x12 - DwarfAttributeEncoding.Reference , // DW_FORM_ref4 0x13 - DwarfAttributeEncoding.Reference , // DW_FORM_ref8 0x14 - DwarfAttributeEncoding.Reference , // DW_FORM_ref_udata 0x15 - DwarfAttributeEncoding.Indirect , // DW_FORM_indirect 0x16 - DwarfAttributeEncoding.AddressPointer | - DwarfAttributeEncoding.LinePointer | - DwarfAttributeEncoding.LocationList | - DwarfAttributeEncoding.LocationListsPointer | - DwarfAttributeEncoding.MacroPointer | - DwarfAttributeEncoding.RangeList | - DwarfAttributeEncoding.RangeListsPointer | - DwarfAttributeEncoding.StringOffsetPointer, // DW_FORM_sec_offset 0x17 - DwarfAttributeEncoding.ExpressionLocation , // DW_FORM_exprloc 0x18 - DwarfAttributeEncoding.Flag , // DW_FORM_flag_present 0x19 - DwarfAttributeEncoding.String , // DW_FORM_strx 0x1a - DwarfAttributeEncoding.Address , // DW_FORM_addrx 0x1b - DwarfAttributeEncoding.Reference , // DW_FORM_ref_sup4 0x1c - DwarfAttributeEncoding.String , // DW_FORM_strp_sup 0x1d - DwarfAttributeEncoding.Constant , // DW_FORM_data16 0x1e - DwarfAttributeEncoding.String , // DW_FORM_line_strp 0x1f - DwarfAttributeEncoding.Reference , // DW_FORM_ref_sig8 0x20 - DwarfAttributeEncoding.Constant , // DW_FORM_implicit_const 0x21 - DwarfAttributeEncoding.LocationList , // DW_FORM_loclistx 0x22 - DwarfAttributeEncoding.RangeList , // DW_FORM_rnglistx 0x23 - DwarfAttributeEncoding.Reference , // DW_FORM_ref_sup8 0x24 - DwarfAttributeEncoding.String , // DW_FORM_strx1 0x25 - DwarfAttributeEncoding.String , // DW_FORM_strx2 0x26 - DwarfAttributeEncoding.String , // DW_FORM_strx3 0x27 - DwarfAttributeEncoding.String , // DW_FORM_strx4 0x28 - DwarfAttributeEncoding.Address , // DW_FORM_addrx1 0x29 - DwarfAttributeEncoding.Address , // DW_FORM_addrx2 0x2a - DwarfAttributeEncoding.Address , // DW_FORM_addrx3 0x2b - DwarfAttributeEncoding.Address , // DW_FORM_addrx4 0x2c - }; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs deleted file mode 100644 index 5358d883940dec..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfIdentifierCaseKind.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfIdentifierCaseKind : byte - { - Sensitive = DwarfNative.DW_ID_case_sensitive, - - UpCase = DwarfNative.DW_ID_up_case, - - DownCase = DwarfNative.DW_ID_down_case, - - Insensitive = DwarfNative.DW_ID_case_insensitive, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs deleted file mode 100644 index 5f727a1e09614c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInfoSection.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfInfoSection : DwarfRelocatableSection - { - private readonly List _units; - - public DwarfInfoSection() - { - _units = new List(); - } - - public IReadOnlyList Units => _units; - - public void AddUnit(DwarfUnit unit) - { - _units.Add(this, unit); - } - - public void RemoveUnit(DwarfUnit unit) - { - _units.Remove(this, unit); - } - - public DwarfUnit RemoveUnitAt(int index) - { - return _units.RemoveAt(this, index); - } - - protected override void Read(DwarfReader reader) - { - var addressRangeTable = reader.File.AddressRangeTable; - - while (reader.Offset < reader.Length) - { - // 7.5 Format of Debugging Information - // - Each such contribution consists of a compilation unit header - - var startOffset = Offset; - - reader.ClearResolveAttributeReferenceWithinCompilationUnit(); - - var cu = DwarfUnit.ReadInstance(reader, out var offsetEndOfUnit); - if (cu == null) - { - reader.Offset = offsetEndOfUnit; - continue; - } - - reader.CurrentUnit = cu; - - // Link AddressRangeTable to Unit - if (addressRangeTable.DebugInfoOffset == cu.Offset) - { - addressRangeTable.Unit = cu; - } - - AddUnit(cu); - } - - reader.ResolveAttributeReferenceWithinSection(); - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - foreach (var unit in _units) - { - unit.Verify(diagnostics); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var offset = Offset; - foreach (var unit in Units) - { - layoutContext.CurrentUnit = unit; - unit.Offset = offset; - unit.UpdateLayoutInternal(layoutContext); - offset += unit.Size; - } - Size = offset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - Debug.Assert(Offset == writer.Offset); - foreach (var unit in _units) - { - writer.CurrentUnit = unit; - unit.WriteInternal(writer); - } - writer.CurrentUnit = null; - Debug.Assert(Size == writer.Offset - Offset); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs deleted file mode 100644 index a7b48d88db1e02..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInlineKind.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfInlineKind : byte - { - NotInlined = DwarfNative.DW_INL_not_inlined, - - Inlined = DwarfNative.DW_INL_inlined, - - DeclaredNotInlined = DwarfNative.DW_INL_declared_not_inlined, - - DeclaredInlined = DwarfNative.DW_INL_declared_inlined, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs deleted file mode 100644 index e00d5d24c8a32a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfInteger.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Runtime.InteropServices; - -namespace LibObjectFile.Dwarf -{ - [StructLayout(LayoutKind.Explicit)] - public struct DwarfInteger - { - [FieldOffset(0)] - public ulong U64; - - [FieldOffset(0)] - public long I64; - - [FieldOffset(0)] - public sbyte I8; - - [FieldOffset(0)] - public byte U8; - - [FieldOffset(0)] - public short I16; - - [FieldOffset(0)] - public ushort U16; - - [FieldOffset(0)] - public int I32; - - [FieldOffset(0)] - public uint U32; - - public override string ToString() - { - return $"0x{U64:x16}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs deleted file mode 100644 index 511fd5720c60cb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLanguageKindEx.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public readonly partial struct DwarfLanguageKindEx : IEquatable - { - public DwarfLanguageKindEx(ushort value) - { - Value = (DwarfLanguageKind)value; - } - - public DwarfLanguageKindEx(DwarfLanguageKind value) - { - Value = value; - } - - public readonly DwarfLanguageKind Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfLanguageKind)} (0x{Value:x4})"; - } - - public bool Equals(DwarfLanguageKindEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfLanguageKindEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(DwarfLanguageKindEx left, DwarfLanguageKindEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfLanguageKindEx left, DwarfLanguageKindEx right) - { - return !left.Equals(right); - } - - public static explicit operator uint(DwarfLanguageKindEx kind) => (uint)kind.Value; - - public static implicit operator DwarfLanguageKindEx(DwarfLanguageKind kind) => new DwarfLanguageKindEx(kind); - - public static implicit operator DwarfLanguageKind(DwarfLanguageKindEx kind) => kind.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs deleted file mode 100644 index 728d7f6e5ca7b3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutConfig.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public class DwarfLayoutConfig - { - private DwarfAttributeForm _defaultAttributeFormForReference; - - public DwarfLayoutConfig() - { - DefaultAttributeFormForReference = DwarfAttributeForm.Ref4; - } - - public DwarfAttributeFormEx DefaultAttributeFormForReference - { - get => _defaultAttributeFormForReference; - set - { - switch (value.Value) - { - case DwarfAttributeForm.Ref1: - case DwarfAttributeForm.Ref2: - case DwarfAttributeForm.Ref4: - break; - default: - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _defaultAttributeFormForReference = value; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs deleted file mode 100644 index 66977b60f757f7..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLayoutContext.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfLayoutContext - { - internal DwarfLayoutContext(DwarfFile file, DwarfLayoutConfig config, DiagnosticBag diagnostics) - { - File = file; - Config = config; - Diagnostics = diagnostics; - } - - public DwarfFile File { get; } - - public DiagnosticBag Diagnostics { get; } - - public DwarfLayoutConfig Config { get; } - - public bool HasErrors => Diagnostics.HasErrors; - - public DwarfUnit CurrentUnit { get; internal set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs deleted file mode 100644 index e6965b7118affb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLine.cs +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Globalization; - -namespace LibObjectFile.Dwarf -{ - public class DwarfLine : DwarfObject - { - public DwarfLine() - { - IsStatement = true; - } - - // ----------------------- - // DWARF 2 - // ----------------------- - - /// - /// The program-counter value corresponding to a machine instruction generated by the compiler. - /// - public ulong Address { get; set; } - - /// - /// An unsigned integer representing the index of an operation within a VLIW instruction. - /// The index of the first operation is 0. For non-VLIW architectures, this register will always be 0. - /// - public byte OperationIndex { get; set; } - - /// - /// The identity of the source file corresponding to a machine instruction. - /// - public DwarfFileName File { get; set; } - - /// - /// An unsigned integer indicating a source line number. - /// Lines are numbered beginning at 1. - /// The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. - /// - public uint Line { get; set; } - - /// - /// An unsigned integer indicating a column number within a source line. - /// Columns are numbered beginning at 1. The value 0 is reserved to indicate that a statement begins at the “left edge” of the line. - /// - public uint Column { get; set; } - - /// - /// A boolean indicating that the current instruction is a recommended breakpoint location. - /// A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement. - /// - public bool IsStatement { get; set; } - - /// - /// A boolean indicating that the current instruction is the beginning of a basic block. - /// - public bool IsBasicBlock { get; set; } - - // ----------------------- - // DWARF 3 - // ----------------------- - - /// - /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an entry breakpoint of a function. - /// - public bool IsPrologueEnd { get; set; } - - /// - /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an exit breakpoint of a function. - /// - public bool IsEpilogueBegin { get; set; } - - /// - /// An unsigned integer whose value encodes the applicable instruction set architecture for the current instruction. - /// - public ulong Isa { get; set; } - - // ----------------------- - // DWARF 4 - // ----------------------- - - /// - /// An unsigned integer identifying the block to which the current instruction belongs. - /// Discriminator values are assigned arbitrarily by the DWARF producer and serve to distinguish among multiple blocks that may all be - /// associated with the same source file, line, and column. - /// Where only one block exists for a given source position, the discriminator value should be zero. - /// - public ulong Discriminator { get; set; } - - public DwarfLine Clone() - { - return (DwarfLine) MemberwiseClone(); - } - - internal void Delta(DwarfLine against, out ulong deltaAddress, - out byte deltaOperationIndex, - out bool fileNameChanged, - out int deltaLine, - out int deltaColumn, - out bool isStatementChanged, - out bool isBasicBlockChanged, - out bool isPrologueEndChanged, - out bool isEpilogueBeginChanged, - out bool isaChanged, - out bool isDiscriminatorChanged) - { - deltaAddress = against.Address - this.Address; - deltaOperationIndex = (byte)(against.OperationIndex - this.OperationIndex); - fileNameChanged = !ReferenceEquals(this.File, against.File); - deltaLine = (int) ((long) against.Line - (long) this.Line); - deltaColumn = (int) ((long) against.Column - (long) this.Column); - isStatementChanged = against.IsStatement != this.IsStatement; - isBasicBlockChanged = against.IsBasicBlock != this.IsBasicBlock; - isPrologueEndChanged = against.IsPrologueEnd != this.IsPrologueEnd; - isEpilogueBeginChanged = against.IsEpilogueBegin != this.IsEpilogueBegin; - isaChanged = against.Isa != this.Isa; - isDiscriminatorChanged = against.Discriminator != this.Discriminator; - } - - internal void Reset(DwarfFileName firstFile, bool isStatement) - { - Address = 0; - File = firstFile; - Line = 1; - Column = 0; - this.IsStatement = isStatement; - IsBasicBlock = false; - - // DWARF 3 - IsPrologueEnd = false; - IsEpilogueBegin = false; - Isa = 0; - - // DWARF 5 - Discriminator = 0; - } - - internal void SpecialReset() - { - IsBasicBlock = false; - IsPrologueEnd = false; - IsEpilogueBegin = false; - Discriminator = 0; - } - - internal DwarfLineState ToState() - { - return new DwarfLineState() - { - Address = Address, - Column = Column, - Discriminator = Discriminator, - File = File, - Isa = Isa, - IsBasicBlock = IsBasicBlock, - IsEpilogueBegin = IsEpilogueBegin, - IsPrologueEnd = IsPrologueEnd, - IsStatement = IsStatement, - OperationIndex = OperationIndex, - Line = Line, - }; - } - - public override string ToString() - { - return $"{nameof(Offset)}: 0x{Offset:x8}, {nameof(Address)}: 0x{Address:x16}, {nameof(File)}: {File}, {nameof(Line)}: {Line,4}, {nameof(Column)}: {Column,2}, {nameof(IsStatement)}: {Bool2Str(IsStatement),5}, {nameof(IsBasicBlock)}: {Bool2Str(IsBasicBlock),5}, {nameof(IsPrologueEnd)}: {Bool2Str(IsPrologueEnd),5}, {nameof(IsEpilogueBegin)}: {Bool2Str(IsEpilogueBegin),5}, {nameof(Isa)}: {Isa,3}, {nameof(Discriminator)}: {Discriminator,3}"; - } - - private static string Bool2Str(bool value) => value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - } - - protected override void Read(DwarfReader reader) - { - } - - protected override void Write(DwarfWriter writer) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs deleted file mode 100644 index 185f5d3a00dc59..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineProgramTable.cs +++ /dev/null @@ -1,1376 +0,0 @@ - -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("Count = {LineSequences.Count,nq}")] - public sealed class DwarfLineProgramTable : DwarfObject - { - private readonly Dictionary _directoryNameToIndex; - private readonly Dictionary _fileNameToIndex; - private readonly List _directoryNames; - private readonly List _lineSequences; - private readonly DwarfLine _stateLine; - private byte _minimumInstructionLength; - private byte _maximumOperationsPerInstruction; - private readonly List _standardOpCodeLengths; - - public DwarfLineProgramTable() - { - FileNames = new List(); - _lineSequences = new List(); - _directoryNameToIndex = new Dictionary(); - _fileNameToIndex = new Dictionary(); - _directoryNames = new List(); - _stateLine = new DwarfLine(); - Version = 2; - LineBase = -5; - LineRange = 14; - _minimumInstructionLength = 1; - _maximumOperationsPerInstruction = 1; - _standardOpCodeLengths = new List(); - foreach (var stdOpCode in DefaultStandardOpCodeLengths) - { - _standardOpCodeLengths.Add(stdOpCode); - } - } - - public bool Is64BitEncoding { get; set; } - - public DwarfAddressSize AddressSize { get; set; } - - public ushort Version { get; set; } - - public sbyte LineBase { get; set; } - - public byte LineRange { get; set; } - - public ulong HeaderLength { get; private set; } - - public List StandardOpCodeLengths => _standardOpCodeLengths; - - public byte OpCodeBase - { - get => (byte)(StandardOpCodeLengths.Count + 1); - } - - public byte MinimumInstructionLength - { - get => _minimumInstructionLength; - set - { - if (value == 0) throw new ArgumentOutOfRangeException(nameof(value), "Must be > 0"); - _minimumInstructionLength = value; - } - } - - public byte MaximumOperationsPerInstruction - { - get => _maximumOperationsPerInstruction; - set - { - if (value == 0) throw new ArgumentOutOfRangeException(nameof(value), "Must be > 0"); - _maximumOperationsPerInstruction = value; - } - } - - public List FileNames { get; } - - public IReadOnlyList LineSequences => _lineSequences; - - public void AddLineSequence(DwarfLineSequence line) - { - _lineSequences.Add(this, line); - } - - public void RemoveLineSequence(DwarfLineSequence line) - { - _lineSequences.Remove(this, line); - } - - public DwarfLineSequence RemoveLineSequenceAt(int index) - { - return _lineSequences.RemoveAt(this, index); - } - - protected override void Read(DwarfReader reader) - { - var log = reader.Log; - var startOfSection = reader.Offset; - - reader.OffsetToLineProgramTable.Add(startOfSection, this); - - var unitLength = reader.ReadUnitLength(); - Is64BitEncoding = reader.Is64BitEncoding; - AddressSize = reader.AddressSize; - var startPosition = reader.Offset; - var version = reader.ReadU16(); - - if (version < 2 || version >= 5) - { - throw new NotSupportedException($"Version .debug_line {version} not supported"); - } - - Version = version; - - var header_length = reader.ReadUIntFromEncoding(); - HeaderLength = header_length; - var minimum_instruction_length = reader.ReadU8(); - MinimumInstructionLength = minimum_instruction_length; - - byte maximum_operations_per_instruction = 1; - if (version >= 4) - { - maximum_operations_per_instruction = reader.ReadU8(); - } - MaximumOperationsPerInstruction = maximum_operations_per_instruction; - - var default_is_stmt = reader.ReadU8(); - var line_base = reader.ReadI8(); - LineBase = line_base; - var line_range = reader.ReadU8(); - LineRange = line_range; - var opcode_base = reader.ReadU8(); - - if (log != null) - { - log.WriteLine(); - log.WriteLine($" Offset: 0x{startOfSection:x}"); - log.WriteLine($" Length: {unitLength}"); - log.WriteLine($" DWARF Version: {Version}"); - log.WriteLine($" Prologue Length: {header_length}"); - log.WriteLine($" Minimum Instruction Length: {minimum_instruction_length}"); - if (Version >= 4) - { - log.WriteLine($" Maximum Operations Per Instruction: {maximum_operations_per_instruction}"); - } - log.WriteLine($" Initial value of 'is_stmt': {default_is_stmt}"); - log.WriteLine($" Line Base: {line_base}"); - log.WriteLine($" Line Range: {line_range}"); - log.WriteLine($" Opcode Base: {opcode_base}"); - } - - _standardOpCodeLengths.Clear(); - for (int i = 1; i < opcode_base; i++) - { - var opcode_length = reader.ReadULEB128AsU32(); - _standardOpCodeLengths.Add((uint)opcode_length); - if (i - 1 <= DefaultStandardOpCodeLengths.Length && opcode_length != DefaultStandardOpCodeLengths[i - 1]) - { - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The standard opcode length at [{i}] = {opcode_length} is different from the expected length {DefaultStandardOpCodeLengths[i - 1]}"); - } - } - - if (log != null && opcode_base > 0) - { - log.WriteLine(); - log.WriteLine(" Opcodes:"); - for (int i = 0; i < _standardOpCodeLengths.Count; i++) - { - var argCount = _standardOpCodeLengths[i]; - log.WriteLine($" Opcode {i + 1} has {argCount} {((argCount == 0 || argCount > 1) ? "args" : "arg")}"); - } - } - - var directoriesOffset = reader.Offset; - var directories = new List(); - while (true) - { - var dir = reader.ReadStringUTF8NullTerminated(); - if (string.IsNullOrEmpty(dir)) - { - break; - } - - directories.Add(dir); - } - - if (log != null) - { - log.WriteLine(); - if (directories.Count > 0) - { - log.WriteLine($" The Directory Table (offset 0x{directoriesOffset:x}):"); - for (int i = 0; i < directories.Count; i++) - { - log.WriteLine($" {i + 1}\t{directories[i]}"); - } - } - else - { - log.WriteLine(" The Directory Table is empty."); - } - } - - var fileNamesOffset = reader.Offset; - bool printDumpHeader = true; - while (true) - { - var name = reader.ReadStringUTF8NullTerminated(); - - if (string.IsNullOrEmpty(name)) - { - break; - } - - var fileName = new DwarfFileName {Name = name}; - - var directoryIndex = reader.ReadULEB128(); - if (!name.Contains('/') && !name.Contains('\\') && directoryIndex > 0 && (directoryIndex - 1) < (ulong) directories.Count) - { - fileName.Directory = directories[(int) directoryIndex - 1]; - } - else - { - // log error - } - - fileName.Time = reader.ReadULEB128(); - fileName.Size = reader.ReadULEB128(); - - if (log != null) - { - if (printDumpHeader) - { - log.WriteLine(); - log.WriteLine($" The File Name Table (offset 0x{fileNamesOffset:x}):"); - log.WriteLine($" Entry\tDir\tTime\tSize\tName"); - printDumpHeader = false; - } - log.WriteLine($" {FileNames.Count + 1}\t{directoryIndex}\t{fileName.Time}\t{fileName.Size}\t{name}"); - } - - FileNames.Add(fileName); - } - - if (log != null && printDumpHeader) - { - log.WriteLine(); - log.WriteLine(" The File Name Table is empty."); - } - - var state = _stateLine; - state.Offset = reader.Offset; - var firstFileName = FileNames.Count > 0 ? FileNames[0] : null; - state.Reset(firstFileName, default_is_stmt != 0); - - var intFileNameCount = FileNames.Count; - - printDumpHeader = true; - var currentSequence = new DwarfLineSequence {Offset = state.Offset}; - - while (true) - { - var currentLength = reader.Offset - startPosition; - if (currentLength >= unitLength) - { - break; - } - - if (log != null) - { - if (printDumpHeader) - { - log.WriteLine(); - log.WriteLine(" Line Number Statements:"); - printDumpHeader = false; - } - - log.Write($" [0x{reader.Offset:x8}]"); - } - - var opcode = reader.ReadU8(); - switch (opcode) - { - case DwarfNative.DW_LNS_copy: - currentSequence.Add(state.Clone()); - state.Offset = reader.Offset; - state.SpecialReset(); - if (log != null) - { - log.WriteLine(" Copy"); - } - break; - case DwarfNative.DW_LNS_advance_pc: - { - var operation_advance = reader.ReadULEB128() * minimum_instruction_length; - - ulong deltaAddress = operation_advance; - if (version >= 4) - { - deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); - state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); - } - state.Address += deltaAddress; - - if (log != null) - { - if (minimum_instruction_length == 1) - { - log.WriteLine($" Advance PC by {deltaAddress} to 0x{state.Address:x}"); - } - else - { - log.WriteLine($" Advance PC by {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); - } - } - break; - } - case DwarfNative.DW_LNS_advance_line: - var deltaLine = reader.ReadILEB128(); - state.Line = (uint) (state.Line + deltaLine); - if (log != null) - { - log.WriteLine($" Advance Line by {deltaLine} to {state.Line}"); - } - break; - case DwarfNative.DW_LNS_set_file: - var fileIndex = reader.ReadLEB128AsI32(); - if (fileIndex == 0 || (fileIndex - 1) >= FileNames.Count ) - { - state.File = null; - } - else - { - state.File = FileNames[fileIndex - 1]; - } - if (log != null) - { - log.WriteLine($" Set File Name to entry {fileIndex} in the File Name Table"); - } - break; - case DwarfNative.DW_LNS_set_column: - state.Column = reader.ReadULEB128AsU32(); - if (log != null) - { - log.WriteLine($" Set column to {state.Column}"); - } - break; - case DwarfNative.DW_LNS_negate_stmt: - state.IsStatement = !state.IsStatement; - if (log != null) - { - log.WriteLine($" Set is_stmt to {(state.IsStatement ? 1 : 0)}"); - } - break; - case DwarfNative.DW_LNS_set_basic_block: - state.IsBasicBlock = true; - if (log != null) - { - log.WriteLine($" Set basic block"); - } - break; - case DwarfNative.DW_LNS_const_add_pc: - { - // Advance by opcode 255 - var adjusted_opcode = 255 - opcode_base; - var operation_advance = (ulong) adjusted_opcode / line_range; - - ulong deltaAddress = operation_advance; - if (version >= 4) - { - deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); - state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); - } - else - { - deltaAddress *= minimum_instruction_length; - } - state.Address += deltaAddress; - - if (log != null) - { - if (minimum_instruction_length == 1) - { - log.WriteLine($" Advance PC by constant {deltaAddress} to 0x{state.Address:x}"); - } - else - { - log.WriteLine($" Advance PC by constant {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); - } - } - break; - } - case DwarfNative.DW_LNS_fixed_advance_pc: - var fixedDelta = reader.ReadU16(); - state.Address += fixedDelta; - state.OperationIndex = 0; - if (log != null) - { - log.WriteLine($" Advance PC by fixed size amount {fixedDelta} to 0x{state.Address:x}"); - } - break; - case DwarfNative.DW_LNS_set_prologue_end: // DWARF 3 - state.IsPrologueEnd = true; - if (log != null) - { - log.WriteLine($" Set prologue_end to true"); - } - break; - case DwarfNative.DW_LNS_set_epilogue_begin: // DWARF 3 - state.IsEpilogueBegin = true; - if (log != null) - { - log.WriteLine($" Set epilogue_begin to true"); - } - break; - case DwarfNative.DW_LNS_set_isa: // DWARF 3 - state.Isa = reader.ReadULEB128(); - if (log != null) - { - log.WriteLine($" Set ISA to {state.Isa}"); - } - break; - case 0: - var sizeOfExtended = reader.ReadULEB128(); - var lengthOffset = reader.Offset; - var endOffset = reader.Offset + sizeOfExtended; - bool hasValidOpCode = true; - if (reader.Offset < endOffset) - { - var sub_opcode = reader.ReadU8(); - - // extended opcode - if (log != null) - { - log.Write($" Extended opcode {sub_opcode}: "); - } - - switch (sub_opcode) - { - case DwarfNative.DW_LNE_end_sequence: - currentSequence.Add(state.Clone()); - currentSequence.Size = reader.Offset - currentSequence.Offset; - AddLineSequence(currentSequence); - - currentSequence = new DwarfLineSequence() {Offset = reader.Offset}; - - state.Offset = reader.Offset; - state.Reset(firstFileName, default_is_stmt != 0); - if (log != null) - { - log.WriteLine("End of Sequence"); - log.WriteLine(); - } - break; - case DwarfNative.DW_LNE_set_address: - state.Address = reader.ReadUInt(); - state.OperationIndex = 0; - if (log != null) - { - log.WriteLine($"set Address to 0x{state.Address:x}"); - } - break; - case DwarfNative.DW_LNE_define_file: - var fileName = reader.ReadStringUTF8NullTerminated(); - var fileDirectoryIndex = reader.ReadLEB128AsI32(); - var fileTime = reader.ReadULEB128(); - var fileSize = reader.ReadULEB128(); - - var debugFileName = new DwarfFileName() {Name = fileName}; - debugFileName.Directory = fileDirectoryIndex == 0 || fileDirectoryIndex >= directories.Count ? null : directories[fileDirectoryIndex - 1]; - debugFileName.Time = fileTime; - debugFileName.Size = fileSize; - - state.File = debugFileName; - - if (log != null) - { - log.WriteLine("define new File Table entry"); - log.WriteLine($" Entry\tDir\tTime\tSize\tName"); - intFileNameCount++; - log.WriteLine($" {intFileNameCount + 1}\t{fileDirectoryIndex}\t{debugFileName.Time}\t{debugFileName.Size,-7}\t{fileName}"); - log.WriteLine(); - } - break; - case DwarfNative.DW_LNE_set_discriminator: // DWARF 4 - state.Discriminator = reader.ReadULEB128(); - if (log != null) - { - log.WriteLine($"set Discriminator to {state.Discriminator}"); - } - break; - default: - if (log != null) - { - log.WriteLine($"Unknown opcode"); - } - - hasValidOpCode = false; - // TODO: Add support for pluggable handling of extensions - reader.Diagnostics.Warning(DiagnosticId.DWARF_WRN_UnsupportedLineExtendedCode, $"Unsupported line extended opcode 0x{sub_opcode:x}"); - break; - } - - } - - // Log a warning if the end offset doesn't match what we are expecting - if (hasValidOpCode && reader.Offset != endOffset) - { - reader.Diagnostics.Warning(DiagnosticId.DWARF_WRN_InvalidExtendedOpCodeLength, $"Invalid length {sizeOfExtended} at offset 0x{lengthOffset:x}"); - } - - reader.Offset = endOffset; - break; - default: - if (opcode < opcode_base) - { - // If this is a standard opcode but not part of DWARF ("extension") - // we still want to be able to continue debugging - Debug.Assert(opcode > 0); - var numberOfLEB128Args = _standardOpCodeLengths[opcode - 1]; - for (ulong i = 0; i < numberOfLEB128Args; i++) - { - reader.ReadULEB128(); - } - - if (log != null) - { - log.WriteLine("Unsupported standard opcode with {numberOfLEB128Args} LEB128 args skipped"); - } - } - else - { - // Special opcode - var adjusted_opcode = opcode - opcode_base; - var operation_advance = (ulong)adjusted_opcode / line_range; - var line_inc = line_base + (adjusted_opcode % line_range); - state.Line = (uint)(state.Line + line_inc); - - ulong deltaAddress; - - if (version >= 4) - { - deltaAddress = minimum_instruction_length * ((state.OperationIndex + operation_advance) / maximum_operations_per_instruction); - state.Address += deltaAddress; - state.OperationIndex = (byte)((state.OperationIndex + operation_advance) % maximum_operations_per_instruction); - } - else - { - deltaAddress = operation_advance; - state.Address = state.Address + operation_advance; - } - - if (log != null) - { - if (minimum_instruction_length == 1) - { - log.Write($" Special opcode {adjusted_opcode}: advance Address by {deltaAddress} to 0x{state.Address:x}"); - } - else - { - log.Write($" Special opcode {adjusted_opcode}: advance Address by {deltaAddress} to 0x{state.Address:x}[{state.OperationIndex}]"); - } - - // TODO: Make verbose version - log.WriteLine($" and Line by {line_inc} to {state.Line}"); - } - - currentSequence.Add(state.Clone()); - state.Offset = reader.Offset; - state.SpecialReset(); - } - - break; - } - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - if (Version < 2 || Version >= 5) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version .debug_line {Version} not supported"); - } - - if (AddressSize == DwarfAddressSize.None) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Address size for .debug_line cannot be None/0"); - } - - if (StandardOpCodeLengths.Count < DefaultStandardOpCodeLengths.Length) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNumberOfStandardOpCodeLengths, $"Invalid length {StandardOpCodeLengths.Count} of {nameof(StandardOpCodeLengths)}. Expecting standard opcode length >= {DefaultStandardOpCodeLengths.Length} for {this}."); - } - else - { - for (int i = 0; i < DefaultStandardOpCodeLengths.Length; i++) - { - var opCodeLength = StandardOpCodeLengths[i]; - var expectedOpCodeLength = DefaultStandardOpCodeLengths[i]; - - if (opCodeLength != expectedOpCodeLength) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidStandardOpCodeLength, $"Invalid Standard OpCode Length {opCodeLength} for OpCode {i+1}. Expecting {expectedOpCodeLength} for {this}."); - } - } - } - - var startLine = LineBase; - var endLine = LineBase + LineRange; - if (startLine > 0 || endLine <= 0) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidStandardOpCodeLength, $"Invalid value for {nameof(LineBase)} = {LineBase} and/or {nameof(LineRange)} = {LineRange}. Expecting the range to cover the Line 0 for {this}"); - } - else - { - // TODO: take into account MaximumOperationsPerInstruction - var maxAdjustedOpCode = 255 - OpCodeBase; - int maxAddressIncrement = maxAdjustedOpCode / LineRange; - if (maxAdjustedOpCode <= 0 || maxAddressIncrement < MinimumInstructionLength) - { - diagnostics.Error(DiagnosticId.DWARF_WRN_CannotEncodeAddressIncrement, $"Cannot encode properly address increment with {nameof(LineBase)} = {LineBase}, {nameof(LineRange)} = {LineRange} and {nameof(StandardOpCodeLengths)}. The combination of {nameof(LineRange)} and {nameof(OpCodeBase)} are not making enough room for encoding address increment for {this}"); - } - } - - if (MaximumOperationsPerInstruction > 1 && Version < 4) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidMaximumOperationsPerInstruction, $"Invalid {nameof(MaximumOperationsPerInstruction)} = {MaximumOperationsPerInstruction}. Must be == 1 for {this}"); - } - - for (var i = 0; i < FileNames.Count; i++) - { - var fileName = FileNames[i]; - if (fileName == null) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNullFileNameEntry, $"Invalid null {nameof(FileNames)} entry at [{i}] for {this}"); - } - else - { - if (fileName.Name == null) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidFileName, $"Invalid null filename for {nameof(FileNames)} entry at [{i}] for {this}"); - } - } - } - - // Check that address increment is positive - foreach (var lineSequence in _lineSequences) - { - var lines = lineSequence.Lines; - ulong previousAddress = 0; - for (var i = 0; i < lines.Count; i++) - { - var line = lines[i]; - var deltaAddress = (long)line.Address - (long)previousAddress; - if (deltaAddress < 0) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidNegativeAddressDelta, $"Invalid address 0x{line.Address:x} after previous 0x{previousAddress:x} for debug line entry at [{i}]. The increment must be positive. for {this}"); - } - previousAddress = line.Address; - - if (line.OperationIndex >= MaximumOperationsPerInstruction) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidOperationIndex, $"Invalid operation index {line.OperationIndex} must be < {MaximumOperationsPerInstruction} for debug line entry at [{i}] for {this}"); - } - } - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - ulong sizeOf = 0; - - // unit_length - sizeOf += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); - - sizeOf += 2; // version (uhalf) - - // header length (calculated just after file names and size added as well) - sizeOf += DwarfHelper.SizeOfUInt(Is64BitEncoding); - ulong headerLengthStart = sizeOf; - - // minimum_instruction_length - sizeOf++; - - if (Version >= 4) - { - // maximum_operations_per_instruction - sizeOf++; - } - - // default_is_stmt - // line_base - // line_range - // opcode_base - sizeOf += 4; - - // StandardOpCodeLengths - foreach (var opcodeLength in _standardOpCodeLengths) - { - sizeOf += DwarfHelper.SizeOfULEB128(opcodeLength); - } - - // Write directory names - _directoryNameToIndex.Clear(); - _directoryNames.Clear(); - _fileNameToIndex.Clear(); - - foreach (var fileName in FileNames) - { - uint dirIndex = 0; - if (fileName.Directory != null) - { - var directoryName = fileName.Directory; - RecordDirectory(directoryName, ref sizeOf, out dirIndex); - } - - _fileNameToIndex.Add(fileName, (uint)_fileNameToIndex.Count + 1); - - sizeOf += (ulong)Encoding.UTF8.GetByteCount(fileName.Name) + 1; - sizeOf += DwarfHelper.SizeOfULEB128(dirIndex); - sizeOf += DwarfHelper.SizeOfULEB128(fileName.Time); - sizeOf += DwarfHelper.SizeOfULEB128(fileName.Size); - } - // byte 0 => end of directory names + end of file names - sizeOf += 2; - - HeaderLength = sizeOf - headerLengthStart; - - LayoutDebugLineOpCodes(ref sizeOf, OpCodeBase); - - Size = sizeOf; - } - - private void RecordDirectory(string directoryName, ref ulong sizeOf, out uint dirIndex) - { - if (!_directoryNameToIndex.TryGetValue(directoryName, out dirIndex)) - { - dirIndex = (uint) _directoryNames.Count + 1; - _directoryNameToIndex.Add(directoryName, dirIndex); - sizeOf += (ulong) Encoding.UTF8.GetByteCount(directoryName) + 1; - _directoryNames.Add(directoryName); - } - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - - writer.Is64BitEncoding = Is64BitEncoding; - writer.WriteUnitLength(Size - DwarfHelper.SizeOfUnitLength(Is64BitEncoding)); - - writer.WriteU16(Version); - writer.WriteUIntFromEncoding(HeaderLength); - - var startOfHeader = writer.Offset; - - writer.WriteU8(MinimumInstructionLength); - - if (Version >= 4) - { - writer.WriteU8(MaximumOperationsPerInstruction); - } - - // default_is_stmt - writer.WriteU8(1); - - // line_base - writer.WriteI8(LineBase); - - // line_range - writer.WriteU8(LineRange); - - // opcode_base - writer.WriteU8(OpCodeBase); - - // standard_opcode_lengths - foreach (var opcodeLength in StandardOpCodeLengths) - { - writer.WriteULEB128(opcodeLength); - } - - // Write directory names - foreach (var directoryName in _directoryNames) - { - writer.WriteStringUTF8NullTerminated(directoryName); - } - // empty string - writer.WriteU8(0); - - // Write filenames - foreach (var fileName in FileNames) - { - writer.WriteStringUTF8NullTerminated(fileName.Name); - - uint directoryIndex = 0; - if (fileName.Directory != null) - { - directoryIndex = _directoryNameToIndex[fileName.Directory]; - } - - writer.WriteULEB128(directoryIndex); - writer.WriteULEB128(fileName.Time); - writer.WriteULEB128(fileName.Size); - } - // empty string - writer.WriteU8(0); - - var headSizeWritten = writer.Offset - startOfHeader; - Debug.Assert(HeaderLength == headSizeWritten, $"Expected Header Length: {HeaderLength} != Written Header Length: {headSizeWritten}"); - - WriteDebugLineOpCodes(writer, OpCodeBase); - - Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); - } - - private void WriteDebugLineOpCodes(DwarfWriter writer, uint opCodeBase) - { - var previousLineState = new DwarfLineState(); - var firstFile = FileNames.Count > 0 ? FileNames[0] : null; - previousLineState.Reset(firstFile, true); - var initialState = previousLineState; - - uint maxDeltaAddressPerSpecialCode; - byte maxOperationAdvance = (byte) ((255 - OpCodeBase) / LineRange); - if (Version >= 4) - { - maxDeltaAddressPerSpecialCode = (uint)maxOperationAdvance / MaximumOperationsPerInstruction; - } - else - { - maxDeltaAddressPerSpecialCode = maxOperationAdvance; - } - maxDeltaAddressPerSpecialCode *= MinimumInstructionLength; - - bool hasSetAddress; - - foreach (var lineSequence in _lineSequences) - { - var lines = lineSequence.Lines; - - hasSetAddress = false; - - for (var lineIndex = 0; lineIndex < lines.Count; lineIndex++) - { - var debugLine = lines[lineIndex]; - ulong deltaAddress; - int deltaOperationIndex; - bool fileNameChanged; - int deltaLine; - int deltaColumn; - bool isStatementChanged; - bool isBasicBlockChanged; - bool isEndSequenceChanged; - bool isPrologueEndChanged; - bool isEpilogueBeginChanged; - bool isaChanged; - bool isDiscriminatorChanged; - - bool hasGeneratedRow = false; - - var debugLineState = debugLine.ToState(); - - previousLineState.Delta(debugLineState, out deltaAddress, - out deltaOperationIndex, - out fileNameChanged, - out deltaLine, - out deltaColumn, - out isStatementChanged, - out isBasicBlockChanged, - out isEndSequenceChanged, - out isPrologueEndChanged, - out isEpilogueBeginChanged, - out isaChanged, - out isDiscriminatorChanged); - - Debug.Assert(debugLine.Offset == writer.Offset, $"Expected Debug Line Offset: {debugLine.Offset} != Written Offset: {writer.Offset}"); - - // DW_LNS_set_column - if (deltaColumn != 0) - { - writer.WriteU8(DwarfNative.DW_LNS_set_column); - writer.WriteULEB128(debugLine.Column); - } - - // DW_LNS_set_file or DW_LNE_define_file - if (fileNameChanged) - { - var fileName = debugLine.File; - - // DW_LNS_set_file - if (_fileNameToIndex.TryGetValue(fileName, out var fileIndex)) - { - writer.WriteU8(DwarfNative.DW_LNS_set_file); - writer.WriteULEB128(fileIndex); - } - else - { - // DW_LNE_define_file - writer.WriteU8(0); - uint dirIndex = fileName.Directory != null && _directoryNameToIndex.ContainsKey(fileName.Directory) ? _directoryNameToIndex[fileName.Directory] : 0; - - ulong sizeOfInlineFileName = 1; - sizeOfInlineFileName += (ulong) Encoding.UTF8.GetByteCount(fileName.Name) + 1; - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(dirIndex); - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Time); - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Size); - - writer.WriteULEB128(sizeOfInlineFileName); - - writer.WriteU8(DwarfNative.DW_LNE_define_file); - writer.WriteStringUTF8NullTerminated(fileName.Name); - writer.WriteULEB128(dirIndex); - writer.WriteULEB128(fileName.Time); - writer.WriteULEB128(fileName.Size); - } - } - - // DW_LNS_copy - if (isBasicBlockChanged && !debugLine.IsBasicBlock || - isPrologueEndChanged && !debugLine.IsPrologueEnd || - isEpilogueBeginChanged && !debugLine.IsEpilogueBegin) - { - writer.WriteU8(DwarfNative.DW_LNS_copy); - isDiscriminatorChanged = debugLine.Discriminator != 0; - hasGeneratedRow = true; - } - - // DW_LNS_set_basic_block - if (isBasicBlockChanged && debugLine.IsBasicBlock) - { - writer.WriteU8(DwarfNative.DW_LNS_set_basic_block); - } - - // DW_LNS_set_prologue_end - if (isPrologueEndChanged && debugLine.IsPrologueEnd) - { - writer.WriteU8(DwarfNative.DW_LNS_set_prologue_end); - } - - // DW_LNS_set_epilogue_begin - if (isEpilogueBeginChanged && debugLine.IsEpilogueBegin) - { - writer.WriteU8(DwarfNative.DW_LNS_set_epilogue_begin); - } - - // DW_LNS_set_isa - if (isaChanged) - { - writer.WriteU8(DwarfNative.DW_LNS_set_isa); - writer.WriteULEB128(debugLine.Isa); - } - - // DW_LNE_set_discriminator - if (isDiscriminatorChanged) - { - writer.WriteU8(0); - writer.WriteULEB128(1 + DwarfHelper.SizeOfULEB128(debugLine.Discriminator)); - writer.WriteU8(DwarfNative.DW_LNE_set_discriminator); - writer.WriteULEB128(debugLine.Discriminator); - } - - // DW_LNS_negate_stmt - if (isStatementChanged) - { - writer.WriteU8(DwarfNative.DW_LNS_negate_stmt); - } - - bool isEndOfSequence = lineIndex + 1 == lines.Count; - bool canEncodeSpecial = !isEndOfSequence; - bool canEncodeLineInSpecialCode = canEncodeSpecial && deltaLine >= LineBase && deltaLine < LineBase + LineRange; - - bool operationAdvancedEncoded = false; - - // Pre-encode address if necessary - if (!hasSetAddress) - { - writer.WriteU8(0); - writer.WriteULEB128(1 + DwarfHelper.SizeOfUInt(writer.AddressSize)); - writer.WriteU8(DwarfNative.DW_LNE_set_address); - writer.WriteAddress(DwarfRelocationTarget.Code, debugLine.Address); - operationAdvancedEncoded = true; - deltaAddress = 0; - hasSetAddress = true; - } - - // DW_LNS_advance_line - // In case we can't encode the line advance via special code - if (!canEncodeLineInSpecialCode) - { - if (deltaLine != 0) - { - writer.WriteU8(DwarfNative.DW_LNS_advance_line); - writer.WriteILEB128(deltaLine); - deltaLine = 0; - } - } - - - if (deltaAddress > maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * maxDeltaAddressPerSpecialCode)) - { - ulong deltaAddressSpecialOpCode255; - - if (Version >= 4) - { - deltaAddressSpecialOpCode255 = (((ulong) previousLineState.OperationIndex + maxOperationAdvance) / MaximumOperationsPerInstruction); - deltaOperationIndex = debugLine.OperationIndex - (byte) ((previousLineState.OperationIndex + maxOperationAdvance) % MaximumOperationsPerInstruction); - } - else - { - deltaAddressSpecialOpCode255 = maxOperationAdvance; - deltaOperationIndex = 0; - } - - Debug.Assert(deltaAddressSpecialOpCode255 * MinimumInstructionLength < deltaAddress); - deltaAddress -= deltaAddressSpecialOpCode255 * MinimumInstructionLength; - - writer.WriteU8(DwarfNative.DW_LNS_const_add_pc); - } - - var operation_advance = deltaAddress * MaximumOperationsPerInstruction / MinimumInstructionLength + debugLine.OperationIndex; - - bool canEncodeAddressInSpecialCode = false; - ulong opcode = 256; - if (canEncodeSpecial && (operation_advance > 0 || deltaOperationIndex != 0 || deltaLine != 0)) - { - opcode = operation_advance * LineRange + opCodeBase + (ulong) (deltaLine - LineBase); - if (opcode > 255) - { - if (deltaLine != 0) - { - opcode = opCodeBase + (ulong) (deltaLine - LineBase); - } - } - else - { - canEncodeAddressInSpecialCode = true; - } - } - - if (!operationAdvancedEncoded && !canEncodeAddressInSpecialCode) - { - if (deltaAddress > 0 || deltaOperationIndex != 0) - { - writer.WriteU8(DwarfNative.DW_LNS_advance_pc); - writer.WriteULEB128(operation_advance); - } - } - - // Special opcode - if (opcode <= 255) - { - writer.WriteU8((byte) opcode); - debugLineState.SpecialReset(); - hasGeneratedRow = true; - } - - if (isEndOfSequence) - { - writer.WriteU8(0); - writer.WriteULEB128(1); - writer.WriteU8(DwarfNative.DW_LNE_end_sequence); - - hasGeneratedRow = true; - - hasSetAddress = false; - previousLineState = initialState; - previousLineState.Reset(firstFile, true); - } - else - { - previousLineState = debugLineState; - } - - if (!hasGeneratedRow) - { - writer.WriteU8(DwarfNative.DW_LNS_copy); - } - - Debug.Assert(debugLine.Size == writer.Offset - debugLine.Offset, $"Expected Debug Line Size: {debugLine.Size} != Written Size: {writer.Offset - debugLine.Offset}"); - } - } - } - - private void LayoutDebugLineOpCodes(ref ulong sizeOf, uint opCodeBase) - { - var previousLineState = new DwarfLineState(); - var firstFile = FileNames.Count > 0 ? FileNames[0] : null; - previousLineState.Reset(firstFile, true); - var initialState = previousLineState; - - uint maxDeltaAddressPerSpecialCode; - byte maxOperationAdvance = (byte)((255 - OpCodeBase) / LineRange); - if (Version >= 4) - { - maxDeltaAddressPerSpecialCode = (uint)maxOperationAdvance / MaximumOperationsPerInstruction; - } - else - { - maxDeltaAddressPerSpecialCode = maxOperationAdvance; - } - maxDeltaAddressPerSpecialCode *= MinimumInstructionLength; - - bool hasSetAddress; - - foreach (var lineSequence in _lineSequences) - { - var lines = lineSequence.Lines; - - lineSequence.Offset = Offset + sizeOf; - hasSetAddress = false; - - for (var lineIndex = 0; lineIndex < lines.Count; lineIndex++) - { - var debugLine = lines[lineIndex]; - ulong deltaAddress; - int deltaOperationIndex; - bool fileNameChanged; - int deltaLine; - int deltaColumn; - bool isStatementChanged; - bool isBasicBlockChanged; - bool isEndSequenceChanged; - bool isPrologueEndChanged; - bool isEpilogueBeginChanged; - bool isaChanged; - bool isDiscriminatorChanged; - - bool hasGeneratedRow = false; - - var debugLineState = debugLine.ToState(); - - previousLineState.Delta(debugLineState, out deltaAddress, - out deltaOperationIndex, - out fileNameChanged, - out deltaLine, - out deltaColumn, - out isStatementChanged, - out isBasicBlockChanged, - out isEndSequenceChanged, - out isPrologueEndChanged, - out isEpilogueBeginChanged, - out isaChanged, - out isDiscriminatorChanged); - - debugLine.Offset = Offset + sizeOf; - - // DW_LNS_set_column - if (deltaColumn != 0) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_column); - sizeOf += DwarfHelper.SizeOfULEB128(debugLine.Column); //writer.WriteLEB128(debugLine.Column)); - } - - // DW_LNS_set_file or DW_LNE_define_file - if (fileNameChanged) - { - var fileName = debugLine.File; - - // DW_LNS_set_file - if (_fileNameToIndex.TryGetValue(fileName, out var fileIndex)) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_file); - sizeOf += DwarfHelper.SizeOfULEB128(fileIndex); // writer.WriteLEB128(fileIndex); - } - else - { - // DW_LNE_define_file - sizeOf += 1; // writer.WriteU8(0); - uint dirIndex = fileName.Directory != null && _directoryNameToIndex.ContainsKey(fileName.Directory) ? _directoryNameToIndex[fileName.Directory] : 0; - - ulong sizeOfInlineFileName = 1; - sizeOfInlineFileName += (ulong) Encoding.UTF8.GetByteCount(fileName.Name) + 1; - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(dirIndex); - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Time); - sizeOfInlineFileName += DwarfHelper.SizeOfULEB128(fileName.Size); - - sizeOf += DwarfHelper.SizeOfULEB128(sizeOfInlineFileName); - sizeOf += sizeOfInlineFileName; - } - } - - // DW_LNS_copy - if (isBasicBlockChanged && !debugLine.IsBasicBlock || - isPrologueEndChanged && !debugLine.IsPrologueEnd || - isEpilogueBeginChanged && !debugLine.IsEpilogueBegin) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_copy); - isDiscriminatorChanged = debugLine.Discriminator != 0; - hasGeneratedRow = true; - } - - // DW_LNS_set_basic_block - if (isBasicBlockChanged && debugLine.IsBasicBlock) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_basic_block); - } - - // DW_LNS_set_prologue_end - if (isPrologueEndChanged && debugLine.IsPrologueEnd) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_prologue_end); - } - - // DW_LNS_set_epilogue_begin - if (isEpilogueBeginChanged && debugLine.IsEpilogueBegin) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_epilogue_begin); - } - - // DW_LNS_set_isa - if (isaChanged) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_set_isa); - sizeOf += DwarfHelper.SizeOfULEB128(debugLine.Isa); // writer.WriteLEB128(debugLine.Isa); - } - - // DW_LNE_set_discriminator - if (isDiscriminatorChanged) - { - sizeOf += 1; // writer.WriteU8(0); - var sizeOfDiscriminator = DwarfHelper.SizeOfULEB128(debugLine.Discriminator); - sizeOf += DwarfHelper.SizeOfULEB128(1 + sizeOfDiscriminator); // writer.WriteLEB128(1 + DwarfHelper.SizeOfLEB128(debugLine.Discriminator)); - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNE_set_discriminator); - sizeOf += sizeOfDiscriminator; // writer.WriteLEB128(debugLine.Discriminator); - } - - // DW_LNS_negate_stmt - if (isStatementChanged) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_negate_stmt); - } - - bool isEndOfSequence = lineIndex + 1 == lines.Count; - bool canEncodeSpecial = !isEndOfSequence; - bool canEncodeLineInSpecialCode = canEncodeSpecial && deltaLine >= LineBase && deltaLine < LineBase + LineRange; - bool operationAdvancedEncoded = false; - - if (!hasSetAddress) - { - sizeOf += 1; // writer.WriteU8(0); - var sizeOfAddress = DwarfHelper.SizeOfUInt(AddressSize); - sizeOf += DwarfHelper.SizeOfULEB128(1 + sizeOfAddress); // writer.WriteLEB128(DwarfHelper.SizeOfNativeInt(writer.IsTargetAddress64Bit)); - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNE_set_address); - sizeOf += sizeOfAddress; // writer.WriteLEB128(debugLine.Address); - operationAdvancedEncoded = true; - deltaAddress = 0; - hasSetAddress = true; - } - else if (deltaAddress > maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * maxDeltaAddressPerSpecialCode)) - { - ulong deltaAddressSpecialOpCode255; - - if (Version >= 4) - { - deltaAddressSpecialOpCode255 = (((ulong) previousLineState.OperationIndex + maxOperationAdvance) / MaximumOperationsPerInstruction); - deltaOperationIndex = debugLine.OperationIndex - (byte) ((previousLineState.OperationIndex + maxOperationAdvance) % MaximumOperationsPerInstruction); - } - else - { - deltaAddressSpecialOpCode255 = maxOperationAdvance; - deltaOperationIndex = 0; - } - - Debug.Assert(deltaAddressSpecialOpCode255 * MinimumInstructionLength < deltaAddress); - deltaAddress -= deltaAddressSpecialOpCode255 * MinimumInstructionLength; - - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_const_add_pc); - } - - // DW_LNS_advance_line - if (!canEncodeLineInSpecialCode) - { - if (deltaLine != 0) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_advance_line); - sizeOf += DwarfHelper.SizeOfILEB128(deltaLine); // writer.WriteSignedLEB128(deltaLine); - deltaLine = 0; - } - } - - var operation_advance = deltaAddress * MaximumOperationsPerInstruction / MinimumInstructionLength + debugLine.OperationIndex; - - bool canEncodeAddress = false; - ulong opcode = 256; - if (canEncodeSpecial && (operation_advance > 0 || deltaOperationIndex > 0 || deltaLine != 0)) - { - opcode = operation_advance * LineRange + opCodeBase + (ulong) (deltaLine - LineBase); - if (opcode > 255) - { - if (deltaLine != 0) - { - opcode = opCodeBase + (ulong) (deltaLine - LineBase); - } - } - else - { - canEncodeAddress = true; - } - } - - if (!operationAdvancedEncoded && !canEncodeAddress) - { - if (deltaAddress > 0 || deltaOperationIndex > 0) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_advance_pc); - sizeOf += DwarfHelper.SizeOfULEB128(operation_advance); // writer.WriteLEB128(operation_advance); - } - } - - // Special opcode - if (opcode <= 255) - { - sizeOf += 1; // writer.WriteU8((byte)opcode); - debugLineState.SpecialReset(); - hasGeneratedRow = true; - } - - if (isEndOfSequence) - { - sizeOf += 3; // writer.WriteU8(0); - // writer.WriteLEB128(1); - // writer.WriteU8(DwarfNative.DW_LNE_end_sequence); - previousLineState = initialState; - previousLineState.Reset(firstFile, true); - hasGeneratedRow = true; - hasSetAddress = false; - } - else - { - previousLineState = debugLineState; - } - - if (!hasGeneratedRow) - { - sizeOf += 1; // writer.WriteU8(DwarfNative.DW_LNS_copy); - } - - debugLine.Size = Offset + sizeOf - debugLine.Offset; - } - lineSequence.Size = Offset + sizeOf - lineSequence.Offset; - } - } - - private static ReadOnlySpan DefaultStandardOpCodeLengths => new ReadOnlySpan(new byte[12] - { - 0, // DwarfNative.DW_LNS_copy - 1, // DwarfNative.DW_LNS_advance_pc - 1, // DwarfNative.DW_LNS_advance_line - 1, // DwarfNative.DW_LNS_set_file - 1, // DwarfNative.DW_LNS_set_column - 0, // DwarfNative.DW_LNS_negate_stmt - 0, // DwarfNative.DW_LNS_set_basic_block - 0, // DwarfNative.DW_LNS_const_add_pc - 1, // DwarfNative.DW_LNS_fixed_advance_pc - 0, // DwarfNative.DW_LNS_set_prologue_end - 0, // DwarfNative.DW_LNS_set_epilogue_begin - 1, // DwarfNative.DW_LNS_set_isa - }); - - public override string ToString() - { - return $"Section .debug_line, {nameof(Version)}: {Version}, {nameof(Is64BitEncoding)}: {Is64BitEncoding}, {nameof(FileNames)}: {FileNames.Count}, {nameof(LineSequences)}: {LineSequences.Count}"; - } - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs deleted file mode 100644 index a259852175b8d4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSection.cs +++ /dev/null @@ -1,90 +0,0 @@ - -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("Count = {LineTables.Count,nq}")] - public sealed class DwarfLineSection : DwarfRelocatableSection - { - private readonly List _tables; - - - public DwarfLineSection() - { - _tables = new List(); - } - - public IReadOnlyList LineTables => _tables; - - public void AddLineProgramTable(DwarfLineProgramTable line) - { - _tables.Add(this, line); - } - - public void RemoveLineProgramTable(DwarfLineProgramTable line) - { - _tables.Remove(this, line); - } - - public DwarfLineProgramTable RemoveLineProgramTableAt(int index) - { - return _tables.RemoveAt(this, index); - } - - protected override void Read(DwarfReader reader) - { - while (reader.Offset < reader.Length) - { - var programTable = new DwarfLineProgramTable(); - programTable.Offset = reader.Offset; - programTable.ReadInternal(reader); - AddLineProgramTable(programTable); - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - foreach (var dwarfLineProgramTable in _tables) - { - dwarfLineProgramTable.Verify(diagnostics); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - ulong sizeOf = 0; - - foreach (var dwarfLineProgramTable in _tables) - { - dwarfLineProgramTable.Offset = Offset + sizeOf; - dwarfLineProgramTable.UpdateLayoutInternal(layoutContext); - sizeOf += dwarfLineProgramTable.Size; - } - Size = sizeOf; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - - foreach (var dwarfLineProgramTable in _tables) - { - dwarfLineProgramTable.WriteInternal(writer); - } - - Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); - } - - public override string ToString() - { - return $"Section .debug_line, Entries: {_tables.Count}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs deleted file mode 100644 index 8846b710dcb13c..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineSequence.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - /// - /// A sequence of - /// - [DebuggerDisplay("Count = {Lines.Count,nq}")] - public class DwarfLineSequence : DwarfObject, IEnumerable - { - private readonly List _lines; - - public DwarfLineSequence() - { - _lines = new List(); - } - - public IReadOnlyList Lines => _lines; - - public void Add(DwarfLine line) - { - _lines.Add(this, line); - } - - public void Remove(DwarfLine line) - { - _lines.Remove(this, line); - } - - public DwarfLine RemoveAt(int index) - { - return _lines.RemoveAt(this, index); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - // This is implemented in DwarfLineSection - } - - protected override void Read(DwarfReader reader) - { - // This is implemented in DwarfLineSection - } - - protected override void Write(DwarfWriter writer) - { - // This is implemented in DwarfLineSection - } - - public List.Enumerator GetEnumerator() - { - return _lines.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable) _lines).GetEnumerator(); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs deleted file mode 100644 index aebdab8c71baa0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLineState.cs +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Globalization; - -namespace LibObjectFile.Dwarf -{ - /// - /// Internal struct used to track line state via a struct, created via - /// - internal struct DwarfLineState - { - // ----------------------- - // DWARF 2 - // ----------------------- - - /// - /// The program-counter value corresponding to a machine instruction generated by the compiler. - /// - public ulong Address { get; set; } - - /// - /// An unsigned integer representing the index of an operation within a VLIW instruction. - /// The index of the first operation is 0. For non-VLIW architectures, this register will always be 0. - /// - public byte OperationIndex { get; set; } - - /// - /// The identity of the source file corresponding to a machine instruction. - /// - public DwarfFileName File { get; set; } - - /// - /// An unsigned integer indicating a source line number. - /// Lines are numbered beginning at 1. - /// The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. - /// - public uint Line { get; set; } - - /// - /// An unsigned integer indicating a column number within a source line. - /// Columns are numbered beginning at 1. The value 0 is reserved to indicate that a statement begins at the “left edge” of the line. - /// - public uint Column { get; set; } - - /// - /// A boolean indicating that the current instruction is a recommended breakpoint location. - /// A recommended breakpoint location is intended to “represent” a line, a statement and/or a semantically distinct subpart of a statement. - /// - public bool IsStatement { get; set; } - - /// - /// A boolean indicating that the current instruction is the beginning of a basic block. - /// - public bool IsBasicBlock { get; set; } - - /// - /// A boolean indicating that the current address is that of the first byte after the end of a sequence of target machine instructions. - /// IsEndSequence terminates a sequence of lines; therefore other information in the same row is not meaningful. - /// - public bool IsEndSequence { get; set; } - - // ----------------------- - // DWARF 3 - // ----------------------- - - /// - /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an entry breakpoint of a function. - /// - public bool IsPrologueEnd { get; set; } - - /// - /// A boolean indicating that the current address is one (of possibly many) where execution should be suspended for an exit breakpoint of a function. - /// - public bool IsEpilogueBegin { get; set; } - - /// - /// An unsigned integer whose value encodes the applicable instruction set architecture for the current instruction. - /// - public ulong Isa { get; set; } - - // ----------------------- - // DWARF 4 - // ----------------------- - - /// - /// An unsigned integer identifying the block to which the current instruction belongs. - /// Discriminator values are assigned arbitrarily by the DWARF producer and serve to distinguish among multiple blocks that may all be - /// associated with the same source file, line, and column. - /// Where only one block exists for a given source position, the discriminator value should be zero. - /// - public ulong Discriminator { get; set; } - - internal void Delta(in DwarfLineState against, - out ulong deltaAddress, - out int deltaOperationIndex, - out bool fileNameChanged, - out int deltaLine, - out int deltaColumn, - out bool isStatementChanged, - out bool isBasicBlockChanged, - out bool isEndSequenceChanged, - out bool isPrologueEndChanged, - out bool isEpilogueBeginChanged, - out bool isaChanged, - out bool isDiscriminatorChanged) - { - deltaAddress = against.Address - this.Address; - deltaOperationIndex = against.OperationIndex - this.OperationIndex; - fileNameChanged = !ReferenceEquals(this.File, against.File); - deltaLine = (int)((long)against.Line - (long)this.Line); - deltaColumn = (int)((long)against.Column - (long)this.Column); - isStatementChanged = against.IsStatement != this.IsStatement; - isBasicBlockChanged = against.IsBasicBlock != this.IsBasicBlock; - isEndSequenceChanged = against.IsEndSequence != this.IsEndSequence; - isPrologueEndChanged = against.IsPrologueEnd != this.IsPrologueEnd; - isEpilogueBeginChanged = against.IsEpilogueBegin != this.IsEpilogueBegin; - isaChanged = against.Isa != this.Isa; - isDiscriminatorChanged = against.Discriminator != this.Discriminator; - } - - internal void Reset(DwarfFileName firstFile, bool isStatement) - { - Address = 0; - File = firstFile; - Line = 1; - Column = 0; - this.IsStatement = isStatement; - IsBasicBlock = false; - IsEndSequence = false; - - // DWARF 3 - IsPrologueEnd = false; - IsEpilogueBegin = false; - Isa = 0; - - // DWARF 5 - Discriminator = 0; - } - - internal void SpecialReset() - { - IsBasicBlock = false; - IsPrologueEnd = false; - IsEpilogueBegin = false; - Discriminator = 0; - } - - public override string ToString() - { - return $"{nameof(Address)}: 0x{Address:x16}, {nameof(File)}: {File}, {nameof(Line)}: {Line,4}, {nameof(Column)}: {Column,2}, {nameof(IsStatement)}: {Bool2Str(IsStatement),5}, {nameof(IsBasicBlock)}: {Bool2Str(IsBasicBlock),5}, {nameof(IsEndSequence)}: {Bool2Str(IsEndSequence),5}, {nameof(IsPrologueEnd)}: {Bool2Str(IsPrologueEnd),5}, {nameof(IsEpilogueBegin)}: {Bool2Str(IsEpilogueBegin),5}, {nameof(Isa)}: {Isa,3}, {nameof(Discriminator)}: {Discriminator,3}"; - } - - private static string Bool2Str(bool value) => value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs deleted file mode 100644 index e6a9f46cd65400..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocation.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public struct DwarfLocation - { - public DwarfLocation(int value) - { - AsValue = new DwarfInteger() { I64 = value }; - AsObject = null; - } - - public DwarfLocation(DwarfExpression expression) - { - AsValue = default; - AsObject = expression; - } - - public DwarfLocation(DwarfLocationList locationList) - { - AsValue = default; - AsObject = locationList; - } - - public DwarfInteger AsValue; - - public object AsObject; - - public DwarfExpression AsExpression => AsObject as DwarfExpression; - - public DwarfLocationList AsLocationList => AsObject as DwarfLocationList; - - public DwarfDIE AsReference => AsObject as DwarfDIE; - - public override string ToString() - { - if (AsExpression != null) return $"Location Expression: {AsExpression}"; - if (AsLocationList != null) return $"Location List: {AsLocationList}"; - if (AsReference != null) return $"Location Reference: {AsReference}"; - return $"Location Constant: {AsValue}"; - } - - public static implicit operator DwarfLocation(DwarfExpression value) - { - return new DwarfLocation(value); - } - - public static implicit operator DwarfLocation(DwarfLocationList value) - { - return new DwarfLocation(value); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs deleted file mode 100644 index d7ab162ca313ed..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationList.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Text; -using System.Collections.Generic; - -namespace LibObjectFile.Dwarf -{ - - public class DwarfLocationList : DwarfContainer - { - private readonly List _locationListEntries; - - public DwarfLocationList() - { - _locationListEntries = new List(); - } - - public IReadOnlyList LocationListEntries => _locationListEntries; - - public void AddLocationListEntry(DwarfLocationListEntry locationListEntry) - { - _locationListEntries.Add(this, locationListEntry); - } - - public void RemoveLocationList(DwarfLocationListEntry locationListEntry) - { - _locationListEntries.Remove(this, locationListEntry); - } - - public DwarfLocationListEntry RemoveLocationListEntryAt(int index) - { - return _locationListEntries.RemoveAt(this, index); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var endOffset = Offset; - - foreach (var locationListEntry in _locationListEntries) - { - locationListEntry.Offset = endOffset; - locationListEntry.UpdateLayoutInternal(layoutContext); - endOffset += locationListEntry.Size; - } - - // End of list - endOffset += 2 * DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); - - Size = endOffset - Offset; - } - - protected override void Read(DwarfReader reader) - { - reader.OffsetToLocationList.Add(reader.Offset, this); - - while (reader.Offset < reader.Length) - { - var locationListEntry = new DwarfLocationListEntry(); - locationListEntry.ReadInternal(reader); - - if (locationListEntry.Start == 0 && locationListEntry.End == 0) - { - // End of list - return; - } - - _locationListEntries.Add(locationListEntry); - } - } - - protected override void Write(DwarfWriter writer) - { - foreach (var locationListEntry in _locationListEntries) - { - locationListEntry.WriteInternal(writer); - } - - // End of list - writer.WriteUInt(0); - writer.WriteUInt(0); - } - - public override string ToString() - { - var builder = new StringBuilder(); - - for (int i = 0; i < _locationListEntries.Count; i++) - { - if (i == 3) - { - builder.Append(", ..."); - return builder.ToString(); - } - else if (i != 0) - { - builder.Append(", "); - } - - builder.Append(_locationListEntries[i].ToString()); - } - - return builder.ToString(); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs deleted file mode 100644 index 829acb2a86074d..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationListEntry.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public class DwarfLocationListEntry : DwarfObject - { - public ulong Start; - - public ulong End; - - public DwarfExpression Expression; - - public DwarfLocationListEntry() - { - } - - protected override void Read(DwarfReader reader) - { - Start = reader.ReadUInt(); - End = reader.ReadUInt(); - - if (Start == 0 && End == 0) - { - // End of list - return; - } - - bool isBaseAddress = - (reader.AddressSize == DwarfAddressSize.Bit64 && Start == ulong.MaxValue) || - (reader.AddressSize == DwarfAddressSize.Bit32 && Start == uint.MaxValue); - if (isBaseAddress) - { - // Sets new base address for following entries - return; - } - - Expression = new DwarfExpression(); - Expression.ReadInternal(reader, inLocationSection: true); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var endOffset = Offset; - - endOffset += 2 * DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); - if (Expression != null) - { - Expression.Offset = endOffset; - Expression.UpdateLayoutInternal(layoutContext, inLocationSection: true); - endOffset += Expression.Size; - } - - Size = endOffset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - bool isBaseAddress = - (writer.AddressSize == DwarfAddressSize.Bit64 && Start == ulong.MaxValue) || - (writer.AddressSize == DwarfAddressSize.Bit32 && Start == uint.MaxValue); - if (isBaseAddress) - { - writer.WriteUInt(Start); - writer.WriteAddress(DwarfRelocationTarget.Code, End); - } - else - { - writer.WriteAddress(DwarfRelocationTarget.Code, Start); - writer.WriteAddress(DwarfRelocationTarget.Code, End); - } - - if (Expression != null) - { - Expression.WriteInternal(writer, inLocationSection: true); - } - } - - public override string ToString() - { - return $"Location: {Start:x} - {End:x} {Expression}"; - } - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs deleted file mode 100644 index e2057af19437b2..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfLocationSection.cs +++ /dev/null @@ -1,89 +0,0 @@ - -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("Count = {LineTables.Count,nq}")] - public sealed class DwarfLocationSection : DwarfRelocatableSection - { - private readonly List _locationLists; - - public DwarfLocationSection() - { - _locationLists = new List(); - } - - public IReadOnlyList LocationLists => _locationLists; - - public void AddLocationList(DwarfLocationList locationList) - { - _locationLists.Add(this, locationList); - } - - public void RemoveLocationList(DwarfLocationList locationList) - { - _locationLists.Remove(this, locationList); - } - - public DwarfLocationList RemoveLineProgramTableAt(int index) - { - return _locationLists.RemoveAt(this, index); - } - - protected override void Read(DwarfReader reader) - { - while (reader.Offset < reader.Length) - { - var locationList = new DwarfLocationList(); - locationList.Offset = reader.Offset; - locationList.ReadInternal(reader); - AddLocationList(locationList); - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - foreach (var locationList in _locationLists) - { - locationList.Verify(diagnostics); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - ulong sizeOf = 0; - - foreach (var locationList in _locationLists) - { - locationList.Offset = Offset + sizeOf; - locationList.UpdateLayoutInternal(layoutContext); - sizeOf += locationList.Size; - } - Size = sizeOf; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - - foreach (var locationList in _locationLists) - { - locationList.WriteInternal(writer); - } - - Debug.Assert(Size == writer.Offset - startOffset, $"Expected Size: {Size} != Written Size: {writer.Offset - startOffset}"); - } - - public override string ToString() - { - return $"Section .debug_loc, Entries: {_locationLists.Count}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs deleted file mode 100644 index 4ebbe5874bf1ac..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfObject.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - - public abstract class DwarfObject : ObjectFileNode - { - public DwarfFile GetParentFile() - { - var check = (ObjectFileNode)this; - while (check != null) - { - if (check is DwarfFile dwarfFile) return dwarfFile; - check = check.Parent; - } - return null; - } - - public DwarfUnit GetParentUnit() - { - var check = (ObjectFileNode)this; - while (check != null) - { - if (check is DwarfUnit dwarfUnit) return dwarfUnit; - check = check.Parent; - } - return null; - } - - public DwarfSection GetParentSection() - { - var check = (ObjectFileNode)this; - while (check != null) - { - if (check is DwarfSection dwarfSection) return dwarfSection; - check = check.Parent; - } - return null; - } - } - - public abstract class DwarfObject : DwarfObject where TContainer : ObjectFileNode - { - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is TContainer)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(TContainer)}"); - } - } - - - /// - /// Gets the containing . Might be null if this section or segment - /// does not belong to an existing . - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - public new TContainer Parent - { - get => (TContainer)base.Parent; - internal set => base.Parent = value; - } - - internal void UpdateLayoutInternal(DwarfLayoutContext layoutContext) - { - UpdateLayout(layoutContext); - } - - protected abstract void UpdateLayout(DwarfLayoutContext layoutContext); - - - internal void ReadInternal(DwarfReader reader) - { - Read(reader); - } - - protected abstract void Read(DwarfReader reader); - - - internal void WriteInternal(DwarfWriter writer) - { - Write(writer); - } - - protected abstract void Write(DwarfWriter writer); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs deleted file mode 100644 index 241d89b2ad29c4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperation.cs +++ /dev/null @@ -1,1172 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class DwarfOperation : DwarfObject - { - public DwarfOperationKindEx Kind { get; set; } - - public object Operand0 { get; set; } - - public DwarfInteger Operand1; - - public DwarfInteger Operand2; - - private string DebuggerDisplay => $"{Kind} {Operand1} {Operand2} {Operand0}"; - - protected override void Read(DwarfReader reader) - { - Offset = reader.Offset; - var kind = new DwarfOperationKindEx(reader.ReadU8()); - Kind = kind; - - switch (kind.Value) - { - case DwarfOperationKind.Addr: - Operand1.U64 = reader.ReadUInt(); - break; - case DwarfOperationKind.Const1u: - Operand1.U64 = reader.ReadU8(); - break; - case DwarfOperationKind.Const1s: - Operand1.I64 = reader.ReadI8(); - break; - case DwarfOperationKind.Const2u: - Operand1.U64 = reader.ReadU16(); - break; - case DwarfOperationKind.Const2s: - Operand1.I64 = reader.ReadI16(); - break; - - case DwarfOperationKind.Const4u: - Operand1.U64 = reader.ReadU32(); - break; - case DwarfOperationKind.Const4s: - Operand1.I64 = reader.ReadU32(); - break; - - case DwarfOperationKind.Const8u: - Operand1.U64 = reader.ReadU64(); - break; - - case DwarfOperationKind.Const8s: - Operand1.I64 = reader.ReadI64(); - break; - - case DwarfOperationKind.Constu: - Operand1.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.Consts: - Operand1.I64 = reader.ReadILEB128(); - break; - - case DwarfOperationKind.Deref: - case DwarfOperationKind.Dup: - case DwarfOperationKind.Drop: - case DwarfOperationKind.Over: - case DwarfOperationKind.Swap: - case DwarfOperationKind.Rot: - case DwarfOperationKind.Xderef: - case DwarfOperationKind.Abs: - case DwarfOperationKind.And: - case DwarfOperationKind.Div: - case DwarfOperationKind.Minus: - case DwarfOperationKind.Mod: - case DwarfOperationKind.Mul: - case DwarfOperationKind.Neg: - case DwarfOperationKind.Not: - case DwarfOperationKind.Or: - case DwarfOperationKind.Plus: - case DwarfOperationKind.Shl: - case DwarfOperationKind.Shr: - case DwarfOperationKind.Shra: - case DwarfOperationKind.Xor: - case DwarfOperationKind.Eq: - case DwarfOperationKind.Ge: - case DwarfOperationKind.Gt: - case DwarfOperationKind.Le: - case DwarfOperationKind.Lt: - case DwarfOperationKind.Ne: - case DwarfOperationKind.Nop: - case DwarfOperationKind.PushObjectAddress: - case DwarfOperationKind.FormTlsAddress: - case DwarfOperationKind.CallFrameCfa: - break; - - case DwarfOperationKind.Pick: - Operand1.U64 = reader.ReadU8(); - break; - - case DwarfOperationKind.PlusUconst: - Operand1.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.Bra: - case DwarfOperationKind.Skip: - // TODO: resolve branches to DwarfOperation - Operand1.I64 = reader.ReadI16(); - break; - - case DwarfOperationKind.Lit0: - case DwarfOperationKind.Lit1: - case DwarfOperationKind.Lit2: - case DwarfOperationKind.Lit3: - case DwarfOperationKind.Lit4: - case DwarfOperationKind.Lit5: - case DwarfOperationKind.Lit6: - case DwarfOperationKind.Lit7: - case DwarfOperationKind.Lit8: - case DwarfOperationKind.Lit9: - case DwarfOperationKind.Lit10: - case DwarfOperationKind.Lit11: - case DwarfOperationKind.Lit12: - case DwarfOperationKind.Lit13: - case DwarfOperationKind.Lit14: - case DwarfOperationKind.Lit15: - case DwarfOperationKind.Lit16: - case DwarfOperationKind.Lit17: - case DwarfOperationKind.Lit18: - case DwarfOperationKind.Lit19: - case DwarfOperationKind.Lit20: - case DwarfOperationKind.Lit21: - case DwarfOperationKind.Lit22: - case DwarfOperationKind.Lit23: - case DwarfOperationKind.Lit24: - case DwarfOperationKind.Lit25: - case DwarfOperationKind.Lit26: - case DwarfOperationKind.Lit27: - case DwarfOperationKind.Lit28: - case DwarfOperationKind.Lit29: - case DwarfOperationKind.Lit30: - case DwarfOperationKind.Lit31: - Operand1.U64 = (ulong)((byte)kind.Value - (byte)DwarfOperationKind.Lit0); - break; - - case DwarfOperationKind.Reg0: - case DwarfOperationKind.Reg1: - case DwarfOperationKind.Reg2: - case DwarfOperationKind.Reg3: - case DwarfOperationKind.Reg4: - case DwarfOperationKind.Reg5: - case DwarfOperationKind.Reg6: - case DwarfOperationKind.Reg7: - case DwarfOperationKind.Reg8: - case DwarfOperationKind.Reg9: - case DwarfOperationKind.Reg10: - case DwarfOperationKind.Reg11: - case DwarfOperationKind.Reg12: - case DwarfOperationKind.Reg13: - case DwarfOperationKind.Reg14: - case DwarfOperationKind.Reg15: - case DwarfOperationKind.Reg16: - case DwarfOperationKind.Reg17: - case DwarfOperationKind.Reg18: - case DwarfOperationKind.Reg19: - case DwarfOperationKind.Reg20: - case DwarfOperationKind.Reg21: - case DwarfOperationKind.Reg22: - case DwarfOperationKind.Reg23: - case DwarfOperationKind.Reg24: - case DwarfOperationKind.Reg25: - case DwarfOperationKind.Reg26: - case DwarfOperationKind.Reg27: - case DwarfOperationKind.Reg28: - case DwarfOperationKind.Reg29: - case DwarfOperationKind.Reg30: - case DwarfOperationKind.Reg31: - Operand1.U64 = (ulong)kind.Value - (ulong)DwarfOperationKind.Reg0; - break; - - case DwarfOperationKind.Breg0: - case DwarfOperationKind.Breg1: - case DwarfOperationKind.Breg2: - case DwarfOperationKind.Breg3: - case DwarfOperationKind.Breg4: - case DwarfOperationKind.Breg5: - case DwarfOperationKind.Breg6: - case DwarfOperationKind.Breg7: - case DwarfOperationKind.Breg8: - case DwarfOperationKind.Breg9: - case DwarfOperationKind.Breg10: - case DwarfOperationKind.Breg11: - case DwarfOperationKind.Breg12: - case DwarfOperationKind.Breg13: - case DwarfOperationKind.Breg14: - case DwarfOperationKind.Breg15: - case DwarfOperationKind.Breg16: - case DwarfOperationKind.Breg17: - case DwarfOperationKind.Breg18: - case DwarfOperationKind.Breg19: - case DwarfOperationKind.Breg20: - case DwarfOperationKind.Breg21: - case DwarfOperationKind.Breg22: - case DwarfOperationKind.Breg23: - case DwarfOperationKind.Breg24: - case DwarfOperationKind.Breg25: - case DwarfOperationKind.Breg26: - case DwarfOperationKind.Breg27: - case DwarfOperationKind.Breg28: - case DwarfOperationKind.Breg29: - case DwarfOperationKind.Breg30: - case DwarfOperationKind.Breg31: - Operand1.U64 = (ulong)kind.Value - (ulong)DwarfOperationKind.Breg0; - Operand2.I64 = reader.ReadILEB128(); - break; - - case DwarfOperationKind.Regx: - Operand1.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.Fbreg: - Operand1.I64 = reader.ReadILEB128(); - break; - - case DwarfOperationKind.Bregx: - Operand1.U64 = reader.ReadULEB128(); - Operand2.I64 = reader.ReadILEB128(); - break; - - case DwarfOperationKind.Piece: - Operand1.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.DerefSize: - Operand1.U64 = reader.ReadU8(); - break; - - case DwarfOperationKind.XderefSize: - Operand1.U64 = reader.ReadU8(); - break; - - case DwarfOperationKind.Call2: - { - var offset = reader.ReadU16(); - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinSection(dieRef, false); - break; - } - - case DwarfOperationKind.Call4: - { - var offset = reader.ReadU32(); - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinSection(dieRef, false); - break; - } - - case DwarfOperationKind.CallRef: - { - var offset = reader.ReadUIntFromEncoding(); - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinSection(dieRef, false); - break; - } - - case DwarfOperationKind.BitPiece: - Operand1.U64 = reader.ReadULEB128(); - Operand2.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.ImplicitValue: - { - var length = reader.ReadULEB128(); - Operand0 = reader.ReadAsStream(length); - break; - } - - case DwarfOperationKind.StackValue: - break; - - case DwarfOperationKind.ImplicitPointer: - case DwarfOperationKind.GNUImplicitPointer: - { - ulong offset; - // a reference to a debugging information entry that describes the dereferenced object’s value - if (reader.CurrentUnit.Version == 2) - { - offset = reader.ReadUInt(); - } - else - { - offset = reader.ReadUIntFromEncoding(); - } - // a signed number that is treated as a byte offset from the start of that value - Operand1.I64 = reader.ReadILEB128(); - - if (offset != 0) - { - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinSection(dieRef, false); - } - break; - } - - case DwarfOperationKind.Addrx: - case DwarfOperationKind.GNUAddrIndex: - case DwarfOperationKind.Constx: - case DwarfOperationKind.GNUConstIndex: - Operand1.U64 = reader.ReadULEB128(); - break; - - case DwarfOperationKind.EntryValue: - case DwarfOperationKind.GNUEntryValue: - { - var subExpression = new DwarfExpression(); - subExpression.ReadInternal(reader); - Operand0 = subExpression; - break; - } - - case DwarfOperationKind.ConstType: - case DwarfOperationKind.GNUConstType: - { - // The DW_OP_const_type operation takes three operands - - // The first operand is an unsigned LEB128 integer that represents the offset - // of a debugging information entry in the current compilation unit, which - // must be a DW_TAG_base_type entry that provides the type of the constant provided - var offset = reader.ReadULEB128(); - if (offset != 0) - { - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); - } - Operand1.U64 = ReadEncodedValue(reader, kind, out var sizeOfEncodedValue); - // Encode size of encoded value in Operand1 - Operand2.U64 = sizeOfEncodedValue; - break; - } - - case DwarfOperationKind.RegvalType: - case DwarfOperationKind.GNURegvalType: - { - // The DW_OP_regval_type operation provides the contents of a given register - // interpreted as a value of a given type - - // The first operand is an unsigned LEB128 number, which identifies a register - // whose contents is to be pushed onto the stack - Operand1.U64 = reader.ReadULEB128(); - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - var offset = reader.ReadULEB128(); - if (offset != 0) - { - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); - } - break; - } - - case DwarfOperationKind.DerefType: - case DwarfOperationKind.GNUDerefType: - case DwarfOperationKind.XderefType: - { - // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: - // it pops the top stack entry and treats it as an address. - - // This operand is a 1-byte unsigned integral constant whose value which is the - // same as the size of the base type referenced by the second operand - Operand1.U64 = reader.ReadU8(); - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - var offset = reader.ReadULEB128(); - if (offset != 0) - { - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); - } - break; - } - - case DwarfOperationKind.Convert: - case DwarfOperationKind.GNUConvert: - case DwarfOperationKind.Reinterpret: - case DwarfOperationKind.GNUReinterpret: - { - ulong offset = reader.ReadULEB128(); - if (offset != 0) - { - var dieRef = new DwarfReader.DwarfDIEReference(offset, this, DwarfExpressionLocationDIEReferenceResolverInstance); - reader.ResolveAttributeReferenceWithinCompilationUnit(dieRef, false); - } - break; - } - - case DwarfOperationKind.GNUPushTlsAddress: - case DwarfOperationKind.GNUUninit: - break; - - case DwarfOperationKind.GNUEncodedAddr: - { - Operand1.U64 = ReadEncodedValue(reader, kind, out var sizeOfEncodedValue); - Operand2.U64 = sizeOfEncodedValue; - break; - } - - case DwarfOperationKind.GNUParameterRef: - Operand1.U64 = reader.ReadU32(); - break; - - default: - throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {kind} is not supported"); - } - - // Store the size of the current op - Size = reader.Offset - Offset; - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var endOffset = Offset; - // 1 byte per opcode - endOffset += 1; - - switch (Kind.Value) - { - case DwarfOperationKind.Addr: - endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); - break; - case DwarfOperationKind.Const1u: - case DwarfOperationKind.Const1s: - case DwarfOperationKind.Pick: - case DwarfOperationKind.DerefSize: - case DwarfOperationKind.XderefSize: - endOffset += 1; - break; - case DwarfOperationKind.Const2u: - case DwarfOperationKind.Const2s: - case DwarfOperationKind.Bra: - case DwarfOperationKind.Skip: - case DwarfOperationKind.Call2: - endOffset += 2; - break; - case DwarfOperationKind.Const4u: - case DwarfOperationKind.Const4s: - case DwarfOperationKind.Call4: - endOffset += 4; - break; - case DwarfOperationKind.Const8u: - case DwarfOperationKind.Const8s: - endOffset += 8; - break; - - case DwarfOperationKind.Constu: - case DwarfOperationKind.PlusUconst: - case DwarfOperationKind.Regx: - case DwarfOperationKind.Piece: - case DwarfOperationKind.Addrx: - case DwarfOperationKind.GNUAddrIndex: - case DwarfOperationKind.Constx: - case DwarfOperationKind.GNUConstIndex: - endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); - break; - - case DwarfOperationKind.Consts: - case DwarfOperationKind.Fbreg: - endOffset += DwarfHelper.SizeOfILEB128(Operand1.I64); - break; - - case DwarfOperationKind.Deref: - case DwarfOperationKind.Dup: - case DwarfOperationKind.Drop: - case DwarfOperationKind.Over: - case DwarfOperationKind.Swap: - case DwarfOperationKind.Rot: - case DwarfOperationKind.Xderef: - case DwarfOperationKind.Abs: - case DwarfOperationKind.And: - case DwarfOperationKind.Div: - case DwarfOperationKind.Minus: - case DwarfOperationKind.Mod: - case DwarfOperationKind.Mul: - case DwarfOperationKind.Neg: - case DwarfOperationKind.Not: - case DwarfOperationKind.Or: - case DwarfOperationKind.Plus: - case DwarfOperationKind.Shl: - case DwarfOperationKind.Shr: - case DwarfOperationKind.Shra: - case DwarfOperationKind.Xor: - case DwarfOperationKind.Eq: - case DwarfOperationKind.Ge: - case DwarfOperationKind.Gt: - case DwarfOperationKind.Le: - case DwarfOperationKind.Lt: - case DwarfOperationKind.Ne: - case DwarfOperationKind.Nop: - case DwarfOperationKind.PushObjectAddress: - case DwarfOperationKind.FormTlsAddress: - case DwarfOperationKind.CallFrameCfa: - case DwarfOperationKind.Lit0: - case DwarfOperationKind.Lit1: - case DwarfOperationKind.Lit2: - case DwarfOperationKind.Lit3: - case DwarfOperationKind.Lit4: - case DwarfOperationKind.Lit5: - case DwarfOperationKind.Lit6: - case DwarfOperationKind.Lit7: - case DwarfOperationKind.Lit8: - case DwarfOperationKind.Lit9: - case DwarfOperationKind.Lit10: - case DwarfOperationKind.Lit11: - case DwarfOperationKind.Lit12: - case DwarfOperationKind.Lit13: - case DwarfOperationKind.Lit14: - case DwarfOperationKind.Lit15: - case DwarfOperationKind.Lit16: - case DwarfOperationKind.Lit17: - case DwarfOperationKind.Lit18: - case DwarfOperationKind.Lit19: - case DwarfOperationKind.Lit20: - case DwarfOperationKind.Lit21: - case DwarfOperationKind.Lit22: - case DwarfOperationKind.Lit23: - case DwarfOperationKind.Lit24: - case DwarfOperationKind.Lit25: - case DwarfOperationKind.Lit26: - case DwarfOperationKind.Lit27: - case DwarfOperationKind.Lit28: - case DwarfOperationKind.Lit29: - case DwarfOperationKind.Lit30: - case DwarfOperationKind.Lit31: - case DwarfOperationKind.Reg0: - case DwarfOperationKind.Reg1: - case DwarfOperationKind.Reg2: - case DwarfOperationKind.Reg3: - case DwarfOperationKind.Reg4: - case DwarfOperationKind.Reg5: - case DwarfOperationKind.Reg6: - case DwarfOperationKind.Reg7: - case DwarfOperationKind.Reg8: - case DwarfOperationKind.Reg9: - case DwarfOperationKind.Reg10: - case DwarfOperationKind.Reg11: - case DwarfOperationKind.Reg12: - case DwarfOperationKind.Reg13: - case DwarfOperationKind.Reg14: - case DwarfOperationKind.Reg15: - case DwarfOperationKind.Reg16: - case DwarfOperationKind.Reg17: - case DwarfOperationKind.Reg18: - case DwarfOperationKind.Reg19: - case DwarfOperationKind.Reg20: - case DwarfOperationKind.Reg21: - case DwarfOperationKind.Reg22: - case DwarfOperationKind.Reg23: - case DwarfOperationKind.Reg24: - case DwarfOperationKind.Reg25: - case DwarfOperationKind.Reg26: - case DwarfOperationKind.Reg27: - case DwarfOperationKind.Reg28: - case DwarfOperationKind.Reg29: - case DwarfOperationKind.Reg30: - case DwarfOperationKind.Reg31: - case DwarfOperationKind.StackValue: - case DwarfOperationKind.GNUPushTlsAddress: - case DwarfOperationKind.GNUUninit: - break; - - case DwarfOperationKind.Breg0: - case DwarfOperationKind.Breg1: - case DwarfOperationKind.Breg2: - case DwarfOperationKind.Breg3: - case DwarfOperationKind.Breg4: - case DwarfOperationKind.Breg5: - case DwarfOperationKind.Breg6: - case DwarfOperationKind.Breg7: - case DwarfOperationKind.Breg8: - case DwarfOperationKind.Breg9: - case DwarfOperationKind.Breg10: - case DwarfOperationKind.Breg11: - case DwarfOperationKind.Breg12: - case DwarfOperationKind.Breg13: - case DwarfOperationKind.Breg14: - case DwarfOperationKind.Breg15: - case DwarfOperationKind.Breg16: - case DwarfOperationKind.Breg17: - case DwarfOperationKind.Breg18: - case DwarfOperationKind.Breg19: - case DwarfOperationKind.Breg20: - case DwarfOperationKind.Breg21: - case DwarfOperationKind.Breg22: - case DwarfOperationKind.Breg23: - case DwarfOperationKind.Breg24: - case DwarfOperationKind.Breg25: - case DwarfOperationKind.Breg26: - case DwarfOperationKind.Breg27: - case DwarfOperationKind.Breg28: - case DwarfOperationKind.Breg29: - case DwarfOperationKind.Breg30: - case DwarfOperationKind.Breg31: - endOffset += DwarfHelper.SizeOfILEB128(Operand2.I64); - break; - - case DwarfOperationKind.Bregx: - endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); - endOffset += DwarfHelper.SizeOfILEB128(Operand2.I64); - break; - - case DwarfOperationKind.CallRef: - endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); - break; - - case DwarfOperationKind.BitPiece: - endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); - endOffset += DwarfHelper.SizeOfULEB128(Operand2.U64); - break; - - case DwarfOperationKind.ImplicitValue: - if (Operand0 == null) - { - layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of implicit value operation {this} from DIE cannot be null."); - } - else if (Operand0 is Stream stream) - { - var streamSize = (ulong)stream.Length; - endOffset += DwarfHelper.SizeOfULEB128(streamSize); - endOffset += streamSize; - } - else - { - layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of implicit value operation {this} must be a System.IO.Stream."); - } - - break; - - case DwarfOperationKind.ImplicitPointer: - case DwarfOperationKind.GNUImplicitPointer: - // a reference to a debugging information entry that describes the dereferenced object’s value - if (layoutContext.CurrentUnit.Version == 2) - { - endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.AddressSize); - } - else - { - endOffset += DwarfHelper.SizeOfUInt(layoutContext.CurrentUnit.Is64BitEncoding); - } - - // a signed number that is treated as a byte offset from the start of that value - endOffset += DwarfHelper.SizeOfILEB128(Operand1.I64); - break; - - case DwarfOperationKind.EntryValue: - case DwarfOperationKind.GNUEntryValue: - if (Operand0 == null) - { - endOffset += DwarfHelper.SizeOfULEB128(0); - } - else if (Operand0 is DwarfExpression expr) - { - expr.Offset = endOffset; - expr.UpdateLayoutInternal(layoutContext); - endOffset += DwarfHelper.SizeOfULEB128(expr.Size); - } - else - { - layoutContext.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of EntryValue operation {this} must be a {nameof(DwarfExpression)} instead of {Operand0.GetType()}."); - } - - break; - - case DwarfOperationKind.ConstType: - case DwarfOperationKind.GNUConstType: - { - // The DW_OP_const_type operation takes three operands - - // The first operand is an unsigned LEB128 integer that represents the offset - // of a debugging information entry in the current compilation unit, which - // must be a DW_TAG_base_type entry that provides the type of the constant provided - - endOffset += SizeOfDIEReference(layoutContext); - endOffset += SizeOfEncodedValue(Kind, Operand1.U64, (byte)Operand2.U64, layoutContext.CurrentUnit.AddressSize); - break; - } - - case DwarfOperationKind.RegvalType: - case DwarfOperationKind.GNURegvalType: - { - // The DW_OP_regval_type operation provides the contents of a given register - // interpreted as a value of a given type - - // The first operand is an unsigned LEB128 number, which identifies a register - // whose contents is to be pushed onto the stack - endOffset += DwarfHelper.SizeOfULEB128(Operand1.U64); - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - endOffset += SizeOfDIEReference(layoutContext); - break; - } - - case DwarfOperationKind.DerefType: - case DwarfOperationKind.GNUDerefType: - case DwarfOperationKind.XderefType: - { - // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: - // it pops the top stack entry and treats it as an address. - - // This operand is a 1-byte unsigned integral constant whose value which is the - // same as the size of the base type referenced by the second operand - endOffset += 1; - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - endOffset += SizeOfDIEReference(layoutContext); - break; - } - - case DwarfOperationKind.Convert: - case DwarfOperationKind.GNUConvert: - case DwarfOperationKind.Reinterpret: - case DwarfOperationKind.GNUReinterpret: - endOffset += SizeOfDIEReference(layoutContext); - break; - - case DwarfOperationKind.GNUEncodedAddr: - endOffset += SizeOfEncodedValue(Kind, Operand1.U64, (byte)Operand2.U64, layoutContext.CurrentUnit.AddressSize); - break; - - case DwarfOperationKind.GNUParameterRef: - endOffset += 4; - break; - - default: - throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {Kind} is not supported"); - } - - Size = endOffset - Offset; - } - - private ulong SizeOfDIEReference(DwarfLayoutContext context) - { - if (Operand0 == null) - { - return DwarfHelper.SizeOfULEB128(0); - } - else if (Operand0 is DwarfDIE die) - { - // TODO: check that die reference is within this section - - if (die.Offset < Offset) - { - return DwarfHelper.SizeOfULEB128(die.Offset); - } - else - { - // TODO: encode depending on Context.DefaultAttributeFormForReference - return DwarfHelper.SizeOfILEB128(uint.MaxValue); - } - } - else - { - context.Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidData, $"The object operand of {Kind} operation {this} must be a {nameof(DwarfDIE)} instead of {Operand0.GetType()}."); - } - - return 0U; - } - - private ulong SizeOfEncodedValue(DwarfOperationKindEx kind, ulong value, byte size, DwarfAddressSize addressSize) - { - switch (size) - { - case 0: - return 1 + DwarfHelper.SizeOfUInt(addressSize); - case 1: - return 1 + 1; - case 2: - return 1 + 2; - case 4: - return 1 + 4; - case 8: - return 1 + 8; - default: - // TODO: report via diagnostics in Verify - throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); - } - } - - protected override void Write(DwarfWriter writer) - { - var startOpOffset = Offset; - Debug.Assert(startOpOffset == Offset); - - writer.WriteU8((byte)Kind); - - switch (Kind.Value) - { - case DwarfOperationKind.Addr: - writer.WriteAddress(DwarfRelocationTarget.Code, Operand1.U64); - break; - case DwarfOperationKind.Const1u: - case DwarfOperationKind.Const1s: - case DwarfOperationKind.Pick: - case DwarfOperationKind.DerefSize: - case DwarfOperationKind.XderefSize: - writer.WriteU8((byte)Operand1.U64); - break; - - case DwarfOperationKind.Const2u: - case DwarfOperationKind.Const2s: - writer.WriteU16((ushort)Operand1.U64); - break; - - case DwarfOperationKind.Const4u: - case DwarfOperationKind.Const4s: - writer.WriteU32((uint)Operand1.U64); - break; - - case DwarfOperationKind.Const8u: - case DwarfOperationKind.Const8s: - writer.WriteU64(Operand1.U64); - break; - - case DwarfOperationKind.Constu: - case DwarfOperationKind.PlusUconst: - case DwarfOperationKind.Regx: - case DwarfOperationKind.Piece: - case DwarfOperationKind.Addrx: - case DwarfOperationKind.GNUAddrIndex: - case DwarfOperationKind.Constx: - case DwarfOperationKind.GNUConstIndex: - writer.WriteULEB128(Operand1.U64); - break; - - case DwarfOperationKind.Consts: - case DwarfOperationKind.Fbreg: - writer.WriteILEB128(Operand1.I64); - break; - - case DwarfOperationKind.Deref: - case DwarfOperationKind.Dup: - case DwarfOperationKind.Drop: - case DwarfOperationKind.Over: - case DwarfOperationKind.Swap: - case DwarfOperationKind.Rot: - case DwarfOperationKind.Xderef: - case DwarfOperationKind.Abs: - case DwarfOperationKind.And: - case DwarfOperationKind.Div: - case DwarfOperationKind.Minus: - case DwarfOperationKind.Mod: - case DwarfOperationKind.Mul: - case DwarfOperationKind.Neg: - case DwarfOperationKind.Not: - case DwarfOperationKind.Or: - case DwarfOperationKind.Plus: - case DwarfOperationKind.Shl: - case DwarfOperationKind.Shr: - case DwarfOperationKind.Shra: - case DwarfOperationKind.Xor: - case DwarfOperationKind.Eq: - case DwarfOperationKind.Ge: - case DwarfOperationKind.Gt: - case DwarfOperationKind.Le: - case DwarfOperationKind.Lt: - case DwarfOperationKind.Ne: - case DwarfOperationKind.Nop: - case DwarfOperationKind.PushObjectAddress: - case DwarfOperationKind.FormTlsAddress: - case DwarfOperationKind.CallFrameCfa: - break; - - case DwarfOperationKind.Bra: - case DwarfOperationKind.Skip: - writer.WriteU16((ushort)((long)Offset + 2 - (long)((DwarfOperation)Operand0).Offset)); - break; - - case DwarfOperationKind.Lit0: - case DwarfOperationKind.Lit1: - case DwarfOperationKind.Lit2: - case DwarfOperationKind.Lit3: - case DwarfOperationKind.Lit4: - case DwarfOperationKind.Lit5: - case DwarfOperationKind.Lit6: - case DwarfOperationKind.Lit7: - case DwarfOperationKind.Lit8: - case DwarfOperationKind.Lit9: - case DwarfOperationKind.Lit10: - case DwarfOperationKind.Lit11: - case DwarfOperationKind.Lit12: - case DwarfOperationKind.Lit13: - case DwarfOperationKind.Lit14: - case DwarfOperationKind.Lit15: - case DwarfOperationKind.Lit16: - case DwarfOperationKind.Lit17: - case DwarfOperationKind.Lit18: - case DwarfOperationKind.Lit19: - case DwarfOperationKind.Lit20: - case DwarfOperationKind.Lit21: - case DwarfOperationKind.Lit22: - case DwarfOperationKind.Lit23: - case DwarfOperationKind.Lit24: - case DwarfOperationKind.Lit25: - case DwarfOperationKind.Lit26: - case DwarfOperationKind.Lit27: - case DwarfOperationKind.Lit28: - case DwarfOperationKind.Lit29: - case DwarfOperationKind.Lit30: - case DwarfOperationKind.Lit31: - case DwarfOperationKind.Reg0: - case DwarfOperationKind.Reg1: - case DwarfOperationKind.Reg2: - case DwarfOperationKind.Reg3: - case DwarfOperationKind.Reg4: - case DwarfOperationKind.Reg5: - case DwarfOperationKind.Reg6: - case DwarfOperationKind.Reg7: - case DwarfOperationKind.Reg8: - case DwarfOperationKind.Reg9: - case DwarfOperationKind.Reg10: - case DwarfOperationKind.Reg11: - case DwarfOperationKind.Reg12: - case DwarfOperationKind.Reg13: - case DwarfOperationKind.Reg14: - case DwarfOperationKind.Reg15: - case DwarfOperationKind.Reg16: - case DwarfOperationKind.Reg17: - case DwarfOperationKind.Reg18: - case DwarfOperationKind.Reg19: - case DwarfOperationKind.Reg20: - case DwarfOperationKind.Reg21: - case DwarfOperationKind.Reg22: - case DwarfOperationKind.Reg23: - case DwarfOperationKind.Reg24: - case DwarfOperationKind.Reg25: - case DwarfOperationKind.Reg26: - case DwarfOperationKind.Reg27: - case DwarfOperationKind.Reg28: - case DwarfOperationKind.Reg29: - case DwarfOperationKind.Reg30: - case DwarfOperationKind.Reg31: - case DwarfOperationKind.StackValue: - break; - - case DwarfOperationKind.Breg0: - case DwarfOperationKind.Breg1: - case DwarfOperationKind.Breg2: - case DwarfOperationKind.Breg3: - case DwarfOperationKind.Breg4: - case DwarfOperationKind.Breg5: - case DwarfOperationKind.Breg6: - case DwarfOperationKind.Breg7: - case DwarfOperationKind.Breg8: - case DwarfOperationKind.Breg9: - case DwarfOperationKind.Breg10: - case DwarfOperationKind.Breg11: - case DwarfOperationKind.Breg12: - case DwarfOperationKind.Breg13: - case DwarfOperationKind.Breg14: - case DwarfOperationKind.Breg15: - case DwarfOperationKind.Breg16: - case DwarfOperationKind.Breg17: - case DwarfOperationKind.Breg18: - case DwarfOperationKind.Breg19: - case DwarfOperationKind.Breg20: - case DwarfOperationKind.Breg21: - case DwarfOperationKind.Breg22: - case DwarfOperationKind.Breg23: - case DwarfOperationKind.Breg24: - case DwarfOperationKind.Breg25: - case DwarfOperationKind.Breg26: - case DwarfOperationKind.Breg27: - case DwarfOperationKind.Breg28: - case DwarfOperationKind.Breg29: - case DwarfOperationKind.Breg30: - case DwarfOperationKind.Breg31: - writer.WriteILEB128(Operand2.I64); - break; - - case DwarfOperationKind.Bregx: - writer.WriteULEB128(Operand1.U64); - writer.WriteILEB128(Operand2.I64); - break; - - case DwarfOperationKind.Call2: - writer.WriteU16((ushort)((DwarfDIE)Operand0).Offset); - break; - - case DwarfOperationKind.Call4: - writer.WriteU32((uint)((DwarfDIE)Operand0).Offset); - break; - - case DwarfOperationKind.CallRef: - writer.WriteUInt(((DwarfDIE)Operand0).Offset); - break; - - case DwarfOperationKind.BitPiece: - writer.WriteULEB128(Operand1.U64); - writer.WriteULEB128(Operand2.U64); - break; - - case DwarfOperationKind.ImplicitValue: - { - var stream = (Stream)Operand0; - writer.WriteULEB128((ulong)stream.Position); - writer.Write(stream); - break; - } - - case DwarfOperationKind.ImplicitPointer: - case DwarfOperationKind.GNUImplicitPointer: - { - ulong offset = ((DwarfDIE)Operand0).Offset; - // a reference to a debugging information entry that describes the dereferenced object’s value - if (writer.CurrentUnit.Version == 2) - { - writer.WriteUInt(offset); - } - else - { - writer.WriteUIntFromEncoding(offset); - } - // a signed number that is treated as a byte offset from the start of that value - writer.WriteILEB128(Operand1.I64); - break; - } - - case DwarfOperationKind.EntryValue: - case DwarfOperationKind.GNUEntryValue: - { - var expression = (DwarfExpression)Operand0; - writer.WriteULEB128(expression.Size); - expression.WriteInternal(writer); - break; - } - - case DwarfOperationKind.ConstType: - case DwarfOperationKind.GNUConstType: - { - // The DW_OP_const_type operation takes three operands - - // The first operand is an unsigned LEB128 integer that represents the offset - // of a debugging information entry in the current compilation unit, which - // must be a DW_TAG_base_type entry that provides the type of the constant provided - writer.WriteULEB128(((DwarfDIE)Operand0).Offset); - WriteEncodedValue(writer, Kind, Operand1.U64, (byte)Operand2.U64); - break; - } - - case DwarfOperationKind.RegvalType: - case DwarfOperationKind.GNURegvalType: - { - // The DW_OP_regval_type operation provides the contents of a given register - // interpreted as a value of a given type - - // The first operand is an unsigned LEB128 number, which identifies a register - // whose contents is to be pushed onto the stack - writer.WriteULEB128(Operand1.U64); - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - writer.WriteULEB128(((DwarfDIE)Operand0).Offset); - break; - } - - case DwarfOperationKind.DerefType: - case DwarfOperationKind.GNUDerefType: - case DwarfOperationKind.XderefType: - { - // The DW_OP_deref_type operation behaves like the DW_OP_deref_size operation: - // it pops the top stack entry and treats it as an address. - - // This operand is a 1-byte unsigned integral constant whose value which is the - // same as the size of the base type referenced by the second operand - writer.WriteU8((byte)Operand1.U64); - - // The second operand is an unsigned LEB128 number that represents the offset - // of a debugging information entry in the current compilation unit - writer.WriteULEB128(((DwarfDIE)Operand0).Offset); - break; - } - - case DwarfOperationKind.Convert: - case DwarfOperationKind.GNUConvert: - case DwarfOperationKind.Reinterpret: - case DwarfOperationKind.GNUReinterpret: - writer.WriteULEB128(((DwarfDIE)Operand0).Offset); - break; - - case DwarfOperationKind.GNUPushTlsAddress: - case DwarfOperationKind.GNUUninit: - break; - - case DwarfOperationKind.GNUEncodedAddr: - WriteEncodedValue(writer, Kind, Operand1.U64, (byte)Operand2.U64); - break; - - case DwarfOperationKind.GNUParameterRef: - writer.WriteU32((uint)Operand1.U64); - break; - - default: - throw new NotSupportedException($"The {nameof(DwarfOperationKind)} {Kind} is not supported"); - } - - Debug.Assert(writer.Offset - startOpOffset == Size); - } - - private static ulong ReadEncodedValue(DwarfReader reader, DwarfOperationKind kind, out byte size) - { - size = reader.ReadU8(); - switch (size) - { - case 0: - return reader.ReadUInt(); - case 1: - return reader.ReadU8(); - case 2: - return reader.ReadU16(); - case 4: - return reader.ReadU32(); - case 8: - return reader.ReadU64(); - default: - throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); - } - } - - private static void WriteEncodedValue(DwarfWriter writer, DwarfOperationKindEx kind, ulong value, byte size) - { - writer.WriteU8(size); - switch (size) - { - case 0: - writer.WriteUInt(value); - break; - case 1: - writer.WriteU8((byte)value); - break; - case 2: - writer.WriteU16((ushort)value); - break; - case 4: - writer.WriteU32((uint)value); - break; - case 8: - writer.WriteU64(value); - break; - default: - // TODO: report via diagnostics in Verify - throw new InvalidOperationException($"Invalid Encoded address size {size} for {kind}"); - } - } - - private static readonly DwarfReader.DwarfDIEReferenceResolver DwarfExpressionLocationDIEReferenceResolverInstance = DwarfExpressionLocationDIEReferenceResolver; - - private static void DwarfExpressionLocationDIEReferenceResolver(ref DwarfReader.DwarfDIEReference dieRef) - { - var op = (DwarfOperation)dieRef.DwarfObject; - op.Operand0 = dieRef.Resolved; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs deleted file mode 100644 index 7f91c06c3b6d94..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfOperationKindEx.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public readonly partial struct DwarfOperationKindEx : IEquatable - { - public DwarfOperationKindEx(byte value) - { - Value = (DwarfOperationKind)value; - } - - public DwarfOperationKindEx(DwarfOperationKind value) - { - Value = value; - } - - public readonly DwarfOperationKind Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfOperationKindEx)} ({(uint)Value:x2})"; - } - - public bool Equals(DwarfOperationKindEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfOperationKindEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(DwarfOperationKindEx left, DwarfOperationKindEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfOperationKindEx left, DwarfOperationKindEx right) - { - return !left.Equals(right); - } - - public static explicit operator uint(DwarfOperationKindEx kind) => (uint)kind.Value; - - public static implicit operator DwarfOperationKindEx(DwarfOperationKind kind) => new DwarfOperationKindEx(kind); - - public static implicit operator DwarfOperationKind(DwarfOperationKindEx kind) => kind.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs deleted file mode 100644 index a1b1eb5acc51b7..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfPrinter.cs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Linq; - -namespace LibObjectFile.Dwarf -{ - public static class DwarfPrinter - { - public static void Print(this DwarfAbbreviationTable abbrevTable, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine("Contents of the .debug_abbrev section:"); - - foreach (var abbreviation in abbrevTable.Abbreviations) - { - Print(abbreviation, writer); - } - } - - public static void Print(this DwarfAbbreviation abbreviation, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine(); - - writer.WriteLine($" Number TAG (0x{abbreviation.Offset})"); - - foreach (var item in abbreviation.Items) - { - writer.WriteLine($" {item.Code} {item.Tag} [{(item.HasChildren ? "has children" : "no children")}]"); - var descriptors = item.Descriptors; - for (int i = 0; i < descriptors.Length; i++) - { - var descriptor = descriptors[i]; - writer.WriteLine($" {descriptor.Kind.ToString(),-18} {descriptor.Form}"); - } - writer.WriteLine(" DW_AT value: 0 DW_FORM value: 0"); - } - } - - public static void PrintRelocations(this DwarfRelocatableSection relocSection, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine(); - if (relocSection.Relocations.Count == 0) - { - writer.WriteLine(" There are no relocations in this section."); - return; - } - - writer.WriteLine($" Relocations of this section contains {(relocSection.Relocations.Count > 1 ? $"{relocSection.Relocations.Count} entries" : "1 entry")}:"); - writer.WriteLine(); - writer.WriteLine(" Offset Target Size Addend"); - foreach (var reloc in relocSection.Relocations) - { - writer.WriteLine($"{reloc.Offset:x16} {reloc.Target,-24} {(uint)reloc.Size,-6} {reloc.Addend:x}"); - } - } - - public static void Print(this DwarfInfoSection debugInfo, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - foreach (var unit in debugInfo.Units) - { - Print(unit, writer); - } - } - - public static void Print(this DwarfUnit unit, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - writer.WriteLine("Contents of the .debug_info section:"); - writer.WriteLine(); - writer.WriteLine($" Compilation Unit @ offset 0x{unit.Offset:x}:"); - writer.WriteLine($" Length: 0x{unit.UnitLength:x}"); - writer.WriteLine($" Version: {unit.Version}"); - writer.WriteLine($" Abbrev Offset: 0x{unit.Abbreviation?.Offset ?? 0:x}"); - writer.WriteLine($" Pointer Size: {(uint)unit.AddressSize}"); - if (unit.Root != null) - { - Print(unit.Root, writer); - } - } - - public static void Print(this DwarfDIE die, TextWriter writer, int level = 0) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine($" <{level}><{die.Offset:x}>: Abbrev Number: {die.Abbrev.Code} ({die.Tag})"); - - foreach (var attr in die.Attributes) - { - string attrValue = null; - switch (attr.ValueAsObject) - { - case DwarfDIE dieRef: - attrValue = $"<0x{dieRef.Offset:x}>"; - break; - case string str: - attrValue = str; - break; - case DwarfExpression expr: - attrValue = $"{expr.Operations.Count} OpCodes ({string.Join(", ", expr.Operations.Select(x => x.Kind))})"; - break; - } - - switch (attr.Kind.Value) - { - case DwarfAttributeKind.Language: - - attrValue = $"{attr.ValueAsU64} {GetLanguageKind((DwarfLanguageKind)attr.ValueAsU64)}"; - break; - } - - if (attrValue == null) - { - - var encoding = DwarfHelper.GetAttributeEncoding(attr.Kind); - if ((encoding & DwarfAttributeEncoding.Address) != 0) - { - attrValue = $"0x{attr.ValueAsU64:x}"; - } - else - { - attrValue = $"{attr.ValueAsU64}"; - } - } - - writer.WriteLine($" <{attr.Offset:x}> {attr.Kind,-18} : {attrValue}"); - } - - foreach (var child in die.Children) - { - Print(child, writer, level + 1); - } - } - - public static void Print(this DwarfAddressRangeTable addressRangeTable, TextWriter writer) - { - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine("Contents of the .debug_aranges section:"); - writer.WriteLine(); - writer.WriteLine($" Length: {addressRangeTable.HeaderLength}"); - writer.WriteLine($" Version: {addressRangeTable.Version}"); - writer.WriteLine($" Offset into .debug_info: 0x{addressRangeTable.DebugInfoOffset:x}"); - writer.WriteLine($" Pointer Size: {(byte)addressRangeTable.AddressSize}"); - writer.WriteLine($" Segment Size: {(byte)addressRangeTable.SegmentSelectorSize}"); - writer.WriteLine(); - var addressSize = (uint)addressRangeTable.AddressSize; - if (addressSize > 4) - { - writer.WriteLine(" Address Length"); - } - else - { - writer.WriteLine(" Address Length"); - } - - var formatStyle = "x" + (addressSize * 2); - foreach (var range in addressRangeTable.Ranges) - { - writer.WriteLine($" {range.Address.ToString(formatStyle)} {range.Length.ToString(formatStyle)}"); - } - writer.WriteLine($" {((ulong)0).ToString(formatStyle)} {((ulong)0).ToString(formatStyle)}"); - } - - private static string GetLanguageKind(DwarfLanguageKind kind) - { - var rawKind = (uint) kind; - switch (rawKind) - { - case DwarfNative.DW_LANG_C89: return "(ANSI C)"; - case DwarfNative.DW_LANG_C: return "(non-ANSI C)"; - case DwarfNative.DW_LANG_Ada83: return "(Ada)"; - case DwarfNative.DW_LANG_C_plus_plus: return "(C++)"; - case DwarfNative.DW_LANG_Cobol74: return "(Cobol 74)"; - case DwarfNative.DW_LANG_Cobol85: return "(Cobol 85)"; - case DwarfNative.DW_LANG_Fortran77: return "(FORTRAN 77)"; - case DwarfNative.DW_LANG_Fortran90: return "(Fortran 90)"; - case DwarfNative.DW_LANG_Pascal83: return "(ANSI Pascal)"; - case DwarfNative.DW_LANG_Modula2: return "(Modula 2)"; - // DWARF 2.1 - case DwarfNative.DW_LANG_Java: return "(Java)"; - case DwarfNative.DW_LANG_C99: return "(ANSI C99)"; - case DwarfNative.DW_LANG_Ada95: return "(ADA 95)"; - case DwarfNative.DW_LANG_Fortran95: return "(Fortran 95)"; - // DWARF 3 - case DwarfNative.DW_LANG_PLI: return "(PLI)"; - case DwarfNative.DW_LANG_ObjC: return "(Objective C)"; - case DwarfNative.DW_LANG_ObjC_plus_plus: return "(Objective C++)"; - case DwarfNative.DW_LANG_UPC: return "(Unified Parallel C)"; - case DwarfNative.DW_LANG_D: return "(D)"; - // DWARF 4 - case DwarfNative.DW_LANG_Python: return "(Python)"; - // DWARF 5 - case DwarfNative.DW_LANG_OpenCL: return "(OpenCL)"; - case DwarfNative.DW_LANG_Go: return "(Go)"; - case DwarfNative.DW_LANG_Modula3: return "(Modula 3)"; - case DwarfNative.DW_LANG_Haskel: return "(Haskell)"; - case DwarfNative.DW_LANG_C_plus_plus_03: return "(C++03)"; - case DwarfNative.DW_LANG_C_plus_plus_11: return "(C++11)"; - case DwarfNative.DW_LANG_OCaml: return "(OCaml)"; - case DwarfNative.DW_LANG_Rust: return "(Rust)"; - case DwarfNative.DW_LANG_C11: return "(C11)"; - case DwarfNative.DW_LANG_Swift: return "(Swift)"; - case DwarfNative.DW_LANG_Julia: return "(Julia)"; - case DwarfNative.DW_LANG_Dylan: return "(Dylan)"; - case DwarfNative.DW_LANG_C_plus_plus_14: return "(C++14)"; - case DwarfNative.DW_LANG_Fortran03: return "(Fortran 03)"; - case DwarfNative.DW_LANG_Fortran08: return "(Fortran 08)"; - case DwarfNative.DW_LANG_RenderScript: return "(RenderScript)"; - - case DwarfNative.DW_LANG_Mips_Assembler: return "(MIPS assembler)"; - - case DwarfNative.DW_LANG_Upc: return "(Unified Parallel C)"; - - default: - if (rawKind >= DwarfNative.DW_LANG_lo_user && rawKind <= DwarfNative.DW_LANG_hi_user) - return $"(implementation defined: {rawKind:x})"; - break; - } - - return $"(Unknown: {rawKind:x})"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs deleted file mode 100644 index 306939b11c9939..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReader.cs +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfReader : DwarfReaderWriter - { - private readonly Dictionary _registeredDIEPerCompilationUnit; - private readonly Dictionary _registeredDIEPerSection; - private readonly List _unresolvedDIECompilationUnitReference; - private readonly List _attributesWithUnresolvedDIESectionReference; - private readonly Stack _stack; - private readonly Stack _stackWithLineProgramTable; - - internal DwarfReader(DwarfReaderContext context, DwarfFile file, DiagnosticBag diagnostics) : base(file, diagnostics) - { - IsReadOnly = context.IsInputReadOnly; - AddressSize = context.AddressSize; - IsLittleEndian = context.IsLittleEndian; - _registeredDIEPerCompilationUnit = new Dictionary(); - _registeredDIEPerSection = new Dictionary(); - _unresolvedDIECompilationUnitReference = new List(); - _attributesWithUnresolvedDIESectionReference = new List(); - OffsetToLineProgramTable = new Dictionary(); - OffsetToLocationList = new Dictionary(); - _stack = new Stack(); - _stackWithLineProgramTable = new Stack(); - } - - public override bool IsReadOnly { get; } - - public DwarfUnitKind DefaultUnitKind { get; internal set; } - - internal int DIELevel { get; set; } - - internal DwarfDIE CurrentDIE => _stack.Count > 0 ? _stack.Peek() : null; - - internal DwarfLineProgramTable CurrentLineProgramTable => _stackWithLineProgramTable.Count > 0 ? _stackWithLineProgramTable.Peek().CurrentLineProgramTable : null; - - internal DwarfAttributeDescriptor CurrentAttributeDescriptor { get; set; } - - internal Dictionary OffsetToLineProgramTable { get; } - - internal Dictionary OffsetToLocationList { get; } - - internal void PushDIE(DwarfDIE die) - { - _registeredDIEPerCompilationUnit.Add(die.Offset - CurrentUnit.Offset, die); - _registeredDIEPerSection.Add(die.Offset, die); - _stack.Push(die); - } - - internal void PushLineProgramTable(DwarfLineProgramTable lineTable) - { - var dieWithLineProgramTable = CurrentDIE; - if (_stackWithLineProgramTable.Count > 0 && ReferenceEquals(_stackWithLineProgramTable.Peek(), dieWithLineProgramTable)) - { - return; - } - - _stackWithLineProgramTable.Push(dieWithLineProgramTable); - dieWithLineProgramTable.CurrentLineProgramTable = lineTable; - } - - internal void PopDIE() - { - var die = _stack.Pop(); - if (die.CurrentLineProgramTable != null) - { - var dieWithProgramLineTable = _stackWithLineProgramTable.Pop(); - Debug.Assert(ReferenceEquals(die, dieWithProgramLineTable)); - dieWithProgramLineTable.CurrentLineProgramTable = null; - } - } - - internal void ClearResolveAttributeReferenceWithinCompilationUnit() - { - _registeredDIEPerCompilationUnit.Clear(); - _unresolvedDIECompilationUnitReference.Clear(); - } - - internal void ResolveAttributeReferenceWithinCompilationUnit() - { - // Resolve attribute reference within the CU - foreach (var unresolvedAttrRef in _unresolvedDIECompilationUnitReference) - { - ResolveAttributeReferenceWithinCompilationUnit(unresolvedAttrRef, true); - } - } - - internal void ResolveAttributeReferenceWithinSection() - { - // Resolve attribute reference within the section - foreach (var unresolvedAttrRef in _attributesWithUnresolvedDIESectionReference) - { - ResolveAttributeReferenceWithinSection(unresolvedAttrRef, true); - } - } - - internal void ResolveAttributeReferenceWithinCompilationUnit(DwarfDIEReference dieRef, bool errorIfNotFound) - { - if (_registeredDIEPerCompilationUnit.TryGetValue(dieRef.Offset, out var die)) - { - dieRef.Resolved = die; - dieRef.Resolver(ref dieRef); - } - else - { - if (errorIfNotFound) - { - if (dieRef.Offset != 0) - { - Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidReference, $"Unable to resolve DIE reference (0x{dieRef.Offset:x}, section 0x{(dieRef.Offset):x}) for {dieRef.DwarfObject} at offset 0x{dieRef.Offset:x}"); - } - } - else - { - _unresolvedDIECompilationUnitReference.Add(dieRef); - } - } - } - - internal void ResolveAttributeReferenceWithinSection(DwarfDIEReference dieRef, bool errorIfNotFound) - { - if (_registeredDIEPerSection.TryGetValue(dieRef.Offset, out var die)) - { - dieRef.Resolved = die; - dieRef.Resolver(ref dieRef); - } - else - { - if (errorIfNotFound) - { - if (dieRef.Offset != 0) - { - Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidReference, $"Unable to resolve DIE reference (0x{dieRef.Offset:x}) for {dieRef.DwarfObject} at offset 0x{dieRef.Offset:x}"); - } - } - else - { - _attributesWithUnresolvedDIESectionReference.Add(dieRef); - } - } - } - - internal struct DwarfDIEReference - { - public DwarfDIEReference(ulong offset, object dwarfObject, DwarfDIEReferenceResolver resolver) : this() - { - Offset = offset; - DwarfObject = dwarfObject; - Resolver = resolver; - } - - public readonly ulong Offset; - - public readonly object DwarfObject; - - public readonly DwarfDIEReferenceResolver Resolver; - - public DwarfDIE Resolved; - } - - internal delegate void DwarfDIEReferenceResolver(ref DwarfDIEReference reference); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs deleted file mode 100644 index 6d4fa71be9cf58..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderContext.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public class DwarfReaderContext : DwarfReaderWriterContext - { - public DwarfReaderContext() - { - } - - public DwarfReaderContext(DwarfElfContext elfContext) - { - if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); - IsLittleEndian = elfContext.IsLittleEndian; - AddressSize = elfContext.AddressSize; - DebugLineStream = elfContext.LineTable?.Stream; - DebugStringStream = elfContext.StringTable?.Stream; - DebugAbbrevStream = elfContext.AbbreviationTable?.Stream; - DebugInfoStream = elfContext.InfoSection?.Stream; - DebugAddressRangeStream = elfContext.AddressRangeTable?.Stream; - DebugLocationStream = elfContext.LocationSection?.Stream; - } - - public bool IsInputReadOnly { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs deleted file mode 100644 index 049ebd62104dd4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriter.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfReaderWriter : ObjectFileReaderWriter - { - internal DwarfReaderWriter(DwarfFile file, DiagnosticBag diagnostics) : base(null, diagnostics) - { - File = file; - } - - public DwarfFile File { get; } - - public bool Is64BitEncoding { get; set; } - - public DwarfAddressSize AddressSize { get; internal set; } - - public DwarfSection CurrentSection { get; internal set; } - - public DwarfUnit CurrentUnit { get; internal set; } - - public DwarfAddressSize SizeOfUIntEncoding() - { - return Is64BitEncoding ? DwarfAddressSize.Bit64 : DwarfAddressSize.Bit32; - } - - public DwarfAddressSize ReadAddressSize() - { - var address_size = (DwarfAddressSize)ReadU8(); - switch (address_size) - { - case DwarfAddressSize.Bit8: - case DwarfAddressSize.Bit16: - case DwarfAddressSize.Bit32: - case DwarfAddressSize.Bit64: - break; - default: - Diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Unsupported address size {(uint)address_size}."); - break; - } - - return address_size; - } - - public void WriteAddressSize(DwarfAddressSize addressSize) - { - WriteU8((byte)addressSize); - } - - public ulong ReadUnitLength() - { - Is64BitEncoding = false; - uint length = ReadU32(); - if (length >= 0xFFFFFFF0) - { - if (length != 0xFFFFFFFF) - { - throw new InvalidOperationException($"Unsupported unit length prefix 0x{length:x8}"); - } - - Is64BitEncoding = true; - return ReadU64(); - } - return length; - } - - public void WriteUnitLength(ulong length) - { - if (Is64BitEncoding) - { - WriteU32(0xFFFFFFFF); - WriteU64(length); - } - else - { - if (length >= 0xFFFFFFF0) - { - throw new ArgumentOutOfRangeException(nameof(length), $"Must be < 0xFFFFFFF0 but is 0x{length:X}"); - } - WriteU32((uint)length); - } - } - - public ulong ReadUIntFromEncoding() - { - return Is64BitEncoding ? ReadU64() : ReadU32(); - } - - public void WriteUIntFromEncoding(ulong value) - { - if (Is64BitEncoding) - { - WriteU64(value); - } - else - { - WriteU32((uint)value); - } - } - - public ulong ReadUInt() - { - switch (AddressSize) - { - case DwarfAddressSize.Bit8: - return ReadU8(); - case DwarfAddressSize.Bit16: - return ReadU16(); - case DwarfAddressSize.Bit32: - return ReadU32(); - case DwarfAddressSize.Bit64: - return ReadU64(); - default: - throw new ArgumentOutOfRangeException($"Invalid AddressSize {AddressSize}"); - } - } - - public void WriteUInt(ulong target) - { - switch (AddressSize) - { - case DwarfAddressSize.Bit8: - WriteU8((byte)target); - break; - case DwarfAddressSize.Bit16: - WriteU16((ushort)target); - break; - case DwarfAddressSize.Bit32: - WriteU32((uint)target); - break; - case DwarfAddressSize.Bit64: - WriteU64(target); - break; - default: - throw new ArgumentOutOfRangeException($"Invalid AddressSize {AddressSize}"); - } - } - - public ulong ReadULEB128() - { - return Stream.ReadULEB128(); - } - - public uint ReadULEB128AsU32() - { - return Stream.ReadULEB128AsU32(); - } - - public int ReadLEB128AsI32() - { - return Stream.ReadLEB128AsI32(); - } - - public long ReadILEB128() - { - return Stream.ReadSignedLEB128(); - } - - public void WriteULEB128(ulong value) - { - Stream.WriteULEB128(value); - } - public void WriteILEB128(long value) - { - Stream.WriteILEB128(value); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs deleted file mode 100644 index 97d3bf3a6618f5..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfReaderWriterContext.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfReaderWriterContext - { - public bool IsLittleEndian { get; set; } - - public DwarfAddressSize AddressSize { get; set; } - - public Stream DebugAbbrevStream { get; set; } - - public Stream DebugStringStream { get; set; } - - public Stream DebugAddressRangeStream { get; set; } - - public Stream DebugLineStream { get; set; } - - public TextWriter DebugLinePrinter { get; set; } - - public Stream DebugInfoStream { get; set; } - - public Stream DebugLocationStream { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs deleted file mode 100644 index 09084726ea57ac..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocatableSection.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using LibObjectFile.Elf; - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfRelocatableSection : DwarfSection - { - protected DwarfRelocatableSection() - { - Relocations = new List(); - } - - - public List Relocations { get; } - } - - public static class DwarfRelocationSectionExtensions - { - public static void CopyRelocationsTo(this DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) - { - if (elfContext == null) throw new ArgumentNullException(nameof(elfContext)); - if (relocTable == null) throw new ArgumentNullException(nameof(relocTable)); - - switch (elfContext.Elf.Arch.Value) - { - case ElfArch.X86_64: - CopyRelocationsX86_64(dwarfRelocSection, elfContext, relocTable); - break; - default: - throw new NotImplementedException($"The relocation for architecture {relocTable.Parent.Arch} is not supported/implemented."); - } - - } - - private static void CopyRelocationsX86_64(DwarfRelocatableSection dwarfRelocSection, DwarfElfContext elfContext, ElfRelocationTable relocTable) - { - relocTable.Entries.Clear(); - foreach (var reloc in dwarfRelocSection.Relocations) - { - var relocType = reloc.Size == DwarfAddressSize.Bit64 ? ElfRelocationType.R_X86_64_64 : ElfRelocationType.R_X86_64_32; - switch (reloc.Target) - { - case DwarfRelocationTarget.Code: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.CodeSectionSymbolIndex, (long) reloc.Addend)); - break; - case DwarfRelocationTarget.DebugString: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.StringTableSymbolIndex, (long)reloc.Addend)); - break; - case DwarfRelocationTarget.DebugAbbrev: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.AbbreviationTableSymbolIndex, (long)reloc.Addend)); - break; - case DwarfRelocationTarget.DebugInfo: - relocTable.Entries.Add(new ElfRelocation(reloc.Offset, relocType, (uint)elfContext.InfoSectionSymbolIndex, (long)reloc.Addend)); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs deleted file mode 100644 index 237d81c94ee225..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocation.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - [DebuggerDisplay("{" + nameof(ToString) + "(),nq}")] - public struct DwarfRelocation - { - public DwarfRelocation(ulong offset, DwarfRelocationTarget target, DwarfAddressSize size, ulong addend) - { - Offset = offset; - Target = target; - Size = size; - Addend = addend; - } - - public ulong Offset { get; set; } - - public DwarfRelocationTarget Target { get; set; } - - public DwarfAddressSize Size { get; set; } - - public ulong Addend { get; set; } - - public override string ToString() - { - return $"{nameof(Offset)}: {Offset}, {nameof(Target)}: {Target}, {nameof(Size)}: {Size}, {nameof(Addend)}: {Addend}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs deleted file mode 100644 index bcec19fda54d73..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfRelocationTarget.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfRelocationTarget - { - Code, - - DebugString, - - DebugAbbrev, - - DebugInfo, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs deleted file mode 100644 index 408c726f25e530..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSection.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - public abstract class DwarfSection : DwarfContainer - { - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is DwarfFile)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(DwarfFile)}"); - } - } - - /// - /// Gets the containing . Might be null if this section or segment - /// does not belong to an existing . - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - public new DwarfFile Parent - { - get => (DwarfFile)base.Parent; - internal set => base.Parent = value; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs deleted file mode 100644 index 3f92cef19edc1f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfSectionLink.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public struct DwarfSectionLink : IEquatable - { - public DwarfSectionLink(ulong offset) - { - Offset = offset; - } - - public readonly ulong Offset; - - public override string ToString() - { - return $"SectionLink {nameof(Offset)}: 0x{Offset:x}"; - } - - public bool Equals(DwarfSectionLink other) - { - return Offset == other.Offset; - } - - public override bool Equals(object obj) - { - return obj is DwarfSectionLink other && Equals(other); - } - - public override int GetHashCode() - { - return Offset.GetHashCode(); - } - - public static bool operator ==(DwarfSectionLink left, DwarfSectionLink right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfSectionLink left, DwarfSectionLink right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs deleted file mode 100644 index 5bbde3539cafbf..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStreamExtensions.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public static class DwarfStreamExtensions - { - public static ulong ReadULEB128(this Stream stream) - { - ulong value = 0; - int shift = 0; - while (true) - { - var b = stream.ReadU8(); - value = ((ulong)(b & 0x7f) << shift) | value; - if ((b & 0x80) == 0) - { - break; - } - shift += 7; - } - return value; - } - - public static void WriteULEB128(this Stream stream, ulong value) - { - do - { - var b = (byte)(value & 0x7f); - value >>= 7; - if (value != 0) - b |= 0x80; - stream.WriteU8(b); - } while (value != 0); - } - - public static void WriteILEB128(this Stream stream, long value) - { - bool cont = true; - while (cont) - { - var b = (byte)((byte)value & 0x7f); - value >>= 7; - bool isSignBitSet = (b & 0x40) != 0; - if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) - { - cont = false; - } - else - { - b |= 0x80; - } - stream.WriteU8(b); - } - } - - public static uint ReadULEB128AsU32(this Stream stream) - { - var offset = stream.Position; - var value = stream.ReadULEB128(); - if (value >= uint.MaxValue) throw new InvalidOperationException($"The LEB128 0x{value:x16} read from stream at offset {offset} is out of range of uint >= {uint.MaxValue}"); - return (uint)value; - } - - public static int ReadLEB128AsI32(this Stream stream) - { - var offset = stream.Position; - var value = stream.ReadULEB128(); - if (value >= int.MaxValue) throw new InvalidOperationException($"The LEB128 0x{value:x16} read from stream at offset {offset} is out of range of int >= {int.MaxValue}"); - return (int)value; - } - - public static long ReadSignedLEB128(this Stream stream) - { - long value = 0; - int shift = 0; - byte b = 0; - do - { - b = stream.ReadU8(); - value |= ((long) (b & 0x7f) << shift); - shift += 7; - } while ((b & 0x80) != 0); - - if (shift < 64 && (b & 0x40) != 0) - { - value |= (long)(~0UL << shift); - } - - return value; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs deleted file mode 100644 index f2a9abf54573e0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfStringTable.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -namespace LibObjectFile.Dwarf -{ - public class DwarfStringTable : DwarfSection - { - private readonly Dictionary _stringToOffset; - private readonly Dictionary _offsetToString; - private Stream _stream; - - public DwarfStringTable() : this(new MemoryStream()) - { - } - - public DwarfStringTable(Stream stream) - { - Stream = stream ?? throw new ArgumentNullException(nameof(stream)); - _stringToOffset = new Dictionary(); - _offsetToString = new Dictionary(); - } - - public Stream Stream - { - get => _stream; - set => _stream = value ?? throw new ArgumentNullException(nameof(value)); - } - - public string GetStringFromOffset(ulong offset) - { - if (_offsetToString.TryGetValue(offset, out var text)) - { - return text; - } - - Stream.Position = (long) offset; - text = Stream.ReadStringUTF8NullTerminated(); - _offsetToString[offset] = text; - _stringToOffset[text] = offset; - return text; - } - - public bool Contains(string text) - { - if (text == null) return false; - return _stringToOffset.ContainsKey(text); - } - - public ulong GetOrCreateString(string text) - { - if (text == null) return 0; - - ulong offset; - if (_stringToOffset.TryGetValue(text, out offset)) - { - return offset; - } - - Stream.Position = Stream.Length; - offset = (ulong)Stream.Position; - Stream.WriteStringUTF8NullTerminated(text); - _offsetToString[offset] = text; - _stringToOffset[text] = offset; - return offset; - } - - protected override void Read(DwarfReader reader) - { - Stream = reader.ReadAsStream((ulong) reader.Stream.Length); - Size = reader.Offset - Offset; - } - - protected override void Write(DwarfWriter writer) - { - writer.Write(Stream); - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - Size = (ulong?)(Stream?.Length) ?? 0UL; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs deleted file mode 100644 index 5681d8577e9cac..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfTagEx.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - /// - /// Defines the tag of an . - /// - public readonly partial struct DwarfTagEx : IEquatable - { - public DwarfTagEx(uint value) - { - Value = (DwarfTag)value; - } - - public DwarfTagEx(DwarfTag value) - { - Value = value; - } - - public readonly DwarfTag Value; - - public bool Equals(DwarfTagEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfTagEx other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(DwarfTagEx left, DwarfTagEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfTagEx left, DwarfTagEx right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(DwarfTagEx)} (0x{Value:X4})"; - } - - public static explicit operator uint(DwarfTagEx tag) => (uint)tag.Value; - - public static implicit operator DwarfTagEx(DwarfTag tag) => new DwarfTagEx(tag); - - public static implicit operator DwarfTag(DwarfTagEx tag) => tag.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs deleted file mode 100644 index 12978e593a27a4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnit.cs +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Dwarf -{ - /// - /// Base class for a Dwarf Unit. - /// - public abstract class DwarfUnit : DwarfContainer - { - private DwarfDIE _root; - - /// - /// Gets or sets the encoding of this unit. - /// - public bool Is64BitEncoding { get; set; } - - /// - /// Gets or sets the address size used by this unit. - /// - public DwarfAddressSize AddressSize { get; set; } - - /// - /// Gets or sets the version of this unit. - /// - public ushort Version { get; set; } - - /// - /// Gets or sets the kind of this unit. - /// - public DwarfUnitKindEx Kind { get; set; } - - /// - /// Gets the abbreviation offset, only valid once the layout has been calculated through . - /// - public ulong DebugAbbreviationOffset { get; internal set; } - - /// - /// Gets the unit length, only valid once the layout has been calculated through . - /// - public ulong UnitLength { get; internal set; } - - /// - /// Gets or sets the root of this compilation unit. - /// - public DwarfDIE Root - { - get => _root; - set => AttachChild(this, value, ref _root, true); - } - - /// - /// Gets the abbreviation associated with the . - /// - /// - /// This abbreviation is automatically setup after reading or after updating the layout through . - /// - public DwarfAbbreviation Abbreviation { get; internal set; } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - if (Version < 2 || Version > 5) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version .debug_info {Version} not supported"); - } - - if (AddressSize == DwarfAddressSize.None) - { - diagnostics.Error(DiagnosticId.DWARF_ERR_InvalidAddressSize, $"Address size for .debug_info cannot be None/0"); - } - - Root?.Verify(diagnostics); - } - - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is DwarfSection)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(DwarfSection)}"); - } - } - - protected override void UpdateLayout(DwarfLayoutContext layoutContext) - { - var offset = this.Offset; - - // 1. unit_length - offset += DwarfHelper.SizeOfUnitLength(Is64BitEncoding); - - var offsetAfterUnitLength = offset; - - // 2. version (uhalf) - offset += sizeof(ushort); // WriteU16(unit.Version); - - if (Version >= 5) - { - // 3. unit_type (ubyte) - offset += 1; // WriteU8(unit.Kind.Value); - } - - // Update the layout specific to the Unit instance - offset += GetLayoutHeaderSize(); - - Abbreviation = null; - - // Compute the full layout of all DIE and attributes (once abbreviation are calculated) - if (Root != null) - { - // Before updating the layout, we need to compute the abbreviation - Abbreviation = new DwarfAbbreviation(); - layoutContext.File.AbbreviationTable.AddAbbreviation(Abbreviation); - - Root.UpdateAbbreviationItem(layoutContext); - - DebugAbbreviationOffset = Abbreviation.Offset; - - Root.Offset = offset; - Root.UpdateLayoutInternal(layoutContext); - offset += Root.Size; - } - - Size = offset - Offset; - UnitLength = offset - offsetAfterUnitLength; - } - - protected abstract ulong GetLayoutHeaderSize(); - - protected abstract void ReadHeader(DwarfReader reader); - - protected abstract void WriteHeader(DwarfWriter writer); - - protected override void Read(DwarfReader reader) - { - reader.CurrentUnit = this; - - foreach (var abbreviation in reader.File.AbbreviationTable.Abbreviations) - { - if (abbreviation.Offset == DebugAbbreviationOffset) - { - Abbreviation = abbreviation; - break; - } - } - - Root = DwarfDIE.ReadInstance(reader); - - reader.ResolveAttributeReferenceWithinCompilationUnit(); - - Size = reader.Offset - Offset; - } - - internal static DwarfUnit ReadInstance(DwarfReader reader, out ulong offsetEndOfUnit) - { - var startOffset = reader.Offset; - - DwarfUnit unit = null; - - // 1. unit_length - var unit_length = reader.ReadUnitLength(); - - offsetEndOfUnit = (ulong)reader.Offset + unit_length; - - // 2. version (uhalf) - var version = reader.ReadU16(); - - DwarfUnitKindEx unitKind = reader.DefaultUnitKind; - - if (version <= 2 || version > 5) - { - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_VersionNotSupported, $"Version {version} is not supported"); - return null; - } - - if (version >= 5) - { - // 3. unit_type (ubyte) - unitKind = new DwarfUnitKindEx(reader.ReadU8()); - } - - switch (unitKind.Value) - { - case DwarfUnitKind.Compile: - case DwarfUnitKind.Partial: - unit = new DwarfCompilationUnit(); - break; - - default: - reader.Diagnostics.Error(DiagnosticId.DWARF_ERR_UnsupportedUnitType, $"Unit Type {unitKind} is not supported"); - return null; - } - - unit.UnitLength = unit_length; - unit.Kind = unitKind; - unit.Is64BitEncoding = reader.Is64BitEncoding; - unit.Offset = startOffset; - unit.Version = version; - - unit.ReadHeader(reader); - - unit.ReadInternal(reader); - - return unit; - } - - protected override void Write(DwarfWriter writer) - { - var startOffset = writer.Offset; - Debug.Assert(Offset == writer.Offset); - - // 1. unit_length - Is64BitEncoding = Is64BitEncoding; - writer.WriteUnitLength(UnitLength); - - var offsetAfterUnitLength = writer.Offset; - - // 2. version (uhalf) - writer.WriteU16(Version); - - if (Version >= 5) - { - // 3. unit_type (ubyte) - writer.WriteU8((byte)Kind.Value); - } - - WriteHeader(writer); - writer.AddressSize = AddressSize; - - Root?.WriteInternal(writer); - // TODO: check size of unit length - - Debug.Assert(Size == writer.Offset - startOffset); - Debug.Assert(UnitLength == writer.Offset - offsetAfterUnitLength); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs deleted file mode 100644 index 07a6b8fb939585..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfUnitKind.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public readonly partial struct DwarfUnitKindEx : IEquatable - { - public DwarfUnitKindEx(byte value) - { - Value = (DwarfUnitKind)value; - } - - public DwarfUnitKindEx(DwarfUnitKind value) - { - Value = value; - } - - public readonly DwarfUnitKind Value; - - public override string ToString() - { - if ((byte)Value >= DwarfNative.DW_UT_lo_user) - { - return $"User {nameof(DwarfUnitKindEx)} (0x{Value:x2})"; - } - return ToStringInternal() ?? $"Unknown {nameof(DwarfUnitKindEx)} (0x{Value:x2})"; - } - - public bool Equals(DwarfUnitKindEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is DwarfUnitKindEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(DwarfUnitKindEx left, DwarfUnitKindEx right) - { - return left.Equals(right); - } - - public static bool operator !=(DwarfUnitKindEx left, DwarfUnitKindEx right) - { - return !left.Equals(right); - } - - public static explicit operator uint(DwarfUnitKindEx kind) => (uint)kind.Value; - - public static implicit operator DwarfUnitKindEx(DwarfUnitKind kind) => new DwarfUnitKindEx(kind); - - public static implicit operator DwarfUnitKind(DwarfUnitKindEx kind) => kind.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs deleted file mode 100644 index 167b04af09d8fa..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVirtuality.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfVirtuality : byte - { - None = DwarfNative.DW_VIRTUALITY_none, - - Virtual = DwarfNative.DW_VIRTUALITY_virtual, - - PureVirtual = DwarfNative.DW_VIRTUALITY_pure_virtual, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs deleted file mode 100644 index ea7e430ba977c8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfVisibility.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Dwarf -{ - public enum DwarfVisibility : byte - { - Local = DwarfNative.DW_VIS_local, - - Exported = DwarfNative.DW_VIS_exported, - - Qualified = DwarfNative.DW_VIS_qualified, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs deleted file mode 100644 index d12d32fd83b251..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriter.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Dwarf -{ - public sealed class DwarfWriter : DwarfReaderWriter - { - internal DwarfWriter(DwarfFile file, bool isLittleEndian, DiagnosticBag diagnostics) : base(file, diagnostics) - { - IsLittleEndian = isLittleEndian; - } - - public override bool IsReadOnly => false; - - public bool EnableRelocation { get; internal set; } - - public void RecordRelocation(DwarfRelocationTarget target, DwarfAddressSize addressSize, ulong address) - { - if (CurrentSection is DwarfRelocatableSection relocSection) - { - - relocSection.Relocations.Add(new DwarfRelocation(Offset, target, addressSize, address)); - - } - else - { - throw new InvalidOperationException($"Invalid {nameof(CurrentSection)} in {nameof(DwarfWriter)}. It must be a {nameof(DwarfRelocatableSection)}."); - } - } - - public void WriteAddress(DwarfRelocationTarget target, ulong address) - { - if (EnableRelocation) - { - RecordRelocation(target, AddressSize, address); - // If the relocation is recorded, we write 0 as an address - address = 0; - } - WriteUInt(address); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs deleted file mode 100644 index 577293a9be9234..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Dwarf/DwarfWriterContext.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using LibObjectFile.Elf; - -namespace LibObjectFile.Dwarf -{ - public class DwarfWriterContext : DwarfReaderWriterContext - { - public DwarfWriterContext() : this(new DwarfLayoutConfig()) - { - } - - public DwarfWriterContext(DwarfLayoutConfig layoutConfig) - { - LayoutConfig = layoutConfig ?? throw new ArgumentNullException(nameof(layoutConfig)); - EnableRelocation = true; - } - - public DwarfLayoutConfig LayoutConfig { get; } - - public bool EnableRelocation { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd deleted file mode 100644 index c409a3ecd340c5..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Elf.cd +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - Elf\ElfObjectFile.cs - - - - - IIAMBiAQAAAEAYCAAAAEHAAggCAoQAkIEUgAiAUBACA= - Elf\ElfObjectFile.cs - - - - - - - - - - EAABhAAAAAAAAQSEgCAAAAQgEEAABIAAARAAQEEEIAA= - Elf\ElfSection.cs - - - - - - AAAABAAAAAAACQAEgCAAAAAIAIAAAAAAAQAAIAAAAAA= - Elf\ElfSegment.cs - - - - - - AAAAAAAAAAAAAACAAAAAAAAgAAAIAAAAAQAAIAEAAAA= - Elf\Sections\ElfCustomSection.cs - - - - - - gAAAAAAAAAAAgCAAAAEAAAAgAAAAAAAAAQAAAAMAAAA= - Elf\Sections\ElfNoteTable.cs - - - - - - - - - AAAABAAAAAAAgAAAgCAAAAQgAAAAAQAAARAAQEEAgAA= - Elf\Sections\ElfNullSection.cs - - - - - - - - - - - - - - AAAAAAAAAIgAgSCAAEAAAAAgEAIAAAAAAcAAAAEAFAA= - Elf\Sections\ElfRelocationTable.cs - - - - - - - - - AAAABAAAAAAACAAAgCAAAAAAAAAAAAAAAQAAAAAAAAA= - Elf\Sections\ElfShadowSection.cs - - - - - - AAAAAAgAAAAAjgAAEAAAAAAgAAAAAAAAAYAAgAEGAAA= - Elf\Sections\ElfStringTable.cs - - - - - - AAAAAAAAAIAAgSCAAEAAAAAgEAAAAAAAAYAAAAEAFAA= - Elf\Sections\ElfSymbolTable.cs - - - - - - - - - QAACAAAAAAAAAAAEAABAAAAAAAAAAAAAIAACAAIBBAA= - Elf\Sections\ElfNote.cs - - - - - - - - - - - - - - AAAAAAAAAAAAAAAAAAAAAAAgAAAIAAAAAAAAIAEAAAA= - Elf\Sections\ElfCustomShadowSection.cs - - - - - - - - - - - - - - AAAAEAAAAAAAAACAAAAAAAAgAAAAAAAAAgAAIAEAAAA= - Elf\Sections\ElfProgramHeaderTable.cs - - - - - - AAAAAAAAAAAAAAAEABAQACAAAAAAAAAAAYAAAAAAgAA= - Elf\Sections\ElfRelocation.cs - - - - - - AEAAgAAAAAAAgAAEgAIAAAQAAAAAAIAAAQAgAIAAAiA= - Elf\Sections\ElfSymbol.cs - - - - - \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs deleted file mode 100644 index 2b2cb73b7940b6..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfArch.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a machine architecture. - /// This is the value seen in or - /// as well as the various machine defines (e.g ). - /// - public readonly partial struct ElfArchEx : IEquatable - { - public ElfArchEx(ushort value) - { - Value = (ElfArch)value; - } - - public ElfArchEx(ElfArch value) - { - Value = value; - } - - /// - /// Raw value. - /// - public readonly ElfArch Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(ElfArchEx)} (0x{Value:X4})"; - } - - public bool Equals(ElfArchEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfArchEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(ElfArchEx left, ElfArchEx right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfArchEx left, ElfArchEx right) - { - return !left.Equals(right); - } - - public static explicit operator uint(ElfArchEx arch) => (uint)arch.Value; - - public static implicit operator ElfArchEx(ElfArch arch) => new ElfArchEx(arch); - - public static implicit operator ElfArch(ElfArchEx arch) => arch.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs deleted file mode 100644 index e5d25d90a7ee82..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderDirect.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// A decoder for the various Elf types that doesn't change LSB/MSB ordering from the current machine. - /// - public struct ElfDecoderDirect : IElfDecoder - { - public ushort Decode(ElfNative.Elf32_Half src) - { - return src.Value; - } - - public ushort Decode(ElfNative.Elf64_Half src) - { - return src.Value; - } - - public uint Decode(ElfNative.Elf32_Word src) - { - return src.Value; - } - - public uint Decode(ElfNative.Elf64_Word src) - { - return src.Value; - } - - public int Decode(ElfNative.Elf32_Sword src) - { - return src.Value; - } - - public int Decode(ElfNative.Elf64_Sword src) - { - return src.Value; - } - - public ulong Decode(ElfNative.Elf32_Xword src) - { - return src.Value; - } - - public long Decode(ElfNative.Elf32_Sxword src) - { - return src.Value; - } - - public ulong Decode(ElfNative.Elf64_Xword src) - { - return src.Value; - } - - public long Decode(ElfNative.Elf64_Sxword src) - { - return src.Value; - } - - public uint Decode(ElfNative.Elf32_Addr src) - { - return src.Value; - } - - public ulong Decode(ElfNative.Elf64_Addr src) - { - return src.Value; - } - - public uint Decode(ElfNative.Elf32_Off src) - { - return src.Value; - } - - public ulong Decode(ElfNative.Elf64_Off src) - { - return src.Value; - } - - public ushort Decode(ElfNative.Elf32_Section src) - { - return src.Value; - } - - public ushort Decode(ElfNative.Elf64_Section src) - { - return src.Value; - } - - public ushort Decode(ElfNative.Elf32_Versym src) - { - return src.Value; - } - - public ushort Decode(ElfNative.Elf64_Versym src) - { - return src.Value; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs deleted file mode 100644 index bdae1529be5018..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfDecoderSwap.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Buffers.Binary; - -namespace LibObjectFile.Elf -{ - /// - /// A decoder for the various Elf types that swap LSB/MSB ordering based on a mismatch between the current machine and file ordering. - /// - public readonly struct ElfDecoderSwap : IElfDecoder - { - public ushort Decode(ElfNative.Elf32_Half src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ushort Decode(ElfNative.Elf64_Half src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public uint Decode(ElfNative.Elf32_Word src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public uint Decode(ElfNative.Elf64_Word src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public int Decode(ElfNative.Elf32_Sword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public int Decode(ElfNative.Elf64_Sword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ulong Decode(ElfNative.Elf32_Xword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public long Decode(ElfNative.Elf32_Sxword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ulong Decode(ElfNative.Elf64_Xword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public long Decode(ElfNative.Elf64_Sxword src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public uint Decode(ElfNative.Elf32_Addr src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ulong Decode(ElfNative.Elf64_Addr src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public uint Decode(ElfNative.Elf32_Off src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ulong Decode(ElfNative.Elf64_Off src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ushort Decode(ElfNative.Elf32_Section src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ushort Decode(ElfNative.Elf64_Section src) - { - return BinaryPrimitives.ReverseEndianness(src); - } - - public ushort Decode(ElfNative.Elf32_Versym src) - { - return BinaryPrimitives.ReverseEndianness((ElfNative.Elf32_Half)src); - } - - public ushort Decode(ElfNative.Elf64_Versym src) - { - return BinaryPrimitives.ReverseEndianness((ElfNative.Elf64_Half)src); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs deleted file mode 100644 index 35df4067727401..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderDirect.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// An encoder for the various Elf types that doesn't change LSB/MSB ordering from the current machine. - /// - internal readonly struct ElfEncoderDirect : IElfEncoder - { - public void Encode(out ElfNative.Elf32_Half dest, ushort value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Half dest, ushort value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Word dest, uint value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Word dest, uint value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Sword dest, int value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Sword dest, int value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Xword dest, ulong value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Sxword dest, long value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Xword dest, ulong value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Sxword dest, long value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Addr dest, uint value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf64_Addr dest, ulong value) - { - dest = value; - } - - public void Encode(out ElfNative.Elf32_Off dest, uint offset) - { - dest = offset; - } - - public void Encode(out ElfNative.Elf64_Off dest, ulong offset) - { - dest = offset; - } - - public void Encode(out ElfNative.Elf32_Section dest, ushort index) - { - dest = index; - } - - public void Encode(out ElfNative.Elf64_Section dest, ushort index) - { - dest = index; - } - - public void Encode(out ElfNative.Elf32_Versym dest, ushort value) - { - dest = (ElfNative.Elf32_Half)value; - } - - public void Encode(out ElfNative.Elf64_Versym dest, ushort value) - { - dest = (ElfNative.Elf64_Half)value; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs deleted file mode 100644 index 7d6f4f4a7d32fb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoderSwap.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Buffers.Binary; - -namespace LibObjectFile.Elf -{ - /// - /// An encoder for the various Elf types that swap LSB/MSB ordering based on a mismatch between the current machine and file ordering. - /// - internal readonly struct ElfEncoderSwap : IElfEncoder - { - public void Encode(out ElfNative.Elf32_Half dest, ushort value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Half dest, ushort value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Word dest, uint value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Word dest, uint value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Sword dest, int value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Sword dest, int value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Xword dest, ulong value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Sxword dest, long value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Xword dest, ulong value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Sxword dest, long value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Addr dest, uint value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Addr dest, ulong value) - { - dest = BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf32_Off dest, uint offset) - { - dest = BinaryPrimitives.ReverseEndianness(offset); - } - - public void Encode(out ElfNative.Elf64_Off dest, ulong offset) - { - dest = BinaryPrimitives.ReverseEndianness(offset); - } - - public void Encode(out ElfNative.Elf32_Section dest, ushort index) - { - dest = BinaryPrimitives.ReverseEndianness(index); - } - - public void Encode(out ElfNative.Elf64_Section dest, ushort index) - { - dest = BinaryPrimitives.ReverseEndianness(index); - } - - public void Encode(out ElfNative.Elf32_Versym dest, ushort value) - { - dest = (ElfNative.Elf32_Half)BinaryPrimitives.ReverseEndianness(value); - } - - public void Encode(out ElfNative.Elf64_Versym dest, ushort value) - { - dest = (ElfNative.Elf64_Half)BinaryPrimitives.ReverseEndianness(value); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs deleted file mode 100644 index f7997e692b2d63..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfEncoding.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Encoding of an . - /// This is the value seen in the ident part of an Elf header at index - /// It is associated with , and - /// - public enum ElfEncoding : byte - { - /// - /// Invalid data encoding. Equivalent of - /// - None = ElfNative.ELFDATANONE, - - /// - /// 2's complement, little endian. Equivalent of - /// - Lsb = ElfNative.ELFDATA2LSB, - - /// - /// 2's complement, big endian. Equivalent of - /// - Msb = ElfNative.ELFDATA2MSB, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs deleted file mode 100644 index 6824a530594cfb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileClass.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - - /// - /// Defines the File class byte index (32bit or 64bits) of an . - /// This is the value seen in the ident part of an Elf header at index - /// It is associated with , and - /// - public enum ElfFileClass : byte - { - /// - /// Invalid class. Equivalent of . - /// - None = ElfNative.ELFCLASSNONE, - - /// - /// 32-bit objects. Equivalent of . - /// - Is32 = ElfNative.ELFCLASS32, - - /// - /// 64-bit objects. Equivalent of . - /// - Is64 = ElfNative.ELFCLASS64, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs deleted file mode 100644 index ca8607a87639f2..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePart.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Elf -{ - /// - /// Internal struct used to identify which part of the file is attached to a section or not. - /// It is used while reading back an ELF file from the disk to create - /// - [DebuggerDisplay("{StartOffset,nq} - {EndOffset,nq} : {Section,nq}")] - internal readonly struct ElfFilePart : IComparable, IEquatable - { - /// - /// Creates an instance that is not yet bound to a section for which an - /// will be created - /// - /// Start of the offset in the file - /// End of the offset in the file (inclusive) - public ElfFilePart(ulong startOffset, ulong endOffset) - { - StartOffset = startOffset; - EndOffset = endOffset; - Section = null; - } - - /// - /// Creates an instance that is bound to a section - /// - /// A section of the file - public ElfFilePart(ElfSection section) - { - Section = section ?? throw new ArgumentNullException(nameof(section)); - Debug.Assert(section.Size > 0); - StartOffset = section.Offset; - EndOffset = StartOffset + Section.Size - 1; - } - - public readonly ulong StartOffset; - - public readonly ulong EndOffset; - - public readonly ElfSection Section; - - public int CompareTo(ElfFilePart other) - { - if (EndOffset < other.StartOffset) - { - return -1; - } - - if (StartOffset > other.EndOffset) - { - return 1; - } - - // May overlap or not - return 0; - } - - - public bool Equals(ElfFilePart other) - { - return StartOffset == other.StartOffset && EndOffset == other.EndOffset; - } - - public override bool Equals(object obj) - { - return obj is ElfFilePart other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return (StartOffset.GetHashCode() * 397) ^ EndOffset.GetHashCode(); - } - } - - public static bool operator ==(ElfFilePart left, ElfFilePart right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfFilePart left, ElfFilePart right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs deleted file mode 100644 index 8625bb1ed24d1b..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFilePartList.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Collections.Generic; - -namespace LibObjectFile.Elf -{ - /// - /// Internal list used to keep an ordered list of based on offsets. - /// It is used to track region of the file that are actually referenced by a - /// but are not declared as a - /// - internal struct ElfFilePartList - { - private readonly List _parts; - - public ElfFilePartList(int capacity) - { - _parts = new List(capacity); - } - - public int Count => _parts.Count; - - public ElfFilePart this[int index] - { - get => _parts[index]; - set => _parts[index] = value; - } - - public void Insert(ElfFilePart part) - { - for (int i = 0; i < _parts.Count; i++) - { - var against = _parts[i]; - var delta = part.CompareTo(against); - if (delta < 0) - { - _parts.Insert(i, part); - return; - } - - // Don't add an overlap - if (delta == 0) - { - // do nothing - return; - } - } - _parts.Add(part); - } - - public void CreateParts(ulong startOffset, ulong endOffset) - { - var offset = startOffset; - for (int i = 0; i < _parts.Count && offset < endOffset; i++) - { - var part = _parts[i]; - if (offset < part.StartOffset) - { - if (endOffset < part.StartOffset) - { - var newPart = new ElfFilePart(offset, endOffset); - _parts.Insert(i, newPart); - offset = endOffset + 1; - break; - } - - // Don't merge parts, so that we will create a single ElfInlineShadowSection per parts - _parts.Insert(i, new ElfFilePart(offset, part.StartOffset - 1)); - } - - offset = part.EndOffset + 1; - } - - if (offset < endOffset) - { - _parts.Add(new ElfFilePart(offset, endOffset)); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs deleted file mode 100644 index 57e2f2b9e88ed0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfFileType.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines the file type of an . - /// This is the value seen in or - /// as well as the various machine defines (e.g ). - /// - public enum ElfFileType : ushort - { - /// - /// No file type - /// - None = ElfNative.ET_NONE, - - /// - /// Relocatable file - /// - Relocatable = ElfNative.ET_REL, - - /// - /// Executable file - /// - Executable = ElfNative.ET_EXEC, - - /// - /// Shared object file - /// - Dynamic = ElfNative.ET_DYN, - - /// - /// Core file - /// - Core = ElfNative.ET_CORE, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs deleted file mode 100644 index 70347e218537a8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfHeaderFlags.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines the flags of an . - /// This is the value seen in or . - /// This is currently not used. - /// - public readonly struct ElfHeaderFlags : IEquatable - { - public ElfHeaderFlags(uint value) - { - Value = value; - } - - public readonly uint Value; - - - public bool Equals(ElfHeaderFlags other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfHeaderFlags other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(ElfHeaderFlags left, ElfHeaderFlags right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfHeaderFlags left, ElfHeaderFlags right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return $"0x{Value:x}"; - } - - public static explicit operator uint(ElfHeaderFlags flags) => flags.Value; - - public static implicit operator ElfHeaderFlags(uint flags) => new ElfHeaderFlags(flags); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs deleted file mode 100644 index 4ae30ced5d3aa5..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfNativeExtensions.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Contains all the low-level structures used for reading/writing ELF data, automatically generated from C headers. - /// - public static partial class ElfNative - { - public partial struct Elf32_Shdr: IEquatable - { - public static readonly Elf32_Shdr Null = new Elf32_Shdr(); - - public bool IsNull => this == Null; - - public bool Equals(Elf32_Shdr other) - { - return sh_name.Equals(other.sh_name) && sh_type.Equals(other.sh_type) && sh_flags.Equals(other.sh_flags) && sh_addr.Equals(other.sh_addr) && sh_offset.Equals(other.sh_offset) && sh_size.Equals(other.sh_size) && sh_link.Equals(other.sh_link) && sh_info.Equals(other.sh_info) && sh_addralign.Equals(other.sh_addralign) && sh_entsize.Equals(other.sh_entsize); - } - - public override bool Equals(object obj) - { - return obj is Elf32_Shdr other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - var hashCode = sh_name.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_type.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_flags.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_addr.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_offset.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_size.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_link.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_info.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_addralign.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_entsize.GetHashCode(); - return hashCode; - } - } - - public static bool operator ==(Elf32_Shdr left, Elf32_Shdr right) - { - return left.Equals(right); - } - - public static bool operator !=(Elf32_Shdr left, Elf32_Shdr right) - { - return !left.Equals(right); - } - } - - public partial struct Elf64_Shdr : IEquatable - { - public static readonly Elf64_Shdr Null = new Elf64_Shdr(); - - public bool IsNull => this == Null; - - public bool Equals(Elf64_Shdr other) - { - return sh_name.Equals(other.sh_name) && sh_type.Equals(other.sh_type) && sh_flags.Equals(other.sh_flags) && sh_addr.Equals(other.sh_addr) && sh_offset.Equals(other.sh_offset) && sh_size.Equals(other.sh_size) && sh_link.Equals(other.sh_link) && sh_info.Equals(other.sh_info) && sh_addralign.Equals(other.sh_addralign) && sh_entsize.Equals(other.sh_entsize); - } - - public override bool Equals(object obj) - { - return obj is Elf64_Shdr other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - var hashCode = sh_name.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_type.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_flags.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_addr.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_offset.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_size.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_link.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_info.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_addralign.GetHashCode(); - hashCode = (hashCode * 397) ^ sh_entsize.GetHashCode(); - return hashCode; - } - } - - public static bool operator ==(Elf64_Shdr left, Elf64_Shdr right) - { - return left.Equals(right); - } - - public static bool operator !=(Elf64_Shdr left, Elf64_Shdr right) - { - return !left.Equals(right); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs deleted file mode 100644 index 7d5f4b0f9c91e8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfOSAbi2.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines an OS ABI. - /// This is the value seen in the ident part of an Elf header at index - /// as well as the various machine defines (e.g ). - /// - public readonly partial struct ElfOSABIEx : IEquatable - { - public ElfOSABIEx(byte value) - { - Value = (ElfOSABI)value; - } - - public ElfOSABIEx(ElfOSABI value) - { - Value = value; - } - - public readonly ElfOSABI Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(ElfOSABIEx)} (0x{Value:X4})"; - } - - public bool Equals(ElfOSABIEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfOSABIEx other && Equals(other); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - - public static bool operator ==(ElfOSABIEx left, ElfOSABIEx right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfOSABIEx left, ElfOSABIEx right) - { - return !left.Equals(right); - } - - public static explicit operator byte(ElfOSABIEx osABI) => (byte)osABI.Value; - - public static implicit operator ElfOSABIEx(ElfOSABI osABI) => new ElfOSABIEx(osABI); - - public static implicit operator ElfOSABI(ElfOSABIEx osABI) => osABI.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs deleted file mode 100644 index d02d710c17270a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObject.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Elf -{ - /// - /// Base class for an and . - /// - public abstract class ElfObject : ObjectFileNode - { - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is ElfObjectFile)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(ElfObjectFile)}"); - } - } - - - /// - /// Gets the containing . Might be null if this section or segment - /// does not belong to an existing . - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - public new ElfObjectFile Parent - { - get => (ElfObjectFile)base.Parent; - internal set => base.Parent = value; - } - - public abstract void UpdateLayout(DiagnosticBag diagnostics); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs deleted file mode 100644 index a21f0ba71a7d42..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFile.cs +++ /dev/null @@ -1,778 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using LibObjectFile.Utils; - -namespace LibObjectFile.Elf -{ - using static ElfNative; - - /// - /// Defines an ELF object file that can be manipulated in memory. - /// - public sealed class ElfObjectFile : ObjectFileNode - { - private readonly List _sections; - private ElfSectionHeaderStringTable _sectionHeaderStringTable; - private readonly List _segments; - - public const int IdentSizeInBytes = ElfNative.EI_NIDENT; - - /// - /// Creates a new instance with the default sections (null and a shadow program header table). - /// - public ElfObjectFile(ElfArch arch) : this(true) - { - Arch = arch; - switch (arch) - { - case ElfArch.I386: - FileClass = ElfFileClass.Is32; - Encoding = ElfEncoding.Lsb; - break; - case ElfArch.X86_64: - FileClass = ElfFileClass.Is64; - Encoding = ElfEncoding.Lsb; - break; - case ElfArch.ARM: - FileClass = ElfFileClass.Is32; - Encoding = ElfEncoding.Lsb; // not 100% valid, but ok for a default - break; - case ElfArch.AARCH64: - FileClass = ElfFileClass.Is64; - Encoding = ElfEncoding.Lsb; // not 100% valid, but ok for a default - break; - - // TODO: Add support for more arch - } - Version = ElfNative.EV_CURRENT; - FileType = ElfFileType.Relocatable; - } - - internal ElfObjectFile(bool addDefaultSections) - { - _segments = new List(); - _sections = new List(); - Layout = new ElfObjectLayout(); - - if (addDefaultSections) - { - AddSection(new ElfNullSection()); - AddSection(new ElfProgramHeaderTable()); - } - } - - /// - /// Gets or sets the file class (i.e. 32 or 64 bits) - /// - public ElfFileClass FileClass { get; set; } - - /// - /// Gets or sets the file encoding (i.e. LSB or MSB) - /// - public ElfEncoding Encoding { get; set; } - - /// - /// Gets or sets the version of this file. - /// - public uint Version { get; set; } - - /// - /// Gets or sets the OS ABI. - /// - public ElfOSABIEx OSABI { get; set; } - - /// - /// Gets or sets the OS ABI version. - /// - public byte AbiVersion { get; set; } - - /// - /// Gets or sets the file type (e.g executable, relocatable...) - /// From Elf Header equivalent of or . - /// - public ElfFileType FileType { get; set; } - - /// - /// Gets or sets the file flags (not used). - /// - public ElfHeaderFlags Flags { get; set; } - - /// - /// Gets or sets the machine architecture (e.g 386, X86_64...) - /// From Elf Header equivalent of or . - /// - public ElfArchEx Arch { get; set; } - - /// - /// Entry point virtual address. - /// From Elf Header equivalent of or . - /// - public ulong EntryPointAddress { get; set; } - - /// - /// List of the segments - program headers defined by this instance. - /// - public IReadOnlyList Segments => _segments; - - /// - /// List of the sections - program headers defined by this instance. - /// - public IReadOnlyList Sections => _sections; - - /// - /// Number of visible sections excluding in the . - /// - public uint VisibleSectionCount { get; private set; } - - /// - /// Number of in the - /// - public uint ShadowSectionCount { get; private set; } - - /// - /// Gets or sets the section header string table used to store the names of the sections. - /// Must have been added to . - /// - public ElfSectionHeaderStringTable SectionHeaderStringTable - { - get => _sectionHeaderStringTable; - set - { - if (value != null) - { - if (value.Parent == null) - { - throw new InvalidOperationException($"The {nameof(ElfSectionHeaderStringTable)} must have been added via `this.{nameof(AddSection)}(section)` before setting {nameof(SectionHeaderStringTable)}"); - } - - if (value.Parent != this) - { - throw new InvalidOperationException($"This {nameof(ElfSectionHeaderStringTable)} belongs already to another {nameof(ElfObjectFile)}. It must be removed from the other instance before adding it to this instance."); - } - } - _sectionHeaderStringTable = value; - } - } - - /// - /// Gets the current calculated layout of this instance (e.g offset of the program header table) - /// - public ElfObjectLayout Layout { get; } - - /// - /// Verifies the integrity of this ELF object file. - /// - /// A DiagnosticBag instance to receive the diagnostics. - public override void Verify(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - if (FileClass == ElfFileClass.None) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderFileClassNone, $"Cannot compute the layout with an {nameof(ElfObjectFile)} having a {nameof(FileClass)} == {ElfFileClass.None}"); - } - - if (VisibleSectionCount >= ElfNative.SHN_LORESERVE && - Sections[0] is not ElfNullSection) - { - diagnostics.Error(DiagnosticId.ELF_ERR_MissingNullSection, $"Section count is higher than SHN_LORESERVE ({ElfNative.SHN_LORESERVE}) but the first section is not a NULL section"); - } - - foreach (var segment in Segments) - { - segment.Verify(diagnostics); - } - - // Verify all sections before doing anything else - foreach (var section in Sections) - { - section.Verify(diagnostics); - } - } - - public List GetSectionsOrderedByStreamIndex() - { - var orderedSections = new List(Sections.Count); - orderedSections.AddRange(Sections); - orderedSections.Sort(CompareStreamIndexAndIndexDelegate); - return orderedSections; - } - - /// - /// Tries to update and calculate the layout of the sections, segments and . - /// - /// A DiagnosticBag instance to receive the diagnostics. - /// true if the calculation of the layout is successful. otherwise false - public unsafe void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - Size = 0; - - ulong offset = FileClass == ElfFileClass.Is32 ? (uint)sizeof(ElfNative.Elf32_Ehdr) : (uint)sizeof(ElfNative.Elf64_Ehdr); - Layout.SizeOfElfHeader = (ushort)offset; - Layout.OffsetOfProgramHeaderTable = 0; - Layout.OffsetOfSectionHeaderTable = 0; - Layout.SizeOfProgramHeaderEntry = FileClass == ElfFileClass.Is32 ? (ushort)sizeof(ElfNative.Elf32_Phdr) : (ushort)sizeof(ElfNative.Elf64_Phdr); - Layout.SizeOfSectionHeaderEntry = FileClass == ElfFileClass.Is32 ? (ushort)sizeof(ElfNative.Elf32_Shdr) : (ushort)sizeof(ElfNative.Elf64_Shdr); - Layout.TotalSize = offset; - - bool programHeaderTableFoundAndUpdated = false; - - // If we have any sections, prepare their offsets - var sections = GetSectionsOrderedByStreamIndex(); - if (sections.Count > 0) - { - // Calculate offsets of all sections in the stream - for (var i = 0; i < sections.Count; i++) - { - var section = sections[i]; - if (i == 0 && section.Type == ElfSectionType.Null) - { - continue; - } - - var align = section.Alignment == 0 ? 1 : section.Alignment; - offset = AlignHelper.AlignToUpper(offset, align); - section.Offset = offset; - - if (section is ElfProgramHeaderTable programHeaderTable) - { - if (Segments.Count > 0) - { - Layout.OffsetOfProgramHeaderTable = section.Offset; - Layout.SizeOfProgramHeaderEntry = (ushort) section.TableEntrySize; - programHeaderTableFoundAndUpdated = true; - } - } - - if (section == SectionHeaderStringTable) - { - var shstrTable = SectionHeaderStringTable; - shstrTable.Reset(); - - // Prepare all section names (to calculate the name indices and the size of the SectionNames) - // Do it in two passes to generate optimal string table - for (var pass = 0; pass < 2; pass++) - { - for (var j = 0; j < sections.Count; j++) - { - var otherSection = sections[j]; - if ((j == 0 && otherSection.Type == ElfSectionType.Null)) continue; - if (otherSection.IsShadow) continue; - if (pass == 0) - { - shstrTable.ReserveString(otherSection.Name); - } - else - { - otherSection.Name = otherSection.Name.WithIndex(shstrTable.GetOrCreateIndex(otherSection.Name)); - } - } - } - } - - section.UpdateLayout(diagnostics); - - // Console.WriteLine($"{section.ToString(),-50} Offset: {section.Offset:x4} Size: {section.Size:x4}"); - - // A section without content doesn't count with its size - if (!section.HasContent) - { - continue; - } - - offset += section.Size; - } - - // The Section Header Table will be put just after all the sections - Layout.OffsetOfSectionHeaderTable = AlignHelper.AlignToUpper(offset, FileClass == ElfFileClass.Is32 ? 4u : 8u); - - Layout.TotalSize = Layout.OffsetOfSectionHeaderTable + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; - } - - // Update program headers with offsets from auto layout - if (Segments.Count > 0) - { - // Write program headers - if (!programHeaderTableFoundAndUpdated) - { - diagnostics.Error(DiagnosticId.ELF_ERR_MissingProgramHeaderTableSection, $"Missing {nameof(ElfProgramHeaderTable)} shadow section for writing program headers / segments from this object file"); - } - - for (int i = 0; i < Segments.Count; i++) - { - var programHeader = Segments[i]; - programHeader.UpdateLayout(diagnostics); - } - } - - Size = offset + (ulong)VisibleSectionCount * Layout.SizeOfSectionHeaderEntry; - } - - /// - /// Adds a segment to . - /// - /// A segment - public void AddSegment(ElfSegment segment) - { - if (segment == null) throw new ArgumentNullException(nameof(segment)); - if (segment.Parent != null) - { - if (segment.Parent == this) throw new InvalidOperationException("Cannot add the segment as it is already added"); - if (segment.Parent != this) throw new InvalidOperationException($"Cannot add the segment as it is already added to another {nameof(ElfObjectFile)} instance"); - } - - segment.Parent = this; - segment.Index = (uint)_segments.Count; - _segments.Add(segment); - } - - /// - /// Inserts a segment into at the specified index. - /// - /// Index into to insert the specified segment - /// The segment to insert - public void InsertSegmentAt(int index, ElfSegment segment) - { - if (index < 0 || index > _segments.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_segments.Count}"); - if (segment == null) throw new ArgumentNullException(nameof(segment)); - if (segment.Parent != null) - { - if (segment.Parent == this) throw new InvalidOperationException("Cannot add the segment as it is already added"); - if (segment.Parent != this) throw new InvalidOperationException($"Cannot add the segment as it is already added to another {nameof(ElfObjectFile)} instance"); - } - - segment.Index = (uint)index; - _segments.Insert(index, segment); - segment.Parent = this; - - // Update the index of following segments - for(int i = index + 1; i < _segments.Count; i++) - { - var nextSegment = _segments[i]; - nextSegment.Index++; - } - } - - /// - /// Removes a segment from - /// - /// The segment to remove - public void RemoveSegment(ElfSegment segment) - { - if (segment == null) throw new ArgumentNullException(nameof(segment)); - if (segment.Parent != this) - { - throw new InvalidOperationException($"Cannot remove this segment as it is not part of this {nameof(ElfObjectFile)} instance"); - } - - var i = (int)segment.Index; - _segments.RemoveAt(i); - segment.Index = 0; - - // Update indices for other sections - for (int j = i + 1; j < _segments.Count; j++) - { - var nextSegments = _segments[j]; - nextSegments.Index--; - } - - segment.Parent = null; - } - - /// - /// Removes a segment from at the specified index. - /// - /// Index into to remove the specified segment - public ElfSegment RemoveSegmentAt(int index) - { - if (index < 0 || index > _segments.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_segments.Count}"); - var segment = _segments[index]; - RemoveSegment(segment); - return segment; - } - - /// - /// Adds a section to . - /// - /// A section - public TSection AddSection(TSection section) where TSection : ElfSection - { - if (section == null) throw new ArgumentNullException(nameof(section)); - if (section.Parent != null) - { - if (section.Parent == this) throw new InvalidOperationException("Cannot add the section as it is already added"); - if (section.Parent != this) throw new InvalidOperationException($"Cannot add the section as it is already added to another {nameof(ElfObjectFile)} instance"); - } - - section.Parent = this; - section.Index = (uint)_sections.Count; - _sections.Add(section); - - if (section.IsShadow) - { - section.SectionIndex = 0; - ShadowSectionCount++; - } - else - { - section.SectionIndex = VisibleSectionCount; - VisibleSectionCount++; - } - - // Setup the ElfSectionHeaderStringTable if not already set - if (section is ElfSectionHeaderStringTable sectionHeaderStringTable && SectionHeaderStringTable == null) - { - SectionHeaderStringTable = sectionHeaderStringTable; - } - - return section; - } - - /// - /// Inserts a section into at the specified index. - /// - /// Index into to insert the specified section - /// The section to insert - public void InsertSectionAt(int index, ElfSection section) - { - if (index < 0 || index > _sections.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_sections.Count}"); - if (section == null) throw new ArgumentNullException(nameof(section)); - if (section.Parent != null) - { - if (section.Parent == this) throw new InvalidOperationException("Cannot add the section as it is already added"); - if (section.Parent != this) throw new InvalidOperationException($"Cannot add the section as it is already added to another {nameof(ElfObjectFile)} instance"); - } - - section.Parent = this; - section.Index = (uint)index; - _sections.Insert(index, section); - - if (section.IsShadow) - { - section.SectionIndex = 0; - ShadowSectionCount++; - - // Update the index of the following sections - for (int j = index + 1; j < _sections.Count; j++) - { - var sectionAfter = _sections[j]; - sectionAfter.Index++; - } - } - else - { - ElfSection previousSection = null; - for (int j = 0; j < index; j++) - { - var sectionBefore = _sections[j]; - if (!sectionBefore.IsShadow) - { - previousSection = sectionBefore; - } - } - section.SectionIndex = previousSection != null ? previousSection.SectionIndex + 1 : 0; - - // Update the index of the following sections - for (int j = index + 1; j < _sections.Count; j++) - { - var sectionAfter = _sections[j]; - if (!sectionAfter.IsShadow) - { - sectionAfter.SectionIndex++; - } - sectionAfter.Index++; - } - - VisibleSectionCount++; - } - - // Setup the ElfSectionHeaderStringTable if not already set - if (section is ElfSectionHeaderStringTable sectionHeaderStringTable && SectionHeaderStringTable == null) - { - SectionHeaderStringTable = sectionHeaderStringTable; - } - } - - /// - /// Removes a section from - /// - /// The section to remove - public void RemoveSection(ElfSection section) - { - if (section == null) throw new ArgumentNullException(nameof(section)); - if (section.Parent != this) - { - throw new InvalidOperationException($"Cannot remove the section as it is not part of this {nameof(ElfObjectFile)} instance"); - } - - var i = (int)section.Index; - _sections.RemoveAt(i); - section.Index = 0; - - bool wasShadow = section.IsShadow; - - // Update indices for other sections - for (int j = i + 1; j < _sections.Count; j++) - { - var nextSection = _sections[j]; - nextSection.Index--; - - // Update section index as well for following non-shadow sections - if (!wasShadow && !nextSection.IsShadow) - { - nextSection.SectionIndex--; - } - } - - if (wasShadow) - { - ShadowSectionCount--; - } - else - { - VisibleSectionCount--; - } - - section.Parent = null; - - // Automatically replace the current ElfSectionHeaderStringTable with another existing one if any - if (section is ElfSectionHeaderStringTable && SectionHeaderStringTable == section) - { - SectionHeaderStringTable = null; - foreach (var nextSection in _sections) - { - if (nextSection is ElfSectionHeaderStringTable nextSectionHeaderStringTable) - { - SectionHeaderStringTable = nextSectionHeaderStringTable; - break; - } - } - } - } - - /// - /// Removes a section from at the specified index. - /// - /// Index into to remove the specified section - public ElfSection RemoveSectionAt(int index) - { - if (index < 0 || index > _sections.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {_sections.Count}"); - var section = _sections[index]; - RemoveSection(section); - return section; - } - - /// - /// Writes this ELF object file to the specified stream. - /// - /// The stream to write to. - public void Write(Stream stream) - { - if (!TryWrite(stream, out var diagnostics)) - { - throw new ObjectFileException($"Invalid {nameof(ElfObjectFile)}", diagnostics); - } - } - - /// - /// Tries to write this ELF object file to the specified stream. - /// - /// The stream to write to. - /// The output diagnostics - /// true if writing was successful. otherwise false - public bool TryWrite(Stream stream, out DiagnosticBag diagnostics) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - var elfWriter = ElfWriter.Create(this, stream); - diagnostics = elfWriter.Diagnostics; - - Verify(diagnostics); - if (diagnostics.HasErrors) - { - return false; - } - - UpdateLayout(diagnostics); - if (diagnostics.HasErrors) - { - return false; - } - - elfWriter.Write(); - - return !diagnostics.HasErrors; - } - - /// - /// Checks if a stream contains an ELF file by checking the magic signature. - /// - /// The stream containing potentially an ELF file - /// true if the stream contains an ELF file. otherwise returns false - public static bool IsElf(Stream stream) - { - return IsElf(stream, out _); - } - - /// - /// Checks if a stream contains an ELF file by checking the magic signature. - /// - /// The stream containing potentially an ELF file - /// Output the encoding if ELF is true. - /// true if the stream contains an ELF file. otherwise returns false - public static bool IsElf(Stream stream, out ElfEncoding encoding) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - - var ident = ArrayPool.Shared.Rent(EI_NIDENT); - encoding = ElfEncoding.None; - try - { - var startPosition = stream.Position; - var length = stream.Read(ident, 0, EI_NIDENT); - stream.Position = startPosition; - - if (length == EI_NIDENT && (ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 && ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) - { - encoding = (ElfEncoding)ident[EI_DATA]; - return true; - } - } - finally - { - ArrayPool.Shared.Return(ident); - } - - return false; - } - - private static bool TryReadElfObjectFileHeader(Stream stream, out ElfObjectFile file) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - - var ident = ArrayPool.Shared.Rent(EI_NIDENT); - file = null; - try - { - var startPosition = stream.Position; - var length = stream.Read(ident, 0, EI_NIDENT); - stream.Position = startPosition; - - if (length == EI_NIDENT && (ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 && ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) - { - file =new ElfObjectFile(false); - file.CopyIndentFrom(ident); - return true; - } - } - finally - { - ArrayPool.Shared.Return(ident); - } - - return false; - } - - /// - /// Reads an from the specified stream. - /// - /// The stream to read ELF object file from - /// The options for the reader - /// An instance of if the read was successful. - public static ElfObjectFile Read(Stream stream, ElfReaderOptions options = null) - { - if (!TryRead(stream, out var objectFile, out var diagnostics, options)) - { - throw new ObjectFileException($"Unexpected error while reading ELF object file", diagnostics); - } - return objectFile; - } - - /// - /// Tries to read an from the specified stream. - /// - /// The stream to read ELF object file from - /// instance of if the read was successful. - /// A instance - /// The options for the reader - /// true An instance of if the read was successful. - public static bool TryRead(Stream stream, out ElfObjectFile objectFile, out DiagnosticBag diagnostics, ElfReaderOptions options = null) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - - if (!TryReadElfObjectFileHeader(stream, out objectFile)) - { - diagnostics = new DiagnosticBag(); - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderMagic, "ELF magic header not found"); - return false; - } - - options ??= new ElfReaderOptions(); - var reader = ElfReader.Create(objectFile, stream, options); - diagnostics = reader.Diagnostics; - - reader.Read(); - - return !reader.Diagnostics.HasErrors; - } - - /// - /// Contains the layout of an object available after reading an - /// or after calling or - /// - public sealed class ElfObjectLayout - { - internal ElfObjectLayout() - { - } - - /// - /// Size of ELF Header. - /// - public ushort SizeOfElfHeader { get; internal set; } - - /// - /// Offset of the program header table. - /// - public ulong OffsetOfProgramHeaderTable { get; internal set; } - - /// - /// Size of a program header entry. - /// - public ushort SizeOfProgramHeaderEntry { get; internal set; } - - /// - /// Offset of the section header table. - /// - public ulong OffsetOfSectionHeaderTable { get; internal set; } - - /// - /// Size of a section header entry. - /// - public ushort SizeOfSectionHeaderEntry { get; internal set; } - - /// - /// Size of the entire file - /// - public ulong TotalSize { get; internal set; } - - } - - private static readonly Comparison CompareStreamIndexAndIndexDelegate = new Comparison(CompareStreamIndexAndIndex); - - private static int CompareStreamIndexAndIndex(ElfSection left, ElfSection right) - { - var delta = left.StreamIndex.CompareTo(right.StreamIndex); - if (delta != 0) return delta; - return left.Index.CompareTo(right.Index); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs deleted file mode 100644 index 34eb6ceb97eb3a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfObjectFileExtensions.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - using static ElfNative; - - /// - /// Extensions for - /// - public static class ElfObjectFileExtensions - { - /// - /// Copy to an array buffer the ident array as found in ELF header - /// or . - /// - /// The object file to copy the ident from. - /// A span receiving the ident. Must be >= 16 bytes length - public static void CopyIdentTo(this ElfObjectFile objectFile, Span ident) - { - if (objectFile == null) throw new ArgumentNullException(nameof(objectFile)); - if (ident.Length < EI_NIDENT) - { - throw new ArgumentException($"Expecting span length to be >= {EI_NIDENT}"); - } - - // Clear ident - for (int i = 0; i < EI_NIDENT; i++) - { - ident[i] = 0; - } - - ident[EI_MAG0] = ELFMAG0; - ident[EI_MAG1] = ELFMAG1; - ident[EI_MAG2] = ELFMAG2; - ident[EI_MAG3] = ELFMAG3; - ident[EI_CLASS] = (byte) objectFile.FileClass; - ident[EI_DATA] = (byte) objectFile.Encoding; - ident[EI_VERSION] = (byte)objectFile.Version; - ident[EI_OSABI] = (byte)objectFile.OSABI.Value; - ident[EI_ABIVERSION] = objectFile.AbiVersion; - } - - /// - /// Tries to copy from an ident array as found in ELF header to this ELF object file instance. - /// or . - /// - /// The object file to receive the ident from. - /// A span to read from. Must be >= 16 bytes length - /// The diagnostics - /// true if copying the ident was successful. false otherwise - public static bool TryCopyIdentFrom(this ElfObjectFile objectFile, ReadOnlySpan ident, DiagnosticBag diagnostics) - { - if (objectFile == null) throw new ArgumentNullException(nameof(objectFile)); - if (ident.Length < EI_NIDENT) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderIdentLength, $"Invalid ELF Ident length found. Must be >= {EI_NIDENT}"); - return false; - } - - if (ident[EI_MAG0] != ELFMAG0 || ident[EI_MAG1] != ELFMAG1 || ident[EI_MAG2] != ELFMAG2 || ident[EI_MAG3] != ELFMAG3) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderMagic, "Invalid ELF Magic found"); - return false; - } - - CopyIndentFrom(objectFile, ident); - return true; - } - - internal static void CopyIndentFrom(this ElfObjectFile objectFile, ReadOnlySpan ident) - { - objectFile.FileClass = (ElfFileClass)ident[EI_CLASS]; - objectFile.Encoding = (ElfEncoding)ident[EI_DATA]; - objectFile.Version = ident[EI_VERSION]; - objectFile.OSABI = new ElfOSABIEx(ident[EI_OSABI]); - objectFile.AbiVersion = ident[EI_ABIVERSION]; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs deleted file mode 100644 index f6666b33f962e7..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfPrinter.cs +++ /dev/null @@ -1,817 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.IO; -using System.Text; -using System.Xml; - -namespace LibObjectFile.Elf -{ - /// - /// Extensions methods for to print their layout in text forms, similar to readelf. - /// - public static class ElfPrinter - { - /// - /// Prints an to the specified writer. - /// - /// The object file to print. - /// The destination text writer. - public static void Print(this ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - PrintElfHeader(elf, writer); - PrintSectionHeaders(elf, writer); - PrintSectionGroups(elf, writer); - PrintProgramHeaders(elf, writer); - PrintDynamicSections(elf, writer); - PrintRelocations(elf, writer); - PrintUnwind(elf, writer); - PrintSymbolTables(elf, writer); - PrintVersionInformation(elf, writer); - PrintNotes(elf, writer); - } - - public static void PrintElfHeader(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - Span ident = stackalloc byte[ElfObjectFile.IdentSizeInBytes]; - elf.CopyIdentTo(ident); - - writer.WriteLine("ELF Header:"); - - writer.Write(" Magic: "); - foreach (var b in ident) - { - writer.Write($"{b:x2} "); - } - writer.WriteLine(); - writer.WriteLine($" Class: {GetElfFileClass(elf.FileClass)}"); - writer.WriteLine($" Data: {GetElfEncoding(elf.Encoding)}"); - writer.WriteLine($" Version: {GetElfVersion((byte)elf.Version)}"); - writer.WriteLine($" OS/ABI: {GetElfOsAbi(elf.OSABI)}"); - writer.WriteLine($" ABI Version: {elf.AbiVersion}"); - writer.WriteLine($" Type: {GetElfFileType(elf.FileType)}"); - writer.WriteLine($" Machine: {GetElfArch(elf.Arch)}"); - writer.WriteLine($" Version: 0x{elf.Version:x}"); - writer.WriteLine($" Entry point address: 0x{elf.EntryPointAddress:x}"); - writer.WriteLine($" Start of program headers: {elf.Layout.OffsetOfProgramHeaderTable} (bytes into file)"); - writer.WriteLine($" Start of section headers: {elf.Layout.OffsetOfSectionHeaderTable} (bytes into file)"); - writer.WriteLine($" Flags: {elf.Flags}"); - writer.WriteLine($" Size of this header: {elf.Layout.SizeOfElfHeader} (bytes)"); - writer.WriteLine($" Size of program headers: {elf.Layout.SizeOfProgramHeaderEntry} (bytes)"); - writer.WriteLine($" Number of program headers: {elf.Segments.Count}"); - writer.WriteLine($" Size of section headers: {elf.Layout.SizeOfSectionHeaderEntry} (bytes)"); - if (elf.VisibleSectionCount >= ElfNative.SHN_LORESERVE || elf.VisibleSectionCount == 0) - { - writer.WriteLine($" Number of section headers: 0 ({elf.VisibleSectionCount})"); - } - else - { - writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}"); - } - writer.WriteLine($" Section header string table index: {elf.SectionHeaderStringTable?.SectionIndex ?? 0}"); - } - - public static void PrintSectionHeaders(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine(); - if (elf.VisibleSectionCount == 0) - { - writer.WriteLine("There are no sections in this file."); - return; - } - - writer.WriteLine(elf.VisibleSectionCount > 1 ? "Section Headers:" : "Section Header:"); - - writer.WriteLine(" [Nr] Name Type Address Off Size ES Flg Lk Inf Al"); - for (int i = 0; i < elf.Sections.Count; i++) - { - var section = elf.Sections[i]; - if (section.IsShadow) continue; - writer.WriteLine($" [{section.SectionIndex,2:#0}] {GetElfSectionName(section),-17} {GetElfSectionType(section.Type),-15} {section.VirtualAddress:x16} {section.Offset:x6} {section.Size:x6} {section.TableEntrySize:x2} {GetElfSectionFlags(section.Flags),3} {section.Link.GetIndex(),2} {section.Info.GetIndex(),3} {section.Alignment,2}"); - } - writer.WriteLine(@"Key to Flags: - W (write), A (alloc), X (execute), M (merge), S (strings), I (info), - L (link order), O (extra OS processing required), G (group), T (TLS), - C (compressed), x (unknown), o (OS specific), E (exclude), - D (mbind), l (large), p (processor specific)"); - } - - public static void PrintSectionGroups(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine(); - writer.WriteLine("There are no section groups in this file."); - // TODO - } - - private static string GetElfSectionName(ElfSection section) - { - return section.Parent.SectionHeaderStringTable == null ? "" : section.Name.Value; - } - - public static void PrintProgramHeaders(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - writer.WriteLine(); - - if (elf.Segments.Count == 0) - { - writer.WriteLine("There are no program headers in this file."); - return; - } - - writer.WriteLine(elf.Segments.Count > 1 ? "Program Headers:" : "Program Header:"); - - writer.WriteLine(" Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align"); - for (int i = 0; i < elf.Segments.Count; i++) - { - var phdr = elf.Segments[i]; - writer.WriteLine($" {GetElfSegmentType(phdr.Type),-14} 0x{phdr.Offset:x6} 0x{phdr.VirtualAddress:x16} 0x{phdr.PhysicalAddress:x16} 0x{phdr.Size:x6} 0x{phdr.SizeInMemory:x6} {GetElfSegmentFlags(phdr.Flags),3} 0x{phdr.Alignment:x}"); - } - - if (elf.Segments.Count > 0 && elf.VisibleSectionCount > 0 && elf.SectionHeaderStringTable != null) - { - writer.WriteLine(); - writer.WriteLine(" Section to Segment mapping:"); - writer.WriteLine(" Segment Sections..."); - - for (int i = 0; i < elf.Segments.Count; i++) - { - var segment = elf.Segments[i]; - writer.Write($" {i:00} "); - - foreach (var section in elf.Sections) - { - if (IsSectionInSegment(section, segment, true, true)) - { - writer.Write($"{GetElfSectionName(section)} "); - } - } - - writer.WriteLine(); - } - } - } - - public static void PrintRelocations(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - bool hasRelocations = false; - - foreach (var section in elf.Sections) - { - if (section.Type == ElfSectionType.Relocation || section.Type == ElfSectionType.RelocationAddends) - { - hasRelocations = true; - var relocTable = (ElfRelocationTable) section; - - writer.WriteLine(); - writer.WriteLine($"Relocation section {(elf.SectionHeaderStringTable == null ? "0" : $"'{section.Name}'")} at offset 0x{section.Offset:x} contains {relocTable.Entries.Count} {(relocTable.Entries.Count > 1 ? "entries" : "entry")}:"); - - if (elf.FileClass == ElfFileClass.Is32) - { - // TODO - writer.WriteLine(" Offset Info Type Symbol's Value Symbol's Name + Addend"); - } - else - { - writer.WriteLine(" Offset Info Type Symbol's Value Symbol's Name + Addend"); - } - foreach (var entry in relocTable.Entries) - { - var symbolTable = relocTable.Link.Section as ElfSymbolTable; - if (symbolTable == null) continue; - string symbolName = string.Empty; - ulong symbolValue = 0; - if (entry.SymbolIndex < symbolTable.Entries.Count) - { - var symbolEntry = symbolTable.Entries[(int) entry.SymbolIndex]; - symbolName = symbolEntry.Name; - symbolValue = symbolEntry.Value; - - if (string.IsNullOrEmpty(symbolName)) - { - switch (symbolEntry.Type) - { - case ElfSymbolType.Section: - if (symbolEntry.Section.Section != null) - { - symbolName = symbolEntry.Section.Section.Name; - } - break; - } - } - } - - if (elf.FileClass == ElfFileClass.Is32) - { - writer.WriteLine($"{entry.Offset:x8} {entry.Info32:x8} {entry.Type.Name,-22} {symbolValue:x8} {symbolName} + {entry.Addend:x}"); - } - else - { - if (string.IsNullOrEmpty(symbolName)) - { - writer.WriteLine($"{entry.Offset:x16} {entry.Info64:x16} {entry.Type.Name,-22} {"",16} {entry.Addend:x}"); - } - else - { - writer.WriteLine($"{entry.Offset:x16} {entry.Info64:x16} {entry.Type.Name,-22} {symbolValue:x16} {symbolName} + {entry.Addend:x}"); - } - } - } - - } - } - - if (!hasRelocations) - { - writer.WriteLine(); - writer.WriteLine("There are no relocations in this file."); - } - } - - public static void PrintUnwind(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - if (elf.Arch == ElfArchEx.I386 || elf.Arch == ElfArchEx.X86_64) - { - writer.WriteLine("No processor specific unwind information to decode"); - } - else - { - writer.WriteLine(); - writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported."); - } - } - - - public static void PrintSymbolTables(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - if (elf.VisibleSectionCount == 0) - { - writer.WriteLine(); - writer.WriteLine("Dynamic symbol information is not available for displaying symbols."); - return; - } - - foreach (var section in elf.Sections) - { - if (!(section is ElfSymbolTable symbolTable)) continue; - - writer.WriteLine(); - writer.WriteLine(symbolTable.Entries.Count <= 1 - ? $"Symbol table '{GetElfSectionName(symbolTable)}' contains {symbolTable.Entries.Count} entry:" - : $"Symbol table '{GetElfSectionName(symbolTable)}' contains {symbolTable.Entries.Count} entries:" - ); - - if (elf.FileClass == ElfFileClass.Is32) - { - writer.WriteLine(" Num: Value Size Type Bind Vis Ndx Name"); - } - else - { - writer.WriteLine(" Num: Value Size Type Bind Vis Ndx Name"); - } - - for (var i = 0; i < symbolTable.Entries.Count; i++) - { - var symbol = symbolTable.Entries[i]; - writer.WriteLine($"{i,6}: {symbol.Value:x16} {symbol.Size,5} {GetElfSymbolType(symbol.Type),-7} {GetElfSymbolBind(symbol.Bind),-6} {GetElfSymbolVisibility(symbol.Visibility),-7} {GetElfSymbolLink(symbol.Section),4} {symbol.Name.Value}"); - } - } - } - - private static string GetElfSymbolLink(ElfSectionLink link) - { - var index = link.GetIndex(); - switch (index) - { - case 0: - return "UND"; - case ElfNative.SHN_ABS: - return "ABS"; - case ElfNative.SHN_COMMON: - return "COMMON"; - } - return index.ToString(); - } - - public static void PrintNotes(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - - foreach (var section in elf.Sections) - { - if (!(section is ElfNoteTable noteTable)) continue; - - writer.WriteLine(); - writer.WriteLine($"Displaying notes found in: {noteTable.Name}"); - - writer.WriteLine(" Owner\t\tData size\tDescription"); - foreach (var note in noteTable.Entries) - { - writer.WriteLine($" {note.GetName()}\t\t0x{(note.GetDescriptorSize()):x8}\t{GetElfNoteDescription(note)}"); - } - } - } - - private static string GetElfNoteDescription(ElfNote note) - { - var builder = new StringBuilder(); - - if (note.GetName() == "GNU") - { - switch (note.GetNoteType().Value) - { - case ElfNoteType.GNU_ABI_TAG: - builder.Append("NT_GNU_ABI_TAG (ABI version tag)"); - break; - case ElfNoteType.GNU_HWCAP: - builder.Append("NT_GNU_HWCAP (DSO-supplied software HWCAP info)"); - break; - case ElfNoteType.GNU_BUILD_ID: - builder.Append("NT_GNU_BUILD_ID (unique build ID bitstring)"); - break; - case ElfNoteType.GNU_GOLD_VERSION: - builder.Append("NT_GNU_GOLD_VERSION (gold version)"); - break; - } - } - else - { - switch (note.GetNoteType().Value) - { - case ElfNoteType.VERSION: - builder.Append("NT_VERSION (version)"); - break; - } - } - - if (builder.Length == 0) - { - builder.Append($"Unknown note type: (0x{(uint)note.GetNoteType().Value:x8})"); - } - - builder.Append("\t\t"); - - builder.Append(note.GetDescriptorAsText()); - return builder.ToString(); - } - - public static void PrintVersionInformation(ElfObjectFile elf, TextWriter writer) - { - if (elf == null) throw new ArgumentNullException(nameof(elf)); - if (writer == null) throw new ArgumentNullException(nameof(writer)); - writer.WriteLine(); - writer.WriteLine("No version information found in this file."); - } - - private static string GetElfSymbolType(ElfSymbolType symbolType) - { - switch (symbolType) - { - case ElfSymbolType.NoType: return "NOTYPE"; - case ElfSymbolType.Object: return "OBJECT"; - case ElfSymbolType.Function: return "FUNC"; - case ElfSymbolType.Section: return "SECTION"; - case ElfSymbolType.File: return "FILE"; - case ElfSymbolType.Common: return "COMMON"; - case ElfSymbolType.Tls: return "TLS"; - case ElfSymbolType.GnuIndirectFunction: - case ElfSymbolType.SpecificOS1: - case ElfSymbolType.SpecificOS2: - return $": {(uint)symbolType}"; - case ElfSymbolType.SpecificProcessor0: - case ElfSymbolType.SpecificProcessor1: - case ElfSymbolType.SpecificProcessor2: - return $": {(uint)symbolType}"; - default: - return $": {(uint)symbolType}"; - } - } - - private static string GetElfSymbolBind(ElfSymbolBind symbolBind) - { - switch (symbolBind) - { - case ElfSymbolBind.Local: - return "LOCAL"; - case ElfSymbolBind.Global: - return "GLOBAL"; - case ElfSymbolBind.Weak: - return "WEAK"; - case ElfSymbolBind.SpecificOS1: - case ElfSymbolBind.SpecificOS2: - return $": {(uint)symbolBind}"; - case ElfSymbolBind.SpecificProcessor0: - case ElfSymbolBind.SpecificProcessor1: - case ElfSymbolBind.SpecificProcessor2: - return $": {(uint)symbolBind}"; - default: - return $": {(uint)symbolBind}"; - } - } - - private static string GetElfSymbolVisibility(ElfSymbolVisibility symbolVisibility) - { - return symbolVisibility switch - { - ElfSymbolVisibility.Default => "DEFAULT", - ElfSymbolVisibility.Internal => "INTERNAL", - ElfSymbolVisibility.Hidden => "HIDDEN", - ElfSymbolVisibility.Protected => "PROTECTED", - _ => $"Unrecognized visibility value: {(uint) symbolVisibility}" - }; - } - - private static bool IsTlsSpecial(ElfSection section, ElfSegment segment) - { - return (((section).Flags & ElfSectionFlags.Tls) != 0 - && (section).Type == ElfSectionType.NoBits - && (segment).Type != ElfSegmentTypeCore.Tls); - } - - private static ulong GetSectionSize(ElfSection section, ElfSegment segment) - { - return IsTlsSpecial(section, segment) ? 0 : section.Size; - } - - private static bool IsSectionInSegment(ElfSection section, ElfSegment segment, bool checkVirtualAddress, bool isStrict) - { - return (( /* Only PT_LOAD, PT_GNU_RELRO and PT_TLS segments can contain SHF_TLS sections. */ - ((((section).Flags & ElfSectionFlags.Tls) != 0) - && (segment.Type == ElfSegmentTypeCore.Tls - //|| segment.Type == ElfSegmentTypeCore.GnuRelPro - || segment.Type == ElfSegmentTypeCore.Load)) - /* PT_TLS segment contains only SHF_TLS sections, PT_PHDR no - sections at all. */ - || (((section).Flags & ElfSectionFlags.Tls) == 0 - - && segment.Type != ElfSegmentTypeCore.Tls - - && segment.Type != ElfSegmentTypeCore.ProgramHeader)) - /* PT_LOAD and similar segments only have SHF_ALLOC sections. */ - && !((section.Flags & ElfSectionFlags.Alloc) == 0 - - && (segment.Type == ElfSegmentTypeCore.Load - - || segment.Type == ElfSegmentTypeCore.Dynamic - //|| segment.Type == PT_GNU_EH_FRAME - //|| segment.Type == PT_GNU_STACK - //|| segment.Type == PT_GNU_RELRO - //|| (segment.Type >= PT_GNU_MBIND_LO - //&& segment.Type <= PT_GNU_MBIND_HI - ))) - /* Any section besides one of type SHT_NOBITS must have file - offsets within the segment. */ - && (section.Type == ElfSectionType.NoBits - || ((section).Offset >= segment.Offset - - && (!(isStrict) - - || (section.Offset - segment.Offset - - <= segment.Size - 1)) - - && ((section.Offset - segment.Offset - + GetSectionSize(section, segment)) - - <= segment.Size))) - /* SHF_ALLOC sections must have VMAs within the segment. */ - && (!(checkVirtualAddress) - || (section.Flags & ElfSectionFlags.Alloc) == 0 - || (section.VirtualAddress >= segment.VirtualAddress - - && (!(isStrict) - - || (section.VirtualAddress - segment.VirtualAddress - - <= segment.SizeInMemory - 1)) - - && ((section.VirtualAddress - segment.VirtualAddress - + GetSectionSize(section, segment)) - - <= segment.SizeInMemory))) - /* No zero size sections at start or end of PT_DYNAMIC nor - PT_NOTE. */ - && ((segment.Type != ElfSegmentTypeCore.Dynamic - - && segment.Type != ElfSegmentTypeCore.Note) - || section.Size != 0 - || segment.SizeInMemory == 0 - || ((section.Type == ElfSectionType.NoBits - - || (section.Offset > segment.Offset - - && (section.Offset - segment.Offset - - < segment.Size))) - - && ((section.Flags & ElfSectionFlags.Alloc) == 0 - - || (section.VirtualAddress > segment.VirtualAddress - - && (section.VirtualAddress - segment.VirtualAddress - - < segment.SizeInMemory))))); - } - - public static void PrintDynamicSections(ElfObjectFile elf, TextWriter writer) - { - writer.WriteLine(); - writer.WriteLine("There is no dynamic section in this file."); - // TODO - } - - private static string GetElfSegmentFlags(ElfSegmentFlags flags) - { - if (flags.Value == 0) return string.Empty; - - var builder = new StringBuilder(); - builder.Append((flags.Value & ElfNative.PF_R) != 0 ? 'R' : ' '); - builder.Append((flags.Value & ElfNative.PF_W) != 0 ? 'W' : ' '); - builder.Append((flags.Value & ElfNative.PF_X) != 0 ? 'E' : ' '); - // TODO: other flags - return builder.ToString(); - } - - public static string GetElfSegmentType(ElfSegmentType segmentType) - { - return segmentType.Value switch - { - ElfNative.PT_NULL => "NULL", - ElfNative.PT_LOAD => "LOAD", - ElfNative.PT_DYNAMIC => "DYNAMIC", - ElfNative.PT_INTERP => "INTERP", - ElfNative.PT_NOTE => "NOTE", - ElfNative.PT_SHLIB => "SHLIB", - ElfNative.PT_PHDR => "PHDR", - ElfNative.PT_TLS => "TLS", - ElfNative.PT_GNU_EH_FRAME => "GNU_EH_FRAME", - ElfNative.PT_GNU_STACK => "GNU_STACK", - ElfNative.PT_GNU_RELRO => "GNU_RELRO", - _ => $": {segmentType.Value:x}" - }; - } - - private static string GetElfSectionFlags(ElfSectionFlags flags) - { - if (flags == ElfSectionFlags.None) return string.Empty; - - var builder = new StringBuilder(); - if ((flags & ElfSectionFlags.Write) != 0) builder.Append('W'); - if ((flags & ElfSectionFlags.Alloc) != 0) builder.Append('A'); - if ((flags & ElfSectionFlags.Executable) != 0) builder.Append('X'); - if ((flags & ElfSectionFlags.Merge) != 0) builder.Append('M'); - if ((flags & ElfSectionFlags.Strings) != 0) builder.Append('S'); - if ((flags & ElfSectionFlags.InfoLink) != 0) builder.Append('I'); - if ((flags & ElfSectionFlags.LinkOrder) != 0) builder.Append('L'); - if ((flags & ElfSectionFlags.OsNonConforming) != 0) builder.Append('O'); - if ((flags & ElfSectionFlags.Group) != 0) builder.Append('G'); - if ((flags & ElfSectionFlags.Tls) != 0) builder.Append('T'); - if ((flags & ElfSectionFlags.Compressed) != 0) builder.Append('C'); - - // TODO: unknown, OS specific, Exclude...etc. - return builder.ToString(); - } - - private static string GetElfSectionType(ElfSectionType sectionType) - { - switch (sectionType) - { - case ElfSectionType.Null: - return "NULL"; - case ElfSectionType.ProgBits: - return "PROGBITS"; - case ElfSectionType.SymbolTable: - return "SYMTAB"; - case ElfSectionType.StringTable: - return "STRTAB"; - case ElfSectionType.RelocationAddends: - return "RELA"; - case ElfSectionType.SymbolHashTable: - return "HASH"; - case ElfSectionType.DynamicLinking: - return "DYNAMIC"; - case ElfSectionType.Note: - return "NOTE"; - case ElfSectionType.NoBits: - return "NOBITS"; - case ElfSectionType.Relocation: - return "REL"; - case ElfSectionType.Shlib: - return "SHLIB"; - case ElfSectionType.DynamicLinkerSymbolTable: - return "DYNSYM"; - case ElfSectionType.InitArray: - return "INIT_ARRAY"; - case ElfSectionType.FiniArray: - return "FINI_ARRAY"; - case ElfSectionType.PreInitArray: - return "PREINIT_ARRAY"; - case ElfSectionType.Group: - return "GROUP"; - case ElfSectionType.SymbolTableSectionHeaderIndices: - return "SYMTAB SECTION INDICIES"; - case ElfSectionType.GnuHash: - return "GNU_HASH"; - case ElfSectionType.GnuLibList: - return "GNU_LIBLIST"; - case ElfSectionType.GnuAttributes: - return "GNU_ATTRIBUTES"; - case ElfSectionType.Checksum: - return "CHECKSUM"; - case ElfSectionType.GnuVersionDefinition: - case (ElfSectionType)0x6ffffffc: - return "VERDEF"; - case ElfSectionType.GnuVersionNeedsSection: - return "VERNEED"; - case ElfSectionType.GnuVersionSymbolTable: - case (ElfSectionType)0x6ffffff0: - return "VERSYM"; - case (ElfSectionType)0x7ffffffd: - return "AUXILIARY"; - case (ElfSectionType)0x7fffffff: - return "FILTER"; - default: - return $"{(uint)sectionType:x8}: "; - } - } - - - private static string GetElfFileClass(ElfFileClass fileClass) - { - switch (fileClass) - { - case ElfFileClass.None: - return "none"; - case ElfFileClass.Is32: - return "ELF32"; - case ElfFileClass.Is64: - return "ELF64"; - default: - return $""; - } - } - - private static string GetElfEncoding(ElfEncoding encoding) - { - return encoding switch - { - ElfEncoding.None => "none", - ElfEncoding.Lsb => "2's complement, little endian", - ElfEncoding.Msb => "2's complement, big endian", - _ => $"" - }; - } - - private static string GetElfVersion(byte version) - { - return version switch - { - ElfNative.EV_CURRENT => $"{version} (current)", - ElfNative.EV_NONE => "", - _ => $"{version} ", - }; - } - - - private static string GetElfOsAbi(ElfOSABIEx osabi) - { - return osabi.Value switch - { - ElfOSABI.NONE => "UNIX - System V", - ElfOSABI.HPUX => "UNIX - HP-UX", - ElfOSABI.NETBSD => "UNIX - NetBSD", - ElfOSABI.GNU => "UNIX - GNU", - ElfOSABI.SOLARIS => "UNIX - Solaris", - ElfOSABI.AIX => "UNIX - AIX", - ElfOSABI.IRIX => "UNIX - IRIX", - ElfOSABI.FREEBSD => "UNIX - FreeBSD", - ElfOSABI.TRU64 => "UNIX - TRU64", - ElfOSABI.MODESTO => "Novell - Modesto", - ElfOSABI.OPENBSD => "UNIX - OpenBSD", - _ => $"= ElfNative.ET_LOPROC && e_type <= ElfNative.ET_HIPROC) return $"Processor Specific: ({e_type:x})"; - else if (e_type >= ElfNative.ET_LOOS && e_type <= ElfNative.ET_HIOS) - return $"OS Specific: ({e_type:x})"; - else - return $": {e_type:x}"; - } - } - - static string GetElfArch(ElfArchEx arch) - { - switch ((ushort)arch.Value) - { - case ElfNative.EM_NONE: return "None"; - case ElfNative.EM_M32: return "WE32100"; - case ElfNative.EM_SPARC: return "Sparc"; - case ElfNative.EM_386: return "Intel 80386"; - case ElfNative.EM_68K: return "MC68000"; - case ElfNative.EM_88K: return "MC88000"; - case ElfNative.EM_860: return "Intel 80860"; - case ElfNative.EM_MIPS: return "MIPS R3000"; - case ElfNative.EM_S370: return "IBM System/370"; - case ElfNative.EM_MIPS_RS3_LE: return "MIPS R4000 big-endian"; - case ElfNative.EM_PARISC: return "HPPA"; - case ElfNative.EM_SPARC32PLUS: return "Sparc v8+"; - case ElfNative.EM_960: return "Intel 80960"; - case ElfNative.EM_PPC: return "PowerPC"; - case ElfNative.EM_PPC64: return "PowerPC64"; - case ElfNative.EM_S390: return "IBM S/390"; - case ElfNative.EM_V800: return "Renesas V850 (using RH850 ABI)"; - case ElfNative.EM_FR20: return "Fujitsu FR20"; - case ElfNative.EM_RH32: return "TRW RH32"; - case ElfNative.EM_ARM: return "ARM"; - case ElfNative.EM_SH: return "Renesas / SuperH SH"; - case ElfNative.EM_SPARCV9: return "Sparc v9"; - case ElfNative.EM_TRICORE: return "Siemens Tricore"; - case ElfNative.EM_ARC: return "ARC"; - case ElfNative.EM_H8_300: return "Renesas H8/300"; - case ElfNative.EM_H8_300H: return "Renesas H8/300H"; - case ElfNative.EM_H8S: return "Renesas H8S"; - case ElfNative.EM_H8_500: return "Renesas H8/500"; - case ElfNative.EM_IA_64: return "Intel IA-64"; - case ElfNative.EM_MIPS_X: return "Stanford MIPS-X"; - case ElfNative.EM_COLDFIRE: return "Motorola Coldfire"; - case ElfNative.EM_68HC12: return "Motorola MC68HC12 Microcontroller"; - case ElfNative.EM_MMA: return "Fujitsu Multimedia Accelerator"; - case ElfNative.EM_PCP: return "Siemens PCP"; - case ElfNative.EM_NCPU: return "Sony nCPU embedded RISC processor"; - case ElfNative.EM_NDR1: return "Denso NDR1 microprocesspr"; - case ElfNative.EM_STARCORE: return "Motorola Star*Core processor"; - case ElfNative.EM_ME16: return "Toyota ME16 processor"; - case ElfNative.EM_ST100: return "STMicroelectronics ST100 processor"; - case ElfNative.EM_TINYJ: return "Advanced Logic Corp. TinyJ embedded processor"; - case ElfNative.EM_X86_64: return "Advanced Micro Devices X86-64"; - case ElfNative.EM_PDSP: return "Sony DSP processor"; - case ElfNative.EM_FX66: return "Siemens FX66 microcontroller"; - case ElfNative.EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller"; - case ElfNative.EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller"; - case ElfNative.EM_68HC16: return "Motorola MC68HC16 Microcontroller"; - case ElfNative.EM_68HC11: return "Motorola MC68HC11 Microcontroller"; - case ElfNative.EM_68HC08: return "Motorola MC68HC08 Microcontroller"; - case ElfNative.EM_68HC05: return "Motorola MC68HC05 Microcontroller"; - case ElfNative.EM_SVX: return "Silicon Graphics SVx"; - case ElfNative.EM_ST19: return "STMicroelectronics ST19 8-bit microcontroller"; - case ElfNative.EM_VAX: return "Digital VAX"; - case ElfNative.EM_CRIS: return "Axis Communications 32-bit embedded processor"; - case ElfNative.EM_JAVELIN: return "Infineon Technologies 32-bit embedded cpu"; - case ElfNative.EM_FIREPATH: return "Element 14 64-bit DSP processor"; - case ElfNative.EM_ZSP: return "LSI Logic's 16-bit DSP processor"; - case ElfNative.EM_MMIX: return "Donald Knuth's educational 64-bit processor"; - case ElfNative.EM_HUANY: return "Harvard Universitys's machine-independent object format"; - case ElfNative.EM_PRISM: return "Vitesse Prism"; - case ElfNative.EM_AVR: return "Atmel AVR 8-bit microcontroller"; - case ElfNative.EM_FR30: return "Fujitsu FR30"; - case ElfNative.EM_D10V: return "d10v"; - case ElfNative.EM_D30V: return "d30v"; - case ElfNative.EM_V850: return "Renesas V850"; - case ElfNative.EM_M32R: return "Renesas M32R (formerly Mitsubishi M32r)"; - case ElfNative.EM_MN10300: return "mn10300"; - case ElfNative.EM_MN10200: return "mn10200"; - case ElfNative.EM_PJ: return "picoJava"; - case ElfNative.EM_XTENSA: return "Tensilica Xtensa Processor"; - default: - return $": 0x{arch.Value:x}"; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs deleted file mode 100644 index a548def7f2b223..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Base class for reading and building an from a . - /// - public abstract class ElfReader : ObjectFileReaderWriter, IElfDecoder - { - private protected ElfReader(ElfObjectFile objectFile, Stream stream, ElfReaderOptions readerOptions) : base(stream) - { - ObjectFile = objectFile ?? throw new ArgumentNullException(nameof(objectFile)); - Options = readerOptions; - } - - private protected ElfObjectFile ObjectFile { get; } - - /// - /// Gets the used for reading the - /// - public ElfReaderOptions Options { get; } - - public override bool IsReadOnly => Options.ReadOnly; - - internal abstract void Read(); - - public abstract ElfSectionLink ResolveLink(ElfSectionLink link, string errorMessageFormat); - - internal static ElfReader Create(ElfObjectFile objectFile, Stream stream, ElfReaderOptions options) - { - var thisComputerEncoding = BitConverter.IsLittleEndian ? ElfEncoding.Lsb : ElfEncoding.Msb; - return objectFile.Encoding == thisComputerEncoding ? (ElfReader) new ElfReaderDirect(objectFile, stream, options) : new ElfReaderSwap(objectFile, stream, options); - } - - public abstract ushort Decode(ElfNative.Elf32_Half src); - public abstract ushort Decode(ElfNative.Elf64_Half src); - public abstract uint Decode(ElfNative.Elf32_Word src); - public abstract uint Decode(ElfNative.Elf64_Word src); - public abstract int Decode(ElfNative.Elf32_Sword src); - public abstract int Decode(ElfNative.Elf64_Sword src); - public abstract ulong Decode(ElfNative.Elf32_Xword src); - public abstract long Decode(ElfNative.Elf32_Sxword src); - public abstract ulong Decode(ElfNative.Elf64_Xword src); - public abstract long Decode(ElfNative.Elf64_Sxword src); - public abstract uint Decode(ElfNative.Elf32_Addr src); - public abstract ulong Decode(ElfNative.Elf64_Addr src); - public abstract uint Decode(ElfNative.Elf32_Off src); - public abstract ulong Decode(ElfNative.Elf64_Off src); - public abstract ushort Decode(ElfNative.Elf32_Section src); - public abstract ushort Decode(ElfNative.Elf64_Section src); - public abstract ushort Decode(ElfNative.Elf32_Versym src); - public abstract ushort Decode(ElfNative.Elf64_Versym src); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs deleted file mode 100644 index a66822fea3d30a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderDirect.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Internal implementation of with a . - /// - internal sealed class ElfReaderDirect : ElfReader - { - public ElfReaderDirect(ElfObjectFile elfObjectFile, Stream stream, ElfReaderOptions options) : base(elfObjectFile, stream, options) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs deleted file mode 100644 index ea9f764a1e47af..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderOptions.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Options used by and - /// - public class ElfReaderOptions - { - /// - /// Gets or sets a boolean indicating if the stream can be used in read-only mode, or false the resulting - /// will be modified. - /// - public bool ReadOnly { get; set; } - - /// - /// Gets or sets a delegate that can be used to replace the creation of when - /// reading from a Stream. - /// - public TryCreateNoteDelegate TryCreateNote { get; set; } - - /// - /// Gets or sets a delegate that can be used to replace the creation of when - /// reading from a Stream. - /// - public TryCreateSectionDelegate TryCreateSection { get; set; } - - /// - /// Tries to create a section instance from the specified type. Might return null. - /// - /// Type of the section to create. - /// The diagnostics - /// null if the section is not supported or an instance of for the specified type. - public delegate ElfSection TryCreateSectionDelegate(ElfSectionType sectionType, DiagnosticBag diagnostics); - - /// - /// Tries to create a note instance from the specified name and type. Might return null. - /// - /// Name of the note. - /// Type of the note - /// null if the note is not supported or an instance of for the specified name and type. - public delegate ElfNote TryCreateNoteDelegate(string noteName, ElfNoteType noteType); - - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs deleted file mode 100644 index 71cb8a3fbd2a02..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReaderSwap.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Internal implementation of with a . - /// - internal sealed class ElfReaderSwap : ElfReader - { - public ElfReaderSwap(ElfObjectFile elfObjectFile, Stream stream, ElfReaderOptions options) : base(elfObjectFile, stream, options) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs deleted file mode 100644 index 2ddcd836b1385b..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfReader{TDecoder}.cs +++ /dev/null @@ -1,859 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using static System.Collections.Specialized.BitVector32; - -namespace LibObjectFile.Elf -{ - /// - /// Internal implementation of to read from a stream to an instance. - /// - /// The decoder used for LSB/MSB conversion - internal abstract class ElfReader : ElfReader where TDecoder : struct, IElfDecoder - { - private TDecoder _decoder; - private ulong _startOfFile; - private ushort _programHeaderCount; - private uint _sectionHeaderCount; - private uint _sectionStringTableIndex; - private bool _isFirstSectionValidNull; - private bool _hasValidSectionStringTable; - - protected ElfReader(ElfObjectFile objectFile, Stream stream, ElfReaderOptions options) : base(objectFile, stream, options) - { - _decoder = new TDecoder(); - } - - private ElfObjectFile.ElfObjectLayout Layout => ObjectFile.Layout; - - internal override void Read() - { - if (ObjectFile.FileClass == ElfFileClass.None) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidHeaderFileClassNone, "Cannot read an ELF Class = None"); - throw new ObjectFileException($"Invalid {nameof(ElfObjectFile)}", Diagnostics); - } - - _startOfFile = (ulong)Stream.Position; - ReadElfHeader(); - ReadProgramHeaders(); - ReadSections(); - - VerifyAndFixProgramHeadersAndSections(); - } - - private void ReadElfHeader() - { - if (ObjectFile.FileClass == ElfFileClass.Is32) - { - ReadElfHeader32(); - } - else - { - ReadElfHeader64(); - } - - if (_sectionHeaderCount >= ElfNative.SHN_LORESERVE) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderCount, $"Invalid number `{_sectionHeaderCount}` of section headers found from Elf Header. Must be < {ElfNative.SHN_LORESERVE}"); - } - } - - private unsafe void ReadElfHeader32() - { - ElfNative.Elf32_Ehdr hdr; - ulong streamOffset = (ulong)Stream.Position; - if (!TryReadData(sizeof(ElfNative.Elf32_Ehdr), out hdr)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteHeader32Size, $"Unable to read entirely Elf header. Not enough data (size: {sizeof(ElfNative.Elf32_Ehdr)}) read at offset {streamOffset} from the stream"); - } - - ObjectFile.FileType = (ElfFileType)_decoder.Decode(hdr.e_type); - ObjectFile.Arch = new ElfArchEx(_decoder.Decode(hdr.e_machine)); - ObjectFile.Version = _decoder.Decode(hdr.e_version); - - ObjectFile.EntryPointAddress = _decoder.Decode(hdr.e_entry); - Layout.SizeOfElfHeader = _decoder.Decode(hdr.e_ehsize); - ObjectFile.Flags = _decoder.Decode(hdr.e_flags); - - // program headers - Layout.OffsetOfProgramHeaderTable = _decoder.Decode(hdr.e_phoff); - Layout.SizeOfProgramHeaderEntry = _decoder.Decode(hdr.e_phentsize); - _programHeaderCount = _decoder.Decode(hdr.e_phnum); - - // entries for sections - Layout.OffsetOfSectionHeaderTable = _decoder.Decode(hdr.e_shoff); - Layout.SizeOfSectionHeaderEntry = _decoder.Decode(hdr.e_shentsize); - _sectionHeaderCount = _decoder.Decode(hdr.e_shnum); - _sectionStringTableIndex = _decoder.Decode(hdr.e_shstrndx); - } - - private unsafe void ReadElfHeader64() - { - ElfNative.Elf64_Ehdr hdr; - ulong streamOffset = (ulong)Stream.Position; - if (!TryReadData(sizeof(ElfNative.Elf64_Ehdr), out hdr)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteHeader64Size, $"Unable to read entirely Elf header. Not enough data (size: {sizeof(ElfNative.Elf64_Ehdr)}) read at offset {streamOffset} from the stream"); - } - - ObjectFile.FileType = (ElfFileType)_decoder.Decode(hdr.e_type); - ObjectFile.Arch = new ElfArchEx(_decoder.Decode(hdr.e_machine)); - ObjectFile.Version = _decoder.Decode(hdr.e_version); - - ObjectFile.EntryPointAddress = _decoder.Decode(hdr.e_entry); - Layout.SizeOfElfHeader = _decoder.Decode(hdr.e_ehsize); - ObjectFile.Flags = _decoder.Decode(hdr.e_flags); - - // program headers - Layout.OffsetOfProgramHeaderTable = _decoder.Decode(hdr.e_phoff); - Layout.SizeOfProgramHeaderEntry = _decoder.Decode(hdr.e_phentsize); - _programHeaderCount = _decoder.Decode(hdr.e_phnum); - - // entries for sections - Layout.OffsetOfSectionHeaderTable = _decoder.Decode(hdr.e_shoff); - Layout.SizeOfSectionHeaderEntry = _decoder.Decode(hdr.e_shentsize); - _sectionHeaderCount = _decoder.Decode(hdr.e_shnum); - _sectionStringTableIndex = _decoder.Decode(hdr.e_shstrndx); - } - - private void ReadProgramHeaders() - { - if (Layout.SizeOfProgramHeaderEntry == 0) - { - if (_programHeaderCount > 0) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidZeroProgramHeaderTableEntrySize, $"Unable to read program header table as the size of program header entry ({nameof(ElfNative.Elf32_Ehdr.e_phentsize)}) == 0 in the Elf Header"); - } - return; - } - - for (int i = 0; i < _programHeaderCount; i++) - { - var offset = Layout.OffsetOfProgramHeaderTable + (ulong)i * Layout.SizeOfProgramHeaderEntry; - - if (offset >= (ulong)Stream.Length) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidProgramHeaderStreamOffset, $"Unable to read program header [{i}] as its offset {offset} is out of bounds"); - break; - } - - // Seek to the header position - Stream.Position = (long)offset; - - var segment = (ObjectFile.FileClass == ElfFileClass.Is32) ? ReadProgramHeader32(i) : ReadProgramHeader64(i); - ObjectFile.AddSegment(segment); - } - } - - private ElfSegment ReadProgramHeader32(int phdrIndex) - { - var streamOffset = Stream.Position; - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Phdr hdr)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteProgramHeader32Size, $"Unable to read entirely program header [{phdrIndex}]. Not enough data (size: {Layout.SizeOfProgramHeaderEntry}) read at offset {streamOffset} from the stream"); - } - - return new ElfSegment - { - Type = new ElfSegmentType(_decoder.Decode(hdr.p_type)), - Offset =_decoder.Decode(hdr.p_offset), - VirtualAddress = _decoder.Decode(hdr.p_vaddr), - PhysicalAddress = _decoder.Decode(hdr.p_paddr), - Size = _decoder.Decode(hdr.p_filesz), - SizeInMemory = _decoder.Decode(hdr.p_memsz), - Flags = new ElfSegmentFlags(_decoder.Decode(hdr.p_flags)), - Alignment = _decoder.Decode(hdr.p_align) - }; - } - - private ElfSegment ReadProgramHeader64(int phdrIndex) - { - var streamOffset = Stream.Position; - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Phdr hdr)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteProgramHeader64Size, $"Unable to read entirely program header [{phdrIndex}]. Not enough data (size: {Layout.SizeOfProgramHeaderEntry}) read at offset {streamOffset} from the stream"); - } - - return new ElfSegment - { - Type = new ElfSegmentType(_decoder.Decode(hdr.p_type)), - Offset = _decoder.Decode(hdr.p_offset), - VirtualAddress = _decoder.Decode(hdr.p_vaddr), - PhysicalAddress = _decoder.Decode(hdr.p_paddr), - Size = _decoder.Decode(hdr.p_filesz), - SizeInMemory = _decoder.Decode(hdr.p_memsz), - Flags = new ElfSegmentFlags(_decoder.Decode(hdr.p_flags)), - Alignment = _decoder.Decode(hdr.p_align) - }; - } - - private void ReadSections() - { - if (Layout.OffsetOfSectionHeaderTable == 0) return; - - // Write section header table - ReadSectionHeaderTable(); - } - - private void ReadSectionHeaderTable() - { - if (Layout.SizeOfSectionHeaderEntry == 0) - { - if (_sectionHeaderCount > 0) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidZeroSectionHeaderTableEntrySize, $"Unable to read section header table as the size of section header entry ({nameof(ElfNative.Elf32_Ehdr.e_ehsize)}) == 0 in the Elf Header"); - } - return; - } - - uint i = 0; - - if (_sectionHeaderCount == 0) - { - // We are dealing with an object file that has more than SHN_LORESERVE - // (0xff00) sections. It has to begin with a NULL section header where - // its Size contains the real number of sections, and Link optionally - // points to string table section if it's section index is too high. - if (ReadExtendedNullSectionTableEntry()) - { - i = 1; - ObjectFile.AddSection(new ElfNullSection()); - _isFirstSectionValidNull = true; - } - } - - for (; i < _sectionHeaderCount; i++) - { - var offset = Layout.OffsetOfSectionHeaderTable + i * Layout.SizeOfSectionHeaderEntry; - - if (offset >= (ulong)Stream.Length) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderStreamOffset, $"Unable to read section [{i}] as its offset {offset} is out of bounds"); - break; - } - - // Seek to the header position - Stream.Position = (long)offset; - - var section = ReadSectionTableEntry(i); - ObjectFile.AddSection(section); - } - } - - private ElfSection ReadSectionTableEntry(uint sectionIndex) - { - return ObjectFile.FileClass == ElfFileClass.Is32 ? ReadSectionTableEntry32(sectionIndex) : ReadSectionTableEntry64(sectionIndex); - } - - private ElfSection ReadSectionTableEntry32(uint sectionIndex) - { - var streamOffset = Stream.Position; - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Shdr rawSection)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader32Size, $"Unable to read entirely section header [{sectionIndex}]. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {streamOffset} from the stream"); - } - - if (sectionIndex == 0) - { - _isFirstSectionValidNull = rawSection.IsNull; - } - - var sectionType = (ElfSectionType)_decoder.Decode(rawSection.sh_type); - bool isValidNullSection = sectionIndex == 0 && rawSection.IsNull; - var section = CreateElfSection(sectionIndex, sectionType, isValidNullSection); - - if (!isValidNullSection) - { - section.Name = new ElfString(_decoder.Decode(rawSection.sh_name)); - section.Type = (ElfSectionType)_decoder.Decode(rawSection.sh_type); - section.Flags = (ElfSectionFlags)_decoder.Decode(rawSection.sh_flags); - section.VirtualAddress = _decoder.Decode(rawSection.sh_addr); - section.Offset = _decoder.Decode(rawSection.sh_offset); - section.Alignment = _decoder.Decode(rawSection.sh_addralign); - section.Link = new ElfSectionLink(_decoder.Decode(rawSection.sh_link)); - section.Info = new ElfSectionLink(_decoder.Decode(rawSection.sh_info)); - section.Size = _decoder.Decode(rawSection.sh_size); - section.OriginalTableEntrySize = _decoder.Decode(rawSection.sh_entsize); - } - - return section; - } - - private ElfSection ReadSectionTableEntry64(uint sectionIndex) - { - var streamOffset = Stream.Position; - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Shdr rawSection)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader64Size, $"Unable to read entirely section header [{sectionIndex}]. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {streamOffset} from the stream"); - } - - if (sectionIndex == 0) - { - _isFirstSectionValidNull = rawSection.IsNull; - } - - var sectionType = (ElfSectionType)_decoder.Decode(rawSection.sh_type); - bool isValidNullSection = sectionIndex == 0 && rawSection.IsNull; - var section = CreateElfSection(sectionIndex, sectionType, sectionIndex == 0 && rawSection.IsNull); - - if (!isValidNullSection) - { - section.Name = new ElfString(_decoder.Decode(rawSection.sh_name)); - section.Type = (ElfSectionType)_decoder.Decode(rawSection.sh_type); - section.Flags = (ElfSectionFlags)_decoder.Decode(rawSection.sh_flags); - section.VirtualAddress = _decoder.Decode(rawSection.sh_addr); - section.Offset = _decoder.Decode(rawSection.sh_offset); - section.Alignment = _decoder.Decode(rawSection.sh_addralign); - section.Link = new ElfSectionLink(_decoder.Decode(rawSection.sh_link)); - section.Info = new ElfSectionLink(_decoder.Decode(rawSection.sh_info)); - section.Size = _decoder.Decode(rawSection.sh_size); - section.OriginalTableEntrySize = _decoder.Decode(rawSection.sh_entsize); - } - - return section; - } - - private bool ReadExtendedNullSectionTableEntry() - { - uint sh_type; - ulong sh_size; - uint sh_link; - bool isNull; - - Stream.Position = (long)Layout.OffsetOfSectionHeaderTable; - - if (ObjectFile.FileClass == ElfFileClass.Is32) - { - - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf32_Shdr rawSection32)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader32Size, $"Unable to read entirely NULL section header. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {Layout.OffsetOfSectionHeaderTable} from the stream"); - return false; - } - - sh_type = _decoder.Decode(rawSection32.sh_type); - sh_size = _decoder.Decode(rawSection32.sh_size); - sh_link = _decoder.Decode(rawSection32.sh_link); - rawSection32.sh_size = 0; - rawSection32.sh_link = 0; - isNull = rawSection32.IsNull; - } - else - { - if (!TryReadData(Layout.SizeOfSectionHeaderEntry, out ElfNative.Elf64_Shdr rawSection64)) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSectionHeader64Size, $"Unable to read entirely NULL section header. Not enough data (size: {Layout.SizeOfSectionHeaderEntry}) read at offset {Layout.OffsetOfSectionHeaderTable} from the stream"); - return false; - } - - sh_type = _decoder.Decode(rawSection64.sh_type); - sh_size = _decoder.Decode(rawSection64.sh_size); - sh_link = _decoder.Decode(rawSection64.sh_link); - rawSection64.sh_size = 0; - rawSection64.sh_link = 0; - isNull = rawSection64.IsNull; - } - - if (!isNull) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSectionExpectingUndefined, $"Invalid Section [0] {(ElfSectionType)sh_type}. Expecting {ElfNative.SHN_UNDEF}"); - return false; - } - - if (sh_size >= uint.MaxValue) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionHeaderCount, $"Extended section count [{sh_size}] exceeds {uint.MaxValue}"); - return false; - } - - _sectionHeaderCount = (uint)sh_size; - if (_sectionStringTableIndex == ElfNative.SHN_XINDEX) - { - _sectionStringTableIndex = sh_link; - } - - return true; - } - - public override ElfSectionLink ResolveLink(ElfSectionLink link, string errorMessageFormat) - { - if (errorMessageFormat == null) throw new ArgumentNullException(nameof(errorMessageFormat)); - - // Connect section Link instance - if (!link.IsEmpty) - { - if (link.SpecialIndex == _sectionStringTableIndex) - { - link = new ElfSectionLink(ObjectFile.SectionHeaderStringTable); - } - else - { - var sectionIndex = link.SpecialIndex; - - bool sectionFound = false; - if (sectionIndex < ObjectFile.Sections.Count && ObjectFile.Sections[(int)sectionIndex].SectionIndex == sectionIndex) - { - link = new ElfSectionLink(ObjectFile.Sections[(int)sectionIndex]); - sectionFound = true; - } - else - { - foreach (var section in ObjectFile.Sections) - { - if (section.SectionIndex == sectionIndex) - { - link = new ElfSectionLink(section); - sectionFound = true; - break; - } - } - } - - if (!sectionFound) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidResolvedLink, string.Format(errorMessageFormat, link.SpecialIndex)); - } - } - } - - return link; - } - - private void VerifyAndFixProgramHeadersAndSections() - { - if (!_isFirstSectionValidNull && ObjectFile.Sections.Count > 0) - { - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSectionExpectingUndefined, $"Invalid Section [0] {ObjectFile.Sections[0].Type}. Expecting {ElfNative.SHN_UNDEF}"); - } - - if (_hasValidSectionStringTable) - { - Stream.Position = (long)ObjectFile.SectionHeaderStringTable.Offset; - ObjectFile.SectionHeaderStringTable.ReadInternal(this); - } - - for (var i = 0; i < ObjectFile.Sections.Count; i++) - { - var section = ObjectFile.Sections[i]; - if (section is ElfNullSection || section is ElfProgramHeaderTable) continue; - - // Resolve the name of the section - if (ObjectFile.SectionHeaderStringTable != null && ObjectFile.SectionHeaderStringTable.TryFind(section.Name.Index, out var sectionName)) - { - section.Name = section.Name.WithName(sectionName); - } - else - { - if (ObjectFile.SectionHeaderStringTable == null) - { - Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidStringIndexMissingStringHeaderTable, $"Unable to resolve string index [{section.Name.Index}] for section [{section.Index}] as section header string table does not exist"); - } - else - { - Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidStringIndex, $"Unable to resolve string index [{section.Name.Index}] for section [{section.Index}] from section header string table"); - } - } - - // Connect section Link instance - section.Link = ResolveLink(section.Link, $"Invalid section Link [{{0}}] for section [{i}]"); - - // Connect section Info instance - if (section.Type != ElfSectionType.DynamicLinkerSymbolTable && section.Type != ElfSectionType.SymbolTable) - { - section.Info = ResolveLink(section.Info, $"Invalid section Info [{{0}}] for section [{i}]"); - } - - if (i == 0 && _isFirstSectionValidNull) - { - continue; - } - - if (i == _sectionStringTableIndex && _hasValidSectionStringTable) - { - continue; - } - - if (section.HasContent) - { - Stream.Position = (long)section.Offset; - section.ReadInternal(this); - } - } - - foreach (var section in ObjectFile.Sections) - { - section.AfterReadInternal(this); - } - - var fileParts = new ElfFilePartList(ObjectFile.Sections.Count + ObjectFile.Segments.Count); - - if (_isFirstSectionValidNull) - { - var programHeaderTable = new ElfProgramHeaderTable() - { - Offset = Layout.OffsetOfProgramHeaderTable, - }; - - // Add the shadow section ElfProgramHeaderTable - ObjectFile.InsertSectionAt(1, programHeaderTable); - programHeaderTable.UpdateLayout(Diagnostics); - - if (programHeaderTable.Size > 0) - { - fileParts.Insert(new ElfFilePart(programHeaderTable)); - } - } - - // Make sure to pre-sort all sections by offset - var orderedSections = new List(ObjectFile.Sections.Count); - orderedSections.AddRange(ObjectFile.Sections); - orderedSections.Sort(CompareSectionOffsetsAndSizesDelegate); - // Store the stream index to recover the same order when saving back. - for(int i = 0; i < orderedSections.Count; i++) - { - orderedSections[i].StreamIndex = (uint)i; - } - - // Lastly verify integrity of all sections - bool hasShadowSections = false; - - var lastOffset = fileParts.Count > 0 ? fileParts[fileParts.Count - 1].EndOffset : 0; - for (var i = 0; i < orderedSections.Count; i++) - { - var section = orderedSections[i]; - section.Verify(this.Diagnostics); - - if (lastOffset > 0 && section.Offset > lastOffset) - { - if (section.Offset > lastOffset) - { - // Create parts for the segment - fileParts.CreateParts(lastOffset + 1, section.Offset - 1); - hasShadowSections = true; - } - } - - if (section.Size == 0 || !section.HasContent) - { - continue; - } - - // Collect sections parts - fileParts.Insert(new ElfFilePart(section)); - lastOffset = section.Offset + section.Size - 1; - - // Verify overlapping sections and generate and error - if (i + 1 < orderedSections.Count) - { - var otherSection = orderedSections[i + 1]; - if (otherSection.Offset < section.Offset + section.Size) - { - Diagnostics.Warning(DiagnosticId.ELF_ERR_InvalidOverlappingSections, $"The section {section} [{section.Offset} : {section.Offset + section.Size - 1}] is overlapping with the section {otherSection} [{otherSection.Offset} : {otherSection.Offset + otherSection.Size - 1}]"); - } - } - } - - // Link segments to sections if we have an exact match. - // otherwise record any segments that are not bound to a section. - - foreach (var segment in ObjectFile.Segments) - { - if (segment.Size == 0) continue; - - var segmentEndOffset = segment.Offset + segment.Size - 1; - foreach (var section in orderedSections) - { - if (section.Size == 0 || !section.HasContent) continue; - - var sectionEndOffset = section.Offset + section.Size - 1; - if (segment.Offset == section.Offset && segmentEndOffset == sectionEndOffset) - { - // Single case: segment == section - // If we found a section, we will bind the program header to this section - // and switch the offset calculation to auto - segment.Range = section; - segment.OffsetKind = ValueKind.Auto; - break; - } - } - - if (segment.Range.IsEmpty) - { - var offset = segment.Offset; - - // If a segment offset is set to 0, we need to take into - // account the fact that the Elf header is already being handled - // so we should not try to create a shadow section for it - if (offset < Layout.SizeOfElfHeader) - { - offset = Layout.SizeOfElfHeader; - } - - // Create parts for the segment - fileParts.CreateParts(offset, segmentEndOffset); - hasShadowSections = true; - } - } - - // If the previous loop has created ElfFilePart, we have to - // create ElfCustomShadowSection and update the ElfSegment.Range - if (hasShadowSections) - { - int shadowCount = 0; - // If we have sections and the first section is NULL valid, we can start inserting - // shadow sections at index 1 (after null section), otherwise we can insert shadow - // sections before. - uint previousSectionIndex = _isFirstSectionValidNull ? 1U : 0U; - - // Create ElfCustomShadowSection for any parts in the file - // that are referenced by a segment but doesn't have a section - for (var i = 0; i < fileParts.Count; i++) - { - var part = fileParts[i]; - if (part.Section == null) - { - var shadowSection = new ElfBinaryShadowSection() - { - Name = ".shadow." + shadowCount, - Offset = part.StartOffset, - Size = part.EndOffset - part.StartOffset + 1 - }; - shadowCount++; - - Stream.Position = (long)shadowSection.Offset; - shadowSection.ReadInternal(this); - - // Insert the shadow section with this order - shadowSection.StreamIndex = previousSectionIndex; - for (int j = (int)previousSectionIndex; j < orderedSections.Count; j++) - { - var otherSection = orderedSections[j]; - otherSection.StreamIndex++; - } - // Update ordered sections - orderedSections.Insert((int)previousSectionIndex, shadowSection); - ObjectFile.AddSection(shadowSection); - - fileParts[i] = new ElfFilePart(shadowSection); - } - else - { - previousSectionIndex = part.Section.StreamIndex + 1; - } - } - - // Update all segment Ranges - foreach (var segment in ObjectFile.Segments) - { - if (segment.Size == 0) continue; - if (!segment.Range.IsEmpty) continue; - - var segmentEndOffset = segment.Offset + segment.Size - 1; - for (var i = 0; i < orderedSections.Count; i++) - { - var section = orderedSections[i]; - if (section.Size == 0 || !section.HasContent) continue; - - var sectionEndOffset = section.Offset + section.Size - 1; - if (segment.Offset >= section.Offset && segment.Offset <= sectionEndOffset) - { - ElfSection beginSection = section; - ElfSection endSection = null; - for (int j = i; j < orderedSections.Count; j++) - { - var nextSection = orderedSections[j]; - if (nextSection.Size == 0 || !nextSection.HasContent) continue; - - sectionEndOffset = nextSection.Offset + nextSection.Size - 1; - - if (segmentEndOffset >= nextSection.Offset && segmentEndOffset <= sectionEndOffset) - { - endSection = nextSection; - break; - } - } - - if (endSection == null) - { - // TODO: is it a throw/assert or a log? - Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRange, $"Invalid range for {segment}. The range is set to empty"); - } - else - { - segment.Range = new ElfSegmentRange(beginSection, segment.Offset - beginSection.Offset, endSection, (long)(segmentEndOffset - endSection.Offset)); - } - - segment.OffsetKind = ValueKind.Auto; - break; - } - } - } - } - } - - private ElfSection CreateElfSection(uint sectionIndex, ElfSectionType sectionType, bool isNullSection) - { - ElfSection section = null; - - switch (sectionType) - { - case ElfSectionType.Null: - if (isNullSection) - { - section = new ElfNullSection(); - } - break; - case ElfSectionType.DynamicLinkerSymbolTable: - case ElfSectionType.SymbolTable: - section = new ElfSymbolTable(); - break; - case ElfSectionType.StringTable: - - if (sectionIndex == _sectionStringTableIndex) - { - _hasValidSectionStringTable = true; - section = new ElfSectionHeaderStringTable(); - } - else - { - section = new ElfStringTable(); - } - break; - case ElfSectionType.Relocation: - case ElfSectionType.RelocationAddends: - section = new ElfRelocationTable(); - break; - case ElfSectionType.Note: - section = new ElfNoteTable(); - break; - case ElfSectionType.SymbolTableSectionHeaderIndices: - section = new ElfSymbolTableSectionHeaderIndices(); - break; - } - - // If the section is not a builtin section, try to offload to a delegate - // or use the default ElfCustomSection. - if (section == null) - { - if (Options.TryCreateSection != null) - { - section = Options.TryCreateSection(sectionType, Diagnostics); - } - - if (section == null) - { - section = new ElfBinarySection(); - } - } - - return section; - } - - public override ushort Decode(ElfNative.Elf32_Half src) - { - return _decoder.Decode(src); - } - - public override ushort Decode(ElfNative.Elf64_Half src) - { - return _decoder.Decode(src); - } - - public override uint Decode(ElfNative.Elf32_Word src) - { - return _decoder.Decode(src); - } - - public override uint Decode(ElfNative.Elf64_Word src) - { - return _decoder.Decode(src); - } - - public override int Decode(ElfNative.Elf32_Sword src) - { - return _decoder.Decode(src); - } - - public override int Decode(ElfNative.Elf64_Sword src) - { - return _decoder.Decode(src); - } - - public override ulong Decode(ElfNative.Elf32_Xword src) - { - return _decoder.Decode(src); - } - - public override long Decode(ElfNative.Elf32_Sxword src) - { - return _decoder.Decode(src); - } - - public override ulong Decode(ElfNative.Elf64_Xword src) - { - return _decoder.Decode(src); - } - - public override long Decode(ElfNative.Elf64_Sxword src) - { - return _decoder.Decode(src); - } - - public override uint Decode(ElfNative.Elf32_Addr src) - { - return _decoder.Decode(src); - } - - public override ulong Decode(ElfNative.Elf64_Addr src) - { - return _decoder.Decode(src); - } - - public override uint Decode(ElfNative.Elf32_Off src) - { - return _decoder.Decode(src); - } - - public override ulong Decode(ElfNative.Elf64_Off src) - { - return _decoder.Decode(src); - } - - public override ushort Decode(ElfNative.Elf32_Section src) - { - return _decoder.Decode(src); - } - - public override ushort Decode(ElfNative.Elf64_Section src) - { - return _decoder.Decode(src); - } - - public override ushort Decode(ElfNative.Elf32_Versym src) - { - return _decoder.Decode(src); - } - - public override ushort Decode(ElfNative.Elf64_Versym src) - { - return _decoder.Decode(src); - } - - private static readonly Comparison CompareSectionOffsetsAndSizesDelegate = new Comparison(CompareSectionOffsetsAndSizes); - - private static int CompareSectionOffsetsAndSizes(ElfSection left, ElfSection right) - { - int result = left.Offset.CompareTo(right.Offset); - if (result == 0) - { - result = left.Size.CompareTo(right.Size); - } - return result; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs deleted file mode 100644 index 12fdae3478bac3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSection.cs +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile.Elf -{ - /// - /// Defines the base class for a section in an . - /// - [DebuggerDisplay("{ToString(),nq}")] - public abstract class ElfSection : ElfObject - { - private ElfSectionType _type; - - protected ElfSection() : this(ElfSectionType.Null) - { - } - - protected ElfSection(ElfSectionType sectionType) - { - _type = sectionType; - } - - public virtual ElfSectionType Type - { - get => _type; - set - { - _type = value; - } - } - - protected override void ValidateParent(ObjectFileNode parent) - { - if (!(parent is ElfObjectFile)) - { - throw new ArgumentException($"Parent must inherit from type {nameof(ElfObjectFile)}"); - } - } - - - /// - /// Gets the containing . Might be null if this section or segment - /// does not belong to an existing . - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - public new ElfObjectFile Parent - { - get => (ElfObjectFile)base.Parent; - internal set => base.Parent = value; - } - - /// - /// Gets or sets the of this section. - /// - public ElfSectionFlags Flags { get; set; } - - /// - /// Gets or sets the name of this section. - /// - public ElfString Name { get; set; } - - /// - /// Gets or sets the virtual address of this section. - /// - public ulong VirtualAddress { get; set; } - - /// - /// Gets or sets the alignment requirement of this section. - /// - public ulong Alignment { get; set; } - - /// - /// Gets or sets the link element of this section. - /// - public ElfSectionLink Link { get; set; } - - /// - /// Gets or sets the info element of this section. - /// - public ElfSectionLink Info { get; set; } - - /// - /// Gets the table entry size of this section. - /// - public virtual ulong TableEntrySize => 0; - - /// - /// Gets the index of the visible sections in (visible == not ) - /// - public uint SectionIndex { get; internal set; } - - /// - /// Gets or sets the ordering index used when writing back this section. - /// - public uint StreamIndex { get; set; } - - /// - /// Gets the size of the original table entry size of this section. - /// - public ulong OriginalTableEntrySize { get; internal set; } - - /// - /// Gets a boolean indicating if this section is a . - /// - public bool IsShadow => this is ElfShadowSection; - - /// - /// Gets a boolean indicating if this section has some content (Size should be taken into account). - /// - public bool HasContent => Type != ElfSectionType.NoBits && (Type != ElfSectionType.Null || this is ElfShadowSection); - - /// - /// Read data from the specified reader to this instance. - /// - /// The reader to read data from. - protected abstract void Read(ElfReader reader); - - /// - /// Writes data to the specified writer from this instance. - /// - /// The writer to write data to. - protected abstract void Write(ElfWriter writer); - - internal void WriteInternal(ElfWriter writer) - { - Write(writer); - } - - internal void ReadInternal(ElfReader reader) - { - Read(reader); - } - - public override void Verify(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - // Check parent for link section - if (Link.Section != null) - { - if (Link.Section.Parent != this.Parent) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionLinkParent, $"Invalid parent for {nameof(Link)}: `{Link}` used by section `{this}`. The {nameof(Link)}.{nameof(ElfSectionLink.Section)} must have the same parent {nameof(ElfObjectFile)} than this section"); - } - } - - if (Info.Section != null) - { - if (Info.Section.Parent != this.Parent) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSectionInfoParent, $"Invalid parent for {nameof(Info)}: `{Info}` used by section `{this}`. The {nameof(Info)}.{nameof(ElfSectionLink.Section)} must have the same parent {nameof(ElfObjectFile)} than this section"); - } - } - - // Verify that Link is correctly setup for this section - switch (Type) - { - case ElfSectionType.DynamicLinking: - case ElfSectionType.DynamicLinkerSymbolTable: - case ElfSectionType.SymbolTable: - Link.TryGetSectionSafe(this.GetType().Name, nameof(Link), this, diagnostics, out _, ElfSectionType.StringTable); - break; - case ElfSectionType.SymbolHashTable: - case ElfSectionType.Relocation: - case ElfSectionType.RelocationAddends: - Link.TryGetSectionSafe(this.GetType().Name, nameof(Link), this, diagnostics, out _, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); - break; - } - } - - protected virtual void AfterRead(ElfReader reader) - { - } - - protected virtual void BeforeWrite(ElfWriter writer) - { - } - - public override string ToString() - { - return $"Section [{SectionIndex}](Internal: {Index}) `{Name}` "; - } - - internal void BeforeWriteInternal(ElfWriter writer) - { - BeforeWrite(writer); - } - - internal void AfterReadInternal(ElfReader reader) - { - AfterRead(reader); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs deleted file mode 100644 index 86cae8d4f6f14d..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionExtension.cs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using LibObjectFile.Utils; - -namespace LibObjectFile.Elf -{ - /// - /// Extensions for - /// - public static class ElfSectionExtension - { - /// - /// Configure a section default name, type and flags with - /// - /// The type of the section to configure - /// The section to configure - /// The special type - /// The section configured - public static TElfSection ConfigureAs(this TElfSection section, ElfSectionSpecialType sectionSpecialType) where TElfSection : ElfSection - { - switch (sectionSpecialType) - { - case ElfSectionSpecialType.None: - break; - case ElfSectionSpecialType.Bss: - section.Name = ".bss"; - section.Type = ElfSectionType.NoBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; - break; - case ElfSectionSpecialType.Comment: - section.Name = ".comment"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Data: - section.Name = ".data"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; - break; - case ElfSectionSpecialType.Data1: - section.Name = ".data1"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Write; - break; - case ElfSectionSpecialType.Debug: - section.Name = ".debug"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Dynamic: - section.Name = ".dynamic"; - section.Type = ElfSectionType.DynamicLinking; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.DynamicStringTable: - section.Name = ".dynstr"; - section.Type = ElfSectionType.StringTable; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.DynamicSymbolTable: - section.Name = ".dynsym"; - section.Type = ElfSectionType.DynamicLinkerSymbolTable; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.Fini: - section.Name = ".fini"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; - break; - case ElfSectionSpecialType.Got: - section.Name = ".got"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Hash: - section.Name = ".hash"; - section.Type = ElfSectionType.SymbolHashTable; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Init: - section.Name = ".init"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; - break; - case ElfSectionSpecialType.Interp: - section.Name = ".interp"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.Line: - section.Name = ".line"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Note: - section.Name = ".note"; - section.Type = ElfSectionType.Note; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Plt: - section.Name = ".plt"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Relocation: - section.Name = ElfRelocationTable.DefaultName; - section.Type = ElfSectionType.Relocation; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.RelocationAddends: - section.Name = ElfRelocationTable.DefaultNameWithAddends; - section.Type = ElfSectionType.RelocationAddends; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.ReadOnlyData: - section.Name = ".rodata"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.ReadOnlyData1: - section.Name = ".rodata1"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc; - break; - case ElfSectionSpecialType.SectionHeaderStringTable: - section.Name = ".shstrtab"; - section.Type = ElfSectionType.StringTable; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.StringTable: - section.Name = ElfStringTable.DefaultName; - section.Type = ElfSectionType.StringTable; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.SymbolTable: - section.Name = ElfSymbolTable.DefaultName; - section.Type = ElfSectionType.SymbolTable; - section.Flags = ElfSectionFlags.None; - break; - case ElfSectionSpecialType.Text: - section.Name = ".text"; - section.Type = ElfSectionType.ProgBits; - section.Flags = ElfSectionFlags.Alloc | ElfSectionFlags.Executable; - break; - default: - throw ThrowHelper.InvalidEnum(sectionSpecialType); - } - return section; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs deleted file mode 100644 index d52c4ea5f5af14..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionFlags.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines the flag of a section. - /// - [Flags] - public enum ElfSectionFlags : uint - { - None = 0, - - /// - /// Writable - /// - Write = ElfNative.SHF_WRITE, - - /// - /// Occupies memory during execution - /// - Alloc = ElfNative.SHF_ALLOC, - - /// - /// Executable - /// - Executable = ElfNative.SHF_EXECINSTR, - - /// - /// Might be merged - /// - Merge = ElfNative.SHF_MERGE, - - /// - /// Contains nul-terminated strings - /// - Strings = ElfNative.SHF_STRINGS, - - /// - /// `sh_info' contains SHT index - /// - InfoLink = ElfNative.SHF_INFO_LINK, - - /// - /// Preserve order after combining - /// - LinkOrder = ElfNative.SHF_LINK_ORDER, - - /// - /// Non-standard OS specific handling required - /// - OsNonConforming = ElfNative.SHF_OS_NONCONFORMING, - - /// - /// Section is member of a group. - /// - Group = ElfNative.SHF_GROUP, - - /// - /// Section hold thread-local data. - /// - Tls = ElfNative.SHF_TLS, - - /// - /// Section with compressed data. - /// - Compressed = ElfNative.SHF_COMPRESSED, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs deleted file mode 100644 index 2ffc79f2cb9ba3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionLink.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a link to a section, special section or an index (used by and ) - /// - public readonly struct ElfSectionLink : IEquatable - { - public static readonly ElfSectionLink Empty = new ElfSectionLink(ElfNative.SHN_UNDEF); - - public static readonly ElfSectionLink SectionAbsolute = new ElfSectionLink(ElfNative.SHN_ABS); - - public static readonly ElfSectionLink SectionCommon = new ElfSectionLink(ElfNative.SHN_COMMON); - - public ElfSectionLink(uint index) - { - Section = null; - SpecialIndex = index; - } - - public ElfSectionLink(ElfSection section) - { - Section = section; - SpecialIndex = 0; - } - - public readonly ElfSection Section; - - public readonly uint SpecialIndex; - - public bool IsEmpty => Section == null && SpecialIndex == 0; - - /// - /// true if this link to a section is a special section. - /// - public bool IsSpecial => Section == null && (SpecialIndex == ElfNative.SHN_UNDEF || SpecialIndex >= ElfNative.SHN_LORESERVE); - - public uint GetIndex() - { - return Section?.SectionIndex ?? SpecialIndex; - } - - public bool Equals(ElfSectionLink other) - { - return Equals(Section, other.Section) && SpecialIndex == other.SpecialIndex; - } - - public override bool Equals(object obj) - { - return obj is ElfSectionLink other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return ((Section != null ? Section.GetHashCode() : 0) * 397) ^ SpecialIndex.GetHashCode(); - } - } - - public static bool operator ==(ElfSectionLink left, ElfSectionLink right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfSectionLink left, ElfSectionLink right) - { - return !left.Equals(right); - } - - public override string ToString() - { - if (Section != null) - { - return Section.ToString(); - } - - if (SpecialIndex == 0) return "Special Section Undefined"; - - if (SpecialIndex > ElfNative.SHN_BEFORE) - { - if (SpecialIndex == ElfNative.SHN_ABS) - { - return "Special Section Absolute"; - } - - if (SpecialIndex == ElfNative.SHN_COMMON) - { - return "Special Section Common"; - } - - if (SpecialIndex == ElfNative.SHN_XINDEX) - { - return "Special Section XIndex"; - } - } - - return $"Unknown Section Value 0x{SpecialIndex:X8}"; - } - - public static implicit operator ElfSectionLink(ElfSection section) - { - return new ElfSectionLink(section); - } - - - public bool TryGetSectionSafe(string className, string propertyName, object context, DiagnosticBag diagnostics, out TSection section, params ElfSectionType[] sectionTypes) where TSection : ElfSection - { - section = null; - - if (Section == null) - { - diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoSectionNull, $"`{className}.{propertyName}` cannot be null for this instance", context); - return false; - } - - bool foundValid = false; - foreach (var elfSectionType in sectionTypes) - { - if (Section.Type == elfSectionType) - { - foundValid = true; - break; - } - } - - if (!foundValid) - { - diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoInvalidSectionType, $"The type `{Section.Type}` of `{className}.{propertyName}` must be a {string.Join(" or ", sectionTypes)}", context); - return false; - } - section = Section as TSection; - - if (section == null) - { - diagnostics.Error(DiagnosticId.ELF_ERR_LinkOrInfoInvalidSectionInstance, $"The `{className}.{propertyName}` must be an instance of {typeof(TSection).Name}"); - return false; - } - return true; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs deleted file mode 100644 index 7a4aabaa8926a1..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionSpecialType.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines special sections that can be configured via - /// - public enum ElfSectionSpecialType - { - None, - Bss, - Comment, - Data, - Data1, - Debug, - Dynamic, - DynamicStringTable, - DynamicSymbolTable, - Fini, - Got, - Hash, - Init, - Interp, - Line, - Note, - Plt, - Relocation, - RelocationAddends, - ReadOnlyData, - ReadOnlyData1, - SectionHeaderStringTable, - StringTable, - SymbolTable, - Text, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs deleted file mode 100644 index ccc1c7e243ca3a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSectionType.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines the type of a section. - /// - public enum ElfSectionType : uint - { - /// - /// Section header table entry unused - /// - Null = ElfNative.SHT_NULL, - - /// - /// Program data - /// - ProgBits = ElfNative.SHT_PROGBITS, - - /// - /// Symbol table - /// - SymbolTable = ElfNative.SHT_SYMTAB, - - /// - /// String table - /// - StringTable = ElfNative.SHT_STRTAB, - - /// - /// Relocation entries with addends - /// - RelocationAddends = ElfNative.SHT_RELA, - - /// - /// Symbol hash table - /// - SymbolHashTable = ElfNative.SHT_HASH, - - /// - /// Dynamic linking information - /// - DynamicLinking = ElfNative.SHT_DYNAMIC, - - /// - /// Notes - /// - Note = ElfNative.SHT_NOTE, - - /// - /// Program space with no data (bss) - /// - NoBits = ElfNative.SHT_NOBITS, - - /// - /// Relocation entries, no addends - /// - Relocation = ElfNative.SHT_REL, - - /// - /// Reserved - /// - Shlib = ElfNative.SHT_SHLIB, - - /// - /// Dynamic linker symbol table - /// - DynamicLinkerSymbolTable = ElfNative.SHT_DYNSYM, - - /// - /// Array of constructors - /// - InitArray = ElfNative.SHT_INIT_ARRAY, - - /// - /// Array of destructors - /// - FiniArray = ElfNative.SHT_FINI_ARRAY, - - /// - /// Array of pre-constructors - /// - PreInitArray = ElfNative.SHT_PREINIT_ARRAY, - - /// - /// Section group - /// - Group = ElfNative.SHT_GROUP, - - /// - /// Extended section indices - /// - SymbolTableSectionHeaderIndices = ElfNative.SHT_SYMTAB_SHNDX, - - /// - /// Object attributes. - /// - GnuAttributes = ElfNative.SHT_GNU_ATTRIBUTES, - - /// - /// GNU-style hash table. - /// - GnuHash = ElfNative.SHT_GNU_HASH, - - /// - /// Prelink library list - /// - GnuLibList = ElfNative.SHT_GNU_LIBLIST, - - /// - /// Checksum for DSO content. - /// - Checksum = ElfNative.SHT_CHECKSUM, - - /// - /// Version definition section. - /// - GnuVersionDefinition = ElfNative.SHT_GNU_verdef, - - /// - /// Version needs section. - /// - GnuVersionNeedsSection = ElfNative.SHT_GNU_verneed, - - /// - /// Version symbol table. - /// - GnuVersionSymbolTable = ElfNative.SHT_GNU_versym, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs deleted file mode 100644 index 57a809a72de52b..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegment.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using LibObjectFile.Utils; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a segment or program header. - /// - public sealed class ElfSegment : ElfObject - { - public ValueKind OffsetKind { get; set; } - - /// - /// Gets or sets the type of this segment. - /// - public ElfSegmentType Type { get; set; } - - /// - /// Gets or sets the range of section this segment applies to. - /// It can applies to . - /// - public ElfSegmentRange Range { get; set; } - - /// - /// Gets or sets the virtual address. - /// - public ulong VirtualAddress { get; set; } - - /// - /// Gets or sets the physical address. - /// - public ulong PhysicalAddress { get; set; } - - /// - /// Gets or sets the size in bytes occupied in memory by this segment. - /// - public ulong SizeInMemory { get; set; } - - /// - /// Gets or sets the flags of this segment. - /// - public ElfSegmentFlags Flags { get; set; } - - /// - /// Gets the alignment requirement of this section. - /// - public ulong Alignment { get; set; } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - if (OffsetKind == ValueKind.Auto) - { - Offset = Range.Offset; - } - - if (Range.IsEmpty) - { - //diagnostics.Error($"Invalid empty {nameof(Range)} in {this}. An {nameof(ElfSegment)} requires to be attached to a section or a range of section or a {nameof(ElfShadowSection)}"); - } - else - { - Size = Range.Size; - - // TODO: Add checks that Alignment is Power Of 2 - var alignment = Alignment == 0 ? Alignment = 1 : Alignment; - if (!AlignHelper.IsPowerOfTwo(alignment)) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentAlignmentForLoad, $"Invalid segment alignment requirements: Alignment = {alignment} must be a power of 2"); - } - - if (Range.BeginSection.Parent == null) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeBeginSectionParent, $"Invalid null parent {nameof(Range)}.{nameof(Range.BeginSection)} in {this}. The section must be attached to the same {nameof(ElfObjectFile)} than this instance"); - } - - if (Range.EndSection.Parent == null) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndSectionParent, $"Invalid null parent {nameof(Range)}.{nameof(Range.EndSection)} in {this}. The section must be attached to the same {nameof(ElfObjectFile)} than this instance"); - } - - if (Type == ElfSegmentTypeCore.Load) - { - // Specs: - // As ‘‘Program Loading’’ later in this part describes, loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size. - // TODO: how to make this configurable? - if ((alignment % 4096) != 0) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentAlignmentForLoad, $"Invalid {nameof(ElfNative.PT_LOAD)} segment alignment requirements: {alignment} must be multiple of the Page Size {4096}"); - } - - var mod = (VirtualAddress - Range.Offset) & (alignment - 1); - if (mod != 0) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentVirtualAddressOrOffset, $"Invalid {nameof(ElfNative.PT_LOAD)} segment alignment requirements: (VirtualAddress - Range.Offset) & (Alignment - 1) == {mod} while it must be == 0"); - } - } - - if (Size > 0) - { - if (Range.BeginOffset >= Range.BeginSection.Size) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeBeginOffset, $"Invalid {nameof(Range)}.{nameof(Range.BeginOffset)}: {Range.BeginOffset} cannot be >= {nameof(Range.BeginSection)}.{nameof(ElfSection.Size)}: {Range.BeginSection.Size} in {this}. The offset must be within the section"); - } - if ((Range.EndOffset >= 0 && (ulong)Range.EndOffset >= Range.EndSection.Size)) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndOffset, $"Invalid {nameof(Range)}.{nameof(Range.EndOffset)}: {Range.EndOffset} cannot be >= {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSection.Size)}: {Range.EndSection.Size} in {this}. The offset must be within the section"); - } - else if (Range.EndOffset < 0) - { - var endOffset = (long)Range.EndSection.Size + Range.EndOffset; - if (endOffset < 0) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeEndOffset, $"Invalid relative {nameof(Range)}.{nameof(Range.EndOffset)}: {Range.EndOffset}. The resulting end offset {endOffset} with {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSection.Size)}: {Range.EndSection.Size} cannot be < 0 in {this}. The offset must be within the section"); - } - } - } - - if (Range.BeginSection.Parent != null && Range.EndSection.Parent != null) - { - if (Range.BeginSection.Index > Range.EndSection.Index) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSegmentRangeIndices, $"Invalid index order between {nameof(Range)}.{nameof(ElfSegmentRange.BeginSection)}.{nameof(ElfSegment.Index)}: {Range.BeginSection.Index} and {nameof(Range)}.{nameof(ElfSegmentRange.EndSection)}.{nameof(ElfSegment.Index)}: {Range.EndSection.Index} in {this}. The from index must be <= to the end index."); - } - } - } - } - - - public override string ToString() - { - return $"Segment [{Index}]"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs deleted file mode 100644 index ccdf795eeb78f9..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlags.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a segment flags - /// - public readonly struct ElfSegmentFlags : IEquatable - { - public ElfSegmentFlags(uint value) - { - Value = value; - } - - public ElfSegmentFlags(ElfSegmentFlagsCore value) - { - Value = (uint)value; - } - - public readonly uint Value; - - public bool Equals(ElfSegmentFlags other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfSegmentFlags other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(ElfSegmentFlags left, ElfSegmentFlags right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfSegmentFlags left, ElfSegmentFlags right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return $"SegmentFlags {((ElfSegmentFlagsCore)(Value&3))} 0x{Value:X8}"; - } - - public static implicit operator ElfSegmentFlags(ElfSegmentFlagsCore segmentFlagsCore) - { - return new ElfSegmentFlags(segmentFlagsCore); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs deleted file mode 100644 index 8a67b0084a7efb..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentFlagsCore.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines the core part of - /// - [Flags] - public enum ElfSegmentFlagsCore : uint - { - /// - /// Segment flags is undefined - /// - None = 0, - - /// - /// Segment is executable - /// - Executable = ElfNative.PF_X, - - /// - /// Segment is writable - /// - Writable = ElfNative.PF_W, - - /// - /// Segment is readable - /// - Readable = ElfNative.PF_R, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs deleted file mode 100644 index e33ffb4287a2c5..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentRange.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines the range of section a segment is bound to. - /// - public readonly struct ElfSegmentRange : IEquatable - { - public static readonly ElfSegmentRange Empty = new ElfSegmentRange(); - - /// - /// Creates a new instance that is bound to an entire section/ - /// - /// The section to be bound to - public ElfSegmentRange(ElfSection section) - { - BeginSection = section ?? throw new ArgumentNullException(nameof(section)); - BeginOffset = 0; - EndSection = section; - EndOffset = -1; - } - - /// - /// Creates a new instance that is bound to a range of section. - /// - /// The first section. - /// The offset inside the first section. - /// The last section. - /// The offset in the last section - public ElfSegmentRange(ElfSection beginSection, ulong beginOffset, ElfSection endSection, long endOffset) - { - BeginSection = beginSection ?? throw new ArgumentNullException(nameof(beginSection)); - BeginOffset = beginOffset; - EndSection = endSection ?? throw new ArgumentNullException(nameof(endSection)); - EndOffset = endOffset; - if (BeginSection.Index > EndSection.Index) - { - throw new ArgumentOutOfRangeException(nameof(beginSection), $"The {nameof(beginSection)}.{nameof(ElfSection.Index)} = {BeginSection.Index} is > {nameof(endSection)}.{nameof(ElfSection.Index)} = {EndSection.Index}, while it must be <="); - } - } - - /// - /// The first section. - /// - public readonly ElfSection BeginSection; - - /// - /// The relative offset in . - /// - public readonly ulong BeginOffset; - - /// - /// The last section. - /// - public readonly ElfSection EndSection; - - /// - /// The offset in the last section. If the offset is < 0, then the actual offset starts from end of the section where finalEndOffset = section.Size + EndOffset. - /// - public readonly long EndOffset; - - /// - /// Gets a boolean indicating if this section is empty. - /// - public bool IsEmpty => this == Empty; - - /// - /// Returns the absolute offset of this range taking into account the .. - /// - public ulong Offset - { - get - { - // If this Begin/End section are not attached we can't calculate any meaningful size - if (BeginSection?.Parent == null || EndSection?.Parent == null || BeginSection?.Parent != EndSection?.Parent) - { - return 0; - } - - return BeginSection.Offset + BeginOffset; - } - } - - /// - /// Returns the size of this range taking into account the size of each section involved in this range. - /// - public ulong Size - { - get - { - // If this Begin/End section are not attached we can't calculate any meaningful size - if (BeginSection?.Parent == null || EndSection?.Parent == null || BeginSection?.Parent != EndSection?.Parent) - { - return 0; - } - - ulong size = EndSection.Offset - BeginSection.Offset; - size -= BeginOffset; - size += EndOffset < 0 ? (ulong)((long)EndSection.Size + EndOffset + 1) : (ulong)(EndOffset + 1); - return size; - } - } - - public bool Equals(ElfSegmentRange other) - { - return Equals(BeginSection, other.BeginSection) && BeginOffset == other.BeginOffset && Equals(EndSection, other.EndSection) && EndOffset == other.EndOffset; - } - - public override bool Equals(object obj) - { - return obj is ElfSegmentRange other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - var hashCode = (BeginSection != null ? BeginSection.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ BeginOffset.GetHashCode(); - hashCode = (hashCode * 397) ^ (EndSection != null ? EndSection.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ EndOffset.GetHashCode(); - return hashCode; - } - } - - public static bool operator ==(ElfSegmentRange left, ElfSegmentRange right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfSegmentRange left, ElfSegmentRange right) - { - return !left.Equals(right); - } - - public static implicit operator ElfSegmentRange(ElfSection section) - { - return section == null ? Empty : new ElfSegmentRange(section); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs deleted file mode 100644 index 88fdba7d22d1cd..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentType.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a segment type - /// - public readonly struct ElfSegmentType : IEquatable - { - public ElfSegmentType(uint value) - { - Value = value; - } - - public ElfSegmentType(ElfSegmentTypeCore value) - { - Value = (uint)value; - } - - public readonly uint Value; - - public bool Equals(ElfSegmentType other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfSegmentType other && Equals(other); - } - - public override int GetHashCode() - { - return (int) Value; - } - - public static bool operator ==(ElfSegmentType left, ElfSegmentType right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfSegmentType left, ElfSegmentType right) - { - return !left.Equals(right); - } - - public override string ToString() - { - return Value < ElfNative.PT_NUM ? $"SegmentType {((ElfSegmentTypeCore) Value)}" : $"SegmentType 0x{Value:X8}"; - } - - public static implicit operator ElfSegmentType(ElfSegmentTypeCore segmentTypeCore) - { - return new ElfSegmentType(segmentTypeCore); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs deleted file mode 100644 index 469dc418f87fbc..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfSegmentTypeCore.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines a core - /// - public enum ElfSegmentTypeCore : uint - { - /// - /// Program header table entry unused - /// - Null = ElfNative.PT_NULL, - - /// - /// Loadable program segment - /// - Load = ElfNative.PT_LOAD, - - /// - /// Dynamic linking information - /// - Dynamic = ElfNative.PT_DYNAMIC, - - /// - /// Program interpreter - /// - Interpreter = ElfNative.PT_INTERP, - - /// - /// Auxiliary information - /// - Note = ElfNative.PT_NOTE, - - /// - /// Reserved - /// - SectionHeaderLib = ElfNative.PT_SHLIB, - - /// - /// Entry for header table itself - /// - ProgramHeader = ElfNative.PT_PHDR, - - /// - /// Thread-local storage segment - /// - Tls = ElfNative.PT_TLS, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs deleted file mode 100644 index 435febba7c5e3a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfString.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Defines a string with the associated index in the string table. - /// - public readonly struct ElfString : IEquatable - { - private ElfString(string value, uint index) - { - Value = value; - Index = index; - } - - public ElfString(string value) - { - Value = value; - Index = 0; - } - - public ElfString(uint index) - { - Value = null; - Index = index; - } - - public readonly string Value; - - public readonly uint Index; - - public bool IsEmpty => Value == null && Index == 0; - - public bool Equals(ElfString other) - { - return (Value ?? string.Empty) == (other.Value ?? string.Empty) && Index == other.Index; - } - - public override bool Equals(object obj) - { - return obj is ElfString other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return ((Value ?? string.Empty).GetHashCode() * 397) ^ (int) Index; - } - } - - public static bool operator ==(ElfString left, ElfString right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfString left, ElfString right) - { - return !left.Equals(right); - } - - public static bool operator ==(string left, ElfString right) - { - return string.Equals(left, right.Value); - } - - public static bool operator !=(ElfString left, string right) - { - return !string.Equals(left.Value, right); - } - - public static bool operator ==(ElfString right, string left) - { - return string.Equals(left, right.Value); - } - - public static bool operator !=(string right, ElfString left) - { - return !string.Equals(left.Value, right); - } - - public static implicit operator string(ElfString elfString) - { - return elfString.Value; - } - - public static implicit operator ElfString(string text) - { - return new ElfString(text); - } - - public ElfString WithName(string name) - { - return new ElfString(name, Index); - } - - public ElfString WithIndex(uint index) - { - return new ElfString(Value, index); - } - - public override string ToString() - { - return Value ?? $"0x{Index:x8}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs deleted file mode 100644 index 46740c15c2db79..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Base class for writing an to a . - /// - public abstract class ElfWriter : ObjectFileReaderWriter, IElfEncoder - { - private protected ElfWriter(ElfObjectFile objectFile, Stream stream) : base(stream) - { - ObjectFile = objectFile ?? throw new ArgumentNullException(nameof(objectFile)); - } - - private protected ElfObjectFile ObjectFile { get; } - - internal abstract void Write(); - - public override bool IsReadOnly => false; - - internal static ElfWriter Create(ElfObjectFile objectFile, Stream stream) - { - var thisComputerEncoding = BitConverter.IsLittleEndian ? ElfEncoding.Lsb : ElfEncoding.Msb; - return objectFile.Encoding == thisComputerEncoding ? (ElfWriter) new ElfWriterDirect(objectFile, stream) : new ElfWriterSwap(objectFile, stream); - } - - public abstract void Encode(out ElfNative.Elf32_Half dest, ushort value); - public abstract void Encode(out ElfNative.Elf64_Half dest, ushort value); - public abstract void Encode(out ElfNative.Elf32_Word dest, uint value); - public abstract void Encode(out ElfNative.Elf64_Word dest, uint value); - public abstract void Encode(out ElfNative.Elf32_Sword dest, int value); - public abstract void Encode(out ElfNative.Elf64_Sword dest, int value); - public abstract void Encode(out ElfNative.Elf32_Xword dest, ulong value); - public abstract void Encode(out ElfNative.Elf32_Sxword dest, long value); - public abstract void Encode(out ElfNative.Elf64_Xword dest, ulong value); - public abstract void Encode(out ElfNative.Elf64_Sxword dest, long value); - public abstract void Encode(out ElfNative.Elf32_Addr dest, uint value); - public abstract void Encode(out ElfNative.Elf64_Addr dest, ulong value); - public abstract void Encode(out ElfNative.Elf32_Off dest, uint offset); - public abstract void Encode(out ElfNative.Elf64_Off dest, ulong offset); - public abstract void Encode(out ElfNative.Elf32_Section dest, ushort index); - public abstract void Encode(out ElfNative.Elf64_Section dest, ushort index); - public abstract void Encode(out ElfNative.Elf32_Versym dest, ushort value); - public abstract void Encode(out ElfNative.Elf64_Versym dest, ushort value); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs deleted file mode 100644 index 329195f4be202a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterDirect.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Internal implementation of with a . - /// - internal sealed class ElfWriterDirect : ElfWriter - { - public ElfWriterDirect(ElfObjectFile elfObjectFile, Stream stream) : base(elfObjectFile, stream) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs deleted file mode 100644 index 3bd6fc26bd022a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriterSwap.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Internal implementation of with a . - /// - internal sealed class ElfWriterSwap : ElfWriter - { - public ElfWriterSwap(ElfObjectFile elfObjectFile, Stream stream) : base(elfObjectFile, stream) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs deleted file mode 100644 index de3c122820c012..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/ElfWriter{TEncoder}.cs +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Elf -{ - using static ElfNative; - - /// - /// Internal implementation of to write to a stream an instance. - /// - /// The encoder used for LSB/MSB conversion - internal abstract class ElfWriter : ElfWriter where TEncoder : struct, IElfEncoder - { - private TEncoder _encoder; - private ulong _startOfFile; - - protected ElfWriter(ElfObjectFile objectFile, Stream stream) : base(objectFile, stream) - { - _encoder = new TEncoder(); - } - - internal override void Write() - { - _startOfFile = (ulong)Stream.Position; - WriteHeader(); - CheckProgramHeaders(); - WriteSections(); - } - - private ElfObjectFile.ElfObjectLayout Layout => ObjectFile.Layout; - - private void WriteHeader() - { - if (ObjectFile.FileClass == ElfFileClass.Is32) - { - WriteSectionHeader32(); - } - else - { - WriteSectionHeader64(); - } - } - - public override void Encode(out Elf32_Half dest, ushort value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Half dest, ushort value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Word dest, uint value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Word dest, uint value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Sword dest, int value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Sword dest, int value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Xword dest, ulong value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Sxword dest, long value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Xword dest, ulong value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Sxword dest, long value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Addr dest, uint value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Addr dest, ulong value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf32_Off dest, uint offset) - { - _encoder.Encode(out dest, offset); - } - - public override void Encode(out Elf64_Off dest, ulong offset) - { - _encoder.Encode(out dest, offset); - } - - public override void Encode(out Elf32_Section dest, ushort index) - { - _encoder.Encode(out dest, index); - } - - public override void Encode(out Elf64_Section dest, ushort index) - { - _encoder.Encode(out dest, index); - } - - public override void Encode(out Elf32_Versym dest, ushort value) - { - _encoder.Encode(out dest, value); - } - - public override void Encode(out Elf64_Versym dest, ushort value) - { - _encoder.Encode(out dest, value); - } - - private unsafe void WriteSectionHeader32() - { - var hdr = new Elf32_Ehdr(); - ObjectFile.CopyIdentTo(new Span(hdr.e_ident, EI_NIDENT)); - - _encoder.Encode(out hdr.e_type, (ushort)ObjectFile.FileType); - _encoder.Encode(out hdr.e_machine, (ushort)ObjectFile.Arch.Value); - _encoder.Encode(out hdr.e_version, EV_CURRENT); - _encoder.Encode(out hdr.e_entry, (uint)ObjectFile.EntryPointAddress); - _encoder.Encode(out hdr.e_ehsize, Layout.SizeOfElfHeader); - _encoder.Encode(out hdr.e_flags, (uint)ObjectFile.Flags); - - // program headers - _encoder.Encode(out hdr.e_phoff, (uint)Layout.OffsetOfProgramHeaderTable); - _encoder.Encode(out hdr.e_phentsize, Layout.SizeOfProgramHeaderEntry); - _encoder.Encode(out hdr.e_phnum, (ushort) ObjectFile.Segments.Count); - - // entries for sections - _encoder.Encode(out hdr.e_shoff, (uint)Layout.OffsetOfSectionHeaderTable); - _encoder.Encode(out hdr.e_shentsize, Layout.SizeOfSectionHeaderEntry); - _encoder.Encode(out hdr.e_shnum, ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE ? (ushort)0 : (ushort)ObjectFile.VisibleSectionCount); - uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; - _encoder.Encode(out hdr.e_shstrndx, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? (ushort)ElfNative.SHN_XINDEX : (ushort)shstrSectionIndex); - - Write(hdr); - } - - private unsafe void WriteSectionHeader64() - { - var hdr = new Elf64_Ehdr(); - ObjectFile.CopyIdentTo(new Span(hdr.e_ident, EI_NIDENT)); - - _encoder.Encode(out hdr.e_type, (ushort)ObjectFile.FileType); - _encoder.Encode(out hdr.e_machine, (ushort)ObjectFile.Arch.Value); - _encoder.Encode(out hdr.e_version, EV_CURRENT); - _encoder.Encode(out hdr.e_entry, ObjectFile.EntryPointAddress); - _encoder.Encode(out hdr.e_ehsize, Layout.SizeOfElfHeader); - _encoder.Encode(out hdr.e_flags, (uint)ObjectFile.Flags); - - // program headers - _encoder.Encode(out hdr.e_phoff, Layout.OffsetOfProgramHeaderTable); - _encoder.Encode(out hdr.e_phentsize, Layout.SizeOfProgramHeaderEntry); - _encoder.Encode(out hdr.e_phnum, (ushort)ObjectFile.Segments.Count); - - // entries for sections - _encoder.Encode(out hdr.e_shoff, Layout.OffsetOfSectionHeaderTable); - _encoder.Encode(out hdr.e_shentsize, (ushort)sizeof(Elf64_Shdr)); - _encoder.Encode(out hdr.e_shnum, ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE ? (ushort)0 : (ushort)ObjectFile.VisibleSectionCount); - uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; - _encoder.Encode(out hdr.e_shstrndx, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? (ushort)ElfNative.SHN_XINDEX : (ushort)shstrSectionIndex); - - Write(hdr); - } - - private void CheckProgramHeaders() - { - if (ObjectFile.Segments.Count == 0) - { - return; - } - - var offset = (ulong)Stream.Position - _startOfFile; - if (offset != Layout.OffsetOfProgramHeaderTable) - { - throw new InvalidOperationException("Internal error. Unexpected offset for ProgramHeaderTable"); - } - } - - private void WriteSections() - { - var sections = ObjectFile.Sections; - if (sections.Count == 0) return; - - sections = ObjectFile.GetSectionsOrderedByStreamIndex(); - - // We write the content all sections including shadows - for (var i = 0; i < sections.Count; i++) - { - var section = sections[i]; - - // Write only section with content - if (section.HasContent) - { - Stream.Position = (long)(_startOfFile + section.Offset); - section.WriteInternal(this); - } - } - - // Write section header table - WriteSectionHeaderTable(); - } - - private void WriteSectionHeaderTable() - { - var offset = (ulong)Stream.Position - _startOfFile; - var diff = Layout.OffsetOfSectionHeaderTable - offset; - if (diff < 0 || diff > 8) - { - throw new InvalidOperationException("Internal error. Unexpected offset for SectionHeaderTable"); - } - else if (diff != 0) - { - // Alignment - Stream.Write(stackalloc byte[(int)diff]); - } - - // Then write all regular sections - var sections = ObjectFile.Sections; - for (var i = 0; i < sections.Count; i++) - { - var section = sections[i]; - if (section.IsShadow) continue; - WriteSectionTableEntry(section); - } - } - - private void WriteSectionTableEntry(ElfSection section) - { - if (ObjectFile.FileClass == ElfFileClass.Is32) - { - WriteSectionTableEntry32(section); - } - else - { - WriteSectionTableEntry64(section); - } - } - - private void WriteSectionTableEntry32(ElfSection section) - { - var shdr = new Elf32_Shdr(); - _encoder.Encode(out shdr.sh_name, ObjectFile.SectionHeaderStringTable?.GetOrCreateIndex(section.Name) ?? 0); - _encoder.Encode(out shdr.sh_type, (uint)section.Type); - _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); - _encoder.Encode(out shdr.sh_addr, (uint)section.VirtualAddress); - _encoder.Encode(out shdr.sh_offset, (uint)section.Offset); - if (section.Index == 0 && ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE) - { - _encoder.Encode(out shdr.sh_size, ObjectFile.VisibleSectionCount); - uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; - _encoder.Encode(out shdr.sh_link, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? shstrSectionIndex : 0); - } - else - { - _encoder.Encode(out shdr.sh_size, (uint)section.Size); - _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); - } - _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); - _encoder.Encode(out shdr.sh_addralign, (uint)section.Alignment); - _encoder.Encode(out shdr.sh_entsize, (uint)section.TableEntrySize); - Write(shdr); - } - - private void WriteSectionTableEntry64(ElfSection section) - { - var shdr = new Elf64_Shdr(); - _encoder.Encode(out shdr.sh_name, ObjectFile.SectionHeaderStringTable?.GetOrCreateIndex(section.Name) ?? 0); - _encoder.Encode(out shdr.sh_type, (uint)section.Type); - _encoder.Encode(out shdr.sh_flags, (uint)section.Flags); - _encoder.Encode(out shdr.sh_addr, section.VirtualAddress); - _encoder.Encode(out shdr.sh_offset, section.Offset); - if (section.Index == 0 && ObjectFile.VisibleSectionCount >= ElfNative.SHN_LORESERVE) - { - _encoder.Encode(out shdr.sh_size, ObjectFile.VisibleSectionCount); - uint shstrSectionIndex = ObjectFile.SectionHeaderStringTable?.SectionIndex ?? 0u; - _encoder.Encode(out shdr.sh_link, shstrSectionIndex >= ElfNative.SHN_LORESERVE ? shstrSectionIndex : 0); - } - else - { - _encoder.Encode(out shdr.sh_size, section.Size); - _encoder.Encode(out shdr.sh_link, section.Link.GetIndex()); - } - _encoder.Encode(out shdr.sh_info, section.Info.GetIndex()); - _encoder.Encode(out shdr.sh_addralign, section.Alignment); - _encoder.Encode(out shdr.sh_entsize, section.TableEntrySize); - Write(shdr); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs deleted file mode 100644 index eba5309fcb134f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfDecoder.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// A decoder interface for the various Elf types that provides decoding of data based on LSB/MSB. - /// - /// - public interface IElfDecoder - { - ushort Decode(ElfNative.Elf32_Half src); - - ushort Decode(ElfNative.Elf64_Half src); - - uint Decode(ElfNative.Elf32_Word src); - - uint Decode(ElfNative.Elf64_Word src); - - int Decode(ElfNative.Elf32_Sword src); - - int Decode(ElfNative.Elf64_Sword src); - - ulong Decode(ElfNative.Elf32_Xword src); - - long Decode(ElfNative.Elf32_Sxword src); - - ulong Decode(ElfNative.Elf64_Xword src); - - long Decode(ElfNative.Elf64_Sxword src); - - uint Decode(ElfNative.Elf32_Addr src); - - ulong Decode(ElfNative.Elf64_Addr src); - - uint Decode(ElfNative.Elf32_Off src); - - ulong Decode(ElfNative.Elf64_Off src); - - ushort Decode(ElfNative.Elf32_Section src); - - ushort Decode(ElfNative.Elf64_Section src); - - ushort Decode(ElfNative.Elf32_Versym src); - - ushort Decode(ElfNative.Elf64_Versym src); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs deleted file mode 100644 index 702612ad5ba674..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/IElfEncoder.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// An encoder interface for the various Elf types that provides encoding of data based on LSB/MSB. - /// - /// - public interface IElfEncoder - { - void Encode(out ElfNative.Elf32_Half dest, ushort value); - - void Encode(out ElfNative.Elf64_Half dest, ushort value); - - void Encode(out ElfNative.Elf32_Word dest, uint value); - - void Encode(out ElfNative.Elf64_Word dest, uint value); - - void Encode(out ElfNative.Elf32_Sword dest, int value); - - void Encode(out ElfNative.Elf64_Sword dest, int value); - - void Encode(out ElfNative.Elf32_Xword dest, ulong value); - - void Encode(out ElfNative.Elf32_Sxword dest, long value); - - void Encode(out ElfNative.Elf64_Xword dest, ulong value); - - void Encode(out ElfNative.Elf64_Sxword dest, long value); - - void Encode(out ElfNative.Elf32_Addr dest, uint value); - - void Encode(out ElfNative.Elf64_Addr dest, ulong value); - - void Encode(out ElfNative.Elf32_Off dest, uint offset); - - void Encode(out ElfNative.Elf64_Off dest, ulong offset); - - void Encode(out ElfNative.Elf32_Section dest, ushort index); - - void Encode(out ElfNative.Elf64_Section dest, ushort index); - - void Encode(out ElfNative.Elf32_Versym dest, ushort value); - - void Encode(out ElfNative.Elf64_Versym dest, ushort value); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs deleted file mode 100644 index eb276b91105b3d..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfAlignedShadowSection.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using LibObjectFile.Utils; - -namespace LibObjectFile.Elf -{ - /// - /// A shadow section allowing to align the following section from - /// to respect the of this section. - /// This section is used to make sure the offset of the following section will be respect - /// a specific alignment. - /// - public sealed class ElfAlignedShadowSection : ElfShadowSection - { - public ElfAlignedShadowSection() : this(0x1000) - { - } - - public ElfAlignedShadowSection(uint upperAlignment) - { - UpperAlignment = upperAlignment; - } - - /// - /// Gets or sets teh alignment requirement that this section will ensure for the - /// following sections placed after this section, so that the offset of the following - /// section is respecting the alignment. - /// - public uint UpperAlignment { get; set; } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - var nextSectionOffset = AlignHelper.AlignToUpper(Offset, UpperAlignment); - Size = nextSectionOffset - Offset; - if (Size >= int.MaxValue) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidAlignmentOutOfRange, $"Invalid alignment 0x{UpperAlignment:x} resulting in an offset beyond int.MaxValue"); - } - } - - protected override void Read(ElfReader reader) - { - throw new NotSupportedException($"An {nameof(ElfAlignedShadowSection)} does not support read and is only used for writing"); - } - - protected override void Write(ElfWriter writer) - { - if (Size == 0) return; - - var sharedBuffer = ArrayPool.Shared.Rent((int)Size); - Array.Clear(sharedBuffer, 0, sharedBuffer.Length); - try - { - writer.Stream.Write(sharedBuffer, 0, (int) Size); - } - finally - { - ArrayPool.Shared.Return(sharedBuffer); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs deleted file mode 100644 index db864d9b6dd923..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinarySection.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// A custom section associated with its stream of data to read/write. - /// - public sealed class ElfBinarySection : ElfSection - { - public ElfBinarySection() - { - } - - public ElfBinarySection(Stream stream) - { - Stream = stream ?? throw new ArgumentNullException(nameof(stream)); - } - - public override ElfSectionType Type - { - get => base.Type; - set - { - // Don't allow relocation or symbol table to enforce proper usage - if (value == ElfSectionType.Relocation || value == ElfSectionType.RelocationAddends) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}]. Must be used on a `{nameof(ElfRelocationTable)}` instead"); - } - - if (value == ElfSectionType.SymbolTable || value == ElfSectionType.DynamicLinkerSymbolTable) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}]. Must be used on a `{nameof(ElfSymbolTable)}` instead"); - } - - base.Type = value; - } - } - - public override ulong TableEntrySize => OriginalTableEntrySize; - - /// - /// Gets or sets the associated stream to this section. - /// - public Stream Stream { get; set; } - - protected override void Read(ElfReader reader) - { - Stream = reader.ReadAsStream(Size); - } - - protected override void Write(ElfWriter writer) - { - if (Stream == null) return; - writer.Write(Stream); - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - if (Type != ElfSectionType.NoBits) - { - Size = Stream != null ? (ulong)Stream.Length : 0; - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - if (Type == ElfSectionType.NoBits && Stream != null) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidStreamForSectionNoBits, $"The {Type} section {this} must have a null stream"); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs deleted file mode 100644 index e0d8435f80d104..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfBinaryShadowSection.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// Equivalent of but used for shadow. - /// - public sealed class ElfBinaryShadowSection : ElfShadowSection - { - public ElfBinaryShadowSection() - { - } - - public Stream Stream { get; set; } - - protected override void Read(ElfReader reader) - { - Stream = reader.ReadAsStream(Size); - } - - protected override void Write(ElfWriter writer) - { - if (Stream == null) return; - writer.Write(Stream); - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - Size = Stream != null ? (ulong)Stream.Length : 0; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs deleted file mode 100644 index 27d614c59225f4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfCustomNote.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Buffers; -using System.IO; -using System.Text; - -namespace LibObjectFile.Elf -{ - /// - /// A custom note entry in - /// - public class ElfCustomNote : ElfNote - { - /// - /// Gets or sets the name of this note. - /// - public string Name { get; set; } - - /// - /// Gets or sets the associated descriptor data. - /// - public Stream Descriptor { get; set; } - - /// - /// Gets or sets the type of this note. - /// - public ElfNoteTypeEx Type { get; set; } - - public override string GetName() - { - return Name; - } - - public override ElfNoteTypeEx GetNoteType() - { - return Type; - } - - public override uint GetDescriptorSize() - { - return Descriptor == null ? 0 : (uint)Descriptor.Length; - } - - public override string GetDescriptorAsText() - { - if (Descriptor == null || Descriptor.Length == 0) return string.Empty; - - Descriptor.Position = 0; - - var length = (int) Descriptor.Length; - var buffer = ArrayPool.Shared.Rent(length); - try - { - length = Descriptor.Read(buffer, 0, length); - Descriptor.Position = 0; - var hasBinary = false; - - // If we have any binary data (don't take into account a potential null terminated string) - for (int i = 0; i < length - 1; i++) - { - if (buffer[i] < ' ') - { - hasBinary = true; - break; - } - } - - if (hasBinary) - { - var builder = new StringBuilder(); - for (int i = 0; i < length; i++) - { - builder.Append($"{buffer[i]:x2}"); - } - - return builder.ToString(); - } - else - { - return Encoding.UTF8.GetString(buffer, 0, length); - } - } - finally - { - ArrayPool.Shared.Return(buffer); - } - } - - protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) - { - if (descriptorLength > 0) - { - Descriptor = reader.ReadAsStream(descriptorLength); - } - } - - protected override void WriteDescriptor(ElfWriter writer) - { - if (Descriptor != null) - { - writer.Write(Descriptor); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs deleted file mode 100644 index 07333293262efc..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNote.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - public abstract class ElfGnuNote : ElfNote - { - public override string GetName() - { - return "GNU"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs deleted file mode 100644 index 20cd616e4a78f9..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteABITag.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Text; - -namespace LibObjectFile.Elf -{ - public class ElfGnuNoteABITag : ElfGnuNote - { - public ElfGnuNoteOSKind OSKind { get; set; } - - public uint MajorVersion { get; set; } - - public uint MinorVersion { get; set; } - - public uint SubMinorVersion { get; set; } - - public override ElfNoteTypeEx GetNoteType() => new ElfNoteTypeEx(ElfNoteType.GNU_ABI_TAG); - - public override uint GetDescriptorSize() => 4 * sizeof(int); - - public override string GetDescriptorAsText() - { - var builder = new StringBuilder(); - builder.Append("OS: "); - switch (OSKind) - { - case ElfGnuNoteOSKind.Linux: - builder.Append("Linux"); - break; - case ElfGnuNoteOSKind.Gnu: - builder.Append("Gnu"); - break; - case ElfGnuNoteOSKind.Solaris: - builder.Append("Solaris"); - break; - case ElfGnuNoteOSKind.FreeBSD: - builder.Append("FreeBSD"); - break; - default: - builder.Append($"0x{(uint) OSKind:x8}"); - break; - } - - builder.Append($", ABI: {MajorVersion}.{MinorVersion}.{SubMinorVersion}"); - return builder.ToString(); - } - - protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) - { - NativeGnuNoteOS nativeGnuNote; - if (!reader.TryReadData((int)descriptorLength, out nativeGnuNote)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleNoteGnuAbiTag, $"The {nameof(ElfGnuNoteABITag)} is incomplete in size. Expecting: {GetDescriptorSize()} but got {descriptorLength}"); - } - - OSKind = (ElfGnuNoteOSKind) reader.Decode(nativeGnuNote.OS); - MajorVersion = reader.Decode(nativeGnuNote.MajorVersion); - MinorVersion = reader.Decode(nativeGnuNote.MinorVersion); - SubMinorVersion = reader.Decode(nativeGnuNote.SubMinorVersion); - } - - protected override void WriteDescriptor(ElfWriter writer) - { - NativeGnuNoteOS nativeGnuNote; - writer.Encode(out nativeGnuNote.OS, (uint) OSKind); - writer.Encode(out nativeGnuNote.MajorVersion, (uint)MajorVersion); - writer.Encode(out nativeGnuNote.MinorVersion, (uint)MinorVersion); - writer.Encode(out nativeGnuNote.SubMinorVersion, (uint)SubMinorVersion); - writer.Write(nativeGnuNote); - } - - private struct NativeGnuNoteOS - { - public ElfNative.Elf32_Word OS; - public ElfNative.Elf32_Word MajorVersion; - public ElfNative.Elf32_Word MinorVersion; - public ElfNative.Elf32_Word SubMinorVersion; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs deleted file mode 100644 index 7976c743e639f3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteBuildId.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System.Buffers; -using System.IO; -using System.Text; - -namespace LibObjectFile.Elf -{ - public class ElfGnuNoteBuildId : ElfGnuNote - { - public override ElfNoteTypeEx GetNoteType() => new ElfNoteTypeEx(ElfNoteType.GNU_BUILD_ID); - - public Stream BuildId { get; set; } - - public override uint GetDescriptorSize() => BuildId != null ? (uint)BuildId.Length : 0; - - public override string GetDescriptorAsText() - { - var builder = new StringBuilder(); - builder.Append("Build ID: "); - - if (BuildId != null) - { - BuildId.Position = 0; - var length = (int)BuildId.Length; - var buffer = ArrayPool.Shared.Rent(length); - length = BuildId.Read(buffer, 0, length); - BuildId.Position = 0; - - for (int i = 0; i < length; i++) - { - builder.Append($"{buffer[i]:x2}"); - } - } - - return builder.ToString(); - } - - - protected override void ReadDescriptor(ElfReader reader, uint descriptorLength) - { - if (descriptorLength > 0) - { - BuildId = reader.ReadAsStream(descriptorLength); - } - } - - protected override void WriteDescriptor(ElfWriter writer) - { - if (BuildId != null) - { - writer.Write(BuildId); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs deleted file mode 100644 index e2ec7c7a90bfc3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfGnuNoteOSKind.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Type of Operating System for a - /// - public enum ElfGnuNoteOSKind : uint - { - /// - /// Linux operating system. - /// - Linux = ElfNative.ELF_NOTE_OS_LINUX, - - /// - /// A Gnu operating system. - /// - Gnu = ElfNative.ELF_NOTE_OS_GNU, - - /// - /// Solaris operating system. - /// - Solaris = ElfNative.ELF_NOTE_OS_SOLARIS2, - - /// - /// FreeBSD operating system. - /// - FreeBSD = ElfNative.ELF_NOTE_OS_FREEBSD, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs deleted file mode 100644 index 19842c15060bbc..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNote.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// A Note entry in - /// - public abstract class ElfNote - { - protected ElfNote() - { - } - - /// - /// Gets or sets the name of this note. - /// - public abstract string GetName(); - - /// - /// Gets or sets the type of this note. - /// - public abstract ElfNoteTypeEx GetNoteType(); - - public abstract uint GetDescriptorSize(); - - public abstract string GetDescriptorAsText(); - - public override string ToString() - { - return $"{nameof(ElfNote)} {GetName()}, Type: {GetNoteType()}"; - } - - internal void ReadDescriptorInternal(ElfReader reader, uint descriptorLength) - { - ReadDescriptor(reader, descriptorLength); - } - - internal void WriteDescriptorInternal(ElfWriter writer) - { - WriteDescriptor(writer); - } - protected abstract void ReadDescriptor(ElfReader reader, uint descriptorLength); - - protected abstract void WriteDescriptor(ElfWriter writer); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs deleted file mode 100644 index 7f79618a8cf81e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteTable.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using LibObjectFile.Utils; - -namespace LibObjectFile.Elf -{ - /// - /// A note section with the type . - /// - public sealed class ElfNoteTable : ElfSection - { - public ElfNoteTable() : base(ElfSectionType.Note) - { - Entries = new List(); - } - - /// - /// Gets a list of entries. - /// - public List Entries { get; } - - public override ElfSectionType Type - { - get => base.Type; - set - { - if (value != ElfSectionType.Note) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfNoteTable)}` while `{ElfSectionType.Note}` is expected"); - } - base.Type = value; - } - } - - public override unsafe void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - ulong size = 0; - ulong entrySize = (ulong)sizeof(ElfNative.Elf32_Nhdr); - - foreach (var elfNote in Entries) - { - var name = elfNote.GetName(); - if (name != null) - { - size += (ulong)Encoding.UTF8.GetByteCount(name) + 1; - size = AlignHelper.AlignToUpper(size, 4); - } - - size += (ulong)elfNote.GetDescriptorSize(); - size = AlignHelper.AlignToUpper(size, 4); - - size += entrySize; - } - Size = size; - } - - protected override unsafe void Read(ElfReader reader) - { - var sizeToRead = (long)base.Size; - - var entrySize = (long)sizeof(ElfNative.Elf32_Nhdr); - - var startPosition = (ulong)reader.Stream.Position; - while (sizeToRead >= entrySize) - { - ElfNative.Elf32_Nhdr nativeNote; - ulong noteStartOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)entrySize, out nativeNote)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteNoteEntrySize, $"Unable to read entirely the note entry [{Entries.Count}] from {Type} section [{Index}]. Not enough data (size: {entrySize}) read at offset {noteStartOffset} from the stream"); - break; - } - - var nameLength = reader.Decode(nativeNote.n_namesz); - var descriptorLength = reader.Decode(nativeNote.n_descsz); - - var noteType = new ElfNoteTypeEx(reader.Decode(nativeNote.n_type)); - var noteName = reader.ReadStringUTF8NullTerminated(nameLength); - SkipPaddingAlignedTo4Bytes(reader, (ulong)reader.Stream.Position - startPosition); - - var note = CreateNote(reader, noteName, noteType); - - note.ReadDescriptorInternal(reader, descriptorLength); - - SkipPaddingAlignedTo4Bytes(reader, (ulong)reader.Stream.Position - startPosition); - - Entries.Add(note); - - ulong noteEndOffset = (ulong)reader.Stream.Position; - sizeToRead = sizeToRead - (long)(noteEndOffset - noteStartOffset); - } - } - - private void SkipPaddingAlignedTo4Bytes(ElfReader reader, ulong offset) - { - if ((offset & 3) != 0) - { - var toWrite = 4 - (int)(offset & 3); - reader.Stream.Position += toWrite; - } - } - - protected override void Write(ElfWriter writer) - { - var expectedSizeWritten = Size; - var startPosition = (ulong) writer.Stream.Position; - foreach (var elfNote in Entries) - { - ElfNative.Elf32_Nhdr nativeNote; - - var noteName = elfNote.GetName(); - writer.Encode(out nativeNote.n_namesz, noteName == null ? 0 : ((uint) Encoding.UTF8.GetByteCount(noteName) + 1)); - writer.Encode(out nativeNote.n_descsz, elfNote.GetDescriptorSize()); - writer.Encode(out nativeNote.n_type, (uint)elfNote.GetNoteType().Value); - - writer.Write(nativeNote); - - if (noteName != null) - { - writer.WriteStringUTF8NullTerminated(noteName); - WritePaddingAlignedTo4Bytes(writer, (ulong)writer.Stream.Position - startPosition); - } - - elfNote.WriteDescriptorInternal(writer); - WritePaddingAlignedTo4Bytes(writer, (ulong)writer.Stream.Position - startPosition); - } - - var sizeWritten = (ulong) writer.Stream.Position - startPosition; - Debug.Assert(expectedSizeWritten == sizeWritten); - } - - private void WritePaddingAlignedTo4Bytes(ElfWriter writer, ulong offset) - { - if ((offset & 3) != 0) - { - var toWrite = 4 - (int)(offset & 3); - for (int i = 0; i < toWrite; i++) writer.Stream.WriteByte(0); - } - } - - private static ElfNote CreateNote(ElfReader reader, string name, ElfNoteType type) - { - if (name == "GNU") - { - switch (type) - { - case ElfNoteType.GNU_ABI_TAG: - return new ElfGnuNoteABITag(); - case ElfNoteType.GNU_BUILD_ID: - return new ElfGnuNoteBuildId(); - } - } - - ElfNote note = null; - - if (reader.Options.TryCreateNote != null) - { - note = reader.Options.TryCreateNote(name, type); - } - - return note ?? new ElfCustomNote() - { - Name = name, - Type = type - }; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs deleted file mode 100644 index 2baa9cfc54be84..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNoteType.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Gets the type of a . - /// - public readonly partial struct ElfNoteTypeEx : IEquatable - { - public ElfNoteTypeEx(uint value) - { - Value = (ElfNoteType)value; - } - - public ElfNoteTypeEx(ElfNoteType value) - { - Value = value; - } - - /// - /// The value of this note type. - /// - public readonly ElfNoteType Value; - - public override string ToString() - { - return ToStringInternal() ?? $"Unknown {nameof(ElfNoteTypeEx)} (0x{(uint)Value:X4})"; - } - - public bool Equals(ElfNoteTypeEx other) - { - return Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfNoteTypeEx other && Equals(other); - } - - public override int GetHashCode() - { - return (int)Value; - } - - public static bool operator ==(ElfNoteTypeEx left, ElfNoteTypeEx right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfNoteTypeEx left, ElfNoteTypeEx right) - { - return !left.Equals(right); - } - - public static explicit operator byte(ElfNoteTypeEx noteType) => (byte)noteType.Value; - - public static implicit operator ElfNoteTypeEx(ElfNoteType noteType) => new ElfNoteTypeEx(noteType); - - public static implicit operator ElfNoteType(ElfNoteTypeEx noteType) => noteType.Value; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs deleted file mode 100644 index 89f92a948afd8e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfNullSection.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// A null section with the type . - /// - public sealed class ElfNullSection : ElfSection - { - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - if (Type != ElfSectionType.Null || - Flags != ElfSectionFlags.None || - !Name.IsEmpty || - VirtualAddress != 0 || - Alignment != 0 || - !Link.IsEmpty || - !Info.IsEmpty || - Offset != 0 || - Size != 0) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidNullSection, "Invalid Null section. This section should not be modified and all properties must be null"); - } - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - } - - protected override void Read(ElfReader reader) - { - } - - protected override void Write(ElfWriter writer) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs deleted file mode 100644 index f1f7754915fad6..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfProgramHeaderTable.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// The program header table as a . - /// - public sealed class ElfProgramHeaderTable : ElfShadowSection - { - public ElfProgramHeaderTable() - { - Name = ".shadow.phdrtab"; - } - - protected override void Read(ElfReader reader) - { - // This is not read by this instance but by ElfReader directly - } - - public override unsafe ulong TableEntrySize - { - get - { - if (Parent == null) return 0; - return Parent.FileClass == ElfFileClass.Is32 ? (ulong)sizeof(ElfNative.Elf32_Phdr) : (ulong)sizeof(ElfNative.Elf64_Phdr); - } - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - Size = 0; - - if (Parent == null) return; - - Size = (ulong) Parent.Segments.Count * Parent.Layout.SizeOfProgramHeaderEntry; - } - - - protected override void Write(ElfWriter writer) - { - for (int i = 0; i < Parent.Segments.Count; i++) - { - var header = Parent.Segments[i]; - if (Parent.FileClass == ElfFileClass.Is32) - { - WriteProgramHeader32(writer, ref header); - } - else - { - WriteProgramHeader64(writer, ref header); - } - } - } - - private void WriteProgramHeader32(ElfWriter writer, ref ElfSegment segment) - { - var hdr = new ElfNative.Elf32_Phdr(); - - writer.Encode(out hdr.p_type, segment.Type.Value); - writer.Encode(out hdr.p_offset, (uint)segment.Offset); - writer.Encode(out hdr.p_vaddr, (uint)segment.VirtualAddress); - writer.Encode(out hdr.p_paddr, (uint)segment.PhysicalAddress); - writer.Encode(out hdr.p_filesz, (uint)segment.Size); - writer.Encode(out hdr.p_memsz, (uint)segment.SizeInMemory); - writer.Encode(out hdr.p_flags, segment.Flags.Value); - writer.Encode(out hdr.p_align, (uint)segment.Alignment); - - writer.Write(hdr); - } - - private void WriteProgramHeader64(ElfWriter writer, ref ElfSegment segment) - { - var hdr = new ElfNative.Elf64_Phdr(); - - writer.Encode(out hdr.p_type, segment.Type.Value); - writer.Encode(out hdr.p_offset, segment.Offset); - writer.Encode(out hdr.p_vaddr, segment.VirtualAddress); - writer.Encode(out hdr.p_paddr, segment.PhysicalAddress); - writer.Encode(out hdr.p_filesz, segment.Size); - writer.Encode(out hdr.p_memsz, segment.SizeInMemory); - writer.Encode(out hdr.p_flags, segment.Flags.Value); - writer.Encode(out hdr.p_align, segment.Alignment); - - writer.Write(hdr); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs deleted file mode 100644 index e76dd0fb146fd4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocation.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// A relocation entry in the - /// This is the value seen in or - /// - public struct ElfRelocation - { - public ElfRelocation(ulong offset, ElfRelocationType type, uint symbolIndex, long addend) - { - Offset = offset; - Type = type; - SymbolIndex = symbolIndex; - Addend = addend; - } - - /// - /// Gets or sets the offset. - /// - public ulong Offset { get; set; } - - /// - /// Gets or sets the type of relocation. - /// - public ElfRelocationType Type { get; set; } - - /// - /// Gets or sets the symbol index associated with the symbol table. - /// - public uint SymbolIndex { get; set; } - - /// - /// Gets or sets the addend value. - /// - public long Addend { get; set; } - - /// - /// Gets the computed Info value as expected by - /// - public uint Info32 => - ((uint) SymbolIndex << 8) | ((Type.Value & 0xFF)); - - /// - /// Gets the computed Info value as expected by - /// - public ulong Info64 => - ((ulong)SymbolIndex << 32) | (Type.Value); - - public override string ToString() - { - return $"{nameof(Offset)}: 0x{Offset:X16}, {nameof(Type)}: {Type}, {nameof(SymbolIndex)}: {SymbolIndex}, {nameof(Addend)}: 0x{Addend:X16}"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs deleted file mode 100644 index b2f82dfce73c64..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationContext.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Context used when applying relocation via . - /// - public struct ElfRelocationContext - { - public ulong BaseAddress { get; set; } - - public ulong GlobalObjectTableAddress { get; set; } - - public ulong GlobalObjectTableOffset { get; set; } - - public ulong ProcedureLinkageTableAddress { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs deleted file mode 100644 index 194d7afe43af10..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTable.cs +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; - -namespace LibObjectFile.Elf -{ - /// - /// A relocation section with the type or - /// - public sealed class ElfRelocationTable : ElfSection - { - private readonly List _entries; - public const string DefaultName = ".rel"; - public const string DefaultNameWithAddends = ".rela"; - - public ElfRelocationTable() : base(ElfSectionType.RelocationAddends) - { - Name = DefaultNameWithAddends; - _entries = new List(); - } - - /// - /// Gets a list of entries. - /// - public List Entries => _entries; - - private static string GetDefaultName(ElfSectionType type) - { - return type == ElfSectionType.Relocation? DefaultName : DefaultNameWithAddends; - } - - public override ElfSectionType Type - { - get => base.Type; - set - { - if (value != ElfSectionType.Relocation && value != ElfSectionType.RelocationAddends) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfRelocationTable)}` while `{ElfSectionType.Relocation}` or `{ElfSectionType.RelocationAddends}` are expected"); - } - base.Type = value; - } - } - - public bool IsRelocationWithAddends => this.Type == ElfSectionType.RelocationAddends; - - protected override void Read(ElfReader reader) - { - if (Parent.FileClass == ElfFileClass.Is32) - { - Read32(reader); - } - else - { - Read64(reader); - } - } - - protected override void Write(ElfWriter writer) - { - if (Parent.FileClass == ElfFileClass.Is32) - { - Write32(writer); - } - else - { - Write64(writer); - } - } - - public override unsafe ulong TableEntrySize => - Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : - Parent.FileClass == ElfFileClass.Is32 ? (ulong) (IsRelocationWithAddends ? sizeof(ElfNative.Elf32_Rela) : sizeof(ElfNative.Elf32_Rel)) : (ulong) (IsRelocationWithAddends ? sizeof(ElfNative.Elf64_Rela) : sizeof(ElfNative.Elf64_Rel)); - - private void Read32(ElfReader reader) - { - var numberOfEntries = base.Size / OriginalTableEntrySize; - if (IsRelocationWithAddends) - { - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf32_Rela rel; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationAddendsEntry32Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var offset = reader.Decode(rel.r_offset); - var r_info = reader.Decode(rel.r_info); - var type = new ElfRelocationType(Parent.Arch, r_info & 0xFF); - var symbolIndex = r_info >> 8; - var addend = reader.Decode(rel.r_addend); - - var entry = new ElfRelocation(offset, type, symbolIndex, addend); - _entries.Add(entry); - } - } - else - { - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf32_Rel rel; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationEntry32Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var offset = reader.Decode(rel.r_offset); - - var r_info = reader.Decode(rel.r_info); - var type = new ElfRelocationType(Parent.Arch, r_info & 0xFF); - var symbolIndex = r_info >> 8; - - var entry = new ElfRelocation(offset, type, symbolIndex, 0); - _entries.Add(entry); - } - } - } - - private void Read64(ElfReader reader) - { - var numberOfEntries = base.Size / OriginalTableEntrySize; - if (IsRelocationWithAddends) - { - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf64_Rela rel; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationAddendsEntry64Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var offset = reader.Decode(rel.r_offset); - - var r_info = reader.Decode(rel.r_info); - var type = new ElfRelocationType(Parent.Arch, (uint)(r_info & 0xFFFFFFFF)); - var symbolIndex = (uint)(r_info >> 32); - var addend = reader.Decode(rel.r_addend); - - var entry = new ElfRelocation(offset, type, symbolIndex, addend); - _entries.Add(entry); - } - } - else - { - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf64_Rel rel; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out rel)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteRelocationEntry64Size, $"Unable to read entirely the relocation entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var offset = reader.Decode(rel.r_offset); - - var r_info = reader.Decode(rel.r_info); - var type = new ElfRelocationType(Parent.Arch, (uint)(r_info & 0xFFFFFFFF)); - var symbolIndex = (uint)(r_info >> 32); - - var entry = new ElfRelocation(offset, type, symbolIndex, 0); - _entries.Add(entry); - } - } - } - - private void Write32(ElfWriter writer) - { - if (IsRelocationWithAddends) - { - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var rel = new ElfNative.Elf32_Rela(); - writer.Encode(out rel.r_offset, (uint)entry.Offset); - uint r_info = entry.Info32; - writer.Encode(out rel.r_info, r_info); - writer.Encode(out rel.r_addend, (int)entry.Addend); - writer.Write(rel); - } - } - else - { - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var rel = new ElfNative.Elf32_Rel(); - writer.Encode(out rel.r_offset, (uint)entry.Offset); - uint r_info = entry.Info32; - writer.Encode(out rel.r_info, r_info); - writer.Write(rel); - } - } - } - - private void Write64(ElfWriter writer) - { - if (IsRelocationWithAddends) - { - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var rel = new ElfNative.Elf64_Rela(); - writer.Encode(out rel.r_offset, entry.Offset); - ulong r_info = entry.Info64; - writer.Encode(out rel.r_info, r_info); - writer.Encode(out rel.r_addend, entry.Addend); - writer.Write(rel); - } - } - else - { - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var rel = new ElfNative.Elf64_Rel(); - writer.Encode(out rel.r_offset, (uint)entry.Offset); - ulong r_info = entry.Info64; - writer.Encode(out rel.r_info, r_info); - writer.Write(rel); - } - } - } - - protected override void AfterRead(ElfReader reader) - { - var name = Name.Value; - if (name == null) - { - return; - } - - var defaultName = GetDefaultName(Type); - - if (!name.StartsWith(defaultName)) - { - reader.Diagnostics.Warning(DiagnosticId.ELF_WRN_InvalidRelocationTablePrefixName, $"The name of the {Type} section `{this}` doesn't start with `{DefaultName}`"); - } - else - { - // Check the name of relocation - var currentTargetName = name.Substring(defaultName.Length); - var sectionTargetName = Info.Section?.Name.Value; - if (sectionTargetName != null && currentTargetName != sectionTargetName) - { - reader.Diagnostics.Warning(DiagnosticId.ELF_WRN_InvalidRelocationTablePrefixTargetName, $"Invalid name `{name}` for relocation table [{Index}] the current link section is named `{sectionTargetName}` so the expected name should be `{defaultName}{sectionTargetName}`", this); - } - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - //if (Info.Section == null) - //{ - // diagnostics.Error($"Invalid {nameof(Info)} of the section [{Index}] `{nameof(ElfRelocationTable)}` that cannot be null and must point to a valid section", this); - //} - //else - if (Info.Section != null && Info.Section.Parent != Parent) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationInfoParent, $"Invalid parent for the {nameof(Info)} of the section [{Index}] `{nameof(ElfRelocationTable)}`. It must point to the same {nameof(ElfObjectFile)} parent instance than this section parent", this); - } - - var symbolTable = Link.Section as ElfSymbolTable; - - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - if (entry.Addend != 0 && !IsRelocationWithAddends) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationEntryAddend, $"Invalid relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`. The addend != 0 while the section is not a `{ElfSectionType.RelocationAddends}`", this); - } - - if (entry.Type.Arch != Parent.Arch) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationEntryArch, $"Invalid Arch `{entry.Type.Arch}` for relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`. The arch doesn't match the arch `{Parent.Arch}`", this); - } - - if (symbolTable != null && entry.SymbolIndex > (uint)symbolTable.Entries.Count) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidRelocationSymbolIndex, $"Out of range symbol index `{entry.SymbolIndex}` (max: {symbolTable.Entries.Count + 1} from symbol table {symbolTable}) for relocation entry {i} in section [{Index}] `{nameof(ElfRelocationTable)}`", this); - } - } - } - - public override unsafe void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : - Parent.FileClass == ElfFileClass.Is32 - ? (ulong)Entries.Count * (IsRelocationWithAddends ? (ulong)sizeof(ElfNative.Elf32_Rela) : (ulong)sizeof(ElfNative.Elf32_Rel)) - : (ulong)Entries.Count * (IsRelocationWithAddends ? (ulong)sizeof(ElfNative.Elf64_Rela) : (ulong)sizeof(ElfNative.Elf64_Rel)); - - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs deleted file mode 100644 index 0b13a44bea43a8..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationTableExtensions.cs +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using LibObjectFile.Dwarf; - -namespace LibObjectFile.Elf -{ - /// - /// Extension methods for - /// - public static class ElfRelocationTableExtensions - { - /// - /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. - /// - public static void Relocate(this ElfRelocationTable relocTable, in ElfRelocationContext context) - { - var relocTarget = relocTable.Info.Section; - if (!(relocTarget is ElfBinarySection relocTargetBinarySection)) - { - throw new InvalidOperationException($"Invalid ElfRelocationTable.Info section. Can only relocate a section that inherits from {nameof(ElfBinarySection)}."); - } - - Relocate(relocTable, relocTargetBinarySection.Stream, context); - } - - /// - /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. - /// - /// - public static void Relocate(this ElfRelocationTable relocTable, Stream stream, in ElfRelocationContext context) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - - switch (relocTable.Parent.Arch.Value) - { - case ElfArch.X86_64: - ApplyX86_64(relocTable, stream, context); - break; - default: - throw new NotImplementedException($"The relocation for architecture {relocTable.Parent.Arch} is not supported/implemented."); - } - stream.Position = 0; - } - - /// - /// Applies the relocation defined by this table to the specified stream. The stream must be seekable and writeable. - /// - /// - private static void ApplyX86_64(this ElfRelocationTable relocTable, Stream stream, in ElfRelocationContext context) - { - if (stream == null) throw new ArgumentNullException(nameof(stream)); - bool isLsb = relocTable.Parent.Encoding == ElfEncoding.Lsb; - - var GOT = (long)context.GlobalObjectTableAddress; - var B = (long)context.BaseAddress; - var G = (long)context.GlobalObjectTableOffset; - - var symbolTable = (ElfSymbolTable)relocTable.Link.Section; - - foreach (var reloc in relocTable.Entries) - { - var P = (long)reloc.Offset; - var L = (long)context.ProcedureLinkageTableAddress + P; // TODO: Is it really that? - var A = reloc.Addend; - var symbol = symbolTable.Entries[(int)reloc.SymbolIndex - 1]; - var Z = (long)symbol.Size; - - var patchOffset = (long)reloc.Offset; - stream.Position = patchOffset; - - switch (reloc.Type.Value) - { - case ElfNative.R_X86_64_NONE: - case ElfNative.R_X86_64_COPY: - case ElfNative.R_X86_64_DTPMOD64: - case ElfNative.R_X86_64_DTPOFF64: - case ElfNative.R_X86_64_TPOFF64: - case ElfNative.R_X86_64_TLSGD: - case ElfNative.R_X86_64_TLSLD: - case ElfNative.R_X86_64_DTPOFF32: - case ElfNative.R_X86_64_GOTTPOFF: - case ElfNative.R_X86_64_TPOFF32: - break; - - case ElfNative.R_X86_64_64: // S + A - { - var S = (long) stream.ReadU64(isLsb); - stream.Position = patchOffset; - stream.WriteU64(isLsb, (ulong) (S + A)); - break; - } - case ElfNative.R_X86_64_PC32: // S + A - P - { - var S = (long) stream.ReadU32(isLsb); - stream.Position = patchOffset; - stream.WriteU32(isLsb, (uint) (S + A - P)); - break; - } - case ElfNative.R_X86_64_GOT32: // G + A - { - stream.WriteU32(isLsb, (uint) (G + A)); - break; - } - case ElfNative.R_X86_64_PLT32: // L + A - P - { - stream.WriteU32(isLsb, (uint) (L + A - P)); - break; - } - case ElfNative.R_X86_64_GLOB_DAT: // S - case ElfNative.R_X86_64_JUMP_SLOT: // S - break; - - case ElfNative.R_X86_64_RELATIVE: // B + A - { - stream.WriteU64(isLsb, (ulong) (B + A)); - break; - } - case ElfNative.R_X86_64_GOTPCREL: // G + GOT + A - P - { - stream.WriteU32(isLsb, (uint) (G + GOT + A - P)); - break; - } - case ElfNative.R_X86_64_32: // S + A - { - var S = (long) stream.ReadU32(isLsb); - stream.Position = patchOffset; - stream.WriteU32(isLsb, (uint) (S + A)); - break; - } - case ElfNative.R_X86_64_32S: // S + A - { - var S = (long) stream.ReadI32(isLsb); - stream.Position = patchOffset; - stream.WriteI32(isLsb, (int) (S + A)); - break; - } - case ElfNative.R_X86_64_16: // S + A - { - var S = (long) stream.ReadU16(isLsb); - stream.Position = patchOffset; - stream.WriteU16(isLsb, (ushort) (S + A)); - break; - } - case ElfNative.R_X86_64_PC16: // S + A - P - { - var S = (long) stream.ReadU16(isLsb); - stream.Position = patchOffset; - stream.WriteU16(isLsb, (ushort) (S + A - P)); - break; - } - case ElfNative.R_X86_64_8: // S + A - { - var S = (long) stream.ReadU8(); - stream.Position = patchOffset; - stream.WriteU8((byte) (S + A)); - break; - } - case ElfNative.R_X86_64_PC8: // S + A - P - { - var S = (long)stream.ReadU8(); - stream.Position = patchOffset; - stream.WriteU8((byte)(S + A - P)); - break; - } - - case ElfNative.R_X86_64_PC64: // S + A - P - { - var S = (long)stream.ReadU64(isLsb); - stream.Position = patchOffset; - stream.WriteU64(isLsb, (ulong)(S + A - P)); - break; - } - - case ElfNative.R_X86_64_GOTOFF64: // S + A - GOT - { - var S = (long)stream.ReadU64(isLsb); - stream.Position = patchOffset; - stream.WriteU64(isLsb, (ulong)(S + A - GOT)); - break; - } - case ElfNative.R_X86_64_GOTPC32: // GOT + A - P - stream.WriteU32(isLsb, (uint)(GOT + A - P)); - break; - - case ElfNative.R_X86_64_GOT64: // G + A - stream.WriteU64(isLsb, (ulong)(G + A)); - break; - - case ElfNative.R_X86_64_GOTPCREL64: // G + GOT - P + A - stream.WriteU64(isLsb, (ulong)(G + GOT - P + A)); - break; - - case ElfNative.R_X86_64_GOTPC64: // GOT - P + A - stream.WriteU64(isLsb, (ulong)(GOT - P + A)); - break; - - case ElfNative.R_X86_64_GOTPLT64: // G + A - stream.WriteU64(isLsb, (ulong)(G + A)); - break; - - case ElfNative.R_X86_64_PLTOFF64: // L - GOT + A - stream.WriteU64(isLsb, (ulong)(L - GOT + A)); - break; - - case ElfNative.R_X86_64_GOTPC32_TLSDESC: - case ElfNative.R_X86_64_TLSDESC_CALL: - case ElfNative.R_X86_64_TLSDESC: - break; - - case ElfNative.R_X86_64_RELATIVE64: // B + A - stream.WriteU64(isLsb, (ulong)(B + A)); - break; - - case ElfNative.R_X86_64_SIZE32: - stream.WriteU32(isLsb, (uint)(Z + A)); - break; - case ElfNative.R_X86_64_SIZE64: - stream.WriteU64(isLsb, (ulong)(Z + A)); - break; - - case ElfNative.R_X86_64_IRELATIVE: - default: - throw new NotImplementedException($"Relocation {reloc} not implemented/supported"); - } - } - - stream.Position = 0; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs deleted file mode 100644 index da37e22810ac4a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfRelocationType.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// Gets the type of a . - /// - public readonly partial struct ElfRelocationType : IEquatable - { - public ElfRelocationType(ElfArchEx arch, uint value) - { - Arch = arch; - Value = value; - } - - /// - /// The associated the applies to. - /// - public readonly ElfArchEx Arch; - - /// - /// The value of this relocation type. - /// - public readonly uint Value; - - public bool Equals(ElfRelocationType other) - { - return Arch.Equals(other.Arch) && Value == other.Value; - } - - public override bool Equals(object obj) - { - return obj is ElfRelocationType other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - return (Arch.GetHashCode() * 397) ^ (int) Value; - } - } - - public static bool operator ==(ElfRelocationType left, ElfRelocationType right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfRelocationType left, ElfRelocationType right) - { - return !left.Equals(right); - } - - public string Name => ToStringInternal(); - - public override string ToString() - { - if (Arch.Value == 0 && Value == 0) return "Empty ElfRelocationType"; - return ToStringInternal() ?? $"Unknown {nameof(ElfRelocationType)} (0x{Value:X4})"; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs deleted file mode 100644 index a0d41fe2283c92..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSectionHeaderStringTable.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// The Section Header String Table used by . - /// - public sealed class ElfSectionHeaderStringTable : ElfStringTable - { - public new const string DefaultName = ".shstrtab"; - - public ElfSectionHeaderStringTable() - { - Name = DefaultName; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs deleted file mode 100644 index 11fead1fbb9ce3..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfShadowSection.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// A shadow section is a section that will not be saved to the section header table but can contain data - /// that will be saved with the . - /// A shadow section is usually associated with an that is referencing a portion of - /// data that is not owned by a visible section. - /// - public abstract class ElfShadowSection : ElfSection - { - protected ElfShadowSection() : base(ElfSectionType.Null) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs deleted file mode 100644 index b7de66f4237b1b..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfStringTable.cs +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; - -namespace LibObjectFile.Elf -{ - /// - /// A string table section with the type . - /// - public class ElfStringTable : ElfSection - { - private readonly MemoryStream _table; - private readonly List _reservedStrings; - private readonly Dictionary _mapStringToIndex; - private readonly Dictionary _mapIndexToString; - - public const string DefaultName = ".strtab"; - - public const int DefaultCapacity = 256; - - public ElfStringTable() : this(DefaultCapacity) - { - } - - public ElfStringTable(int capacityInBytes) : base(ElfSectionType.StringTable) - { - if (capacityInBytes < 0) throw new ArgumentOutOfRangeException(nameof(capacityInBytes)); - Name = DefaultName; - _table = new MemoryStream(capacityInBytes); - _mapStringToIndex = new Dictionary(); - _mapIndexToString = new Dictionary(); - _reservedStrings = new List(); - // Always create an empty string - CreateIndex(string.Empty); - } - - public override ElfSectionType Type - { - get => base.Type; - set - { - if (value != ElfSectionType.StringTable) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfStringTable)}`. Only `{ElfSectionType.StringTable}` is valid"); - } - base.Type = value; - } - } - - public override void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - if (_reservedStrings.Count > 0) FlushReservedStrings(); - Size = (ulong)_table.Length; - } - - protected override void Read(ElfReader reader) - { - Debug.Assert(_table.Position == 1 && _table.Length == 1); - var length = (long) base.Size; - _table.SetLength(length); - var buffer = _table.GetBuffer(); - reader.Stream.Read(buffer, 0, (int)length); - _table.Position = _table.Length; - } - - protected override void Write(ElfWriter writer) - { - writer.Stream.Write(_table.GetBuffer(), 0, (int)_table.Length); - } - - internal void ReserveString(string text) - { - if (text is object && !_mapStringToIndex.ContainsKey(text)) - { - _reservedStrings.Add(text); - } - } - - internal void FlushReservedStrings() - { - // TODO: Use CollectionsMarshal.AsSpan - string[] reservedStrings = _reservedStrings.ToArray(); - - // Pre-sort the string based on their matching suffix - MultiKeySort(reservedStrings, 0); - - // Add the strings to string table - string lastText = null; - for (int i = 0; i < reservedStrings.Length; i++) - { - var text = reservedStrings[i]; - uint index; - if (lastText != null && lastText.EndsWith(text, StringComparison.Ordinal)) - { - // Suffix matches the last symbol - index = (uint)(_table.Length - Encoding.UTF8.GetByteCount(text) - 1); - _mapIndexToString.Add(index, text); - _mapStringToIndex.Add(text, index); - } - else - { - lastText = text; - CreateIndex(text); - } - } - - _reservedStrings.Clear(); - - static char TailCharacter(string str, int pos) - { - int index = str.Length - pos - 1; - if ((uint)index < str.Length) - return str[index]; - return '\0'; - } - - static void MultiKeySort(Span input, int pos) - { - if (!MultiKeySortSmallInput(input, pos)) - { - MultiKeySortLargeInput(input, pos); - } - } - - static void MultiKeySortLargeInput(Span input, int pos) - { - tailcall: - char pivot = TailCharacter(input[0], pos); - int l = 0, h = input.Length; - for (int i = 1; i < h;) - { - char c = TailCharacter(input[i], pos); - if (c > pivot) - { - (input[l], input[i]) = (input[i], input[l]); - l++; i++; - } - else if (c < pivot) - { - h--; - (input[h], input[i]) = (input[i], input[h]); - } - else - { - i++; - } - } - - MultiKeySort(input.Slice(0, l), pos); - MultiKeySort(input.Slice(h), pos); - if (pivot != '\0') - { - // Use a loop as a poor man's tailcall - // MultiKeySort(input.Slice(l, h - l), pos + 1); - pos++; - input = input.Slice(l, h - l); - if (!MultiKeySortSmallInput(input, pos)) - { - goto tailcall; - } - } - } - - static bool MultiKeySortSmallInput(Span input, int pos) - { - if (input.Length <= 1) - return true; - - // Optimize comparing two strings - if (input.Length == 2) - { - while (true) - { - char c0 = TailCharacter(input[0], pos); - char c1 = TailCharacter(input[1], pos); - if (c0 < c1) - { - (input[0], input[1]) = (input[1], input[0]); - break; - } - else if (c0 > c1 || c0 == (char)0) - { - break; - } - pos++; - } - return true; - } - - return false; - } - } - - private uint CreateIndex(string text) - { - uint index = (uint) _table.Length; - _mapIndexToString.Add(index, text); - _mapStringToIndex.Add(text, index); - - if (index == 0) - { - Debug.Assert(index == 0); - _table.WriteByte(0); - } - else - { - var reservedBytes = Encoding.UTF8.GetByteCount(text) + 1; - var buffer = ArrayPool.Shared.Rent(reservedBytes); - var span = new Span(buffer, 0, reservedBytes); - Encoding.UTF8.GetEncoder().GetBytes(text, span, true); - span[reservedBytes - 1] = 0; - if (_table.Position != index) - { - _table.Position = index; - } - _table.Write(span); - ArrayPool.Shared.Return(buffer); - } - - return index; - } - - public uint GetOrCreateIndex(string text) - { - // Same as empty string - if (text == null) return 0; - - if (_reservedStrings.Count > 0) FlushReservedStrings(); - - if (_mapStringToIndex.TryGetValue(text, out uint index)) - { - return index; - } - - return CreateIndex(text); - } - - public bool TryResolve(ElfString inStr, out ElfString outStr) - { - outStr = inStr; - if (inStr.Value != null) - { - outStr = inStr.WithIndex(GetOrCreateIndex(inStr.Value)); - } - else - { - if (TryFind(inStr.Index, out var text)) - { - outStr = inStr.WithName(text); - } - else - { - return false; - } - } - return true; - } - - public bool TryFind(uint index, out string text) - { - if (index == 0) - { - text = string.Empty; - return true; - } - - if (_reservedStrings.Count > 0) FlushReservedStrings(); - - if (_mapIndexToString.TryGetValue(index, out text)) - { - return true; - } - - if (index >= _table.Length) - { - return false; - } - - _table.Position = index; - - var buffer = _table.GetBuffer(); - var indexOfByte0 = Array.IndexOf(buffer, (byte)0, (int)index); - - if (indexOfByte0 < 0 || indexOfByte0 >= _table.Length) - { - indexOfByte0 = (int)(_table.Length - 1); - } - - var strLength = (int)(indexOfByte0 - index); - text = Encoding.UTF8.GetString(buffer, (int)index, strLength); - _mapIndexToString.Add(index, text); - - // Don't try to override an existing mapping - if (!_mapStringToIndex.TryGetValue(text, out var existingIndex)) - { - _mapStringToIndex.Add(text, index); - } - - return true; - } - - public void Reset() - { - _table.SetLength(0); - _mapStringToIndex.Clear(); - _mapIndexToString.Clear(); - _reservedStrings.Clear(); - - // Always create an empty string - CreateIndex(string.Empty); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs deleted file mode 100644 index 1cf390b51d15b4..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbol.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile.Elf -{ - /// - /// A symbol entry in the - /// This is the value seen in or - /// - public struct ElfSymbol : IEquatable - { - public static readonly ElfSymbol Empty = new ElfSymbol(); - - /// - /// Gets or sets the value associated to this symbol. - /// - public ulong Value { get; set; } - - /// - /// Gets or sets the size of this symbol. - /// - public ulong Size { get; set; } - - /// - /// Gets or sets the type of this symbol (e.g or ). - /// - public ElfSymbolType Type { get; set; } - - /// - /// Get or sets the binding applying to this symbol (e.g or ). - /// - public ElfSymbolBind Bind { get; set; } - - /// - /// Gets or sets the visibility of this symbol (e.g ) - /// - public ElfSymbolVisibility Visibility { get; set; } - - /// - /// Gets or sets the associated section to this symbol. - /// - public ElfSectionLink Section { get; set; } - - /// - /// Gets or sets the name of this symbol. - /// - public ElfString Name { get; set; } - - public override string ToString() - { - return $"{nameof(Value)}: 0x{Value:X16}, {nameof(Size)}: {Size:#####}, {nameof(Type)}: {Type}, {nameof(Bind)}: {Bind}, {nameof(Visibility)}: {Visibility}, {nameof(Section)}: {Section}, {nameof(Name)}: {Name}"; - } - - public bool Equals(ElfSymbol other) - { - return Value == other.Value && Size == other.Size && Type == other.Type && Bind == other.Bind && Visibility == other.Visibility && Section.Equals(other.Section) && Name == other.Name; - } - - public override bool Equals(object obj) - { - return obj is ElfSymbol other && Equals(other); - } - - public override int GetHashCode() - { - unchecked - { - var hashCode = Value.GetHashCode(); - hashCode = (hashCode * 397) ^ Size.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) Type; - hashCode = (hashCode * 397) ^ (int) Bind; - hashCode = (hashCode * 397) ^ (int) Visibility; - hashCode = (hashCode * 397) ^ Section.GetHashCode(); - hashCode = (hashCode * 397) ^ Name.GetHashCode(); - return hashCode; - } - } - - public static bool operator ==(ElfSymbol left, ElfSymbol right) - { - return left.Equals(right); - } - - public static bool operator !=(ElfSymbol left, ElfSymbol right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs deleted file mode 100644 index 742af667ff2b35..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolBind.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines a symbol binding - /// This is the value seen compressed in or - /// as well as the various defines (e.g ). - /// - public enum ElfSymbolBind : byte - { - /// - /// Local symbol - /// - Local = ElfNative.STB_LOCAL, - - /// - /// Global symbol - /// - Global = ElfNative.STB_GLOBAL, - - /// - /// Weak symbol - /// - Weak = ElfNative.STB_WEAK, - - /// - /// Unique symbol - /// - GnuUnique = ElfNative.STB_GNU_UNIQUE, - - /// - /// OS-specific 0 - /// - SpecificOS0 = ElfNative.STB_GNU_UNIQUE, - - /// - /// OS-specific 1 - /// - SpecificOS1 = ElfNative.STB_GNU_UNIQUE + 1, - - /// - /// OS-specific 2 - /// - SpecificOS2 = ElfNative.STB_GNU_UNIQUE + 2, - - /// - /// Processor-specific 0 - /// - SpecificProcessor0 = ElfNative.STB_LOPROC, - - /// - /// Processor-specific 1 - /// - SpecificProcessor1 = ElfNative.STB_LOPROC + 1, - - /// - /// Processor-specific 2 - /// - SpecificProcessor2 = ElfNative.STB_LOPROC + 2, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs deleted file mode 100644 index cd1c8f62b095f0..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTable.cs +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace LibObjectFile.Elf -{ - /// - /// A symbol table section with the type or - /// - public sealed class ElfSymbolTable : ElfSection - { - public const string DefaultName = ".symtab"; - - public ElfSymbolTable() : base(ElfSectionType.SymbolTable) - { - Name = DefaultName; - Entries = new List(); - Entries.Add(new ElfSymbol()); - } - - public override ElfSectionType Type - { - get => base.Type; - set - { - if (value != ElfSectionType.SymbolTable && value != ElfSectionType.DynamicLinkerSymbolTable) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfSymbolTable)}`. Only `{ElfSectionType.SymbolTable}` or `{ElfSectionType.DynamicLinkerSymbolTable}` are valid"); - } - base.Type = value; - } - } - - /// - /// Gets a list of entries. - /// - public List Entries { get; } - - public override unsafe ulong TableEntrySize => - Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : - Parent.FileClass == ElfFileClass.Is32 ? (ulong) sizeof(ElfNative.Elf32_Sym) : (ulong) sizeof(ElfNative.Elf64_Sym); - - protected override void Read(ElfReader reader) - { - if (Parent.FileClass == ElfFileClass.Is32) - { - Read32(reader); - } - else - { - Read64(reader); - } - } - - protected override void Write(ElfWriter writer) - { - if (Parent.FileClass == ElfFileClass.Is32) - { - Write32(writer); - } - else - { - Write64(writer); - } - } - - private void Read32(ElfReader reader) - { - var numberOfEntries = base.Size / OriginalTableEntrySize; - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf32_Sym sym; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out sym)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSymbolEntry32Size, $"Unable to read entirely the symbol entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var entry = new ElfSymbol(); - entry.Name = new ElfString(reader.Decode(sym.st_name)); - entry.Value = reader.Decode(sym.st_value); - entry.Size = reader.Decode(sym.st_size); - - var st_info = sym.st_info; - entry.Type = (ElfSymbolType) (st_info & 0xF); - entry.Bind = (ElfSymbolBind)(st_info >> 4); - entry.Visibility = (ElfSymbolVisibility) sym.st_other; - entry.Section = new ElfSectionLink(reader.Decode(sym.st_shndx)); - - // If the entry 0 was validated - if (i == 0 && entry == ElfSymbol.Empty) - { - continue; - } - - Entries.Add(entry); - } - } - - private void Read64(ElfReader reader) - { - var numberOfEntries = base.Size / OriginalTableEntrySize; - for (ulong i = 0; i < numberOfEntries; i++) - { - ElfNative.Elf64_Sym sym; - ulong streamOffset = (ulong)reader.Stream.Position; - if (!reader.TryReadData((int)OriginalTableEntrySize, out sym)) - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_IncompleteSymbolEntry64Size, $"Unable to read entirely the symbol entry [{i}] from {Type} section [{Index}]. Not enough data (size: {OriginalTableEntrySize}) read at offset {streamOffset} from the stream"); - } - - var entry = new ElfSymbol(); - entry.Name = new ElfString(reader.Decode(sym.st_name)); - entry.Value = reader.Decode(sym.st_value); - entry.Size = reader.Decode(sym.st_size); - - var st_info = sym.st_info; - entry.Type = (ElfSymbolType)(st_info & 0xF); - entry.Bind = (ElfSymbolBind)(st_info >> 4); - entry.Visibility = (ElfSymbolVisibility)sym.st_other; - entry.Section = new ElfSectionLink(reader.Decode(sym.st_shndx)); - - // If the entry 0 was validated - if (i == 0 && entry == ElfSymbol.Empty) - { - continue; - } - - Entries.Add(entry); - } - } - - - private void Write32(ElfWriter writer) - { - var stringTable = (ElfStringTable)Link.Section; - - // Write all entries - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var sym = new ElfNative.Elf32_Sym(); - writer.Encode(out sym.st_name, (ushort)stringTable.GetOrCreateIndex(entry.Name)); - writer.Encode(out sym.st_value, (uint)entry.Value); - writer.Encode(out sym.st_size, (uint)entry.Size); - sym.st_info = (byte)(((byte) entry.Bind << 4) | (byte) entry.Type); - sym.st_other = (byte) ((byte) entry.Visibility & 3); - var sectionIndex = entry.Section.GetIndex(); - writer.Encode(out sym.st_shndx, sectionIndex < ElfNative.SHN_LORESERVE || entry.Section.IsSpecial ? (ElfNative.Elf32_Half)sectionIndex : (ElfNative.Elf32_Half)ElfNative.SHN_XINDEX); - - writer.Write(sym); - } - } - - private void Write64(ElfWriter writer) - { - var stringTable = (ElfStringTable)Link.Section; - - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - var sym = new ElfNative.Elf64_Sym(); - writer.Encode(out sym.st_name, stringTable.GetOrCreateIndex(entry.Name)); - writer.Encode(out sym.st_value, entry.Value); - writer.Encode(out sym.st_size, entry.Size); - sym.st_info = (byte)(((byte)entry.Bind << 4) | (byte)entry.Type); - sym.st_other = (byte)((byte)entry.Visibility & 3); - var sectionIndex = entry.Section.GetIndex(); - writer.Encode(out sym.st_shndx, sectionIndex < ElfNative.SHN_LORESERVE || entry.Section.IsSpecial ? (ElfNative.Elf64_Half)sectionIndex : (ElfNative.Elf64_Half)ElfNative.SHN_XINDEX); - - writer.Write(sym); - } - } - - protected override void AfterRead(ElfReader reader) - { - // Verify that the link is safe and configured as expected - Link.TryGetSectionSafe(nameof(ElfSymbolTable), nameof(Link), this, reader.Diagnostics, out var stringTable, ElfSectionType.StringTable); - - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - if (stringTable != null) - { - if (stringTable.TryResolve(entry.Name, out var newEntry)) - { - entry.Name = newEntry; - } - else - { - reader.Diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntryNameIndex, $"Invalid name index [{entry.Name.Index}] for symbol [{i}] in section [{this}]"); - } - } - - if (entry.Section.SpecialIndex < ElfNative.SHN_LORESERVE) - { - entry.Section = reader.ResolveLink(entry.Section, $"Invalid link section index {entry.Section.SpecialIndex} for symbol table entry [{i}] from symbol table section [{this}]"); - } - - Entries[i] = entry; - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - // Verify that the link is safe and configured as expected - if (!Link.TryGetSectionSafe(nameof(ElfSymbolTable), nameof(Link), this, diagnostics, out var stringTable, ElfSectionType.StringTable)) - { - return; - } - - bool isAllowingLocal = true; - bool needsSectionHeaderIndices = false; - - for (int i = 0; i < Entries.Count; i++) - { - var entry = Entries[i]; - - if (i == 0 && entry != ElfSymbol.Empty) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidFirstSymbolEntryNonNull, $"Invalid entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The first entry must be null/undefined"); - } - - if (entry.Section.Section != null) - { - if (entry.Section.Section.Parent != Parent) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntrySectionParent, $"Invalid section for the symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. The section of the entry `{entry}` must the same than this symbol table section"); - } - - needsSectionHeaderIndices |= entry.Section.GetIndex() >= ElfNative.SHN_LORESERVE; - } - - stringTable.ReserveString(entry.Name); - - // Update the last local index - if (entry.Bind == ElfSymbolBind.Local) - { - // + 1 For the plus one - Info = new ElfSectionLink((uint)(i + 1)); - if (!isAllowingLocal) - { - diagnostics.Error(DiagnosticId.ELF_ERR_InvalidSymbolEntryLocalPosition, $"Invalid position for the LOCAL symbol entry #{i} in the {nameof(ElfSymbolTable)} section [{Index}]. A LOCAL symbol entry must be before any other symbol entry"); - } - } - else - { - isAllowingLocal = false; - } - } - - if (needsSectionHeaderIndices) - { - bool foundSectionHeaderIndices = false; - foreach (ElfSection otherSection in Parent.Sections) - { - if (otherSection is ElfSymbolTableSectionHeaderIndices && otherSection.Link.Section == this) - { - foundSectionHeaderIndices = true; - break; - } - } - - if (!foundSectionHeaderIndices) - { - diagnostics.Error(DiagnosticId.ELF_ERR_MissingSectionHeaderIndices, $"Symbol table [{Name.Value}] references section indexes higher than SHN_LORESERVE and accompanying {nameof(ElfSymbolTableSectionHeaderIndices)} section is missing"); - } - } - } - - public override unsafe void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : - Parent.FileClass == ElfFileClass.Is32 ? (ulong)(Entries.Count * sizeof(ElfNative.Elf32_Sym)) : (ulong)(Entries.Count * sizeof(ElfNative.Elf64_Sym)); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs deleted file mode 100644 index 483c529456fd04..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolTableSectionHeaderIndices.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace LibObjectFile.Elf -{ - /// - /// A section with the type - /// - public sealed class ElfSymbolTableSectionHeaderIndices : ElfSection - { - public const string DefaultName = ".symtab_shndx"; - - private readonly List _entries; - - public ElfSymbolTableSectionHeaderIndices() : base(ElfSectionType.SymbolTableSectionHeaderIndices) - { - Name = DefaultName; - _entries = new List(); - } - - public override ElfSectionType Type - { - get => base.Type; - set - { - if (value != ElfSectionType.SymbolTableSectionHeaderIndices) - { - throw new ArgumentException($"Invalid type `{Type}` of the section [{Index}] `{nameof(ElfSymbolTableSectionHeaderIndices)}`. Only `{ElfSectionType.SymbolTableSectionHeaderIndices}` is valid"); - } - base.Type = value; - } - } - - public override unsafe ulong TableEntrySize => sizeof(uint); - - protected override void Read(ElfReader reader) - { - var numberOfEntries = base.Size / TableEntrySize; - _entries.Clear(); - _entries.Capacity = (int)numberOfEntries; - for (ulong i = 0; i < numberOfEntries; i++) - { - _entries.Add(reader.ReadU32()); - } - } - - protected override void Write(ElfWriter writer) - { - // Write all entries - for (int i = 0; i < _entries.Count; i++) - { - writer.WriteU32(_entries[i]); - } - } - - protected override void AfterRead(ElfReader reader) - { - // Verify that the link is safe and configured as expected - Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, reader.Diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); - - for (int i = 0; i < _entries.Count; i++) - { - var entry = _entries[i]; - if (entry != 0) - { - var resolvedLink = reader.ResolveLink(new ElfSectionLink(entry), $"Invalid link section index {entry} for symbol table entry [{i}] from symbol table section [{this}]"); - - // Update the link in symbol table - var symbolTableEntry = symbolTable.Entries[i]; - symbolTableEntry.Section = resolvedLink; - symbolTable.Entries[i] = symbolTableEntry; - } - } - } - - public override void Verify(DiagnosticBag diagnostics) - { - base.Verify(diagnostics); - - // Verify that the link is safe and configured as expected - if (!Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable)) - { - return; - } - } - - public override unsafe void UpdateLayout(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - - // Verify that the link is safe and configured as expected - Link.TryGetSectionSafe(nameof(ElfSymbolTableSectionHeaderIndices), nameof(Link), this, diagnostics, out var symbolTable, ElfSectionType.SymbolTable, ElfSectionType.DynamicLinkerSymbolTable); - - int numberOfEntries = 0; - for (int i = 0; i < symbolTable.Entries.Count; i++) - { - if (symbolTable.Entries[i].Section.Section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) - { - numberOfEntries = i + 1; - } - } - - _entries.Capacity = numberOfEntries; - _entries.Clear(); - - for (int i = 0; i < numberOfEntries; i++) - { - var section = symbolTable.Entries[i].Section.Section; - if (section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) - { - _entries.Add(section.SectionIndex); - } - else - { - _entries.Add(0); - } - } - - Size = Parent == null || Parent.FileClass == ElfFileClass.None ? 0 : (ulong)numberOfEntries * sizeof(uint); - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs deleted file mode 100644 index df20d20575dedf..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolType.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines a symbol type. - /// This is the value seen compressed in or - /// as well as the various defines (e.g ). - /// - public enum ElfSymbolType : byte - { - /// - /// Symbol type is unspecified - /// - NoType = ElfNative.STT_NOTYPE, - - /// - /// Symbol is a data object - /// - Object = ElfNative.STT_OBJECT, - - /// - /// Symbol is a code object - /// - Function = ElfNative.STT_FUNC, - - /// - /// Symbol associated with a section - /// - Section = ElfNative.STT_SECTION, - - /// - /// Symbol's name is file name - /// - File = ElfNative.STT_FILE, - - /// - /// Symbol is a common data object - /// - Common = ElfNative.STT_COMMON, - - /// - /// Symbol is thread-local data object - /// - Tls = ElfNative.STT_TLS, - - /// - /// Symbol is indirect code object - /// - GnuIndirectFunction = ElfNative.STT_GNU_IFUNC, - - /// - /// OS-specific 0 - /// - SpecificOS0 = ElfNative.STT_GNU_IFUNC, - - /// - /// OS-specific 1 - /// - SpecificOS1 = ElfNative.STT_GNU_IFUNC + 1, - - /// - /// OS-specific 2 - /// - SpecificOS2 = ElfNative.STT_GNU_IFUNC + 2, - - /// - /// Processor-specific 0 - /// - SpecificProcessor0 = ElfNative.STT_LOPROC, - - /// - /// Processor-specific 1 - /// - SpecificProcessor1 = ElfNative.STT_LOPROC + 1, - - /// - /// Processor-specific 2 - /// - SpecificProcessor2 = ElfNative.STT_LOPROC + 2, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs deleted file mode 100644 index 08d372528aa2df..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Elf/Sections/ElfSymbolVisibility.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile.Elf -{ - /// - /// Defines the visibility of a symbol - /// This is the value seen compressed in or - /// as well as the various defines (e.g ). - /// - public enum ElfSymbolVisibility : byte - { - /// - /// Default symbol visibility rules - /// - Default = ElfNative.STV_DEFAULT, - - /// - /// Processor specific hidden class - /// - Internal = ElfNative.STV_INTERNAL, - - /// - /// Sym unavailable in other modules - /// - Hidden = ElfNative.STV_HIDDEN, - - /// - /// Not preemptible, not exported - /// - Protected = ElfNative.STV_PROTECTED, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs deleted file mode 100644 index 5b8d364568ddcd..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/IObjectFileNodeLink.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - public interface IObjectFileNodeLink - { - ulong GetRelativeOffset(); - - ObjectFileNode GetObjectFileNode(); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj deleted file mode 100644 index be7c9ea8498eb6..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - net7.0 - true - - - - LibObjectFile is a .NET library to read, manipulate and write linker and executable object files (e.g ELF, ar, DWARF, COFF...) - Alexandre Mutel - en-US - Alexandre Mutel - ELF DWARF ar archive objectfile - BSD-2-Clause - readme.md - logo.png - https://github.com/xoofx/LibObjectFile - - true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - - true - - - - - - - - - - - - - diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings deleted file mode 100644 index 02a34e61ff2c46..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/LibObjectFile.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs deleted file mode 100644 index 10f0b5838b1f31..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileException.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; - -namespace LibObjectFile -{ - /// - /// An exception used when diagnostics error are happening during read/write. - /// - public class ObjectFileException : Exception - { - public ObjectFileException(string message, DiagnosticBag diagnostics) : base(message) - { - - Diagnostics = diagnostics ?? throw new ArgumentNullException(nameof(diagnostics)); - } - - public override string Message => base.Message + Environment.NewLine + Diagnostics; - - /// - /// The associated diagnostics messages. - /// - public DiagnosticBag Diagnostics { get; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs deleted file mode 100644 index fda135aad89973..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileExtensions.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Collections.Generic; - -namespace LibObjectFile -{ - public static class ObjectFileExtensions - { - /// - /// Adds an attribute to . - /// - /// A attribute - public static void Add(this List list, TParent parent, TChild element) where TChild : ObjectFileNode where TParent: ObjectFileNode - { - if (element == null) throw new ArgumentNullException(nameof(element)); - if (element.Parent != null) - { - if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); - if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); - } - - element.Parent = parent; - element.Index = (uint)list.Count; - list.Add(element); - } - - /// - /// Adds an element to the sorted list - /// - /// An element to add - public static void AddSorted(this List list, TParent parent, TChild element, bool requiresUnique = false) where TChild : ObjectFileNode, IComparable where TParent : ObjectFileNode - { - if (element == null) throw new ArgumentNullException(nameof(element)); - if (element.Parent != null) - { - if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); - if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); - } - - int index; - - // Optimistic case, we add in order - if (list.Count == 0 || list[^1].CompareTo(element) < 0) - { - element.Parent = parent; - index = list.Count; - list.Add(element); - } - else - { - index = list.BinarySearch(element); - if (index < 0) - index = ~index; - else if (requiresUnique && list[index].CompareTo(element) == 0) - { - throw new InvalidOperationException($"A similar element to `{element}` has been already added to this collection at index {index}"); - } - - element.Parent = parent; - list.Insert(index, element); - } - - element.Index = (uint)index; - - // Update the index of following attributes - for (int i = index + 1; i < list.Count; i++) - { - var nextAttribute = list[i]; - nextAttribute.Index++; - } - } - - /// - /// Inserts an attribute into at the specified index. - /// - /// Index into to insert the specified attribute - /// The attribute to insert - public static void InsertAt(this List list, TParent parent, int index, TChild element) where TChild : ObjectFileNode where TParent : ObjectFileNode - { - if (index < 0 || index > list.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {list.Count}"); - if (element == null) throw new ArgumentNullException(nameof(element)); - if (element.Parent != null) - { - if (element.Parent == parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added"); - if (element.Parent != parent) throw new InvalidOperationException($"Cannot add the {element.GetType()} as it is already added to another {parent.GetType()} instance"); - } - - element.Index = (uint)index; - list.Insert(index, element); - element.Parent = parent; - - // Update the index of following attributes - for (int i = index + 1; i < list.Count; i++) - { - var nextAttribute = list[i]; - nextAttribute.Index++; - } - } - - /// - /// Removes an attribute from - /// - /// The attribute to remove - public static void Remove(this List list, TParent parent, TChild child) where TChild : ObjectFileNode where TParent : ObjectFileNode - { - if (child == null) throw new ArgumentNullException(nameof(child)); - if (!ReferenceEquals(child.Parent, parent)) - { - throw new InvalidOperationException($"Cannot remove the {nameof(TChild)} as it is not part of this {parent.GetType()} instance"); - } - - var i = (int)child.Index; - list.RemoveAt(i); - child.Index = 0; - - // Update indices for other sections - for (int j = i + 1; j < list.Count; j++) - { - var nextEntry = list[j]; - nextEntry.Index--; - } - - child.Parent = null; - } - - /// - /// Removes an attribute from at the specified index. - /// - /// Index into to remove the specified attribute - public static TChild RemoveAt(this List list, TParent parent, int index) where TChild : ObjectFileNode where TParent : ObjectFileNode - { - if (index < 0 || index > list.Count) throw new ArgumentOutOfRangeException(nameof(index), $"Invalid index {index}, Must be >= 0 && <= {list.Count}"); - var child = list[index]; - Remove(list, parent, child); - return child; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs deleted file mode 100644 index 72030cffbc3143..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileNode.cs +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace LibObjectFile -{ - public abstract class ObjectFileNode - { - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private ObjectFileNode _parent; - - /// - /// Gets or sets the offset of this section or segment in the parent . - /// - public ulong Offset { get; set; } - - /// - /// Gets the containing parent. - /// - public ObjectFileNode Parent - { - get => _parent; - - internal set - { - if (value == null) - { - _parent = null; - } - else - { - ValidateParent(value); - } - - _parent = value; - } - } - - protected virtual void ValidateParent(ObjectFileNode parent) - { - } - - /// - /// Index within the containing list in the - /// - public uint Index { get; internal set; } - - /// - /// Gets or sets the size of this section or segment in the parent . - /// - public virtual ulong Size { get; set; } - - /// - /// Checks if the specified offset is contained by this instance. - /// - /// The offset to check if it belongs to this instance. - /// true if the offset is within the segment or section range. - public bool Contains(ulong offset) - { - return offset >= Offset && offset < Offset + Size; - } - - /// - /// Checks this instance contains either the beginning or the end of the specified section or segment. - /// - /// The specified section or segment. - /// true if the either the offset or end of the part is within this segment or section range. - public bool Contains(ObjectFileNode node) - { - if (node == null) throw new ArgumentNullException(nameof(node)); - return Contains((ulong)node.Offset) || node.Size != 0 && Contains((ulong)(node.Offset + node.Size - 1)); - } - - /// - /// Verifies the integrity of this file. - /// - /// The result of the diagnostics - public DiagnosticBag Verify() - { - var diagnostics = new DiagnosticBag(); - Verify(diagnostics); - return diagnostics; - } - - /// - /// Verifies the integrity of this file. - /// - /// A DiagnosticBag instance to receive the diagnostics. - public virtual void Verify(DiagnosticBag diagnostics) - { - if (diagnostics == null) throw new ArgumentNullException(nameof(diagnostics)); - } - - protected static void AttachChild(TParent parent, T child, ref T field, bool allowNull) where T : ObjectFileNode where TParent : ObjectFileNode - { - if (parent == null) throw new ArgumentNullException(nameof(parent)); - if (!allowNull && child == null) throw new ArgumentNullException(nameof(child)); - - if (field != null) - { - field.Parent = null; - } - - if (child?.Parent != null) throw new InvalidOperationException($"Cannot set the {child.GetType()} as it already belongs to another {child.Parent.GetType()} instance"); - field = child; - - if (child != null) - { - child.Parent = parent; - } - } - } - - ///// - ///// Base class for a part of a file. - ///// - //public abstract class ObjectFileNode : ObjectFileNode where TParentFile : ObjectFileNode - //{ - // protected override void ValidateParent(ObjectFileNode parent) - // { - // if (!(parent is TParentFile)) - // { - // throw new ArgumentException($"Parent must inherit from type {nameof(TParentFile)}"); - // } - // } - - // internal void UpdateLayoutInternal(TLayoutContext layout) - // { - // UpdateLayoutImpl(layout); - // } - - // /// - // /// Updates the layout of this object. - // /// - // /// The layout context of this object. - // protected abstract void UpdateLayoutImpl(TLayoutContext layout); - - // /// - // /// Gets the containing . Might be null if this section or segment - // /// does not belong to an existing . - // /// - // [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)] - // public new TParentFile Parent - // { - // get => (TParentFile) base.Parent; - // internal set => base.Parent = value; - // } - //} -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs deleted file mode 100644 index 3e6ff927e303b7..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileReaderWriter.cs +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Buffers.Binary; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using LibObjectFile.Utils; - -namespace LibObjectFile -{ - /// - /// Base class used for reading / writing an object file to/from a stream. - /// - public abstract class ObjectFileReaderWriter - { - private Stream _stream; - - protected ObjectFileReaderWriter(Stream stream) : this(stream, new DiagnosticBag()) - { - } - - protected ObjectFileReaderWriter(Stream stream, DiagnosticBag diagnostics) - { - Stream = stream; - Diagnostics = diagnostics; - IsLittleEndian = true; - } - - /// - /// Gets or sets stream of the object file. - /// - public Stream Stream - { - get => _stream; - set => _stream = value; - } - - public ulong Offset - { - get => (ulong) Stream.Position; - set => Stream.Position = (long) value; - } - - public ulong Length - { - get => (ulong) Stream.Length; - } - - /// - /// The diagnostics while read/writing this object file. - /// - public DiagnosticBag Diagnostics { get; protected set; } - - /// - /// Gets a boolean indicating if this reader is operating in read-only mode. - /// - public abstract bool IsReadOnly { get; } - - public bool IsLittleEndian { get; protected set; } - - public TextWriter Log { get; set; } - - /// - /// Reads from the and current position to the specified buffer. - /// - /// The buffer to receive the content of the read. - /// The offset into the buffer. - /// The number of bytes to write from the buffer. - public int Read(byte[] buffer, int offset, int count) - { - return Stream.Read(buffer, offset, count); - } - - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// true if the string was successfully read from the stream, false otherwise - public string ReadStringUTF8NullTerminated() - { - return Stream.ReadStringUTF8NullTerminated(); - } - - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// The number of bytes to read including the null - /// A string - public string ReadStringUTF8NullTerminated(uint byteLength) - { - return Stream.ReadStringUTF8NullTerminated(byteLength); - } - - public byte ReadU8() - { - return Stream.ReadU8(); - } - - public sbyte ReadI8() - { - return Stream.ReadI8(); - } - - public short ReadI16() - { - return Stream.ReadI16(IsLittleEndian); - } - - public ushort ReadU16() - { - return Stream.ReadU16(IsLittleEndian); - } - - public int ReadI32() - { - return Stream.ReadI32(IsLittleEndian); - } - - public uint ReadU32() - { - return Stream.ReadU32(IsLittleEndian); - } - - public long ReadI64() - { - return Stream.ReadI64(IsLittleEndian); - } - - public ulong ReadU64() - { - return Stream.ReadU64(IsLittleEndian); - } - - public void WriteI8(sbyte value) - { - Stream.WriteI8(value); - } - - public void WriteU8(byte value) - { - Stream.WriteU8(value); - } - - public void WriteU16(ushort value) - { - Stream.WriteU16(IsLittleEndian, value); - } - - public void WriteU32(uint value) - { - Stream.WriteU32(IsLittleEndian, value); - } - - public void WriteU64(ulong value) - { - Stream.WriteU64(IsLittleEndian, value); - } - - /// - /// Writes a null terminated UTF8 string to the stream. - /// - public void WriteStringUTF8NullTerminated(string text) - { - Stream.WriteStringUTF8NullTerminated(text); - } - - /// - /// Tries to read an element of type with a specified size. - /// - /// Type of the element to read. - /// Size of the element to read (might be smaller or bigger). - /// The data read. - /// true if reading was successful. false otherwise. - public unsafe bool TryReadData(int sizeToRead, out T data) where T : unmanaged - { - if (sizeToRead <= 0) throw new ArgumentOutOfRangeException(nameof(sizeToRead)); - - int dataByteCount = sizeof(T); - int byteRead; - - // If we are requested to read more data than the sizeof(T) - // we need to read it to an intermediate buffer before transferring it to T data - if (sizeToRead > dataByteCount) - { - var buffer = ArrayPool.Shared.Rent(sizeToRead); - var span = new Span(buffer, 0, sizeToRead); - byteRead = Stream.Read(span); - data = MemoryMarshal.Cast(span)[0]; - ArrayPool.Shared.Return(buffer); - } - else - { - // Clear the data if the size requested is less than the expected struct to read - if (sizeToRead < dataByteCount) - { - data = default; - } - - fixed (void* pData = &data) - { - var span = new Span(pData, sizeToRead); - byteRead = Stream.Read(span); - } - } - return byteRead == sizeToRead; - } - - /// - /// Reads from the current bytes and return the data as - /// a if is false otherwise as a - /// . - /// - /// Size of the data to read. - /// A if is false otherwise as a - /// . - public Stream ReadAsStream(ulong size) - { - if (IsReadOnly) - { - var stream = ReadAsSliceStream(size); - Stream.Position += stream.Length; - return stream; - } - - return ReadAsMemoryStream(size); - } - - /// - /// Writes to the and current position from the specified buffer. - /// - /// The buffer to write the content from. - /// The offset into the buffer. - /// The number of bytes to read from the buffer and write to the stream. - public void Write(byte[] buffer, int offset, int count) - { - Stream.Write(buffer, offset, count); - } - - /// - /// Writes an element of type to the stream. - /// - /// Type of the element to read. - /// The data to write. - public unsafe void Write(in T data) where T : unmanaged - { - fixed (void* pData = &data) - { - var span = new ReadOnlySpan(pData, sizeof(T)); - Stream.Write(span); - } - } - - /// - /// Writes from the specified stream to the current of this instance. - /// The position of the input stream is set to 0 before writing and reset back to 0 after writing. - /// - /// The input stream to read from and write to - /// The amount of data to read from the input stream (if == 0, by default, it will read the entire input stream) - /// The size of the intermediate buffer used to transfer the data. - public void Write(Stream inputStream, ulong size = 0, int bufferSize = 4096) - { - if (inputStream == null) throw new ArgumentNullException(nameof(inputStream)); - if (bufferSize <= 0) throw new ArgumentOutOfRangeException(nameof(bufferSize)); - - inputStream.Position = 0; - size = size == 0 ? (ulong)inputStream.Length : size; - var buffer = ArrayPool.Shared.Rent(bufferSize); - - while (size != 0) - { - var sizeToRead = size >= (ulong)buffer.Length ? buffer.Length : (int)size; - var sizeRead = inputStream.Read(buffer, 0, sizeToRead); - if (sizeRead <= 0) break; - - Stream.Write(buffer, 0, sizeRead); - size -= (ulong)sizeRead; - } - - inputStream.Position = 0; - if (size != 0) - { - throw new InvalidOperationException("Unable to write stream entirely"); - } - } - - private SliceStream ReadAsSliceStream(ulong size) - { - var position = Stream.Position; - if (position + (long)size > Stream.Length) - { - if (position < Stream.Length) - { - size = Stream.Position < Stream.Length ? (ulong)(Stream.Length - Stream.Position) : 0; - Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Expecting to slice {size} bytes at offset {position} while remaining length is {size}"); - } - else - { - position = Stream.Length; - size = 0; - Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Position of slice {position} is outside of the stream length {Stream.Length} in bytes"); - } - } - - return new SliceStream(Stream, position, (long)size); - } - - private MemoryStream ReadAsMemoryStream(ulong size) - { - var memoryStream = new MemoryStream((int)size); - if (size == 0) return memoryStream; - - memoryStream.SetLength((long)size); - - var buffer = memoryStream.GetBuffer(); - while (size != 0) - { - var lengthToRead = size >= int.MaxValue ? int.MaxValue : (int)size; - var lengthRead = Stream.Read(buffer, 0, lengthToRead); - if (lengthRead < 0) break; - if ((uint)lengthRead >= size) - { - size -= (uint)lengthRead; - } - else - { - break; - } - } - - if (size != 0) - { - Diagnostics.Error(DiagnosticId.CMN_ERR_UnexpectedEndOfFile, $"Unexpected end of file. Expecting to read {size} bytes at offset {Stream.Position}"); - } - - return memoryStream; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs deleted file mode 100644 index 027abd2d544356..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ObjectFileStreamExtensions.cs +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Buffers.Binary; -using System.IO; -using System.Text; -using LibObjectFile.Utils; - -namespace LibObjectFile -{ - public static class ObjectFileStreamExtensions - { - public static byte ReadU8(this Stream stream) - { - int nextValue = stream.ReadByte(); - if (nextValue < 0) throw new EndOfStreamException(); - return (byte)nextValue; - } - - public static void WriteU8(this Stream stream, byte value) - { - stream.WriteByte(value); - } - - public static sbyte ReadI8(this Stream stream) - { - int nextValue = stream.ReadByte(); - if (nextValue < 0) throw new EndOfStreamException(); - return (sbyte)nextValue; - } - - public static void WriteI8(this Stream stream, sbyte value) - { - stream.WriteByte((byte)value); - } - - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// true if the string was successfully read from the stream, false otherwise - public static string ReadStringUTF8NullTerminated(this Stream stream) - { - var buffer = ArrayPool.Shared.Rent((int)128); - int textLength = 0; - try - { - while (true) - { - int nextByte = stream.ReadByte(); - if (nextByte < 0) - { - throw new EndOfStreamException("Unexpected end of stream while trying to read a null terminated UTF8 string"); - } - - if (nextByte == 0) - { - break; - } - - if (textLength >= buffer.Length) - { - var newBuffer = ArrayPool.Shared.Rent((int)textLength * 2); - Array.Copy(buffer, 0, newBuffer, 0, buffer.Length); - ArrayPool.Shared.Return(buffer); - buffer = newBuffer; - } - - buffer[textLength++] = (byte)nextByte; - } - - return Encoding.UTF8.GetString(buffer, 0, textLength); - } - finally - { - ArrayPool.Shared.Return(buffer); - } - } - - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// The number of bytes to read including the null - /// A string - public static string ReadStringUTF8NullTerminated(this Stream stream, uint byteLength) - { - if (byteLength == 0) return string.Empty; - - var buffer = ArrayPool.Shared.Rent((int)byteLength); - try - { - var dataLength = stream.Read(buffer, 0, (int)byteLength); - if (dataLength < 0) throw new EndOfStreamException("Unexpected end of stream while trying to read data"); - - var byteReadLength = (uint)dataLength; - if (byteReadLength != byteLength) throw new EndOfStreamException($"Not enough data read {byteReadLength} bytes while expecting to read {byteLength} bytes"); - - var isNullTerminated = buffer[byteReadLength - 1] == 0; - - var text = Encoding.UTF8.GetString(buffer, 0, (int)(isNullTerminated ? byteReadLength - 1 : byteReadLength)); - return text; - } - finally - { - ArrayPool.Shared.Return(buffer); - } - } - - - public static short ReadI16(this Stream stream, bool isLittleEndian) - { - return (short) ReadU16(stream, isLittleEndian); - } - - public static ushort ReadU16(this Stream stream, bool isLittleEndian) - { - ushort value = 0; - int nextValue = stream.ReadByte(); - if (nextValue < 0) throw new EndOfStreamException(); - value = (byte)nextValue; - - nextValue = stream.ReadByte(); - if (nextValue < 0) throw new EndOfStreamException(); - value = (ushort)((nextValue << 8) | (byte)value); - - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - - return value; - } - - public static int ReadI32(this Stream stream, bool isLittleEndian) - { - return (int)ReadU32(stream, isLittleEndian); - } - - public static unsafe uint ReadU32(this Stream stream, bool isLittleEndian) - { - uint value = 0; - var span = new Span((byte*)&value, sizeof(uint)); - if (stream.Read(span) != sizeof(uint)) - { - throw new EndOfStreamException(); - } - - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - return value; - } - public static long ReadI64(this Stream stream, bool isLittleEndian) - { - return (long)ReadU64(stream, isLittleEndian); - } - - public static unsafe ulong ReadU64(this Stream stream, bool isLittleEndian) - { - ulong value = 0; - var span = new Span((byte*)&value, sizeof(ulong)); - if (stream.Read(span) != sizeof(ulong)) - { - throw new EndOfStreamException(); - } - - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - return value; - } - - public static unsafe void WriteU16(this Stream stream, bool isLittleEndian, ushort value) - { - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - var span = new Span((byte*)&value, sizeof(ushort)); - stream.Write(span); - } - - public static void WriteI32(this Stream stream, bool isLittleEndian, int value) - { - WriteU32(stream, isLittleEndian, (uint)value); - } - - public static unsafe void WriteU32(this Stream stream, bool isLittleEndian, uint value) - { - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - var span = new Span((byte*)&value, sizeof(uint)); - stream.Write(span); - } - - public static unsafe void WriteU64(this Stream stream, bool isLittleEndian, ulong value) - { - if (isLittleEndian != BitConverter.IsLittleEndian) - { - value = BinaryPrimitives.ReverseEndianness(value); - } - var span = new Span((byte*)&value, sizeof(ulong)); - stream.Write(span); - } - - /// - /// Writes a null terminated UTF8 string to the stream. - /// - public static void WriteStringUTF8NullTerminated(this Stream stream, string text) - { - if (text == null) throw new ArgumentNullException(nameof(text)); - - int byteLength = Encoding.UTF8.GetByteCount(text); - var buffer = ArrayPool.Shared.Rent(byteLength + 1); - try - { - Encoding.UTF8.GetBytes(text, 0, text.Length, buffer, 0); - buffer[byteLength] = 0; - stream.Write(buffer, 0, byteLength + 1); - } - finally - { - ArrayPool.Shared.Return(buffer); - } - } - - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs deleted file mode 100644 index 78cd8e593d244f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/RelocationSize.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - public enum RelocationSize - { - I8, - I16, - I32, - I64, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs deleted file mode 100644 index e2daf539389b98..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/AlignHelper.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Runtime.CompilerServices; - -namespace LibObjectFile.Utils -{ - /// - /// Helper class to perform alignment. - /// - public static class AlignHelper - { - /// - /// Returns true if alignment is a power of 2. - /// - /// The alignment - /// true if it is a power of 2. - public static bool IsPowerOfTwo(ulong align) - { - return (align & (align - 1)) == 0; - } - - /// - /// Aligns a value to the required alignment. - /// - /// The value to align. - /// The alignment. - /// The value aligned or unchanged it is was already aligned. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong AlignToUpper(ulong value, ulong align) - { - if (align == 0) throw new ArgumentOutOfRangeException(nameof(align), "Alignment must be > 0"); - if (!IsPowerOfTwo(align)) throw new ArgumentOutOfRangeException(nameof(align), "Alignment must be a power of 2"); - - var nextValue = ((value + align - 1) / align) * align; - return nextValue; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs deleted file mode 100644 index c5c9765e3c0833..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/SliceStream.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; - -namespace LibObjectFile.Utils -{ - /// - /// Defines a stream as a slice of another existing stream. - /// - public class SliceStream : Stream - { - private Stream _baseStream; - private readonly long _length; - private readonly long _basePosition; - private long _localPosition; - - public SliceStream(Stream baseStream, long position, long length) - { - if (baseStream == null) throw new ArgumentNullException(nameof(baseStream)); - if (!baseStream.CanSeek) throw new ArgumentException("Invalid base stream that can't be seek."); - if (position < 0) throw new ArgumentOutOfRangeException(nameof(position)); - if (length < 0) throw new ArgumentOutOfRangeException(nameof(length)); - if (position + length > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(position), $"The position {position} + length {length} > baseStream.Length {baseStream.Length}"); - - _baseStream = baseStream; - _length = length; - _basePosition = position; - } - public override int Read(byte[] buffer, int offset, int count) - { - ThrowIfDisposed(); - - long remaining = _length - _localPosition; - if (remaining <= 0) return 0; - if (remaining < count) count = (int)remaining; - - _baseStream.Position = _basePosition + _localPosition; - int read = _baseStream.Read(buffer, offset, count); - _localPosition += read; - - return read; - } - private void ThrowIfDisposed() - { - if (_baseStream == null) throw new ObjectDisposedException(GetType().Name); - } - public override long Length - { - get { ThrowIfDisposed(); return _length; } - } - public override bool CanRead - { - get { ThrowIfDisposed(); return _baseStream.CanRead; } - } - public override bool CanWrite - { - get { ThrowIfDisposed(); return _baseStream.CanWrite; } - } - public override bool CanSeek - { - get { ThrowIfDisposed(); return _baseStream.CanSeek; } - } - public override long Position - { - get - { - ThrowIfDisposed(); - return _localPosition; - } - set => Seek(value, SeekOrigin.Begin); - } - public override long Seek(long offset, SeekOrigin origin) - { - long newPosition = _localPosition; - switch (origin) - { - case SeekOrigin.Begin: - newPosition = offset; - break; - case SeekOrigin.Current: - newPosition += offset; - break; - case SeekOrigin.End: - newPosition = _length - offset; - break; - default: - throw new ArgumentOutOfRangeException(nameof(origin), origin, null); - } - - if (newPosition < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is < 0"); - if (newPosition > _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is > Length {_length}"); - - // Check that we can seek on the origin stream - _baseStream.Position = _basePosition + newPosition; - _localPosition = newPosition; - - return newPosition; - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override void Flush() - { - ThrowIfDisposed(); _baseStream.Flush(); - } - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) - { - if (_baseStream != null) - { - try - { - _baseStream.Dispose(); - } - catch - { - // ignored - } - _baseStream = null; - } - } - } - public override void Write(byte[] buffer, int offset, int count) - { - ThrowIfDisposed(); - if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - if (count == 0) return; - - var isOverLength = _localPosition + count > Length; - var maxLength = isOverLength ? (int)(Length - _localPosition) : count; - _baseStream.Position = _basePosition + _localPosition; - _baseStream.Write(buffer, offset, maxLength); - _localPosition += maxLength; - if (isOverLength) - { - throw new InvalidOperationException("Cannot write outside of this stream slice"); - } - } - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs deleted file mode 100644 index 738239233fecef..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/Utils/ThrowHelper.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.IO; -using System.Text; - -namespace LibObjectFile.Utils -{ - /// - /// Internal helper class for throwing exceptions. - /// - internal static class ThrowHelper - { - public static InvalidOperationException InvalidEnum(object v) - { - return new InvalidOperationException($"Invalid Enum {v.GetType()}.{v}"); - } - } - - public static class StreamExtensions - { - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// true if the string was successfully read from the stream, false otherwise - public static string ReadStringUTF8NullTerminated(this Stream stream) - { - if (!TryReadStringUTF8NullTerminated(stream, out var text)) - { - throw new EndOfStreamException(); - } - return text; - } - - /// - /// Reads a null terminated UTF8 string from the stream. - /// - /// true if the string was successfully read from the stream, false otherwise - public static bool TryReadStringUTF8NullTerminated(this Stream stream, out string text) - { - text = null; - var buffer = ArrayPool.Shared.Rent((int)128); - int textLength = 0; - try - { - while (true) - { - // TODO: not efficient to read byte by byte - int nextByte = stream.ReadByte(); - if (nextByte < 0) - { - return false; - } - - if (nextByte == 0) - { - break; - } - - if (textLength > buffer.Length) - { - var newBuffer = ArrayPool.Shared.Rent((int)textLength * 2); - Array.Copy(buffer, 0, newBuffer, 0, buffer.Length); - ArrayPool.Shared.Return(buffer); - buffer = newBuffer; - } - - buffer[textLength++] = (byte)nextByte; - } - - text = Encoding.UTF8.GetString(buffer, 0, textLength); - } - finally - { - ArrayPool.Shared.Return(buffer); - } - - return true; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs deleted file mode 100644 index 70aa41a73948ec..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/ValueKind.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -namespace LibObjectFile -{ - /// - /// Defines the way a value is calculated. - /// - public enum ValueKind - { - /// - /// The associated value is automatically calculated by the system. - /// - Auto, - - /// - /// The associated value is set manually. - /// - Manual, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs deleted file mode 100644 index cc065ac967cc0e..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Dwarf.generated.cs +++ /dev/null @@ -1,15181 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ -using System; - -#pragma warning disable 1591 - -namespace LibObjectFile.Dwarf -{ - public static partial class DwarfNative - { - public const ushort DW_TAG_array_type = 1; - - public const ushort DW_TAG_class_type = 2; - - public const ushort DW_TAG_entry_point = 3; - - public const ushort DW_TAG_enumeration_type = 4; - - public const ushort DW_TAG_formal_parameter = 5; - - public const ushort DW_TAG_imported_declaration = 8; - - public const ushort DW_TAG_label = 10; - - public const ushort DW_TAG_lexical_block = 11; - - public const ushort DW_TAG_member = 13; - - public const ushort DW_TAG_pointer_type = 15; - - public const ushort DW_TAG_reference_type = 16; - - public const ushort DW_TAG_compile_unit = 17; - - public const ushort DW_TAG_string_type = 18; - - public const ushort DW_TAG_structure_type = 19; - - public const ushort DW_TAG_subroutine_type = 21; - - public const ushort DW_TAG_typedef = 22; - - public const ushort DW_TAG_union_type = 23; - - public const ushort DW_TAG_unspecified_parameters = 24; - - public const ushort DW_TAG_variant = 25; - - public const ushort DW_TAG_common_block = 26; - - public const ushort DW_TAG_common_inclusion = 27; - - public const ushort DW_TAG_inheritance = 28; - - public const ushort DW_TAG_inlined_subroutine = 29; - - public const ushort DW_TAG_module = 30; - - public const ushort DW_TAG_ptr_to_member_type = 31; - - public const ushort DW_TAG_set_type = 32; - - public const ushort DW_TAG_subrange_type = 33; - - public const ushort DW_TAG_with_stmt = 34; - - public const ushort DW_TAG_access_declaration = 35; - - public const ushort DW_TAG_base_type = 36; - - public const ushort DW_TAG_catch_block = 37; - - public const ushort DW_TAG_const_type = 38; - - public const ushort DW_TAG_constant = 39; - - public const ushort DW_TAG_enumerator = 40; - - public const ushort DW_TAG_file_type = 41; - - public const ushort DW_TAG_friend = 42; - - public const ushort DW_TAG_namelist = 43; - - /// - /// DWARF3/2 spelling - /// - public const ushort DW_TAG_namelist_item = 44; - - /// - /// SGI misspelling/typo - /// - public const ushort DW_TAG_namelist_items = 44; - - public const ushort DW_TAG_packed_type = 45; - - public const ushort DW_TAG_subprogram = 46; - - /// - /// DWARF3/2 spelling - /// - public const ushort DW_TAG_template_type_parameter = 47; - - /// - /// DWARF2 spelling - /// - public const ushort DW_TAG_template_type_param = 47; - - /// - /// DWARF3/2 spelling - /// - public const ushort DW_TAG_template_value_parameter = 48; - - /// - /// DWARF2 spelling - /// - public const ushort DW_TAG_template_value_param = 48; - - public const ushort DW_TAG_thrown_type = 49; - - public const ushort DW_TAG_try_block = 50; - - public const ushort DW_TAG_variant_part = 51; - - public const ushort DW_TAG_variable = 52; - - public const ushort DW_TAG_volatile_type = 53; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_dwarf_procedure = 54; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_restrict_type = 55; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_interface_type = 56; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_namespace = 57; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_imported_module = 58; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_unspecified_type = 59; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_partial_unit = 60; - - /// - /// DWARF3 - /// - public const ushort DW_TAG_imported_unit = 61; - - /// - /// Withdrawn from DWARF3 by DWARF3f. - /// - public const ushort DW_TAG_mutable_type = 62; - - /// - /// DWARF3f - /// - public const ushort DW_TAG_condition = 63; - - /// - /// DWARF3f - /// - public const ushort DW_TAG_shared_type = 64; - - /// - /// DWARF4 - /// - public const ushort DW_TAG_type_unit = 65; - - /// - /// DWARF4 - /// - public const ushort DW_TAG_rvalue_reference_type = 66; - - /// - /// DWARF4 - /// - public const ushort DW_TAG_template_alias = 67; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_coarray_type = 68; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_generic_subrange = 69; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_dynamic_type = 70; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_atomic_type = 71; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_call_site = 72; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_call_site_parameter = 73; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_skeleton_unit = 74; - - /// - /// DWARF5 - /// - public const ushort DW_TAG_immutable_type = 75; - - public const ushort DW_TAG_lo_user = 16512; - - public const ushort DW_TAG_MIPS_loop = 16513; - - /// - /// HP - /// - public const ushort DW_TAG_HP_array_descriptor = 16528; - - /// - /// GNU. Fortran. - /// - public const ushort DW_TAG_format_label = 16641; - - /// - /// GNU. For C++ - /// - public const ushort DW_TAG_function_template = 16642; - - /// - /// GNU. For C++ - /// - public const ushort DW_TAG_class_template = 16643; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_BINCL = 16644; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_EINCL = 16645; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_template_template_parameter = 16646; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_template_template_param = 16646; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_template_parameter_pack = 16647; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_formal_parameter_pack = 16648; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_call_site = 16649; - - /// - /// GNU - /// - public const ushort DW_TAG_GNU_call_site_parameter = 16650; - - /// - /// ALTIUM - /// - public const ushort DW_TAG_ALTIUM_circ_type = 20737; - - /// - /// ALTIUM - /// - public const ushort DW_TAG_ALTIUM_mwa_circ_type = 20738; - - /// - /// ALTIUM - /// - public const ushort DW_TAG_ALTIUM_rev_carry_type = 20739; - - /// - /// ALTIUM - /// - public const ushort DW_TAG_ALTIUM_rom = 20753; - - /// - /// UPC - /// - public const ushort DW_TAG_upc_shared_type = 34661; - - /// - /// UPC - /// - public const ushort DW_TAG_upc_strict_type = 34662; - - /// - /// UPC - /// - public const ushort DW_TAG_upc_relaxed_type = 34663; - - /// - /// PGI - /// - public const ushort DW_TAG_PGI_kanji_type = 40960; - - /// - /// PGI - /// - public const ushort DW_TAG_PGI_interface_block = 40992; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_function_template = 16897; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_class_template = 16898; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_struct_template = 16899; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_union_template = 16900; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_indirect_inheritance = 16901; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_codeflags = 16902; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_memop_info = 16903; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_omp_child_func = 16904; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_rtti_descriptor = 16905; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_dtor_info = 16906; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_dtor = 16907; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_f90_interface = 16908; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_fortran_vax_structure = 16909; - - /// - /// SUN - /// - public const ushort DW_TAG_SUN_hi = 17151; - - public const ushort DW_TAG_hi_user = 65535; - - public const ushort DW_FORM_addr = 1; - - public const ushort DW_FORM_block2 = 3; - - public const ushort DW_FORM_block4 = 4; - - public const ushort DW_FORM_data2 = 5; - - public const ushort DW_FORM_data4 = 6; - - public const ushort DW_FORM_data8 = 7; - - public const ushort DW_FORM_string = 8; - - public const ushort DW_FORM_block = 9; - - public const ushort DW_FORM_block1 = 10; - - public const ushort DW_FORM_data1 = 11; - - public const ushort DW_FORM_flag = 12; - - public const ushort DW_FORM_sdata = 13; - - public const ushort DW_FORM_strp = 14; - - public const ushort DW_FORM_udata = 15; - - public const ushort DW_FORM_ref_addr = 16; - - public const ushort DW_FORM_ref1 = 17; - - public const ushort DW_FORM_ref2 = 18; - - public const ushort DW_FORM_ref4 = 19; - - public const ushort DW_FORM_ref8 = 20; - - public const ushort DW_FORM_ref_udata = 21; - - public const ushort DW_FORM_indirect = 22; - - /// - /// DWARF4 - /// - public const ushort DW_FORM_sec_offset = 23; - - /// - /// DWARF4 - /// - public const ushort DW_FORM_exprloc = 24; - - /// - /// DWARF4 - /// - public const ushort DW_FORM_flag_present = 25; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strx = 26; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_addrx = 27; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_ref_sup4 = 28; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strp_sup = 29; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_data16 = 30; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_line_strp = 31; - - /// - /// DWARF4 - /// - public const ushort DW_FORM_ref_sig8 = 32; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_implicit_const = 33; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_loclistx = 34; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_rnglistx = 35; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_ref_sup8 = 36; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strx1 = 37; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strx2 = 38; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strx3 = 39; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_strx4 = 40; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_addrx1 = 41; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_addrx2 = 42; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_addrx3 = 43; - - /// - /// DWARF5 - /// - public const ushort DW_FORM_addrx4 = 44; - - /// - /// GNU extension in debug_info.dwo. - /// - public const ushort DW_FORM_GNU_addr_index = 7937; - - /// - /// GNU extension, somewhat like DW_FORM_strp - /// - public const ushort DW_FORM_GNU_str_index = 7938; - - /// - /// GNU extension. Offset in .debug_info. - /// - public const ushort DW_FORM_GNU_ref_alt = 7968; - - /// - /// GNU extension. Offset in .debug_str of another object file. - /// - public const ushort DW_FORM_GNU_strp_alt = 7969; - - public const ushort DW_AT_sibling = 1; - - public const ushort DW_AT_location = 2; - - public const ushort DW_AT_name = 3; - - public const ushort DW_AT_ordering = 9; - - public const ushort DW_AT_subscr_data = 10; - - public const ushort DW_AT_byte_size = 11; - - public const ushort DW_AT_bit_offset = 12; - - public const ushort DW_AT_bit_size = 13; - - public const ushort DW_AT_element_list = 15; - - public const ushort DW_AT_stmt_list = 16; - - public const ushort DW_AT_low_pc = 17; - - public const ushort DW_AT_high_pc = 18; - - public const ushort DW_AT_language = 19; - - public const ushort DW_AT_member = 20; - - public const ushort DW_AT_discr = 21; - - public const ushort DW_AT_discr_value = 22; - - public const ushort DW_AT_visibility = 23; - - public const ushort DW_AT_import = 24; - - public const ushort DW_AT_string_length = 25; - - public const ushort DW_AT_common_reference = 26; - - public const ushort DW_AT_comp_dir = 27; - - public const ushort DW_AT_const_value = 28; - - public const ushort DW_AT_containing_type = 29; - - public const ushort DW_AT_default_value = 30; - - public const ushort DW_AT_inline = 32; - - public const ushort DW_AT_is_optional = 33; - - public const ushort DW_AT_lower_bound = 34; - - public const ushort DW_AT_producer = 37; - - public const ushort DW_AT_prototyped = 39; - - public const ushort DW_AT_return_addr = 42; - - public const ushort DW_AT_start_scope = 44; - - /// - /// DWARF3 name - /// - public const ushort DW_AT_bit_stride = 46; - - /// - /// DWARF2 name - /// - public const ushort DW_AT_stride_size = 46; - - public const ushort DW_AT_upper_bound = 47; - - public const ushort DW_AT_abstract_origin = 49; - - public const ushort DW_AT_accessibility = 50; - - public const ushort DW_AT_address_class = 51; - - public const ushort DW_AT_artificial = 52; - - public const ushort DW_AT_base_types = 53; - - public const ushort DW_AT_calling_convention = 54; - - public const ushort DW_AT_count = 55; - - public const ushort DW_AT_data_member_location = 56; - - public const ushort DW_AT_decl_column = 57; - - public const ushort DW_AT_decl_file = 58; - - public const ushort DW_AT_decl_line = 59; - - public const ushort DW_AT_declaration = 60; - - /// - /// DWARF2 - /// - public const ushort DW_AT_discr_list = 61; - - public const ushort DW_AT_encoding = 62; - - public const ushort DW_AT_external = 63; - - public const ushort DW_AT_frame_base = 64; - - public const ushort DW_AT_friend = 65; - - public const ushort DW_AT_identifier_case = 66; - - /// - /// DWARF{234} not DWARF5 - /// - public const ushort DW_AT_macro_info = 67; - - public const ushort DW_AT_namelist_item = 68; - - public const ushort DW_AT_priority = 69; - - public const ushort DW_AT_segment = 70; - - public const ushort DW_AT_specification = 71; - - public const ushort DW_AT_static_link = 72; - - public const ushort DW_AT_type = 73; - - public const ushort DW_AT_use_location = 74; - - public const ushort DW_AT_variable_parameter = 75; - - public const ushort DW_AT_virtuality = 76; - - public const ushort DW_AT_vtable_elem_location = 77; - - /// - /// DWARF3 - /// - public const ushort DW_AT_allocated = 78; - - /// - /// DWARF3 - /// - public const ushort DW_AT_associated = 79; - - /// - /// DWARF3 - /// - public const ushort DW_AT_data_location = 80; - - /// - /// DWARF3f - /// - public const ushort DW_AT_byte_stride = 81; - - /// - /// DWARF3 (do not use) - /// - public const ushort DW_AT_stride = 81; - - /// - /// DWARF3 - /// - public const ushort DW_AT_entry_pc = 82; - - /// - /// DWARF3 - /// - public const ushort DW_AT_use_UTF8 = 83; - - /// - /// DWARF3 - /// - public const ushort DW_AT_extension = 84; - - /// - /// DWARF3 - /// - public const ushort DW_AT_ranges = 85; - - /// - /// DWARF3 - /// - public const ushort DW_AT_trampoline = 86; - - /// - /// DWARF3 - /// - public const ushort DW_AT_call_column = 87; - - /// - /// DWARF3 - /// - public const ushort DW_AT_call_file = 88; - - /// - /// DWARF3 - /// - public const ushort DW_AT_call_line = 89; - - /// - /// DWARF3 - /// - public const ushort DW_AT_description = 90; - - /// - /// DWARF3f - /// - public const ushort DW_AT_binary_scale = 91; - - /// - /// DWARF3f - /// - public const ushort DW_AT_decimal_scale = 92; - - /// - /// DWARF3f - /// - public const ushort DW_AT_small = 93; - - /// - /// DWARF3f - /// - public const ushort DW_AT_decimal_sign = 94; - - /// - /// DWARF3f - /// - public const ushort DW_AT_digit_count = 95; - - /// - /// DWARF3f - /// - public const ushort DW_AT_picture_string = 96; - - /// - /// DWARF3f - /// - public const ushort DW_AT_mutable = 97; - - /// - /// DWARF3f - /// - public const ushort DW_AT_threads_scaled = 98; - - /// - /// DWARF3f - /// - public const ushort DW_AT_explicit = 99; - - /// - /// DWARF3f - /// - public const ushort DW_AT_object_pointer = 100; - - /// - /// DWARF3f - /// - public const ushort DW_AT_endianity = 101; - - /// - /// DWARF3f - /// - public const ushort DW_AT_elemental = 102; - - /// - /// DWARF3f - /// - public const ushort DW_AT_pure = 103; - - /// - /// DWARF3f - /// - public const ushort DW_AT_recursive = 104; - - /// - /// DWARF4 - /// - public const ushort DW_AT_signature = 105; - - /// - /// DWARF4 - /// - public const ushort DW_AT_main_subprogram = 106; - - /// - /// DWARF4 - /// - public const ushort DW_AT_data_bit_offset = 107; - - /// - /// DWARF4 - /// - public const ushort DW_AT_const_expr = 108; - - /// - /// DWARF4 - /// - public const ushort DW_AT_enum_class = 109; - - /// - /// DWARF4 - /// - public const ushort DW_AT_linkage_name = 110; - - /// - /// DWARF5 - /// - public const ushort DW_AT_string_length_bit_size = 111; - - /// - /// DWARF5 - /// - public const ushort DW_AT_string_length_byte_size = 112; - - /// - /// DWARF5 - /// - public const ushort DW_AT_rank = 113; - - /// - /// DWARF5 - /// - public const ushort DW_AT_str_offsets_base = 114; - - /// - /// DWARF5 - /// - public const ushort DW_AT_addr_base = 115; - - /// - /// DWARF5 - /// - public const ushort DW_AT_rnglists_base = 116; - - /// - /// DWARF4! - /// - public const ushort DW_AT_dwo_id = 117; - - /// - /// DWARF5 - /// - public const ushort DW_AT_dwo_name = 118; - - /// - /// DWARF5 - /// - public const ushort DW_AT_reference = 119; - - /// - /// DWARF5 - /// - public const ushort DW_AT_rvalue_reference = 120; - - /// - /// DWARF5 - /// - public const ushort DW_AT_macros = 121; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_all_calls = 122; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_all_source_calls = 123; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_all_tail_calls = 124; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_return_pc = 125; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_value = 126; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_origin = 127; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_parameter = 128; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_pc = 129; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_tail_call = 130; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_target = 131; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_target_clobbered = 132; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_data_location = 133; - - /// - /// DWARF5 - /// - public const ushort DW_AT_call_data_value = 134; - - /// - /// DWARF5 - /// - public const ushort DW_AT_noreturn = 135; - - /// - /// DWARF5 - /// - public const ushort DW_AT_alignment = 136; - - /// - /// DWARF5 - /// - public const ushort DW_AT_export_symbols = 137; - - /// - /// DWARF5 - /// - public const ushort DW_AT_deleted = 138; - - /// - /// DWARF5 - /// - public const ushort DW_AT_defaulted = 139; - - /// - /// DWARF5 - /// - public const ushort DW_AT_loclists_base = 140; - - /// - /// HP - /// - public const ushort DW_AT_HP_block_index = 8192; - - public const ushort DW_AT_lo_user = 8192; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_fde = 8193; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_loop_begin = 8194; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_tail_loop_begin = 8195; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_epilog_begin = 8196; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_loop_unroll_factor = 8197; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_software_pipeline_depth = 8198; - - /// - /// MIPS/SGI, GNU, and others. - /// - public const ushort DW_AT_MIPS_linkage_name = 8199; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_stride = 8200; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_abstract_name = 8201; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_clone_origin = 8202; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_has_inlines = 8203; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_stride_byte = 8204; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_stride_elem = 8205; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_ptr_dopetype = 8206; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_allocatable_dopetype = 8207; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_assumed_shape_dopetype = 8208; - - /// - /// MIPS/SGI - /// - public const ushort DW_AT_MIPS_assumed_size = 8209; - - /// - /// conflict: MIPS - /// - public const ushort DW_AT_HP_unmodifiable = 8193; - - /// - /// conflict: MIPS - /// - public const ushort DW_AT_HP_actuals_stmt_list = 8208; - - /// - /// conflict: MIPS - /// - public const ushort DW_AT_HP_proc_per_section = 8209; - - /// - /// HP - /// - public const ushort DW_AT_HP_raw_data_ptr = 8210; - - /// - /// HP - /// - public const ushort DW_AT_HP_pass_by_reference = 8211; - - /// - /// HP - /// - public const ushort DW_AT_HP_opt_level = 8212; - - /// - /// HP - /// - public const ushort DW_AT_HP_prof_version_id = 8213; - - /// - /// HP - /// - public const ushort DW_AT_HP_opt_flags = 8214; - - /// - /// HP - /// - public const ushort DW_AT_HP_cold_region_low_pc = 8215; - - /// - /// HP - /// - public const ushort DW_AT_HP_cold_region_high_pc = 8216; - - /// - /// HP - /// - public const ushort DW_AT_HP_all_variables_modifiable = 8217; - - /// - /// HP - /// - public const ushort DW_AT_HP_linkage_name = 8218; - - /// - /// HP - /// - public const ushort DW_AT_HP_prof_flags = 8219; - - /// - /// COMPAQ/HP - /// - public const ushort DW_AT_CPQ_discontig_ranges = 8193; - - /// - /// COMPAQ/HP - /// - public const ushort DW_AT_CPQ_semantic_events = 8194; - - /// - /// COMPAQ/HP - /// - public const ushort DW_AT_CPQ_split_lifetimes_var = 8195; - - /// - /// COMPAQ/HP - /// - public const ushort DW_AT_CPQ_split_lifetimes_rtn = 8196; - - /// - /// COMPAQ/HP - /// - public const ushort DW_AT_CPQ_prologue_length = 8197; - - /// - /// Intel, 1 if byte swapped. - /// - public const ushort DW_AT_INTEL_other_endian = 8230; - - /// - /// GNU - /// - public const ushort DW_AT_sf_names = 8449; - - /// - /// GNU - /// - public const ushort DW_AT_src_info = 8450; - - /// - /// GNU - /// - public const ushort DW_AT_mac_info = 8451; - - /// - /// GNU - /// - public const ushort DW_AT_src_coords = 8452; - - /// - /// GNU - /// - public const ushort DW_AT_body_begin = 8453; - - /// - /// GNU - /// - public const ushort DW_AT_body_end = 8454; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_vector = 8455; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_guarded_by = 8456; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_pt_guarded_by = 8457; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_guarded = 8458; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_pt_guarded = 8459; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_locks_excluded = 8460; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_exclusive_locks_required = 8461; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_shared_locks_required = 8462; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_odr_signature = 8463; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_template_name = 8464; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_call_site_value = 8465; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_call_site_data_value = 8466; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_call_site_target = 8467; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_call_site_target_clobbered = 8468; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_tail_call = 8469; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_all_tail_call_sites = 8470; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_all_call_sites = 8471; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_all_source_call_sites = 8472; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_macros = 8473; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_dwo_name = 8496; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_dwo_id = 8497; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_ranges_base = 8498; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_addr_base = 8499; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_pubnames = 8500; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_pubtypes = 8501; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_discriminator = 8502; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_numerator = 8963; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_denominator = 8964; - - /// - /// GNU - /// - public const ushort DW_AT_GNU_bias = 8965; - - /// - /// ALTIUM - /// - public const ushort DW_AT_ALTIUM_loclist = 8960; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_template = 8705; - - /// - /// VMS - /// - public const ushort DW_AT_VMS_rtnbeg_pd_address = 8705; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_alignment = 8706; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_vtable = 8707; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_count_guarantee = 8708; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_command_line = 8709; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_vbase = 8710; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_compile_options = 8711; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_language = 8712; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_browser_file = 8713; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_vtable_abi = 8720; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_func_offsets = 8721; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_cf_kind = 8722; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_vtable_index = 8723; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_omp_tpriv_addr = 8724; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_omp_child_func = 8725; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_func_offset = 8726; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_memop_type_ref = 8727; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_profile_id = 8728; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_memop_signature = 8729; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_obj_dir = 8736; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_obj_file = 8737; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_original_name = 8738; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_hwcprof_signature = 8739; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_amd64_parmdump = 8740; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_part_link_name = 8741; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_link_name = 8742; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_pass_with_const = 8743; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_return_with_const = 8744; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_import_by_name = 8745; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_f90_pointer = 8746; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_pass_by_ref = 8747; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_f90_allocatable = 8748; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_f90_assumed_shape_array = 8749; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_c_vla = 8750; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_return_value_ptr = 8752; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_dtor_start = 8753; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_dtor_length = 8754; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_dtor_state_initial = 8755; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_dtor_state_final = 8756; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_dtor_state_deltas = 8757; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_import_by_lname = 8758; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_f90_use_only = 8759; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_namelist_spec = 8760; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_is_omp_child_func = 8761; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_fortran_main_alias = 8762; - - /// - /// SUN - /// - public const ushort DW_AT_SUN_fortran_based = 8763; - - /// - /// GNAT - /// - public const ushort DW_AT_use_GNAT_descriptive_type = 8961; - - /// - /// GNAT - /// - public const ushort DW_AT_GNAT_descriptive_type = 8962; - - /// - /// UPC - /// - public const ushort DW_AT_upc_threads_scaled = 12816; - - /// - /// PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. - /// - public const ushort DW_AT_PGI_lbase = 14848; - - /// - /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. - /// - public const ushort DW_AT_PGI_soffset = 14849; - - /// - /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. - /// - public const ushort DW_AT_PGI_lstride = 14850; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_optimized = 16353; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_flags = 16354; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_isa = 16355; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_block = 16356; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_major_runtime_vers = 16357; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_runtime_class = 16358; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_omit_frame_ptr = 16359; - - /// - /// Apple - /// - public const ushort DW_AT_APPLE_closure = 16356; - - public const ushort DW_AT_hi_user = 16383; - - public const byte DW_OP_addr = 3; - - public const byte DW_OP_deref = 6; - - public const byte DW_OP_const1u = 8; - - public const byte DW_OP_const1s = 9; - - public const byte DW_OP_const2u = 10; - - public const byte DW_OP_const2s = 11; - - public const byte DW_OP_const4u = 12; - - public const byte DW_OP_const4s = 13; - - public const byte DW_OP_const8u = 14; - - public const byte DW_OP_const8s = 15; - - public const byte DW_OP_constu = 16; - - public const byte DW_OP_consts = 17; - - public const byte DW_OP_dup = 18; - - public const byte DW_OP_drop = 19; - - public const byte DW_OP_over = 20; - - public const byte DW_OP_pick = 21; - - public const byte DW_OP_swap = 22; - - public const byte DW_OP_rot = 23; - - public const byte DW_OP_xderef = 24; - - public const byte DW_OP_abs = 25; - - public const byte DW_OP_and = 26; - - public const byte DW_OP_div = 27; - - public const byte DW_OP_minus = 28; - - public const byte DW_OP_mod = 29; - - public const byte DW_OP_mul = 30; - - public const byte DW_OP_neg = 31; - - public const byte DW_OP_not = 32; - - public const byte DW_OP_or = 33; - - public const byte DW_OP_plus = 34; - - public const byte DW_OP_plus_uconst = 35; - - public const byte DW_OP_shl = 36; - - public const byte DW_OP_shr = 37; - - public const byte DW_OP_shra = 38; - - public const byte DW_OP_xor = 39; - - public const byte DW_OP_bra = 40; - - public const byte DW_OP_eq = 41; - - public const byte DW_OP_ge = 42; - - public const byte DW_OP_gt = 43; - - public const byte DW_OP_le = 44; - - public const byte DW_OP_lt = 45; - - public const byte DW_OP_ne = 46; - - public const byte DW_OP_skip = 47; - - public const byte DW_OP_lit0 = 48; - - public const byte DW_OP_lit1 = 49; - - public const byte DW_OP_lit2 = 50; - - public const byte DW_OP_lit3 = 51; - - public const byte DW_OP_lit4 = 52; - - public const byte DW_OP_lit5 = 53; - - public const byte DW_OP_lit6 = 54; - - public const byte DW_OP_lit7 = 55; - - public const byte DW_OP_lit8 = 56; - - public const byte DW_OP_lit9 = 57; - - public const byte DW_OP_lit10 = 58; - - public const byte DW_OP_lit11 = 59; - - public const byte DW_OP_lit12 = 60; - - public const byte DW_OP_lit13 = 61; - - public const byte DW_OP_lit14 = 62; - - public const byte DW_OP_lit15 = 63; - - public const byte DW_OP_lit16 = 64; - - public const byte DW_OP_lit17 = 65; - - public const byte DW_OP_lit18 = 66; - - public const byte DW_OP_lit19 = 67; - - public const byte DW_OP_lit20 = 68; - - public const byte DW_OP_lit21 = 69; - - public const byte DW_OP_lit22 = 70; - - public const byte DW_OP_lit23 = 71; - - public const byte DW_OP_lit24 = 72; - - public const byte DW_OP_lit25 = 73; - - public const byte DW_OP_lit26 = 74; - - public const byte DW_OP_lit27 = 75; - - public const byte DW_OP_lit28 = 76; - - public const byte DW_OP_lit29 = 77; - - public const byte DW_OP_lit30 = 78; - - public const byte DW_OP_lit31 = 79; - - public const byte DW_OP_reg0 = 80; - - public const byte DW_OP_reg1 = 81; - - public const byte DW_OP_reg2 = 82; - - public const byte DW_OP_reg3 = 83; - - public const byte DW_OP_reg4 = 84; - - public const byte DW_OP_reg5 = 85; - - public const byte DW_OP_reg6 = 86; - - public const byte DW_OP_reg7 = 87; - - public const byte DW_OP_reg8 = 88; - - public const byte DW_OP_reg9 = 89; - - public const byte DW_OP_reg10 = 90; - - public const byte DW_OP_reg11 = 91; - - public const byte DW_OP_reg12 = 92; - - public const byte DW_OP_reg13 = 93; - - public const byte DW_OP_reg14 = 94; - - public const byte DW_OP_reg15 = 95; - - public const byte DW_OP_reg16 = 96; - - public const byte DW_OP_reg17 = 97; - - public const byte DW_OP_reg18 = 98; - - public const byte DW_OP_reg19 = 99; - - public const byte DW_OP_reg20 = 100; - - public const byte DW_OP_reg21 = 101; - - public const byte DW_OP_reg22 = 102; - - public const byte DW_OP_reg23 = 103; - - public const byte DW_OP_reg24 = 104; - - public const byte DW_OP_reg25 = 105; - - public const byte DW_OP_reg26 = 106; - - public const byte DW_OP_reg27 = 107; - - public const byte DW_OP_reg28 = 108; - - public const byte DW_OP_reg29 = 109; - - public const byte DW_OP_reg30 = 110; - - public const byte DW_OP_reg31 = 111; - - public const byte DW_OP_breg0 = 112; - - public const byte DW_OP_breg1 = 113; - - public const byte DW_OP_breg2 = 114; - - public const byte DW_OP_breg3 = 115; - - public const byte DW_OP_breg4 = 116; - - public const byte DW_OP_breg5 = 117; - - public const byte DW_OP_breg6 = 118; - - public const byte DW_OP_breg7 = 119; - - public const byte DW_OP_breg8 = 120; - - public const byte DW_OP_breg9 = 121; - - public const byte DW_OP_breg10 = 122; - - public const byte DW_OP_breg11 = 123; - - public const byte DW_OP_breg12 = 124; - - public const byte DW_OP_breg13 = 125; - - public const byte DW_OP_breg14 = 126; - - public const byte DW_OP_breg15 = 127; - - public const byte DW_OP_breg16 = 128; - - public const byte DW_OP_breg17 = 129; - - public const byte DW_OP_breg18 = 130; - - public const byte DW_OP_breg19 = 131; - - public const byte DW_OP_breg20 = 132; - - public const byte DW_OP_breg21 = 133; - - public const byte DW_OP_breg22 = 134; - - public const byte DW_OP_breg23 = 135; - - public const byte DW_OP_breg24 = 136; - - public const byte DW_OP_breg25 = 137; - - public const byte DW_OP_breg26 = 138; - - public const byte DW_OP_breg27 = 139; - - public const byte DW_OP_breg28 = 140; - - public const byte DW_OP_breg29 = 141; - - public const byte DW_OP_breg30 = 142; - - public const byte DW_OP_breg31 = 143; - - public const byte DW_OP_regx = 144; - - public const byte DW_OP_fbreg = 145; - - public const byte DW_OP_bregx = 146; - - public const byte DW_OP_piece = 147; - - public const byte DW_OP_deref_size = 148; - - public const byte DW_OP_xderef_size = 149; - - public const byte DW_OP_nop = 150; - - /// - /// DWARF3 - /// - public const byte DW_OP_push_object_address = 151; - - /// - /// DWARF3 - /// - public const byte DW_OP_call2 = 152; - - /// - /// DWARF3 - /// - public const byte DW_OP_call4 = 153; - - /// - /// DWARF3 - /// - public const byte DW_OP_call_ref = 154; - - /// - /// DWARF3f - /// - public const byte DW_OP_form_tls_address = 155; - - /// - /// DWARF3f - /// - public const byte DW_OP_call_frame_cfa = 156; - - /// - /// DWARF3f - /// - public const byte DW_OP_bit_piece = 157; - - /// - /// DWARF4 - /// - public const byte DW_OP_implicit_value = 158; - - /// - /// DWARF4 - /// - public const byte DW_OP_stack_value = 159; - - /// - /// DWARF5 - /// - public const byte DW_OP_implicit_pointer = 160; - - /// - /// DWARF5 - /// - public const byte DW_OP_addrx = 161; - - /// - /// DWARF5 - /// - public const byte DW_OP_constx = 162; - - /// - /// DWARF5 - /// - public const byte DW_OP_entry_value = 163; - - /// - /// DWARF5 - /// - public const byte DW_OP_const_type = 164; - - /// - /// DWARF5 - /// - public const byte DW_OP_regval_type = 165; - - /// - /// DWARF5 - /// - public const byte DW_OP_deref_type = 166; - - /// - /// DWARF5 - /// - public const byte DW_OP_xderef_type = 167; - - /// - /// DWARF5 - /// - public const byte DW_OP_convert = 168; - - /// - /// DWARF5 - /// - public const byte DW_OP_reinterpret = 169; - - /// - /// GNU - /// - public const byte DW_OP_GNU_push_tls_address = 224; - - public const byte DW_OP_lo_user = 224; - - /// - /// GNU - /// - public const byte DW_OP_GNU_uninit = 240; - - /// - /// GNU - /// - public const byte DW_OP_GNU_encoded_addr = 241; - - /// - /// GNU - /// - public const byte DW_OP_GNU_implicit_pointer = 242; - - /// - /// GNU - /// - public const byte DW_OP_GNU_entry_value = 243; - - /// - /// GNU - /// - public const byte DW_OP_GNU_const_type = 244; - - /// - /// GNU - /// - public const byte DW_OP_GNU_regval_type = 245; - - /// - /// GNU - /// - public const byte DW_OP_GNU_deref_type = 246; - - /// - /// GNU - /// - public const byte DW_OP_GNU_convert = 247; - - /// - /// GNU - /// - public const byte DW_OP_GNU_reinterpret = 249; - - /// - /// GNU - /// - public const byte DW_OP_GNU_parameter_ref = 250; - - /// - /// GNU DebugFission - /// - public const byte DW_OP_GNU_addr_index = 251; - - /// - /// GNU DebugFission - /// - public const byte DW_OP_GNU_const_index = 252; - - /// - /// HP conflict: GNU - /// - public const byte DW_OP_HP_unknown = 224; - - /// - /// HP - /// - public const byte DW_OP_HP_is_value = 225; - - /// - /// HP - /// - public const byte DW_OP_HP_fltconst4 = 226; - - /// - /// HP - /// - public const byte DW_OP_HP_fltconst8 = 227; - - /// - /// HP - /// - public const byte DW_OP_HP_mod_range = 228; - - /// - /// HP - /// - public const byte DW_OP_HP_unmod_range = 229; - - /// - /// HP - /// - public const byte DW_OP_HP_tls = 230; - - /// - /// Intel: made obsolete by DW_OP_bit_piece above. - /// - public const byte DW_OP_INTEL_bit_piece = 232; - - /// - /// Apple - /// - public const byte DW_OP_APPLE_uninit = 240; - - /// - /// PGI (STMicroelectronics) - /// - public const byte DW_OP_PGI_omp_thread_num = 248; - - public const byte DW_OP_hi_user = 255; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_compile_unit = 1; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_type_unit = 2; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_die_offset = 3; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_parent = 4; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_type_hash = 5; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_lo_user = 8192; - - /// - /// DWARF5 - /// - public const ushort DW_IDX_hi_user = 4095; - - /// - /// DWARF5 - /// - public const byte DW_UT_compile = 1; - - /// - /// DWARF5 - /// - public const byte DW_UT_type = 2; - - /// - /// DWARF5 - /// - public const byte DW_UT_partial = 3; - - /// - /// DWARF5 - /// - public const byte DW_UT_skeleton = 4; - - /// - /// DWARF5 - /// - public const byte DW_UT_split_compile = 5; - - /// - /// DWARF5 - /// - public const byte DW_UT_split_type = 6; - - /// - /// DWARF5 - /// - public const byte DW_UT_lo_user = 128; - - /// - /// DWARF5 - /// - public const byte DW_UT_hi_user = 255; - - public const byte DW_ACCESS_public = 1; - - public const byte DW_ACCESS_protected = 2; - - public const byte DW_ACCESS_private = 3; - - public const byte DW_VIS_local = 1; - - public const byte DW_VIS_exported = 2; - - public const byte DW_VIS_qualified = 3; - - public const byte DW_VIRTUALITY_none = 0; - - public const byte DW_VIRTUALITY_virtual = 1; - - public const byte DW_VIRTUALITY_pure_virtual = 2; - - public const ushort DW_LANG_C89 = 1; - - public const ushort DW_LANG_C = 2; - - public const ushort DW_LANG_Ada83 = 3; - - public const ushort DW_LANG_C_plus_plus = 4; - - public const ushort DW_LANG_Cobol74 = 5; - - public const ushort DW_LANG_Cobol85 = 6; - - public const ushort DW_LANG_Fortran77 = 7; - - public const ushort DW_LANG_Fortran90 = 8; - - public const ushort DW_LANG_Pascal83 = 9; - - public const ushort DW_LANG_Modula2 = 10; - - /// - /// DWARF3 - /// - public const ushort DW_LANG_Java = 11; - - /// - /// DWARF3 - /// - public const ushort DW_LANG_C99 = 12; - - /// - /// DWARF3 - /// - public const ushort DW_LANG_Ada95 = 13; - - /// - /// DWARF3 - /// - public const ushort DW_LANG_Fortran95 = 14; - - /// - /// DWARF3 - /// - public const ushort DW_LANG_PLI = 15; - - /// - /// DWARF3f - /// - public const ushort DW_LANG_ObjC = 16; - - /// - /// DWARF3f - /// - public const ushort DW_LANG_ObjC_plus_plus = 17; - - /// - /// DWARF3f - /// - public const ushort DW_LANG_UPC = 18; - - /// - /// DWARF3f - /// - public const ushort DW_LANG_D = 19; - - /// - /// DWARF4 - /// - public const ushort DW_LANG_Python = 20; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_OpenCL = 21; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Go = 22; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Modula3 = 23; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Haskel = 24; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_C_plus_plus_03 = 25; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_C_plus_plus_11 = 26; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_OCaml = 27; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Rust = 28; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_C11 = 29; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Swift = 30; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Julia = 31; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Dylan = 32; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_C_plus_plus_14 = 33; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Fortran03 = 34; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_Fortran08 = 35; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_RenderScript = 36; - - /// - /// DWARF5 - /// - public const ushort DW_LANG_BLISS = 37; - - public const ushort DW_LANG_lo_user = 32768; - - /// - /// MIPS - /// - public const ushort DW_LANG_Mips_Assembler = 32769; - - /// - /// UPC, use - /// DW_LANG_UPC instead. - /// - public const ushort DW_LANG_Upc = 34661; - - /// - /// ALTIUM - /// - public const ushort DW_LANG_ALTIUM_Assembler = 37121; - - /// - /// SUN - /// - public const ushort DW_LANG_SUN_Assembler = 36865; - - public const ushort DW_LANG_hi_user = 65535; - - public const byte DW_ID_case_sensitive = 0; - - public const byte DW_ID_up_case = 1; - - public const byte DW_ID_down_case = 2; - - public const byte DW_ID_case_insensitive = 3; - - public const byte DW_CC_normal = 1; - - public const byte DW_CC_program = 2; - - public const byte DW_CC_nocall = 3; - - /// - /// DWARF5 - /// - public const byte DW_CC_pass_by_reference = 4; - - /// - /// DWARF5 - /// - public const byte DW_CC_pass_by_value = 5; - - public const byte DW_CC_lo_user = 64; - - /// - /// GNU - /// - public const byte DW_CC_GNU_renesas_sh = 64; - - /// - /// GNU - /// - public const byte DW_CC_GNU_borland_fastcall_i386 = 65; - - /// - /// ALTIUM - /// - public const byte DW_CC_ALTIUM_interrupt = 101; - - /// - /// ALTIUM - /// - public const byte DW_CC_ALTIUM_near_system_stack = 102; - - /// - /// ALTIUM - /// - public const byte DW_CC_ALTIUM_near_user_stack = 103; - - /// - /// ALTIUM - /// - public const byte DW_CC_ALTIUM_huge_user_stack = 104; - - public const byte DW_CC_hi_user = 255; - - public const byte DW_INL_not_inlined = 0; - - public const byte DW_INL_inlined = 1; - - public const byte DW_INL_declared_not_inlined = 2; - - public const byte DW_INL_declared_inlined = 3; - - public const byte DW_ORD_row_major = 0; - - public const byte DW_ORD_col_major = 1; - - public const byte DW_DSC_label = 0; - - public const byte DW_DSC_range = 1; - - public const byte DW_LNS_copy = 1; - - public const byte DW_LNS_advance_pc = 2; - - public const byte DW_LNS_advance_line = 3; - - public const byte DW_LNS_set_file = 4; - - public const byte DW_LNS_set_column = 5; - - public const byte DW_LNS_negate_stmt = 6; - - public const byte DW_LNS_set_basic_block = 7; - - public const byte DW_LNS_const_add_pc = 8; - - public const byte DW_LNS_fixed_advance_pc = 9; - - /// - /// DWARF3 - /// - public const byte DW_LNS_set_prologue_end = 10; - - /// - /// DWARF3 - /// - public const byte DW_LNS_set_epilogue_begin = 11; - - /// - /// DWARF3 - /// - public const byte DW_LNS_set_isa = 12; - - /// - /// Actuals table only - /// - public const byte DW_LNS_set_address_from_logical = 13; - - /// - /// Logicals table only - /// - public const byte DW_LNS_set_subprogram = 13; - - /// - /// Logicals table only - /// - public const byte DW_LNS_inlined_call = 14; - - /// - /// Logicals table only - /// - public const byte DW_LNS_pop_context = 15; - - public const byte DW_LNE_end_sequence = 1; - - public const byte DW_LNE_set_address = 2; - - /// - /// DWARF4 and earlier only - /// - public const byte DW_LNE_define_file = 3; - - /// - /// DWARF4 - /// - public const byte DW_LNE_set_discriminator = 4; - - /// - /// 17 HP - /// - public const byte DW_LNE_HP_negate_is_UV_update = 17; - - /// - /// 18 HP - /// - public const byte DW_LNE_HP_push_context = 18; - - /// - /// 19 HP - /// - public const byte DW_LNE_HP_pop_context = 19; - - /// - /// 20 HP - /// - public const byte DW_LNE_HP_set_file_line_column = 20; - - /// - /// 21 HP - /// - public const byte DW_LNE_HP_set_routine_name = 21; - - /// - /// 22 HP - /// - public const byte DW_LNE_HP_set_sequence = 22; - - /// - /// 23 HP - /// - public const byte DW_LNE_HP_negate_post_semantics = 23; - - /// - /// 24 HP - /// - public const byte DW_LNE_HP_negate_function_exit = 24; - - /// - /// 25 HP - /// - public const byte DW_LNE_HP_negate_front_end_logical = 25; - - /// - /// 32 HP - /// - public const byte DW_LNE_HP_define_proc = 32; - - /// - /// HP - /// - public const byte DW_LNE_HP_source_file_correlation = 128; - - /// - /// DWARF3 - /// - public const byte DW_LNE_lo_user = 128; - - /// - /// DWARF3 - /// - public const byte DW_LNE_hi_user = 255; - - public const byte DW_ISA_UNKNOWN = 0; - - /// - /// ARM ISA - /// - public const byte DW_ISA_ARM_thumb = 1; - - /// - /// ARM ISA - /// - public const byte DW_ISA_ARM_arm = 2; - - public const byte DW_CHILDREN_no = 0; - - public const byte DW_CHILDREN_yes = 1; - } - - public readonly partial struct DwarfAttributeKindEx - { - public static readonly DwarfAttributeKindEx Sibling = new DwarfAttributeKindEx(DwarfNative.DW_AT_sibling); - - public static readonly DwarfAttributeKindEx Location = new DwarfAttributeKindEx(DwarfNative.DW_AT_location); - - public static readonly DwarfAttributeKindEx Name = new DwarfAttributeKindEx(DwarfNative.DW_AT_name); - - public static readonly DwarfAttributeKindEx Ordering = new DwarfAttributeKindEx(DwarfNative.DW_AT_ordering); - - public static readonly DwarfAttributeKindEx SubscrData = new DwarfAttributeKindEx(DwarfNative.DW_AT_subscr_data); - - public static readonly DwarfAttributeKindEx ByteSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_byte_size); - - public static readonly DwarfAttributeKindEx BitOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_offset); - - public static readonly DwarfAttributeKindEx BitSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_size); - - public static readonly DwarfAttributeKindEx ElementList = new DwarfAttributeKindEx(DwarfNative.DW_AT_element_list); - - public static readonly DwarfAttributeKindEx StmtList = new DwarfAttributeKindEx(DwarfNative.DW_AT_stmt_list); - - public static readonly DwarfAttributeKindEx LowPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_low_pc); - - public static readonly DwarfAttributeKindEx HighPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_high_pc); - - public static readonly DwarfAttributeKindEx Language = new DwarfAttributeKindEx(DwarfNative.DW_AT_language); - - public static readonly DwarfAttributeKindEx Member = new DwarfAttributeKindEx(DwarfNative.DW_AT_member); - - public static readonly DwarfAttributeKindEx Discr = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr); - - public static readonly DwarfAttributeKindEx DiscrValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr_value); - - public static readonly DwarfAttributeKindEx Visibility = new DwarfAttributeKindEx(DwarfNative.DW_AT_visibility); - - public static readonly DwarfAttributeKindEx Import = new DwarfAttributeKindEx(DwarfNative.DW_AT_import); - - public static readonly DwarfAttributeKindEx StringLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length); - - public static readonly DwarfAttributeKindEx CommonReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_common_reference); - - public static readonly DwarfAttributeKindEx CompDir = new DwarfAttributeKindEx(DwarfNative.DW_AT_comp_dir); - - public static readonly DwarfAttributeKindEx ConstValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_const_value); - - public static readonly DwarfAttributeKindEx ContainingType = new DwarfAttributeKindEx(DwarfNative.DW_AT_containing_type); - - public static readonly DwarfAttributeKindEx DefaultValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_default_value); - - public static readonly DwarfAttributeKindEx Inline = new DwarfAttributeKindEx(DwarfNative.DW_AT_inline); - - public static readonly DwarfAttributeKindEx IsOptional = new DwarfAttributeKindEx(DwarfNative.DW_AT_is_optional); - - public static readonly DwarfAttributeKindEx LowerBound = new DwarfAttributeKindEx(DwarfNative.DW_AT_lower_bound); - - public static readonly DwarfAttributeKindEx Producer = new DwarfAttributeKindEx(DwarfNative.DW_AT_producer); - - public static readonly DwarfAttributeKindEx Prototyped = new DwarfAttributeKindEx(DwarfNative.DW_AT_prototyped); - - public static readonly DwarfAttributeKindEx ReturnAddr = new DwarfAttributeKindEx(DwarfNative.DW_AT_return_addr); - - public static readonly DwarfAttributeKindEx StartScope = new DwarfAttributeKindEx(DwarfNative.DW_AT_start_scope); - - /// - /// DWARF3 name - /// - public static readonly DwarfAttributeKindEx BitStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_bit_stride); - - /// - /// DWARF2 name - /// - public static readonly DwarfAttributeKindEx StrideSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_stride_size); - - public static readonly DwarfAttributeKindEx UpperBound = new DwarfAttributeKindEx(DwarfNative.DW_AT_upper_bound); - - public static readonly DwarfAttributeKindEx AbstractOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_abstract_origin); - - public static readonly DwarfAttributeKindEx Accessibility = new DwarfAttributeKindEx(DwarfNative.DW_AT_accessibility); - - public static readonly DwarfAttributeKindEx AddressClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_address_class); - - public static readonly DwarfAttributeKindEx Artificial = new DwarfAttributeKindEx(DwarfNative.DW_AT_artificial); - - public static readonly DwarfAttributeKindEx BaseTypes = new DwarfAttributeKindEx(DwarfNative.DW_AT_base_types); - - public static readonly DwarfAttributeKindEx CallingConvention = new DwarfAttributeKindEx(DwarfNative.DW_AT_calling_convention); - - public static readonly DwarfAttributeKindEx Count = new DwarfAttributeKindEx(DwarfNative.DW_AT_count); - - public static readonly DwarfAttributeKindEx DataMemberLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_member_location); - - public static readonly DwarfAttributeKindEx DeclColumn = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_column); - - public static readonly DwarfAttributeKindEx DeclFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_file); - - public static readonly DwarfAttributeKindEx DeclLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_decl_line); - - public static readonly DwarfAttributeKindEx Declaration = new DwarfAttributeKindEx(DwarfNative.DW_AT_declaration); - - /// - /// DWARF2 - /// - public static readonly DwarfAttributeKindEx DiscrList = new DwarfAttributeKindEx(DwarfNative.DW_AT_discr_list); - - public static readonly DwarfAttributeKindEx Encoding = new DwarfAttributeKindEx(DwarfNative.DW_AT_encoding); - - public static readonly DwarfAttributeKindEx External = new DwarfAttributeKindEx(DwarfNative.DW_AT_external); - - public static readonly DwarfAttributeKindEx FrameBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_frame_base); - - public static readonly DwarfAttributeKindEx Friend = new DwarfAttributeKindEx(DwarfNative.DW_AT_friend); - - public static readonly DwarfAttributeKindEx IdentifierCase = new DwarfAttributeKindEx(DwarfNative.DW_AT_identifier_case); - - /// - /// DWARF{234} not DWARF5 - /// - public static readonly DwarfAttributeKindEx MacroInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_macro_info); - - public static readonly DwarfAttributeKindEx NamelistItem = new DwarfAttributeKindEx(DwarfNative.DW_AT_namelist_item); - - public static readonly DwarfAttributeKindEx Priority = new DwarfAttributeKindEx(DwarfNative.DW_AT_priority); - - public static readonly DwarfAttributeKindEx Segment = new DwarfAttributeKindEx(DwarfNative.DW_AT_segment); - - public static readonly DwarfAttributeKindEx Specification = new DwarfAttributeKindEx(DwarfNative.DW_AT_specification); - - public static readonly DwarfAttributeKindEx StaticLink = new DwarfAttributeKindEx(DwarfNative.DW_AT_static_link); - - public static readonly DwarfAttributeKindEx Type = new DwarfAttributeKindEx(DwarfNative.DW_AT_type); - - public static readonly DwarfAttributeKindEx UseLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_location); - - public static readonly DwarfAttributeKindEx VariableParameter = new DwarfAttributeKindEx(DwarfNative.DW_AT_variable_parameter); - - public static readonly DwarfAttributeKindEx Virtuality = new DwarfAttributeKindEx(DwarfNative.DW_AT_virtuality); - - public static readonly DwarfAttributeKindEx VtableElemLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_vtable_elem_location); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Allocated = new DwarfAttributeKindEx(DwarfNative.DW_AT_allocated); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Associated = new DwarfAttributeKindEx(DwarfNative.DW_AT_associated); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx DataLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_location); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx ByteStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_byte_stride); - - /// - /// DWARF3 (do not use) - /// - public static readonly DwarfAttributeKindEx Stride = new DwarfAttributeKindEx(DwarfNative.DW_AT_stride); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx EntryPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_entry_pc); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx UseUTF8 = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_UTF8); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Extension = new DwarfAttributeKindEx(DwarfNative.DW_AT_extension); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Ranges = new DwarfAttributeKindEx(DwarfNative.DW_AT_ranges); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Trampoline = new DwarfAttributeKindEx(DwarfNative.DW_AT_trampoline); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx CallColumn = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_column); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx CallFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_file); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx CallLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_line); - - /// - /// DWARF3 - /// - public static readonly DwarfAttributeKindEx Description = new DwarfAttributeKindEx(DwarfNative.DW_AT_description); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx BinaryScale = new DwarfAttributeKindEx(DwarfNative.DW_AT_binary_scale); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx DecimalScale = new DwarfAttributeKindEx(DwarfNative.DW_AT_decimal_scale); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Small = new DwarfAttributeKindEx(DwarfNative.DW_AT_small); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx DecimalSign = new DwarfAttributeKindEx(DwarfNative.DW_AT_decimal_sign); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx DigitCount = new DwarfAttributeKindEx(DwarfNative.DW_AT_digit_count); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx PictureString = new DwarfAttributeKindEx(DwarfNative.DW_AT_picture_string); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Mutable = new DwarfAttributeKindEx(DwarfNative.DW_AT_mutable); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx ThreadsScaled = new DwarfAttributeKindEx(DwarfNative.DW_AT_threads_scaled); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Explicit = new DwarfAttributeKindEx(DwarfNative.DW_AT_explicit); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx ObjectPointer = new DwarfAttributeKindEx(DwarfNative.DW_AT_object_pointer); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Endianity = new DwarfAttributeKindEx(DwarfNative.DW_AT_endianity); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Elemental = new DwarfAttributeKindEx(DwarfNative.DW_AT_elemental); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Pure = new DwarfAttributeKindEx(DwarfNative.DW_AT_pure); - - /// - /// DWARF3f - /// - public static readonly DwarfAttributeKindEx Recursive = new DwarfAttributeKindEx(DwarfNative.DW_AT_recursive); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx Signature = new DwarfAttributeKindEx(DwarfNative.DW_AT_signature); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx MainSubprogram = new DwarfAttributeKindEx(DwarfNative.DW_AT_main_subprogram); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx DataBitOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_data_bit_offset); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx ConstExpr = new DwarfAttributeKindEx(DwarfNative.DW_AT_const_expr); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx EnumClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_enum_class); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeKindEx LinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_linkage_name); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx StringLengthBitSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length_bit_size); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx StringLengthByteSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_string_length_byte_size); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Rank = new DwarfAttributeKindEx(DwarfNative.DW_AT_rank); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx StrOffsetsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_str_offsets_base); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx AddrBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_addr_base); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx RnglistsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_rnglists_base); - - /// - /// DWARF4! - /// - public static readonly DwarfAttributeKindEx DwoId = new DwarfAttributeKindEx(DwarfNative.DW_AT_dwo_id); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx DwoName = new DwarfAttributeKindEx(DwarfNative.DW_AT_dwo_name); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Reference = new DwarfAttributeKindEx(DwarfNative.DW_AT_reference); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx RvalueReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_rvalue_reference); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Macros = new DwarfAttributeKindEx(DwarfNative.DW_AT_macros); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallAllCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_calls); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallAllSourceCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_source_calls); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallAllTailCalls = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_all_tail_calls); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallReturnPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_return_pc); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_value); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_origin); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallParameter = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_parameter); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_pc); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallTailCall = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_tail_call); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallTarget = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_target); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallTargetClobbered = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_target_clobbered); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallDataLocation = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_data_location); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx CallDataValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_call_data_value); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Noreturn = new DwarfAttributeKindEx(DwarfNative.DW_AT_noreturn); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Alignment = new DwarfAttributeKindEx(DwarfNative.DW_AT_alignment); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx ExportSymbols = new DwarfAttributeKindEx(DwarfNative.DW_AT_export_symbols); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Deleted = new DwarfAttributeKindEx(DwarfNative.DW_AT_deleted); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx Defaulted = new DwarfAttributeKindEx(DwarfNative.DW_AT_defaulted); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeKindEx LoclistsBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_loclists_base); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPBlockIndex = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_block_index); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSFde = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_fde); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSLoopBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_loop_begin); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSTailLoopBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_tail_loop_begin); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSEpilogBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_epilog_begin); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSLoopUnrollFactor = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_loop_unroll_factor); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSSoftwarePipelineDepth = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_software_pipeline_depth); - - /// - /// MIPS/SGI, GNU, and others. - /// - public static readonly DwarfAttributeKindEx MIPSLinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_linkage_name); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSStride = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSAbstractName = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_abstract_name); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSCloneOrigin = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_clone_origin); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSHasInlines = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_has_inlines); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSStrideByte = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride_byte); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSStrideElem = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_stride_elem); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSPtrDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_ptr_dopetype); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSAllocatableDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_allocatable_dopetype); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSAssumedShapeDopetype = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_assumed_shape_dopetype); - - /// - /// MIPS/SGI - /// - public static readonly DwarfAttributeKindEx MIPSAssumedSize = new DwarfAttributeKindEx(DwarfNative.DW_AT_MIPS_assumed_size); - - /// - /// conflict: MIPS - /// - public static readonly DwarfAttributeKindEx HPUnmodifiable = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_unmodifiable); - - /// - /// conflict: MIPS - /// - public static readonly DwarfAttributeKindEx HPActualsStmtList = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_actuals_stmt_list); - - /// - /// conflict: MIPS - /// - public static readonly DwarfAttributeKindEx HPProcPerSection = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_proc_per_section); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPRawDataPtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_raw_data_ptr); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPPassByReference = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_pass_by_reference); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPOptLevel = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_opt_level); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPProfVersionId = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_prof_version_id); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPOptFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_opt_flags); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPColdRegionLowPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_cold_region_low_pc); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPColdRegionHighPC = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_cold_region_high_pc); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPAllVariablesModifiable = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_all_variables_modifiable); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPLinkageName = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_linkage_name); - - /// - /// HP - /// - public static readonly DwarfAttributeKindEx HPProfFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_HP_prof_flags); - - /// - /// COMPAQ/HP - /// - public static readonly DwarfAttributeKindEx CPQDiscontigRanges = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_discontig_ranges); - - /// - /// COMPAQ/HP - /// - public static readonly DwarfAttributeKindEx CPQSemanticEvents = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_semantic_events); - - /// - /// COMPAQ/HP - /// - public static readonly DwarfAttributeKindEx CPQSplitLifetimesVar = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_split_lifetimes_var); - - /// - /// COMPAQ/HP - /// - public static readonly DwarfAttributeKindEx CPQSplitLifetimesRtn = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_split_lifetimes_rtn); - - /// - /// COMPAQ/HP - /// - public static readonly DwarfAttributeKindEx CPQPrologueLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_CPQ_prologue_length); - - /// - /// Intel, 1 if byte swapped. - /// - public static readonly DwarfAttributeKindEx INTELOtherEndian = new DwarfAttributeKindEx(DwarfNative.DW_AT_INTEL_other_endian); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx SfNames = new DwarfAttributeKindEx(DwarfNative.DW_AT_sf_names); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx SrcInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_src_info); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx MacInfo = new DwarfAttributeKindEx(DwarfNative.DW_AT_mac_info); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx SrcCoords = new DwarfAttributeKindEx(DwarfNative.DW_AT_src_coords); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx BodyBegin = new DwarfAttributeKindEx(DwarfNative.DW_AT_body_begin); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx BodyEnd = new DwarfAttributeKindEx(DwarfNative.DW_AT_body_end); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUVector = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_vector); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUGuardedBy = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_guarded_by); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUPtGuardedBy = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pt_guarded_by); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUGuarded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_guarded); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUPtGuarded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pt_guarded); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNULocksExcluded = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_locks_excluded); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUExclusiveLocksRequired = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_exclusive_locks_required); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUSharedLocksRequired = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_shared_locks_required); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUOdrSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_odr_signature); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUTemplateName = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_template_name); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUCallSiteValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_value); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUCallSiteDataValue = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_data_value); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUCallSiteTarget = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_target); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUCallSiteTargetClobbered = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_call_site_target_clobbered); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUTailCall = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_tail_call); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUAllTailCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_tail_call_sites); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUAllCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_call_sites); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUAllSourceCallSites = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_all_source_call_sites); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUMacros = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_macros); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUDwoName = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_dwo_name); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUDwoId = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_dwo_id); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNURangesBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_ranges_base); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUAddrBase = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_addr_base); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUPubnames = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pubnames); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUPubtypes = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_pubtypes); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUDiscriminator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_discriminator); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUNumerator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_numerator); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUDenominator = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_denominator); - - /// - /// GNU - /// - public static readonly DwarfAttributeKindEx GNUBias = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNU_bias); - - /// - /// ALTIUM - /// - public static readonly DwarfAttributeKindEx ALTIUMLoclist = new DwarfAttributeKindEx(DwarfNative.DW_AT_ALTIUM_loclist); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNTemplate = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_template); - - /// - /// VMS - /// - public static readonly DwarfAttributeKindEx VMSRtnbegPdAddress = new DwarfAttributeKindEx(DwarfNative.DW_AT_VMS_rtnbeg_pd_address); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNAlignment = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_alignment); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNVtable = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNCountGuarantee = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_count_guarantee); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNCommandLine = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_command_line); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNVbase = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vbase); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNCompileOptions = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_compile_options); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNLanguage = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_language); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNBrowserFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_browser_file); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNVtableAbi = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable_abi); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNFuncOffsets = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_func_offsets); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNCfKind = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_cf_kind); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNVtableIndex = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_vtable_index); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNOmpTprivAddr = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_omp_tpriv_addr); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNOmpChildFunc = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_omp_child_func); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNFuncOffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_func_offset); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNMemopTypeRef = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_memop_type_ref); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNProfileId = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_profile_id); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNMemopSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_memop_signature); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNObjDir = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_obj_dir); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNObjFile = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_obj_file); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNOriginalName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_original_name); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNHwcprofSignature = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_hwcprof_signature); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNAmd64Parmdump = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_amd64_parmdump); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNPartLinkName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_part_link_name); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNLinkName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_link_name); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNPassWithConst = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_pass_with_const); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNReturnWithConst = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_return_with_const); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNImportByName = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_import_by_name); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNF90Pointer = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_pointer); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNPassByRef = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_pass_by_ref); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNF90Allocatable = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_allocatable); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNF90AssumedShapeArray = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_assumed_shape_array); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNCVla = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_c_vla); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNReturnValuePtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_return_value_ptr); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNDtorStart = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_start); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNDtorLength = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_length); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNDtorStateInitial = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_initial); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNDtorStateFinal = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_final); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNDtorStateDeltas = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_dtor_state_deltas); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNImportByLname = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_import_by_lname); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNF90UseOnly = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_f90_use_only); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNNamelistSpec = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_namelist_spec); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNIsOmpChildFunc = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_is_omp_child_func); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNFortranMainAlias = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_fortran_main_alias); - - /// - /// SUN - /// - public static readonly DwarfAttributeKindEx SUNFortranBased = new DwarfAttributeKindEx(DwarfNative.DW_AT_SUN_fortran_based); - - /// - /// GNAT - /// - public static readonly DwarfAttributeKindEx UseGNATDescriptiveType = new DwarfAttributeKindEx(DwarfNative.DW_AT_use_GNAT_descriptive_type); - - /// - /// GNAT - /// - public static readonly DwarfAttributeKindEx GNATDescriptiveType = new DwarfAttributeKindEx(DwarfNative.DW_AT_GNAT_descriptive_type); - - /// - /// UPC - /// - public static readonly DwarfAttributeKindEx UpcThreadsScaled = new DwarfAttributeKindEx(DwarfNative.DW_AT_upc_threads_scaled); - - /// - /// PGI. Block, constant, reference. This attribute is an ASTPLAB extension used to describe the array local base. - /// - public static readonly DwarfAttributeKindEx PGILbase = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_lbase); - - /// - /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the section offset, or the offset to the first element in the dimension. - /// - public static readonly DwarfAttributeKindEx PGISoffset = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_soffset); - - /// - /// PGI. Block, constant, reference. ASTPLAB adds this attribute to describe the linear stride or the distance between elements in the dimension. - /// - public static readonly DwarfAttributeKindEx PGILstride = new DwarfAttributeKindEx(DwarfNative.DW_AT_PGI_lstride); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEOptimized = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_optimized); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEFlags = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_flags); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEIsa = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_isa); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEBlock = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_block); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEMajorRuntimeVers = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_major_runtime_vers); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLERuntimeClass = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_runtime_class); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEOmitFramePtr = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_omit_frame_ptr); - - /// - /// Apple - /// - public static readonly DwarfAttributeKindEx APPLEClosure = new DwarfAttributeKindEx(DwarfNative.DW_AT_APPLE_closure); - - private string ToStringInternal() - { - switch ((ushort)Value) - { - case DwarfNative.DW_AT_sibling: return "DW_AT_sibling"; - case DwarfNative.DW_AT_location: return "DW_AT_location"; - case DwarfNative.DW_AT_name: return "DW_AT_name"; - case DwarfNative.DW_AT_ordering: return "DW_AT_ordering"; - case DwarfNative.DW_AT_subscr_data: return "DW_AT_subscr_data"; - case DwarfNative.DW_AT_byte_size: return "DW_AT_byte_size"; - case DwarfNative.DW_AT_bit_offset: return "DW_AT_bit_offset"; - case DwarfNative.DW_AT_bit_size: return "DW_AT_bit_size"; - case DwarfNative.DW_AT_element_list: return "DW_AT_element_list"; - case DwarfNative.DW_AT_stmt_list: return "DW_AT_stmt_list"; - case DwarfNative.DW_AT_low_pc: return "DW_AT_low_pc"; - case DwarfNative.DW_AT_high_pc: return "DW_AT_high_pc"; - case DwarfNative.DW_AT_language: return "DW_AT_language"; - case DwarfNative.DW_AT_member: return "DW_AT_member"; - case DwarfNative.DW_AT_discr: return "DW_AT_discr"; - case DwarfNative.DW_AT_discr_value: return "DW_AT_discr_value"; - case DwarfNative.DW_AT_visibility: return "DW_AT_visibility"; - case DwarfNative.DW_AT_import: return "DW_AT_import"; - case DwarfNative.DW_AT_string_length: return "DW_AT_string_length"; - case DwarfNative.DW_AT_common_reference: return "DW_AT_common_reference"; - case DwarfNative.DW_AT_comp_dir: return "DW_AT_comp_dir"; - case DwarfNative.DW_AT_const_value: return "DW_AT_const_value"; - case DwarfNative.DW_AT_containing_type: return "DW_AT_containing_type"; - case DwarfNative.DW_AT_default_value: return "DW_AT_default_value"; - case DwarfNative.DW_AT_inline: return "DW_AT_inline"; - case DwarfNative.DW_AT_is_optional: return "DW_AT_is_optional"; - case DwarfNative.DW_AT_lower_bound: return "DW_AT_lower_bound"; - case DwarfNative.DW_AT_producer: return "DW_AT_producer"; - case DwarfNative.DW_AT_prototyped: return "DW_AT_prototyped"; - case DwarfNative.DW_AT_return_addr: return "DW_AT_return_addr"; - case DwarfNative.DW_AT_start_scope: return "DW_AT_start_scope"; - case DwarfNative.DW_AT_bit_stride: return "DW_AT_bit_stride"; - case DwarfNative.DW_AT_upper_bound: return "DW_AT_upper_bound"; - case DwarfNative.DW_AT_abstract_origin: return "DW_AT_abstract_origin"; - case DwarfNative.DW_AT_accessibility: return "DW_AT_accessibility"; - case DwarfNative.DW_AT_address_class: return "DW_AT_address_class"; - case DwarfNative.DW_AT_artificial: return "DW_AT_artificial"; - case DwarfNative.DW_AT_base_types: return "DW_AT_base_types"; - case DwarfNative.DW_AT_calling_convention: return "DW_AT_calling_convention"; - case DwarfNative.DW_AT_count: return "DW_AT_count"; - case DwarfNative.DW_AT_data_member_location: return "DW_AT_data_member_location"; - case DwarfNative.DW_AT_decl_column: return "DW_AT_decl_column"; - case DwarfNative.DW_AT_decl_file: return "DW_AT_decl_file"; - case DwarfNative.DW_AT_decl_line: return "DW_AT_decl_line"; - case DwarfNative.DW_AT_declaration: return "DW_AT_declaration"; - case DwarfNative.DW_AT_discr_list: return "DW_AT_discr_list"; - case DwarfNative.DW_AT_encoding: return "DW_AT_encoding"; - case DwarfNative.DW_AT_external: return "DW_AT_external"; - case DwarfNative.DW_AT_frame_base: return "DW_AT_frame_base"; - case DwarfNative.DW_AT_friend: return "DW_AT_friend"; - case DwarfNative.DW_AT_identifier_case: return "DW_AT_identifier_case"; - case DwarfNative.DW_AT_macro_info: return "DW_AT_macro_info"; - case DwarfNative.DW_AT_namelist_item: return "DW_AT_namelist_item"; - case DwarfNative.DW_AT_priority: return "DW_AT_priority"; - case DwarfNative.DW_AT_segment: return "DW_AT_segment"; - case DwarfNative.DW_AT_specification: return "DW_AT_specification"; - case DwarfNative.DW_AT_static_link: return "DW_AT_static_link"; - case DwarfNative.DW_AT_type: return "DW_AT_type"; - case DwarfNative.DW_AT_use_location: return "DW_AT_use_location"; - case DwarfNative.DW_AT_variable_parameter: return "DW_AT_variable_parameter"; - case DwarfNative.DW_AT_virtuality: return "DW_AT_virtuality"; - case DwarfNative.DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location"; - case DwarfNative.DW_AT_allocated: return "DW_AT_allocated"; - case DwarfNative.DW_AT_associated: return "DW_AT_associated"; - case DwarfNative.DW_AT_data_location: return "DW_AT_data_location"; - case DwarfNative.DW_AT_byte_stride: return "DW_AT_byte_stride"; - case DwarfNative.DW_AT_entry_pc: return "DW_AT_entry_pc"; - case DwarfNative.DW_AT_use_UTF8: return "DW_AT_use_UTF8"; - case DwarfNative.DW_AT_extension: return "DW_AT_extension"; - case DwarfNative.DW_AT_ranges: return "DW_AT_ranges"; - case DwarfNative.DW_AT_trampoline: return "DW_AT_trampoline"; - case DwarfNative.DW_AT_call_column: return "DW_AT_call_column"; - case DwarfNative.DW_AT_call_file: return "DW_AT_call_file"; - case DwarfNative.DW_AT_call_line: return "DW_AT_call_line"; - case DwarfNative.DW_AT_description: return "DW_AT_description"; - case DwarfNative.DW_AT_binary_scale: return "DW_AT_binary_scale"; - case DwarfNative.DW_AT_decimal_scale: return "DW_AT_decimal_scale"; - case DwarfNative.DW_AT_small: return "DW_AT_small"; - case DwarfNative.DW_AT_decimal_sign: return "DW_AT_decimal_sign"; - case DwarfNative.DW_AT_digit_count: return "DW_AT_digit_count"; - case DwarfNative.DW_AT_picture_string: return "DW_AT_picture_string"; - case DwarfNative.DW_AT_mutable: return "DW_AT_mutable"; - case DwarfNative.DW_AT_threads_scaled: return "DW_AT_threads_scaled"; - case DwarfNative.DW_AT_explicit: return "DW_AT_explicit"; - case DwarfNative.DW_AT_object_pointer: return "DW_AT_object_pointer"; - case DwarfNative.DW_AT_endianity: return "DW_AT_endianity"; - case DwarfNative.DW_AT_elemental: return "DW_AT_elemental"; - case DwarfNative.DW_AT_pure: return "DW_AT_pure"; - case DwarfNative.DW_AT_recursive: return "DW_AT_recursive"; - case DwarfNative.DW_AT_signature: return "DW_AT_signature"; - case DwarfNative.DW_AT_main_subprogram: return "DW_AT_main_subprogram"; - case DwarfNative.DW_AT_data_bit_offset: return "DW_AT_data_bit_offset"; - case DwarfNative.DW_AT_const_expr: return "DW_AT_const_expr"; - case DwarfNative.DW_AT_enum_class: return "DW_AT_enum_class"; - case DwarfNative.DW_AT_linkage_name: return "DW_AT_linkage_name"; - case DwarfNative.DW_AT_string_length_bit_size: return "DW_AT_string_length_bit_size"; - case DwarfNative.DW_AT_string_length_byte_size: return "DW_AT_string_length_byte_size"; - case DwarfNative.DW_AT_rank: return "DW_AT_rank"; - case DwarfNative.DW_AT_str_offsets_base: return "DW_AT_str_offsets_base"; - case DwarfNative.DW_AT_addr_base: return "DW_AT_addr_base"; - case DwarfNative.DW_AT_rnglists_base: return "DW_AT_rnglists_base"; - case DwarfNative.DW_AT_dwo_id: return "DW_AT_dwo_id"; - case DwarfNative.DW_AT_dwo_name: return "DW_AT_dwo_name"; - case DwarfNative.DW_AT_reference: return "DW_AT_reference"; - case DwarfNative.DW_AT_rvalue_reference: return "DW_AT_rvalue_reference"; - case DwarfNative.DW_AT_macros: return "DW_AT_macros"; - case DwarfNative.DW_AT_call_all_calls: return "DW_AT_call_all_calls"; - case DwarfNative.DW_AT_call_all_source_calls: return "DW_AT_call_all_source_calls"; - case DwarfNative.DW_AT_call_all_tail_calls: return "DW_AT_call_all_tail_calls"; - case DwarfNative.DW_AT_call_return_pc: return "DW_AT_call_return_pc"; - case DwarfNative.DW_AT_call_value: return "DW_AT_call_value"; - case DwarfNative.DW_AT_call_origin: return "DW_AT_call_origin"; - case DwarfNative.DW_AT_call_parameter: return "DW_AT_call_parameter"; - case DwarfNative.DW_AT_call_pc: return "DW_AT_call_pc"; - case DwarfNative.DW_AT_call_tail_call: return "DW_AT_call_tail_call"; - case DwarfNative.DW_AT_call_target: return "DW_AT_call_target"; - case DwarfNative.DW_AT_call_target_clobbered: return "DW_AT_call_target_clobbered"; - case DwarfNative.DW_AT_call_data_location: return "DW_AT_call_data_location"; - case DwarfNative.DW_AT_call_data_value: return "DW_AT_call_data_value"; - case DwarfNative.DW_AT_noreturn: return "DW_AT_noreturn"; - case DwarfNative.DW_AT_alignment: return "DW_AT_alignment"; - case DwarfNative.DW_AT_export_symbols: return "DW_AT_export_symbols"; - case DwarfNative.DW_AT_deleted: return "DW_AT_deleted"; - case DwarfNative.DW_AT_defaulted: return "DW_AT_defaulted"; - case DwarfNative.DW_AT_loclists_base: return "DW_AT_loclists_base"; - case DwarfNative.DW_AT_HP_block_index: return "DW_AT_HP_block_index"; - case DwarfNative.DW_AT_MIPS_fde: return "DW_AT_MIPS_fde"; - case DwarfNative.DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin"; - case DwarfNative.DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin"; - case DwarfNative.DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin"; - case DwarfNative.DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor"; - case DwarfNative.DW_AT_MIPS_software_pipeline_depth: return "DW_AT_MIPS_software_pipeline_depth"; - case DwarfNative.DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name"; - case DwarfNative.DW_AT_MIPS_stride: return "DW_AT_MIPS_stride"; - case DwarfNative.DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name"; - case DwarfNative.DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin"; - case DwarfNative.DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines"; - case DwarfNative.DW_AT_MIPS_stride_byte: return "DW_AT_MIPS_stride_byte"; - case DwarfNative.DW_AT_MIPS_stride_elem: return "DW_AT_MIPS_stride_elem"; - case DwarfNative.DW_AT_MIPS_ptr_dopetype: return "DW_AT_MIPS_ptr_dopetype"; - case DwarfNative.DW_AT_MIPS_allocatable_dopetype: return "DW_AT_MIPS_allocatable_dopetype"; - case DwarfNative.DW_AT_MIPS_assumed_shape_dopetype: return "DW_AT_MIPS_assumed_shape_dopetype"; - case DwarfNative.DW_AT_MIPS_assumed_size: return "DW_AT_MIPS_assumed_size"; - case DwarfNative.DW_AT_HP_raw_data_ptr: return "DW_AT_HP_raw_data_ptr"; - case DwarfNative.DW_AT_HP_pass_by_reference: return "DW_AT_HP_pass_by_reference"; - case DwarfNative.DW_AT_HP_opt_level: return "DW_AT_HP_opt_level"; - case DwarfNative.DW_AT_HP_prof_version_id: return "DW_AT_HP_prof_version_id"; - case DwarfNative.DW_AT_HP_opt_flags: return "DW_AT_HP_opt_flags"; - case DwarfNative.DW_AT_HP_cold_region_low_pc: return "DW_AT_HP_cold_region_low_pc"; - case DwarfNative.DW_AT_HP_cold_region_high_pc: return "DW_AT_HP_cold_region_high_pc"; - case DwarfNative.DW_AT_HP_all_variables_modifiable: return "DW_AT_HP_all_variables_modifiable"; - case DwarfNative.DW_AT_HP_linkage_name: return "DW_AT_HP_linkage_name"; - case DwarfNative.DW_AT_HP_prof_flags: return "DW_AT_HP_prof_flags"; - case DwarfNative.DW_AT_INTEL_other_endian: return "DW_AT_INTEL_other_endian"; - case DwarfNative.DW_AT_sf_names: return "DW_AT_sf_names"; - case DwarfNative.DW_AT_src_info: return "DW_AT_src_info"; - case DwarfNative.DW_AT_mac_info: return "DW_AT_mac_info"; - case DwarfNative.DW_AT_src_coords: return "DW_AT_src_coords"; - case DwarfNative.DW_AT_body_begin: return "DW_AT_body_begin"; - case DwarfNative.DW_AT_body_end: return "DW_AT_body_end"; - case DwarfNative.DW_AT_GNU_vector: return "DW_AT_GNU_vector"; - case DwarfNative.DW_AT_GNU_guarded_by: return "DW_AT_GNU_guarded_by"; - case DwarfNative.DW_AT_GNU_pt_guarded_by: return "DW_AT_GNU_pt_guarded_by"; - case DwarfNative.DW_AT_GNU_guarded: return "DW_AT_GNU_guarded"; - case DwarfNative.DW_AT_GNU_pt_guarded: return "DW_AT_GNU_pt_guarded"; - case DwarfNative.DW_AT_GNU_locks_excluded: return "DW_AT_GNU_locks_excluded"; - case DwarfNative.DW_AT_GNU_exclusive_locks_required: return "DW_AT_GNU_exclusive_locks_required"; - case DwarfNative.DW_AT_GNU_shared_locks_required: return "DW_AT_GNU_shared_locks_required"; - case DwarfNative.DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature"; - case DwarfNative.DW_AT_GNU_template_name: return "DW_AT_GNU_template_name"; - case DwarfNative.DW_AT_GNU_call_site_value: return "DW_AT_GNU_call_site_value"; - case DwarfNative.DW_AT_GNU_call_site_data_value: return "DW_AT_GNU_call_site_data_value"; - case DwarfNative.DW_AT_GNU_call_site_target: return "DW_AT_GNU_call_site_target"; - case DwarfNative.DW_AT_GNU_call_site_target_clobbered: return "DW_AT_GNU_call_site_target_clobbered"; - case DwarfNative.DW_AT_GNU_tail_call: return "DW_AT_GNU_tail_call"; - case DwarfNative.DW_AT_GNU_all_tail_call_sites: return "DW_AT_GNU_all_tail_call_sites"; - case DwarfNative.DW_AT_GNU_all_call_sites: return "DW_AT_GNU_all_call_sites"; - case DwarfNative.DW_AT_GNU_all_source_call_sites: return "DW_AT_GNU_all_source_call_sites"; - case DwarfNative.DW_AT_GNU_macros: return "DW_AT_GNU_macros"; - case DwarfNative.DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name"; - case DwarfNative.DW_AT_GNU_dwo_id: return "DW_AT_GNU_dwo_id"; - case DwarfNative.DW_AT_GNU_ranges_base: return "DW_AT_GNU_ranges_base"; - case DwarfNative.DW_AT_GNU_addr_base: return "DW_AT_GNU_addr_base"; - case DwarfNative.DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames"; - case DwarfNative.DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes"; - case DwarfNative.DW_AT_GNU_discriminator: return "DW_AT_GNU_discriminator"; - case DwarfNative.DW_AT_GNU_numerator: return "DW_AT_GNU_numerator"; - case DwarfNative.DW_AT_GNU_denominator: return "DW_AT_GNU_denominator"; - case DwarfNative.DW_AT_GNU_bias: return "DW_AT_GNU_bias"; - case DwarfNative.DW_AT_ALTIUM_loclist: return "DW_AT_ALTIUM_loclist"; - case DwarfNative.DW_AT_SUN_template: return "DW_AT_SUN_template"; - case DwarfNative.DW_AT_SUN_alignment: return "DW_AT_SUN_alignment"; - case DwarfNative.DW_AT_SUN_vtable: return "DW_AT_SUN_vtable"; - case DwarfNative.DW_AT_SUN_count_guarantee: return "DW_AT_SUN_count_guarantee"; - case DwarfNative.DW_AT_SUN_command_line: return "DW_AT_SUN_command_line"; - case DwarfNative.DW_AT_SUN_vbase: return "DW_AT_SUN_vbase"; - case DwarfNative.DW_AT_SUN_compile_options: return "DW_AT_SUN_compile_options"; - case DwarfNative.DW_AT_SUN_language: return "DW_AT_SUN_language"; - case DwarfNative.DW_AT_SUN_browser_file: return "DW_AT_SUN_browser_file"; - case DwarfNative.DW_AT_SUN_vtable_abi: return "DW_AT_SUN_vtable_abi"; - case DwarfNative.DW_AT_SUN_func_offsets: return "DW_AT_SUN_func_offsets"; - case DwarfNative.DW_AT_SUN_cf_kind: return "DW_AT_SUN_cf_kind"; - case DwarfNative.DW_AT_SUN_vtable_index: return "DW_AT_SUN_vtable_index"; - case DwarfNative.DW_AT_SUN_omp_tpriv_addr: return "DW_AT_SUN_omp_tpriv_addr"; - case DwarfNative.DW_AT_SUN_omp_child_func: return "DW_AT_SUN_omp_child_func"; - case DwarfNative.DW_AT_SUN_func_offset: return "DW_AT_SUN_func_offset"; - case DwarfNative.DW_AT_SUN_memop_type_ref: return "DW_AT_SUN_memop_type_ref"; - case DwarfNative.DW_AT_SUN_profile_id: return "DW_AT_SUN_profile_id"; - case DwarfNative.DW_AT_SUN_memop_signature: return "DW_AT_SUN_memop_signature"; - case DwarfNative.DW_AT_SUN_obj_dir: return "DW_AT_SUN_obj_dir"; - case DwarfNative.DW_AT_SUN_obj_file: return "DW_AT_SUN_obj_file"; - case DwarfNative.DW_AT_SUN_original_name: return "DW_AT_SUN_original_name"; - case DwarfNative.DW_AT_SUN_hwcprof_signature: return "DW_AT_SUN_hwcprof_signature"; - case DwarfNative.DW_AT_SUN_amd64_parmdump: return "DW_AT_SUN_amd64_parmdump"; - case DwarfNative.DW_AT_SUN_part_link_name: return "DW_AT_SUN_part_link_name"; - case DwarfNative.DW_AT_SUN_link_name: return "DW_AT_SUN_link_name"; - case DwarfNative.DW_AT_SUN_pass_with_const: return "DW_AT_SUN_pass_with_const"; - case DwarfNative.DW_AT_SUN_return_with_const: return "DW_AT_SUN_return_with_const"; - case DwarfNative.DW_AT_SUN_import_by_name: return "DW_AT_SUN_import_by_name"; - case DwarfNative.DW_AT_SUN_f90_pointer: return "DW_AT_SUN_f90_pointer"; - case DwarfNative.DW_AT_SUN_pass_by_ref: return "DW_AT_SUN_pass_by_ref"; - case DwarfNative.DW_AT_SUN_f90_allocatable: return "DW_AT_SUN_f90_allocatable"; - case DwarfNative.DW_AT_SUN_f90_assumed_shape_array: return "DW_AT_SUN_f90_assumed_shape_array"; - case DwarfNative.DW_AT_SUN_c_vla: return "DW_AT_SUN_c_vla"; - case DwarfNative.DW_AT_SUN_return_value_ptr: return "DW_AT_SUN_return_value_ptr"; - case DwarfNative.DW_AT_SUN_dtor_start: return "DW_AT_SUN_dtor_start"; - case DwarfNative.DW_AT_SUN_dtor_length: return "DW_AT_SUN_dtor_length"; - case DwarfNative.DW_AT_SUN_dtor_state_initial: return "DW_AT_SUN_dtor_state_initial"; - case DwarfNative.DW_AT_SUN_dtor_state_final: return "DW_AT_SUN_dtor_state_final"; - case DwarfNative.DW_AT_SUN_dtor_state_deltas: return "DW_AT_SUN_dtor_state_deltas"; - case DwarfNative.DW_AT_SUN_import_by_lname: return "DW_AT_SUN_import_by_lname"; - case DwarfNative.DW_AT_SUN_f90_use_only: return "DW_AT_SUN_f90_use_only"; - case DwarfNative.DW_AT_SUN_namelist_spec: return "DW_AT_SUN_namelist_spec"; - case DwarfNative.DW_AT_SUN_is_omp_child_func: return "DW_AT_SUN_is_omp_child_func"; - case DwarfNative.DW_AT_SUN_fortran_main_alias: return "DW_AT_SUN_fortran_main_alias"; - case DwarfNative.DW_AT_SUN_fortran_based: return "DW_AT_SUN_fortran_based"; - case DwarfNative.DW_AT_use_GNAT_descriptive_type: return "DW_AT_use_GNAT_descriptive_type"; - case DwarfNative.DW_AT_GNAT_descriptive_type: return "DW_AT_GNAT_descriptive_type"; - case DwarfNative.DW_AT_upc_threads_scaled: return "DW_AT_upc_threads_scaled"; - case DwarfNative.DW_AT_PGI_lbase: return "DW_AT_PGI_lbase"; - case DwarfNative.DW_AT_PGI_soffset: return "DW_AT_PGI_soffset"; - case DwarfNative.DW_AT_PGI_lstride: return "DW_AT_PGI_lstride"; - case DwarfNative.DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized"; - case DwarfNative.DW_AT_APPLE_flags: return "DW_AT_APPLE_flags"; - case DwarfNative.DW_AT_APPLE_isa: return "DW_AT_APPLE_isa"; - case DwarfNative.DW_AT_APPLE_block: return "DW_AT_APPLE_block"; - case DwarfNative.DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers"; - case DwarfNative.DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class"; - case DwarfNative.DW_AT_APPLE_omit_frame_ptr: return "DW_AT_APPLE_omit_frame_ptr"; - default: return null; - } - } - } - - public enum DwarfAttributeKind : ushort - { - Sibling = DwarfNative.DW_AT_sibling, - - Location = DwarfNative.DW_AT_location, - - Name = DwarfNative.DW_AT_name, - - Ordering = DwarfNative.DW_AT_ordering, - - SubscrData = DwarfNative.DW_AT_subscr_data, - - ByteSize = DwarfNative.DW_AT_byte_size, - - BitOffset = DwarfNative.DW_AT_bit_offset, - - BitSize = DwarfNative.DW_AT_bit_size, - - ElementList = DwarfNative.DW_AT_element_list, - - StmtList = DwarfNative.DW_AT_stmt_list, - - LowPC = DwarfNative.DW_AT_low_pc, - - HighPC = DwarfNative.DW_AT_high_pc, - - Language = DwarfNative.DW_AT_language, - - Member = DwarfNative.DW_AT_member, - - Discr = DwarfNative.DW_AT_discr, - - DiscrValue = DwarfNative.DW_AT_discr_value, - - Visibility = DwarfNative.DW_AT_visibility, - - Import = DwarfNative.DW_AT_import, - - StringLength = DwarfNative.DW_AT_string_length, - - CommonReference = DwarfNative.DW_AT_common_reference, - - CompDir = DwarfNative.DW_AT_comp_dir, - - ConstValue = DwarfNative.DW_AT_const_value, - - ContainingType = DwarfNative.DW_AT_containing_type, - - DefaultValue = DwarfNative.DW_AT_default_value, - - Inline = DwarfNative.DW_AT_inline, - - IsOptional = DwarfNative.DW_AT_is_optional, - - LowerBound = DwarfNative.DW_AT_lower_bound, - - Producer = DwarfNative.DW_AT_producer, - - Prototyped = DwarfNative.DW_AT_prototyped, - - ReturnAddr = DwarfNative.DW_AT_return_addr, - - StartScope = DwarfNative.DW_AT_start_scope, - - BitStride = DwarfNative.DW_AT_bit_stride, - - StrideSize = DwarfNative.DW_AT_stride_size, - - UpperBound = DwarfNative.DW_AT_upper_bound, - - AbstractOrigin = DwarfNative.DW_AT_abstract_origin, - - Accessibility = DwarfNative.DW_AT_accessibility, - - AddressClass = DwarfNative.DW_AT_address_class, - - Artificial = DwarfNative.DW_AT_artificial, - - BaseTypes = DwarfNative.DW_AT_base_types, - - CallingConvention = DwarfNative.DW_AT_calling_convention, - - Count = DwarfNative.DW_AT_count, - - DataMemberLocation = DwarfNative.DW_AT_data_member_location, - - DeclColumn = DwarfNative.DW_AT_decl_column, - - DeclFile = DwarfNative.DW_AT_decl_file, - - DeclLine = DwarfNative.DW_AT_decl_line, - - Declaration = DwarfNative.DW_AT_declaration, - - DiscrList = DwarfNative.DW_AT_discr_list, - - Encoding = DwarfNative.DW_AT_encoding, - - External = DwarfNative.DW_AT_external, - - FrameBase = DwarfNative.DW_AT_frame_base, - - Friend = DwarfNative.DW_AT_friend, - - IdentifierCase = DwarfNative.DW_AT_identifier_case, - - MacroInfo = DwarfNative.DW_AT_macro_info, - - NamelistItem = DwarfNative.DW_AT_namelist_item, - - Priority = DwarfNative.DW_AT_priority, - - Segment = DwarfNative.DW_AT_segment, - - Specification = DwarfNative.DW_AT_specification, - - StaticLink = DwarfNative.DW_AT_static_link, - - Type = DwarfNative.DW_AT_type, - - UseLocation = DwarfNative.DW_AT_use_location, - - VariableParameter = DwarfNative.DW_AT_variable_parameter, - - Virtuality = DwarfNative.DW_AT_virtuality, - - VtableElemLocation = DwarfNative.DW_AT_vtable_elem_location, - - Allocated = DwarfNative.DW_AT_allocated, - - Associated = DwarfNative.DW_AT_associated, - - DataLocation = DwarfNative.DW_AT_data_location, - - ByteStride = DwarfNative.DW_AT_byte_stride, - - Stride = DwarfNative.DW_AT_stride, - - EntryPC = DwarfNative.DW_AT_entry_pc, - - UseUTF8 = DwarfNative.DW_AT_use_UTF8, - - Extension = DwarfNative.DW_AT_extension, - - Ranges = DwarfNative.DW_AT_ranges, - - Trampoline = DwarfNative.DW_AT_trampoline, - - CallColumn = DwarfNative.DW_AT_call_column, - - CallFile = DwarfNative.DW_AT_call_file, - - CallLine = DwarfNative.DW_AT_call_line, - - Description = DwarfNative.DW_AT_description, - - BinaryScale = DwarfNative.DW_AT_binary_scale, - - DecimalScale = DwarfNative.DW_AT_decimal_scale, - - Small = DwarfNative.DW_AT_small, - - DecimalSign = DwarfNative.DW_AT_decimal_sign, - - DigitCount = DwarfNative.DW_AT_digit_count, - - PictureString = DwarfNative.DW_AT_picture_string, - - Mutable = DwarfNative.DW_AT_mutable, - - ThreadsScaled = DwarfNative.DW_AT_threads_scaled, - - Explicit = DwarfNative.DW_AT_explicit, - - ObjectPointer = DwarfNative.DW_AT_object_pointer, - - Endianity = DwarfNative.DW_AT_endianity, - - Elemental = DwarfNative.DW_AT_elemental, - - Pure = DwarfNative.DW_AT_pure, - - Recursive = DwarfNative.DW_AT_recursive, - - Signature = DwarfNative.DW_AT_signature, - - MainSubprogram = DwarfNative.DW_AT_main_subprogram, - - DataBitOffset = DwarfNative.DW_AT_data_bit_offset, - - ConstExpr = DwarfNative.DW_AT_const_expr, - - EnumClass = DwarfNative.DW_AT_enum_class, - - LinkageName = DwarfNative.DW_AT_linkage_name, - - StringLengthBitSize = DwarfNative.DW_AT_string_length_bit_size, - - StringLengthByteSize = DwarfNative.DW_AT_string_length_byte_size, - - Rank = DwarfNative.DW_AT_rank, - - StrOffsetsBase = DwarfNative.DW_AT_str_offsets_base, - - AddrBase = DwarfNative.DW_AT_addr_base, - - RnglistsBase = DwarfNative.DW_AT_rnglists_base, - - DwoId = DwarfNative.DW_AT_dwo_id, - - DwoName = DwarfNative.DW_AT_dwo_name, - - Reference = DwarfNative.DW_AT_reference, - - RvalueReference = DwarfNative.DW_AT_rvalue_reference, - - Macros = DwarfNative.DW_AT_macros, - - CallAllCalls = DwarfNative.DW_AT_call_all_calls, - - CallAllSourceCalls = DwarfNative.DW_AT_call_all_source_calls, - - CallAllTailCalls = DwarfNative.DW_AT_call_all_tail_calls, - - CallReturnPC = DwarfNative.DW_AT_call_return_pc, - - CallValue = DwarfNative.DW_AT_call_value, - - CallOrigin = DwarfNative.DW_AT_call_origin, - - CallParameter = DwarfNative.DW_AT_call_parameter, - - CallPC = DwarfNative.DW_AT_call_pc, - - CallTailCall = DwarfNative.DW_AT_call_tail_call, - - CallTarget = DwarfNative.DW_AT_call_target, - - CallTargetClobbered = DwarfNative.DW_AT_call_target_clobbered, - - CallDataLocation = DwarfNative.DW_AT_call_data_location, - - CallDataValue = DwarfNative.DW_AT_call_data_value, - - Noreturn = DwarfNative.DW_AT_noreturn, - - Alignment = DwarfNative.DW_AT_alignment, - - ExportSymbols = DwarfNative.DW_AT_export_symbols, - - Deleted = DwarfNative.DW_AT_deleted, - - Defaulted = DwarfNative.DW_AT_defaulted, - - LoclistsBase = DwarfNative.DW_AT_loclists_base, - - HPBlockIndex = DwarfNative.DW_AT_HP_block_index, - - MIPSFde = DwarfNative.DW_AT_MIPS_fde, - - MIPSLoopBegin = DwarfNative.DW_AT_MIPS_loop_begin, - - MIPSTailLoopBegin = DwarfNative.DW_AT_MIPS_tail_loop_begin, - - MIPSEpilogBegin = DwarfNative.DW_AT_MIPS_epilog_begin, - - MIPSLoopUnrollFactor = DwarfNative.DW_AT_MIPS_loop_unroll_factor, - - MIPSSoftwarePipelineDepth = DwarfNative.DW_AT_MIPS_software_pipeline_depth, - - MIPSLinkageName = DwarfNative.DW_AT_MIPS_linkage_name, - - MIPSStride = DwarfNative.DW_AT_MIPS_stride, - - MIPSAbstractName = DwarfNative.DW_AT_MIPS_abstract_name, - - MIPSCloneOrigin = DwarfNative.DW_AT_MIPS_clone_origin, - - MIPSHasInlines = DwarfNative.DW_AT_MIPS_has_inlines, - - MIPSStrideByte = DwarfNative.DW_AT_MIPS_stride_byte, - - MIPSStrideElem = DwarfNative.DW_AT_MIPS_stride_elem, - - MIPSPtrDopetype = DwarfNative.DW_AT_MIPS_ptr_dopetype, - - MIPSAllocatableDopetype = DwarfNative.DW_AT_MIPS_allocatable_dopetype, - - MIPSAssumedShapeDopetype = DwarfNative.DW_AT_MIPS_assumed_shape_dopetype, - - MIPSAssumedSize = DwarfNative.DW_AT_MIPS_assumed_size, - - HPUnmodifiable = DwarfNative.DW_AT_HP_unmodifiable, - - HPActualsStmtList = DwarfNative.DW_AT_HP_actuals_stmt_list, - - HPProcPerSection = DwarfNative.DW_AT_HP_proc_per_section, - - HPRawDataPtr = DwarfNative.DW_AT_HP_raw_data_ptr, - - HPPassByReference = DwarfNative.DW_AT_HP_pass_by_reference, - - HPOptLevel = DwarfNative.DW_AT_HP_opt_level, - - HPProfVersionId = DwarfNative.DW_AT_HP_prof_version_id, - - HPOptFlags = DwarfNative.DW_AT_HP_opt_flags, - - HPColdRegionLowPC = DwarfNative.DW_AT_HP_cold_region_low_pc, - - HPColdRegionHighPC = DwarfNative.DW_AT_HP_cold_region_high_pc, - - HPAllVariablesModifiable = DwarfNative.DW_AT_HP_all_variables_modifiable, - - HPLinkageName = DwarfNative.DW_AT_HP_linkage_name, - - HPProfFlags = DwarfNative.DW_AT_HP_prof_flags, - - CPQDiscontigRanges = DwarfNative.DW_AT_CPQ_discontig_ranges, - - CPQSemanticEvents = DwarfNative.DW_AT_CPQ_semantic_events, - - CPQSplitLifetimesVar = DwarfNative.DW_AT_CPQ_split_lifetimes_var, - - CPQSplitLifetimesRtn = DwarfNative.DW_AT_CPQ_split_lifetimes_rtn, - - CPQPrologueLength = DwarfNative.DW_AT_CPQ_prologue_length, - - INTELOtherEndian = DwarfNative.DW_AT_INTEL_other_endian, - - SfNames = DwarfNative.DW_AT_sf_names, - - SrcInfo = DwarfNative.DW_AT_src_info, - - MacInfo = DwarfNative.DW_AT_mac_info, - - SrcCoords = DwarfNative.DW_AT_src_coords, - - BodyBegin = DwarfNative.DW_AT_body_begin, - - BodyEnd = DwarfNative.DW_AT_body_end, - - GNUVector = DwarfNative.DW_AT_GNU_vector, - - GNUGuardedBy = DwarfNative.DW_AT_GNU_guarded_by, - - GNUPtGuardedBy = DwarfNative.DW_AT_GNU_pt_guarded_by, - - GNUGuarded = DwarfNative.DW_AT_GNU_guarded, - - GNUPtGuarded = DwarfNative.DW_AT_GNU_pt_guarded, - - GNULocksExcluded = DwarfNative.DW_AT_GNU_locks_excluded, - - GNUExclusiveLocksRequired = DwarfNative.DW_AT_GNU_exclusive_locks_required, - - GNUSharedLocksRequired = DwarfNative.DW_AT_GNU_shared_locks_required, - - GNUOdrSignature = DwarfNative.DW_AT_GNU_odr_signature, - - GNUTemplateName = DwarfNative.DW_AT_GNU_template_name, - - GNUCallSiteValue = DwarfNative.DW_AT_GNU_call_site_value, - - GNUCallSiteDataValue = DwarfNative.DW_AT_GNU_call_site_data_value, - - GNUCallSiteTarget = DwarfNative.DW_AT_GNU_call_site_target, - - GNUCallSiteTargetClobbered = DwarfNative.DW_AT_GNU_call_site_target_clobbered, - - GNUTailCall = DwarfNative.DW_AT_GNU_tail_call, - - GNUAllTailCallSites = DwarfNative.DW_AT_GNU_all_tail_call_sites, - - GNUAllCallSites = DwarfNative.DW_AT_GNU_all_call_sites, - - GNUAllSourceCallSites = DwarfNative.DW_AT_GNU_all_source_call_sites, - - GNUMacros = DwarfNative.DW_AT_GNU_macros, - - GNUDwoName = DwarfNative.DW_AT_GNU_dwo_name, - - GNUDwoId = DwarfNative.DW_AT_GNU_dwo_id, - - GNURangesBase = DwarfNative.DW_AT_GNU_ranges_base, - - GNUAddrBase = DwarfNative.DW_AT_GNU_addr_base, - - GNUPubnames = DwarfNative.DW_AT_GNU_pubnames, - - GNUPubtypes = DwarfNative.DW_AT_GNU_pubtypes, - - GNUDiscriminator = DwarfNative.DW_AT_GNU_discriminator, - - GNUNumerator = DwarfNative.DW_AT_GNU_numerator, - - GNUDenominator = DwarfNative.DW_AT_GNU_denominator, - - GNUBias = DwarfNative.DW_AT_GNU_bias, - - ALTIUMLoclist = DwarfNative.DW_AT_ALTIUM_loclist, - - SUNTemplate = DwarfNative.DW_AT_SUN_template, - - VMSRtnbegPdAddress = DwarfNative.DW_AT_VMS_rtnbeg_pd_address, - - SUNAlignment = DwarfNative.DW_AT_SUN_alignment, - - SUNVtable = DwarfNative.DW_AT_SUN_vtable, - - SUNCountGuarantee = DwarfNative.DW_AT_SUN_count_guarantee, - - SUNCommandLine = DwarfNative.DW_AT_SUN_command_line, - - SUNVbase = DwarfNative.DW_AT_SUN_vbase, - - SUNCompileOptions = DwarfNative.DW_AT_SUN_compile_options, - - SUNLanguage = DwarfNative.DW_AT_SUN_language, - - SUNBrowserFile = DwarfNative.DW_AT_SUN_browser_file, - - SUNVtableAbi = DwarfNative.DW_AT_SUN_vtable_abi, - - SUNFuncOffsets = DwarfNative.DW_AT_SUN_func_offsets, - - SUNCfKind = DwarfNative.DW_AT_SUN_cf_kind, - - SUNVtableIndex = DwarfNative.DW_AT_SUN_vtable_index, - - SUNOmpTprivAddr = DwarfNative.DW_AT_SUN_omp_tpriv_addr, - - SUNOmpChildFunc = DwarfNative.DW_AT_SUN_omp_child_func, - - SUNFuncOffset = DwarfNative.DW_AT_SUN_func_offset, - - SUNMemopTypeRef = DwarfNative.DW_AT_SUN_memop_type_ref, - - SUNProfileId = DwarfNative.DW_AT_SUN_profile_id, - - SUNMemopSignature = DwarfNative.DW_AT_SUN_memop_signature, - - SUNObjDir = DwarfNative.DW_AT_SUN_obj_dir, - - SUNObjFile = DwarfNative.DW_AT_SUN_obj_file, - - SUNOriginalName = DwarfNative.DW_AT_SUN_original_name, - - SUNHwcprofSignature = DwarfNative.DW_AT_SUN_hwcprof_signature, - - SUNAmd64Parmdump = DwarfNative.DW_AT_SUN_amd64_parmdump, - - SUNPartLinkName = DwarfNative.DW_AT_SUN_part_link_name, - - SUNLinkName = DwarfNative.DW_AT_SUN_link_name, - - SUNPassWithConst = DwarfNative.DW_AT_SUN_pass_with_const, - - SUNReturnWithConst = DwarfNative.DW_AT_SUN_return_with_const, - - SUNImportByName = DwarfNative.DW_AT_SUN_import_by_name, - - SUNF90Pointer = DwarfNative.DW_AT_SUN_f90_pointer, - - SUNPassByRef = DwarfNative.DW_AT_SUN_pass_by_ref, - - SUNF90Allocatable = DwarfNative.DW_AT_SUN_f90_allocatable, - - SUNF90AssumedShapeArray = DwarfNative.DW_AT_SUN_f90_assumed_shape_array, - - SUNCVla = DwarfNative.DW_AT_SUN_c_vla, - - SUNReturnValuePtr = DwarfNative.DW_AT_SUN_return_value_ptr, - - SUNDtorStart = DwarfNative.DW_AT_SUN_dtor_start, - - SUNDtorLength = DwarfNative.DW_AT_SUN_dtor_length, - - SUNDtorStateInitial = DwarfNative.DW_AT_SUN_dtor_state_initial, - - SUNDtorStateFinal = DwarfNative.DW_AT_SUN_dtor_state_final, - - SUNDtorStateDeltas = DwarfNative.DW_AT_SUN_dtor_state_deltas, - - SUNImportByLname = DwarfNative.DW_AT_SUN_import_by_lname, - - SUNF90UseOnly = DwarfNative.DW_AT_SUN_f90_use_only, - - SUNNamelistSpec = DwarfNative.DW_AT_SUN_namelist_spec, - - SUNIsOmpChildFunc = DwarfNative.DW_AT_SUN_is_omp_child_func, - - SUNFortranMainAlias = DwarfNative.DW_AT_SUN_fortran_main_alias, - - SUNFortranBased = DwarfNative.DW_AT_SUN_fortran_based, - - UseGNATDescriptiveType = DwarfNative.DW_AT_use_GNAT_descriptive_type, - - GNATDescriptiveType = DwarfNative.DW_AT_GNAT_descriptive_type, - - UpcThreadsScaled = DwarfNative.DW_AT_upc_threads_scaled, - - PGILbase = DwarfNative.DW_AT_PGI_lbase, - - PGISoffset = DwarfNative.DW_AT_PGI_soffset, - - PGILstride = DwarfNative.DW_AT_PGI_lstride, - - APPLEOptimized = DwarfNative.DW_AT_APPLE_optimized, - - APPLEFlags = DwarfNative.DW_AT_APPLE_flags, - - APPLEIsa = DwarfNative.DW_AT_APPLE_isa, - - APPLEBlock = DwarfNative.DW_AT_APPLE_block, - - APPLEMajorRuntimeVers = DwarfNative.DW_AT_APPLE_major_runtime_vers, - - APPLERuntimeClass = DwarfNative.DW_AT_APPLE_runtime_class, - - APPLEOmitFramePtr = DwarfNative.DW_AT_APPLE_omit_frame_ptr, - - APPLEClosure = DwarfNative.DW_AT_APPLE_closure, - } - - public readonly partial struct DwarfAttributeFormEx - { - public static readonly DwarfAttributeFormEx Addr = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addr); - - public static readonly DwarfAttributeFormEx Block2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block2); - - public static readonly DwarfAttributeFormEx Block4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block4); - - public static readonly DwarfAttributeFormEx Data2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data2); - - public static readonly DwarfAttributeFormEx Data4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data4); - - public static readonly DwarfAttributeFormEx Data8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data8); - - public static readonly DwarfAttributeFormEx String = new DwarfAttributeFormEx(DwarfNative.DW_FORM_string); - - public static readonly DwarfAttributeFormEx Block = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block); - - public static readonly DwarfAttributeFormEx Block1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_block1); - - public static readonly DwarfAttributeFormEx Data1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data1); - - public static readonly DwarfAttributeFormEx Flag = new DwarfAttributeFormEx(DwarfNative.DW_FORM_flag); - - public static readonly DwarfAttributeFormEx Sdata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_sdata); - - public static readonly DwarfAttributeFormEx Strp = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strp); - - public static readonly DwarfAttributeFormEx Udata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_udata); - - public static readonly DwarfAttributeFormEx RefAddr = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_addr); - - public static readonly DwarfAttributeFormEx Ref1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref1); - - public static readonly DwarfAttributeFormEx Ref2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref2); - - public static readonly DwarfAttributeFormEx Ref4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref4); - - public static readonly DwarfAttributeFormEx Ref8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref8); - - public static readonly DwarfAttributeFormEx RefUdata = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_udata); - - public static readonly DwarfAttributeFormEx Indirect = new DwarfAttributeFormEx(DwarfNative.DW_FORM_indirect); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeFormEx SecOffset = new DwarfAttributeFormEx(DwarfNative.DW_FORM_sec_offset); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeFormEx Exprloc = new DwarfAttributeFormEx(DwarfNative.DW_FORM_exprloc); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeFormEx FlagPresent = new DwarfAttributeFormEx(DwarfNative.DW_FORM_flag_present); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Strx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Addrx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx RefSup4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sup4); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx StrpSup = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strp_sup); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Data16 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_data16); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx LineStrp = new DwarfAttributeFormEx(DwarfNative.DW_FORM_line_strp); - - /// - /// DWARF4 - /// - public static readonly DwarfAttributeFormEx RefSig8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sig8); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx ImplicitConst = new DwarfAttributeFormEx(DwarfNative.DW_FORM_implicit_const); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Loclistx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_loclistx); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Rnglistx = new DwarfAttributeFormEx(DwarfNative.DW_FORM_rnglistx); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx RefSup8 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_ref_sup8); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Strx1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx1); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Strx2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx2); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Strx3 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx3); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Strx4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_strx4); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Addrx1 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx1); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Addrx2 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx2); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Addrx3 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx3); - - /// - /// DWARF5 - /// - public static readonly DwarfAttributeFormEx Addrx4 = new DwarfAttributeFormEx(DwarfNative.DW_FORM_addrx4); - - /// - /// GNU extension in debug_info.dwo. - /// - public static readonly DwarfAttributeFormEx GNUAddrIndex = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_addr_index); - - /// - /// GNU extension, somewhat like DW_FORM_strp - /// - public static readonly DwarfAttributeFormEx GNUStrIndex = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_str_index); - - /// - /// GNU extension. Offset in .debug_info. - /// - public static readonly DwarfAttributeFormEx GNURefAlt = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_ref_alt); - - /// - /// GNU extension. Offset in .debug_str of another object file. - /// - public static readonly DwarfAttributeFormEx GNUStrpAlt = new DwarfAttributeFormEx(DwarfNative.DW_FORM_GNU_strp_alt); - - private string ToStringInternal() - { - switch ((ushort)Value) - { - case DwarfNative.DW_FORM_addr: return "DW_FORM_addr"; - case DwarfNative.DW_FORM_block2: return "DW_FORM_block2"; - case DwarfNative.DW_FORM_block4: return "DW_FORM_block4"; - case DwarfNative.DW_FORM_data2: return "DW_FORM_data2"; - case DwarfNative.DW_FORM_data4: return "DW_FORM_data4"; - case DwarfNative.DW_FORM_data8: return "DW_FORM_data8"; - case DwarfNative.DW_FORM_string: return "DW_FORM_string"; - case DwarfNative.DW_FORM_block: return "DW_FORM_block"; - case DwarfNative.DW_FORM_block1: return "DW_FORM_block1"; - case DwarfNative.DW_FORM_data1: return "DW_FORM_data1"; - case DwarfNative.DW_FORM_flag: return "DW_FORM_flag"; - case DwarfNative.DW_FORM_sdata: return "DW_FORM_sdata"; - case DwarfNative.DW_FORM_strp: return "DW_FORM_strp"; - case DwarfNative.DW_FORM_udata: return "DW_FORM_udata"; - case DwarfNative.DW_FORM_ref_addr: return "DW_FORM_ref_addr"; - case DwarfNative.DW_FORM_ref1: return "DW_FORM_ref1"; - case DwarfNative.DW_FORM_ref2: return "DW_FORM_ref2"; - case DwarfNative.DW_FORM_ref4: return "DW_FORM_ref4"; - case DwarfNative.DW_FORM_ref8: return "DW_FORM_ref8"; - case DwarfNative.DW_FORM_ref_udata: return "DW_FORM_ref_udata"; - case DwarfNative.DW_FORM_indirect: return "DW_FORM_indirect"; - case DwarfNative.DW_FORM_sec_offset: return "DW_FORM_sec_offset"; - case DwarfNative.DW_FORM_exprloc: return "DW_FORM_exprloc"; - case DwarfNative.DW_FORM_flag_present: return "DW_FORM_flag_present"; - case DwarfNative.DW_FORM_strx: return "DW_FORM_strx"; - case DwarfNative.DW_FORM_addrx: return "DW_FORM_addrx"; - case DwarfNative.DW_FORM_ref_sup4: return "DW_FORM_ref_sup4"; - case DwarfNative.DW_FORM_strp_sup: return "DW_FORM_strp_sup"; - case DwarfNative.DW_FORM_data16: return "DW_FORM_data16"; - case DwarfNative.DW_FORM_line_strp: return "DW_FORM_line_strp"; - case DwarfNative.DW_FORM_ref_sig8: return "DW_FORM_ref_sig8"; - case DwarfNative.DW_FORM_implicit_const: return "DW_FORM_implicit_const"; - case DwarfNative.DW_FORM_loclistx: return "DW_FORM_loclistx"; - case DwarfNative.DW_FORM_rnglistx: return "DW_FORM_rnglistx"; - case DwarfNative.DW_FORM_ref_sup8: return "DW_FORM_ref_sup8"; - case DwarfNative.DW_FORM_strx1: return "DW_FORM_strx1"; - case DwarfNative.DW_FORM_strx2: return "DW_FORM_strx2"; - case DwarfNative.DW_FORM_strx3: return "DW_FORM_strx3"; - case DwarfNative.DW_FORM_strx4: return "DW_FORM_strx4"; - case DwarfNative.DW_FORM_addrx1: return "DW_FORM_addrx1"; - case DwarfNative.DW_FORM_addrx2: return "DW_FORM_addrx2"; - case DwarfNative.DW_FORM_addrx3: return "DW_FORM_addrx3"; - case DwarfNative.DW_FORM_addrx4: return "DW_FORM_addrx4"; - case DwarfNative.DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index"; - case DwarfNative.DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index"; - case DwarfNative.DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt"; - case DwarfNative.DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt"; - default: return null; - } - } - } - - public enum DwarfAttributeForm : ushort - { - Addr = DwarfNative.DW_FORM_addr, - - Block2 = DwarfNative.DW_FORM_block2, - - Block4 = DwarfNative.DW_FORM_block4, - - Data2 = DwarfNative.DW_FORM_data2, - - Data4 = DwarfNative.DW_FORM_data4, - - Data8 = DwarfNative.DW_FORM_data8, - - String = DwarfNative.DW_FORM_string, - - Block = DwarfNative.DW_FORM_block, - - Block1 = DwarfNative.DW_FORM_block1, - - Data1 = DwarfNative.DW_FORM_data1, - - Flag = DwarfNative.DW_FORM_flag, - - Sdata = DwarfNative.DW_FORM_sdata, - - Strp = DwarfNative.DW_FORM_strp, - - Udata = DwarfNative.DW_FORM_udata, - - RefAddr = DwarfNative.DW_FORM_ref_addr, - - Ref1 = DwarfNative.DW_FORM_ref1, - - Ref2 = DwarfNative.DW_FORM_ref2, - - Ref4 = DwarfNative.DW_FORM_ref4, - - Ref8 = DwarfNative.DW_FORM_ref8, - - RefUdata = DwarfNative.DW_FORM_ref_udata, - - Indirect = DwarfNative.DW_FORM_indirect, - - SecOffset = DwarfNative.DW_FORM_sec_offset, - - Exprloc = DwarfNative.DW_FORM_exprloc, - - FlagPresent = DwarfNative.DW_FORM_flag_present, - - Strx = DwarfNative.DW_FORM_strx, - - Addrx = DwarfNative.DW_FORM_addrx, - - RefSup4 = DwarfNative.DW_FORM_ref_sup4, - - StrpSup = DwarfNative.DW_FORM_strp_sup, - - Data16 = DwarfNative.DW_FORM_data16, - - LineStrp = DwarfNative.DW_FORM_line_strp, - - RefSig8 = DwarfNative.DW_FORM_ref_sig8, - - ImplicitConst = DwarfNative.DW_FORM_implicit_const, - - Loclistx = DwarfNative.DW_FORM_loclistx, - - Rnglistx = DwarfNative.DW_FORM_rnglistx, - - RefSup8 = DwarfNative.DW_FORM_ref_sup8, - - Strx1 = DwarfNative.DW_FORM_strx1, - - Strx2 = DwarfNative.DW_FORM_strx2, - - Strx3 = DwarfNative.DW_FORM_strx3, - - Strx4 = DwarfNative.DW_FORM_strx4, - - Addrx1 = DwarfNative.DW_FORM_addrx1, - - Addrx2 = DwarfNative.DW_FORM_addrx2, - - Addrx3 = DwarfNative.DW_FORM_addrx3, - - Addrx4 = DwarfNative.DW_FORM_addrx4, - - GNUAddrIndex = DwarfNative.DW_FORM_GNU_addr_index, - - GNUStrIndex = DwarfNative.DW_FORM_GNU_str_index, - - GNURefAlt = DwarfNative.DW_FORM_GNU_ref_alt, - - GNUStrpAlt = DwarfNative.DW_FORM_GNU_strp_alt, - } - - public readonly partial struct DwarfTagEx - { - public static readonly DwarfTagEx ArrayType = new DwarfTagEx(DwarfNative.DW_TAG_array_type); - - public static readonly DwarfTagEx ClassType = new DwarfTagEx(DwarfNative.DW_TAG_class_type); - - public static readonly DwarfTagEx EntryPoint = new DwarfTagEx(DwarfNative.DW_TAG_entry_point); - - public static readonly DwarfTagEx EnumerationType = new DwarfTagEx(DwarfNative.DW_TAG_enumeration_type); - - public static readonly DwarfTagEx FormalParameter = new DwarfTagEx(DwarfNative.DW_TAG_formal_parameter); - - public static readonly DwarfTagEx ImportedDeclaration = new DwarfTagEx(DwarfNative.DW_TAG_imported_declaration); - - public static readonly DwarfTagEx Label = new DwarfTagEx(DwarfNative.DW_TAG_label); - - public static readonly DwarfTagEx LexicalBlock = new DwarfTagEx(DwarfNative.DW_TAG_lexical_block); - - public static readonly DwarfTagEx Member = new DwarfTagEx(DwarfNative.DW_TAG_member); - - public static readonly DwarfTagEx PointerType = new DwarfTagEx(DwarfNative.DW_TAG_pointer_type); - - public static readonly DwarfTagEx ReferenceType = new DwarfTagEx(DwarfNative.DW_TAG_reference_type); - - public static readonly DwarfTagEx CompileUnit = new DwarfTagEx(DwarfNative.DW_TAG_compile_unit); - - public static readonly DwarfTagEx StringType = new DwarfTagEx(DwarfNative.DW_TAG_string_type); - - public static readonly DwarfTagEx StructureType = new DwarfTagEx(DwarfNative.DW_TAG_structure_type); - - public static readonly DwarfTagEx SubroutineType = new DwarfTagEx(DwarfNative.DW_TAG_subroutine_type); - - public static readonly DwarfTagEx Typedef = new DwarfTagEx(DwarfNative.DW_TAG_typedef); - - public static readonly DwarfTagEx UnionType = new DwarfTagEx(DwarfNative.DW_TAG_union_type); - - public static readonly DwarfTagEx UnspecifiedParameters = new DwarfTagEx(DwarfNative.DW_TAG_unspecified_parameters); - - public static readonly DwarfTagEx Variant = new DwarfTagEx(DwarfNative.DW_TAG_variant); - - public static readonly DwarfTagEx CommonBlock = new DwarfTagEx(DwarfNative.DW_TAG_common_block); - - public static readonly DwarfTagEx CommonInclusion = new DwarfTagEx(DwarfNative.DW_TAG_common_inclusion); - - public static readonly DwarfTagEx Inheritance = new DwarfTagEx(DwarfNative.DW_TAG_inheritance); - - public static readonly DwarfTagEx InlinedSubroutine = new DwarfTagEx(DwarfNative.DW_TAG_inlined_subroutine); - - public static readonly DwarfTagEx Module = new DwarfTagEx(DwarfNative.DW_TAG_module); - - public static readonly DwarfTagEx PtrToMemberType = new DwarfTagEx(DwarfNative.DW_TAG_ptr_to_member_type); - - public static readonly DwarfTagEx SetType = new DwarfTagEx(DwarfNative.DW_TAG_set_type); - - public static readonly DwarfTagEx SubrangeType = new DwarfTagEx(DwarfNative.DW_TAG_subrange_type); - - public static readonly DwarfTagEx WithStmt = new DwarfTagEx(DwarfNative.DW_TAG_with_stmt); - - public static readonly DwarfTagEx AccessDeclaration = new DwarfTagEx(DwarfNative.DW_TAG_access_declaration); - - public static readonly DwarfTagEx BaseType = new DwarfTagEx(DwarfNative.DW_TAG_base_type); - - public static readonly DwarfTagEx CatchBlock = new DwarfTagEx(DwarfNative.DW_TAG_catch_block); - - public static readonly DwarfTagEx ConstType = new DwarfTagEx(DwarfNative.DW_TAG_const_type); - - public static readonly DwarfTagEx Constant = new DwarfTagEx(DwarfNative.DW_TAG_constant); - - public static readonly DwarfTagEx Enumerator = new DwarfTagEx(DwarfNative.DW_TAG_enumerator); - - public static readonly DwarfTagEx FileType = new DwarfTagEx(DwarfNative.DW_TAG_file_type); - - public static readonly DwarfTagEx Friend = new DwarfTagEx(DwarfNative.DW_TAG_friend); - - public static readonly DwarfTagEx Namelist = new DwarfTagEx(DwarfNative.DW_TAG_namelist); - - /// - /// DWARF3/2 spelling - /// - public static readonly DwarfTagEx NamelistItem = new DwarfTagEx(DwarfNative.DW_TAG_namelist_item); - - /// - /// SGI misspelling/typo - /// - public static readonly DwarfTagEx NamelistItems = new DwarfTagEx(DwarfNative.DW_TAG_namelist_items); - - public static readonly DwarfTagEx PackedType = new DwarfTagEx(DwarfNative.DW_TAG_packed_type); - - public static readonly DwarfTagEx Subprogram = new DwarfTagEx(DwarfNative.DW_TAG_subprogram); - - /// - /// DWARF3/2 spelling - /// - public static readonly DwarfTagEx TemplateTypeParameter = new DwarfTagEx(DwarfNative.DW_TAG_template_type_parameter); - - /// - /// DWARF2 spelling - /// - public static readonly DwarfTagEx TemplateTypeParam = new DwarfTagEx(DwarfNative.DW_TAG_template_type_param); - - /// - /// DWARF3/2 spelling - /// - public static readonly DwarfTagEx TemplateValueParameter = new DwarfTagEx(DwarfNative.DW_TAG_template_value_parameter); - - /// - /// DWARF2 spelling - /// - public static readonly DwarfTagEx TemplateValueParam = new DwarfTagEx(DwarfNative.DW_TAG_template_value_param); - - public static readonly DwarfTagEx ThrownType = new DwarfTagEx(DwarfNative.DW_TAG_thrown_type); - - public static readonly DwarfTagEx TryBlock = new DwarfTagEx(DwarfNative.DW_TAG_try_block); - - public static readonly DwarfTagEx VariantPart = new DwarfTagEx(DwarfNative.DW_TAG_variant_part); - - public static readonly DwarfTagEx Variable = new DwarfTagEx(DwarfNative.DW_TAG_variable); - - public static readonly DwarfTagEx VolatileType = new DwarfTagEx(DwarfNative.DW_TAG_volatile_type); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx DwarfProcedure = new DwarfTagEx(DwarfNative.DW_TAG_dwarf_procedure); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx RestrictType = new DwarfTagEx(DwarfNative.DW_TAG_restrict_type); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx InterfaceType = new DwarfTagEx(DwarfNative.DW_TAG_interface_type); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx Namespace = new DwarfTagEx(DwarfNative.DW_TAG_namespace); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx ImportedModule = new DwarfTagEx(DwarfNative.DW_TAG_imported_module); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx UnspecifiedType = new DwarfTagEx(DwarfNative.DW_TAG_unspecified_type); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx PartialUnit = new DwarfTagEx(DwarfNative.DW_TAG_partial_unit); - - /// - /// DWARF3 - /// - public static readonly DwarfTagEx ImportedUnit = new DwarfTagEx(DwarfNative.DW_TAG_imported_unit); - - /// - /// Withdrawn from DWARF3 by DWARF3f. - /// - public static readonly DwarfTagEx MutableType = new DwarfTagEx(DwarfNative.DW_TAG_mutable_type); - - /// - /// DWARF3f - /// - public static readonly DwarfTagEx Condition = new DwarfTagEx(DwarfNative.DW_TAG_condition); - - /// - /// DWARF3f - /// - public static readonly DwarfTagEx SharedType = new DwarfTagEx(DwarfNative.DW_TAG_shared_type); - - /// - /// DWARF4 - /// - public static readonly DwarfTagEx TypeUnit = new DwarfTagEx(DwarfNative.DW_TAG_type_unit); - - /// - /// DWARF4 - /// - public static readonly DwarfTagEx RvalueReferenceType = new DwarfTagEx(DwarfNative.DW_TAG_rvalue_reference_type); - - /// - /// DWARF4 - /// - public static readonly DwarfTagEx TemplateAlias = new DwarfTagEx(DwarfNative.DW_TAG_template_alias); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx CoarrayType = new DwarfTagEx(DwarfNative.DW_TAG_coarray_type); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx GenericSubrange = new DwarfTagEx(DwarfNative.DW_TAG_generic_subrange); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx DynamicType = new DwarfTagEx(DwarfNative.DW_TAG_dynamic_type); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx AtomicType = new DwarfTagEx(DwarfNative.DW_TAG_atomic_type); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx CallSite = new DwarfTagEx(DwarfNative.DW_TAG_call_site); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx CallSiteParameter = new DwarfTagEx(DwarfNative.DW_TAG_call_site_parameter); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx SkeletonUnit = new DwarfTagEx(DwarfNative.DW_TAG_skeleton_unit); - - /// - /// DWARF5 - /// - public static readonly DwarfTagEx ImmutableType = new DwarfTagEx(DwarfNative.DW_TAG_immutable_type); - - public static readonly DwarfTagEx MIPSLoop = new DwarfTagEx(DwarfNative.DW_TAG_MIPS_loop); - - /// - /// HP - /// - public static readonly DwarfTagEx HPArrayDescriptor = new DwarfTagEx(DwarfNative.DW_TAG_HP_array_descriptor); - - /// - /// GNU. Fortran. - /// - public static readonly DwarfTagEx FormatLabel = new DwarfTagEx(DwarfNative.DW_TAG_format_label); - - /// - /// GNU. For C++ - /// - public static readonly DwarfTagEx FunctionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_function_template); - - /// - /// GNU. For C++ - /// - public static readonly DwarfTagEx ClassTemplate = new DwarfTagEx(DwarfNative.DW_TAG_class_template); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUBINCL = new DwarfTagEx(DwarfNative.DW_TAG_GNU_BINCL); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUEINCL = new DwarfTagEx(DwarfNative.DW_TAG_GNU_EINCL); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUTemplateTemplateParameter = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_template_parameter); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUTemplateTemplateParam = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_template_param); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUTemplateParameterPack = new DwarfTagEx(DwarfNative.DW_TAG_GNU_template_parameter_pack); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUFormalParameterPack = new DwarfTagEx(DwarfNative.DW_TAG_GNU_formal_parameter_pack); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUCallSite = new DwarfTagEx(DwarfNative.DW_TAG_GNU_call_site); - - /// - /// GNU - /// - public static readonly DwarfTagEx GNUCallSiteParameter = new DwarfTagEx(DwarfNative.DW_TAG_GNU_call_site_parameter); - - /// - /// ALTIUM - /// - public static readonly DwarfTagEx ALTIUMCircType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_circ_type); - - /// - /// ALTIUM - /// - public static readonly DwarfTagEx ALTIUMMwaCircType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_mwa_circ_type); - - /// - /// ALTIUM - /// - public static readonly DwarfTagEx ALTIUMRevCarryType = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_rev_carry_type); - - /// - /// ALTIUM - /// - public static readonly DwarfTagEx ALTIUMRom = new DwarfTagEx(DwarfNative.DW_TAG_ALTIUM_rom); - - /// - /// UPC - /// - public static readonly DwarfTagEx UpcSharedType = new DwarfTagEx(DwarfNative.DW_TAG_upc_shared_type); - - /// - /// UPC - /// - public static readonly DwarfTagEx UpcStrictType = new DwarfTagEx(DwarfNative.DW_TAG_upc_strict_type); - - /// - /// UPC - /// - public static readonly DwarfTagEx UpcRelaxedType = new DwarfTagEx(DwarfNative.DW_TAG_upc_relaxed_type); - - /// - /// PGI - /// - public static readonly DwarfTagEx PGIKanjiType = new DwarfTagEx(DwarfNative.DW_TAG_PGI_kanji_type); - - /// - /// PGI - /// - public static readonly DwarfTagEx PGIInterfaceBlock = new DwarfTagEx(DwarfNative.DW_TAG_PGI_interface_block); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNFunctionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_function_template); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNClassTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_class_template); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNStructTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_struct_template); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNUnionTemplate = new DwarfTagEx(DwarfNative.DW_TAG_SUN_union_template); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNIndirectInheritance = new DwarfTagEx(DwarfNative.DW_TAG_SUN_indirect_inheritance); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNCodeflags = new DwarfTagEx(DwarfNative.DW_TAG_SUN_codeflags); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNMemopInfo = new DwarfTagEx(DwarfNative.DW_TAG_SUN_memop_info); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNOmpChildFunc = new DwarfTagEx(DwarfNative.DW_TAG_SUN_omp_child_func); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNRttiDescriptor = new DwarfTagEx(DwarfNative.DW_TAG_SUN_rtti_descriptor); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNDtorInfo = new DwarfTagEx(DwarfNative.DW_TAG_SUN_dtor_info); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNDtor = new DwarfTagEx(DwarfNative.DW_TAG_SUN_dtor); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNF90Interface = new DwarfTagEx(DwarfNative.DW_TAG_SUN_f90_interface); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNFortranVaxStructure = new DwarfTagEx(DwarfNative.DW_TAG_SUN_fortran_vax_structure); - - /// - /// SUN - /// - public static readonly DwarfTagEx SUNHi = new DwarfTagEx(DwarfNative.DW_TAG_SUN_hi); - - private string ToStringInternal() - { - switch ((ushort)Value) - { - case DwarfNative.DW_TAG_array_type: return "DW_TAG_array_type"; - case DwarfNative.DW_TAG_class_type: return "DW_TAG_class_type"; - case DwarfNative.DW_TAG_entry_point: return "DW_TAG_entry_point"; - case DwarfNative.DW_TAG_enumeration_type: return "DW_TAG_enumeration_type"; - case DwarfNative.DW_TAG_formal_parameter: return "DW_TAG_formal_parameter"; - case DwarfNative.DW_TAG_imported_declaration: return "DW_TAG_imported_declaration"; - case DwarfNative.DW_TAG_label: return "DW_TAG_label"; - case DwarfNative.DW_TAG_lexical_block: return "DW_TAG_lexical_block"; - case DwarfNative.DW_TAG_member: return "DW_TAG_member"; - case DwarfNative.DW_TAG_pointer_type: return "DW_TAG_pointer_type"; - case DwarfNative.DW_TAG_reference_type: return "DW_TAG_reference_type"; - case DwarfNative.DW_TAG_compile_unit: return "DW_TAG_compile_unit"; - case DwarfNative.DW_TAG_string_type: return "DW_TAG_string_type"; - case DwarfNative.DW_TAG_structure_type: return "DW_TAG_structure_type"; - case DwarfNative.DW_TAG_subroutine_type: return "DW_TAG_subroutine_type"; - case DwarfNative.DW_TAG_typedef: return "DW_TAG_typedef"; - case DwarfNative.DW_TAG_union_type: return "DW_TAG_union_type"; - case DwarfNative.DW_TAG_unspecified_parameters: return "DW_TAG_unspecified_parameters"; - case DwarfNative.DW_TAG_variant: return "DW_TAG_variant"; - case DwarfNative.DW_TAG_common_block: return "DW_TAG_common_block"; - case DwarfNative.DW_TAG_common_inclusion: return "DW_TAG_common_inclusion"; - case DwarfNative.DW_TAG_inheritance: return "DW_TAG_inheritance"; - case DwarfNative.DW_TAG_inlined_subroutine: return "DW_TAG_inlined_subroutine"; - case DwarfNative.DW_TAG_module: return "DW_TAG_module"; - case DwarfNative.DW_TAG_ptr_to_member_type: return "DW_TAG_ptr_to_member_type"; - case DwarfNative.DW_TAG_set_type: return "DW_TAG_set_type"; - case DwarfNative.DW_TAG_subrange_type: return "DW_TAG_subrange_type"; - case DwarfNative.DW_TAG_with_stmt: return "DW_TAG_with_stmt"; - case DwarfNative.DW_TAG_access_declaration: return "DW_TAG_access_declaration"; - case DwarfNative.DW_TAG_base_type: return "DW_TAG_base_type"; - case DwarfNative.DW_TAG_catch_block: return "DW_TAG_catch_block"; - case DwarfNative.DW_TAG_const_type: return "DW_TAG_const_type"; - case DwarfNative.DW_TAG_constant: return "DW_TAG_constant"; - case DwarfNative.DW_TAG_enumerator: return "DW_TAG_enumerator"; - case DwarfNative.DW_TAG_file_type: return "DW_TAG_file_type"; - case DwarfNative.DW_TAG_friend: return "DW_TAG_friend"; - case DwarfNative.DW_TAG_namelist: return "DW_TAG_namelist"; - case DwarfNative.DW_TAG_namelist_item: return "DW_TAG_namelist_item"; - case DwarfNative.DW_TAG_packed_type: return "DW_TAG_packed_type"; - case DwarfNative.DW_TAG_subprogram: return "DW_TAG_subprogram"; - case DwarfNative.DW_TAG_template_type_parameter: return "DW_TAG_template_type_parameter"; - case DwarfNative.DW_TAG_template_value_parameter: return "DW_TAG_template_value_parameter"; - case DwarfNative.DW_TAG_thrown_type: return "DW_TAG_thrown_type"; - case DwarfNative.DW_TAG_try_block: return "DW_TAG_try_block"; - case DwarfNative.DW_TAG_variant_part: return "DW_TAG_variant_part"; - case DwarfNative.DW_TAG_variable: return "DW_TAG_variable"; - case DwarfNative.DW_TAG_volatile_type: return "DW_TAG_volatile_type"; - case DwarfNative.DW_TAG_dwarf_procedure: return "DW_TAG_dwarf_procedure"; - case DwarfNative.DW_TAG_restrict_type: return "DW_TAG_restrict_type"; - case DwarfNative.DW_TAG_interface_type: return "DW_TAG_interface_type"; - case DwarfNative.DW_TAG_namespace: return "DW_TAG_namespace"; - case DwarfNative.DW_TAG_imported_module: return "DW_TAG_imported_module"; - case DwarfNative.DW_TAG_unspecified_type: return "DW_TAG_unspecified_type"; - case DwarfNative.DW_TAG_partial_unit: return "DW_TAG_partial_unit"; - case DwarfNative.DW_TAG_imported_unit: return "DW_TAG_imported_unit"; - case DwarfNative.DW_TAG_mutable_type: return "DW_TAG_mutable_type"; - case DwarfNative.DW_TAG_condition: return "DW_TAG_condition"; - case DwarfNative.DW_TAG_shared_type: return "DW_TAG_shared_type"; - case DwarfNative.DW_TAG_type_unit: return "DW_TAG_type_unit"; - case DwarfNative.DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type"; - case DwarfNative.DW_TAG_template_alias: return "DW_TAG_template_alias"; - case DwarfNative.DW_TAG_coarray_type: return "DW_TAG_coarray_type"; - case DwarfNative.DW_TAG_generic_subrange: return "DW_TAG_generic_subrange"; - case DwarfNative.DW_TAG_dynamic_type: return "DW_TAG_dynamic_type"; - case DwarfNative.DW_TAG_atomic_type: return "DW_TAG_atomic_type"; - case DwarfNative.DW_TAG_call_site: return "DW_TAG_call_site"; - case DwarfNative.DW_TAG_call_site_parameter: return "DW_TAG_call_site_parameter"; - case DwarfNative.DW_TAG_skeleton_unit: return "DW_TAG_skeleton_unit"; - case DwarfNative.DW_TAG_immutable_type: return "DW_TAG_immutable_type"; - case DwarfNative.DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop"; - case DwarfNative.DW_TAG_HP_array_descriptor: return "DW_TAG_HP_array_descriptor"; - case DwarfNative.DW_TAG_format_label: return "DW_TAG_format_label"; - case DwarfNative.DW_TAG_function_template: return "DW_TAG_function_template"; - case DwarfNative.DW_TAG_class_template: return "DW_TAG_class_template"; - case DwarfNative.DW_TAG_GNU_BINCL: return "DW_TAG_GNU_BINCL"; - case DwarfNative.DW_TAG_GNU_EINCL: return "DW_TAG_GNU_EINCL"; - case DwarfNative.DW_TAG_GNU_template_template_parameter: return "DW_TAG_GNU_template_template_parameter"; - case DwarfNative.DW_TAG_GNU_template_parameter_pack: return "DW_TAG_GNU_template_parameter_pack"; - case DwarfNative.DW_TAG_GNU_formal_parameter_pack: return "DW_TAG_GNU_formal_parameter_pack"; - case DwarfNative.DW_TAG_GNU_call_site: return "DW_TAG_GNU_call_site"; - case DwarfNative.DW_TAG_GNU_call_site_parameter: return "DW_TAG_GNU_call_site_parameter"; - case DwarfNative.DW_TAG_ALTIUM_circ_type: return "DW_TAG_ALTIUM_circ_type"; - case DwarfNative.DW_TAG_ALTIUM_mwa_circ_type: return "DW_TAG_ALTIUM_mwa_circ_type"; - case DwarfNative.DW_TAG_ALTIUM_rev_carry_type: return "DW_TAG_ALTIUM_rev_carry_type"; - case DwarfNative.DW_TAG_ALTIUM_rom: return "DW_TAG_ALTIUM_rom"; - case DwarfNative.DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type"; - case DwarfNative.DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type"; - case DwarfNative.DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type"; - case DwarfNative.DW_TAG_PGI_kanji_type: return "DW_TAG_PGI_kanji_type"; - case DwarfNative.DW_TAG_PGI_interface_block: return "DW_TAG_PGI_interface_block"; - case DwarfNative.DW_TAG_SUN_function_template: return "DW_TAG_SUN_function_template"; - case DwarfNative.DW_TAG_SUN_class_template: return "DW_TAG_SUN_class_template"; - case DwarfNative.DW_TAG_SUN_struct_template: return "DW_TAG_SUN_struct_template"; - case DwarfNative.DW_TAG_SUN_union_template: return "DW_TAG_SUN_union_template"; - case DwarfNative.DW_TAG_SUN_indirect_inheritance: return "DW_TAG_SUN_indirect_inheritance"; - case DwarfNative.DW_TAG_SUN_codeflags: return "DW_TAG_SUN_codeflags"; - case DwarfNative.DW_TAG_SUN_memop_info: return "DW_TAG_SUN_memop_info"; - case DwarfNative.DW_TAG_SUN_omp_child_func: return "DW_TAG_SUN_omp_child_func"; - case DwarfNative.DW_TAG_SUN_rtti_descriptor: return "DW_TAG_SUN_rtti_descriptor"; - case DwarfNative.DW_TAG_SUN_dtor_info: return "DW_TAG_SUN_dtor_info"; - case DwarfNative.DW_TAG_SUN_dtor: return "DW_TAG_SUN_dtor"; - case DwarfNative.DW_TAG_SUN_f90_interface: return "DW_TAG_SUN_f90_interface"; - case DwarfNative.DW_TAG_SUN_fortran_vax_structure: return "DW_TAG_SUN_fortran_vax_structure"; - case DwarfNative.DW_TAG_SUN_hi: return "DW_TAG_SUN_hi"; - default: return null; - } - } - } - - public enum DwarfTag : ushort - { - ArrayType = DwarfNative.DW_TAG_array_type, - - ClassType = DwarfNative.DW_TAG_class_type, - - EntryPoint = DwarfNative.DW_TAG_entry_point, - - EnumerationType = DwarfNative.DW_TAG_enumeration_type, - - FormalParameter = DwarfNative.DW_TAG_formal_parameter, - - ImportedDeclaration = DwarfNative.DW_TAG_imported_declaration, - - Label = DwarfNative.DW_TAG_label, - - LexicalBlock = DwarfNative.DW_TAG_lexical_block, - - Member = DwarfNative.DW_TAG_member, - - PointerType = DwarfNative.DW_TAG_pointer_type, - - ReferenceType = DwarfNative.DW_TAG_reference_type, - - CompileUnit = DwarfNative.DW_TAG_compile_unit, - - StringType = DwarfNative.DW_TAG_string_type, - - StructureType = DwarfNative.DW_TAG_structure_type, - - SubroutineType = DwarfNative.DW_TAG_subroutine_type, - - Typedef = DwarfNative.DW_TAG_typedef, - - UnionType = DwarfNative.DW_TAG_union_type, - - UnspecifiedParameters = DwarfNative.DW_TAG_unspecified_parameters, - - Variant = DwarfNative.DW_TAG_variant, - - CommonBlock = DwarfNative.DW_TAG_common_block, - - CommonInclusion = DwarfNative.DW_TAG_common_inclusion, - - Inheritance = DwarfNative.DW_TAG_inheritance, - - InlinedSubroutine = DwarfNative.DW_TAG_inlined_subroutine, - - Module = DwarfNative.DW_TAG_module, - - PtrToMemberType = DwarfNative.DW_TAG_ptr_to_member_type, - - SetType = DwarfNative.DW_TAG_set_type, - - SubrangeType = DwarfNative.DW_TAG_subrange_type, - - WithStmt = DwarfNative.DW_TAG_with_stmt, - - AccessDeclaration = DwarfNative.DW_TAG_access_declaration, - - BaseType = DwarfNative.DW_TAG_base_type, - - CatchBlock = DwarfNative.DW_TAG_catch_block, - - ConstType = DwarfNative.DW_TAG_const_type, - - Constant = DwarfNative.DW_TAG_constant, - - Enumerator = DwarfNative.DW_TAG_enumerator, - - FileType = DwarfNative.DW_TAG_file_type, - - Friend = DwarfNative.DW_TAG_friend, - - Namelist = DwarfNative.DW_TAG_namelist, - - NamelistItem = DwarfNative.DW_TAG_namelist_item, - - NamelistItems = DwarfNative.DW_TAG_namelist_items, - - PackedType = DwarfNative.DW_TAG_packed_type, - - Subprogram = DwarfNative.DW_TAG_subprogram, - - TemplateTypeParameter = DwarfNative.DW_TAG_template_type_parameter, - - TemplateTypeParam = DwarfNative.DW_TAG_template_type_param, - - TemplateValueParameter = DwarfNative.DW_TAG_template_value_parameter, - - TemplateValueParam = DwarfNative.DW_TAG_template_value_param, - - ThrownType = DwarfNative.DW_TAG_thrown_type, - - TryBlock = DwarfNative.DW_TAG_try_block, - - VariantPart = DwarfNative.DW_TAG_variant_part, - - Variable = DwarfNative.DW_TAG_variable, - - VolatileType = DwarfNative.DW_TAG_volatile_type, - - DwarfProcedure = DwarfNative.DW_TAG_dwarf_procedure, - - RestrictType = DwarfNative.DW_TAG_restrict_type, - - InterfaceType = DwarfNative.DW_TAG_interface_type, - - Namespace = DwarfNative.DW_TAG_namespace, - - ImportedModule = DwarfNative.DW_TAG_imported_module, - - UnspecifiedType = DwarfNative.DW_TAG_unspecified_type, - - PartialUnit = DwarfNative.DW_TAG_partial_unit, - - ImportedUnit = DwarfNative.DW_TAG_imported_unit, - - MutableType = DwarfNative.DW_TAG_mutable_type, - - Condition = DwarfNative.DW_TAG_condition, - - SharedType = DwarfNative.DW_TAG_shared_type, - - TypeUnit = DwarfNative.DW_TAG_type_unit, - - RvalueReferenceType = DwarfNative.DW_TAG_rvalue_reference_type, - - TemplateAlias = DwarfNative.DW_TAG_template_alias, - - CoarrayType = DwarfNative.DW_TAG_coarray_type, - - GenericSubrange = DwarfNative.DW_TAG_generic_subrange, - - DynamicType = DwarfNative.DW_TAG_dynamic_type, - - AtomicType = DwarfNative.DW_TAG_atomic_type, - - CallSite = DwarfNative.DW_TAG_call_site, - - CallSiteParameter = DwarfNative.DW_TAG_call_site_parameter, - - SkeletonUnit = DwarfNative.DW_TAG_skeleton_unit, - - ImmutableType = DwarfNative.DW_TAG_immutable_type, - - MIPSLoop = DwarfNative.DW_TAG_MIPS_loop, - - HPArrayDescriptor = DwarfNative.DW_TAG_HP_array_descriptor, - - FormatLabel = DwarfNative.DW_TAG_format_label, - - FunctionTemplate = DwarfNative.DW_TAG_function_template, - - ClassTemplate = DwarfNative.DW_TAG_class_template, - - GNUBINCL = DwarfNative.DW_TAG_GNU_BINCL, - - GNUEINCL = DwarfNative.DW_TAG_GNU_EINCL, - - GNUTemplateTemplateParameter = DwarfNative.DW_TAG_GNU_template_template_parameter, - - GNUTemplateTemplateParam = DwarfNative.DW_TAG_GNU_template_template_param, - - GNUTemplateParameterPack = DwarfNative.DW_TAG_GNU_template_parameter_pack, - - GNUFormalParameterPack = DwarfNative.DW_TAG_GNU_formal_parameter_pack, - - GNUCallSite = DwarfNative.DW_TAG_GNU_call_site, - - GNUCallSiteParameter = DwarfNative.DW_TAG_GNU_call_site_parameter, - - ALTIUMCircType = DwarfNative.DW_TAG_ALTIUM_circ_type, - - ALTIUMMwaCircType = DwarfNative.DW_TAG_ALTIUM_mwa_circ_type, - - ALTIUMRevCarryType = DwarfNative.DW_TAG_ALTIUM_rev_carry_type, - - ALTIUMRom = DwarfNative.DW_TAG_ALTIUM_rom, - - UpcSharedType = DwarfNative.DW_TAG_upc_shared_type, - - UpcStrictType = DwarfNative.DW_TAG_upc_strict_type, - - UpcRelaxedType = DwarfNative.DW_TAG_upc_relaxed_type, - - PGIKanjiType = DwarfNative.DW_TAG_PGI_kanji_type, - - PGIInterfaceBlock = DwarfNative.DW_TAG_PGI_interface_block, - - SUNFunctionTemplate = DwarfNative.DW_TAG_SUN_function_template, - - SUNClassTemplate = DwarfNative.DW_TAG_SUN_class_template, - - SUNStructTemplate = DwarfNative.DW_TAG_SUN_struct_template, - - SUNUnionTemplate = DwarfNative.DW_TAG_SUN_union_template, - - SUNIndirectInheritance = DwarfNative.DW_TAG_SUN_indirect_inheritance, - - SUNCodeflags = DwarfNative.DW_TAG_SUN_codeflags, - - SUNMemopInfo = DwarfNative.DW_TAG_SUN_memop_info, - - SUNOmpChildFunc = DwarfNative.DW_TAG_SUN_omp_child_func, - - SUNRttiDescriptor = DwarfNative.DW_TAG_SUN_rtti_descriptor, - - SUNDtorInfo = DwarfNative.DW_TAG_SUN_dtor_info, - - SUNDtor = DwarfNative.DW_TAG_SUN_dtor, - - SUNF90Interface = DwarfNative.DW_TAG_SUN_f90_interface, - - SUNFortranVaxStructure = DwarfNative.DW_TAG_SUN_fortran_vax_structure, - - SUNHi = DwarfNative.DW_TAG_SUN_hi, - } - - public readonly partial struct DwarfOperationKindEx - { - public static readonly DwarfOperationKindEx Addr = new DwarfOperationKindEx(DwarfNative.DW_OP_addr); - - public static readonly DwarfOperationKindEx Deref = new DwarfOperationKindEx(DwarfNative.DW_OP_deref); - - public static readonly DwarfOperationKindEx Const1u = new DwarfOperationKindEx(DwarfNative.DW_OP_const1u); - - public static readonly DwarfOperationKindEx Const1s = new DwarfOperationKindEx(DwarfNative.DW_OP_const1s); - - public static readonly DwarfOperationKindEx Const2u = new DwarfOperationKindEx(DwarfNative.DW_OP_const2u); - - public static readonly DwarfOperationKindEx Const2s = new DwarfOperationKindEx(DwarfNative.DW_OP_const2s); - - public static readonly DwarfOperationKindEx Const4u = new DwarfOperationKindEx(DwarfNative.DW_OP_const4u); - - public static readonly DwarfOperationKindEx Const4s = new DwarfOperationKindEx(DwarfNative.DW_OP_const4s); - - public static readonly DwarfOperationKindEx Const8u = new DwarfOperationKindEx(DwarfNative.DW_OP_const8u); - - public static readonly DwarfOperationKindEx Const8s = new DwarfOperationKindEx(DwarfNative.DW_OP_const8s); - - public static readonly DwarfOperationKindEx Constu = new DwarfOperationKindEx(DwarfNative.DW_OP_constu); - - public static readonly DwarfOperationKindEx Consts = new DwarfOperationKindEx(DwarfNative.DW_OP_consts); - - public static readonly DwarfOperationKindEx Dup = new DwarfOperationKindEx(DwarfNative.DW_OP_dup); - - public static readonly DwarfOperationKindEx Drop = new DwarfOperationKindEx(DwarfNative.DW_OP_drop); - - public static readonly DwarfOperationKindEx Over = new DwarfOperationKindEx(DwarfNative.DW_OP_over); - - public static readonly DwarfOperationKindEx Pick = new DwarfOperationKindEx(DwarfNative.DW_OP_pick); - - public static readonly DwarfOperationKindEx Swap = new DwarfOperationKindEx(DwarfNative.DW_OP_swap); - - public static readonly DwarfOperationKindEx Rot = new DwarfOperationKindEx(DwarfNative.DW_OP_rot); - - public static readonly DwarfOperationKindEx Xderef = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef); - - public static readonly DwarfOperationKindEx Abs = new DwarfOperationKindEx(DwarfNative.DW_OP_abs); - - public static readonly DwarfOperationKindEx And = new DwarfOperationKindEx(DwarfNative.DW_OP_and); - - public static readonly DwarfOperationKindEx Div = new DwarfOperationKindEx(DwarfNative.DW_OP_div); - - public static readonly DwarfOperationKindEx Minus = new DwarfOperationKindEx(DwarfNative.DW_OP_minus); - - public static readonly DwarfOperationKindEx Mod = new DwarfOperationKindEx(DwarfNative.DW_OP_mod); - - public static readonly DwarfOperationKindEx Mul = new DwarfOperationKindEx(DwarfNative.DW_OP_mul); - - public static readonly DwarfOperationKindEx Neg = new DwarfOperationKindEx(DwarfNative.DW_OP_neg); - - public static readonly DwarfOperationKindEx Not = new DwarfOperationKindEx(DwarfNative.DW_OP_not); - - public static readonly DwarfOperationKindEx Or = new DwarfOperationKindEx(DwarfNative.DW_OP_or); - - public static readonly DwarfOperationKindEx Plus = new DwarfOperationKindEx(DwarfNative.DW_OP_plus); - - public static readonly DwarfOperationKindEx PlusUconst = new DwarfOperationKindEx(DwarfNative.DW_OP_plus_uconst); - - public static readonly DwarfOperationKindEx Shl = new DwarfOperationKindEx(DwarfNative.DW_OP_shl); - - public static readonly DwarfOperationKindEx Shr = new DwarfOperationKindEx(DwarfNative.DW_OP_shr); - - public static readonly DwarfOperationKindEx Shra = new DwarfOperationKindEx(DwarfNative.DW_OP_shra); - - public static readonly DwarfOperationKindEx Xor = new DwarfOperationKindEx(DwarfNative.DW_OP_xor); - - public static readonly DwarfOperationKindEx Bra = new DwarfOperationKindEx(DwarfNative.DW_OP_bra); - - public static readonly DwarfOperationKindEx Eq = new DwarfOperationKindEx(DwarfNative.DW_OP_eq); - - public static readonly DwarfOperationKindEx Ge = new DwarfOperationKindEx(DwarfNative.DW_OP_ge); - - public static readonly DwarfOperationKindEx Gt = new DwarfOperationKindEx(DwarfNative.DW_OP_gt); - - public static readonly DwarfOperationKindEx Le = new DwarfOperationKindEx(DwarfNative.DW_OP_le); - - public static readonly DwarfOperationKindEx Lt = new DwarfOperationKindEx(DwarfNative.DW_OP_lt); - - public static readonly DwarfOperationKindEx Ne = new DwarfOperationKindEx(DwarfNative.DW_OP_ne); - - public static readonly DwarfOperationKindEx Skip = new DwarfOperationKindEx(DwarfNative.DW_OP_skip); - - public static readonly DwarfOperationKindEx Lit0 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit0); - - public static readonly DwarfOperationKindEx Lit1 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit1); - - public static readonly DwarfOperationKindEx Lit2 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit2); - - public static readonly DwarfOperationKindEx Lit3 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit3); - - public static readonly DwarfOperationKindEx Lit4 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit4); - - public static readonly DwarfOperationKindEx Lit5 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit5); - - public static readonly DwarfOperationKindEx Lit6 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit6); - - public static readonly DwarfOperationKindEx Lit7 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit7); - - public static readonly DwarfOperationKindEx Lit8 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit8); - - public static readonly DwarfOperationKindEx Lit9 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit9); - - public static readonly DwarfOperationKindEx Lit10 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit10); - - public static readonly DwarfOperationKindEx Lit11 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit11); - - public static readonly DwarfOperationKindEx Lit12 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit12); - - public static readonly DwarfOperationKindEx Lit13 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit13); - - public static readonly DwarfOperationKindEx Lit14 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit14); - - public static readonly DwarfOperationKindEx Lit15 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit15); - - public static readonly DwarfOperationKindEx Lit16 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit16); - - public static readonly DwarfOperationKindEx Lit17 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit17); - - public static readonly DwarfOperationKindEx Lit18 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit18); - - public static readonly DwarfOperationKindEx Lit19 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit19); - - public static readonly DwarfOperationKindEx Lit20 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit20); - - public static readonly DwarfOperationKindEx Lit21 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit21); - - public static readonly DwarfOperationKindEx Lit22 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit22); - - public static readonly DwarfOperationKindEx Lit23 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit23); - - public static readonly DwarfOperationKindEx Lit24 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit24); - - public static readonly DwarfOperationKindEx Lit25 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit25); - - public static readonly DwarfOperationKindEx Lit26 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit26); - - public static readonly DwarfOperationKindEx Lit27 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit27); - - public static readonly DwarfOperationKindEx Lit28 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit28); - - public static readonly DwarfOperationKindEx Lit29 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit29); - - public static readonly DwarfOperationKindEx Lit30 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit30); - - public static readonly DwarfOperationKindEx Lit31 = new DwarfOperationKindEx(DwarfNative.DW_OP_lit31); - - public static readonly DwarfOperationKindEx Reg0 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg0); - - public static readonly DwarfOperationKindEx Reg1 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg1); - - public static readonly DwarfOperationKindEx Reg2 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg2); - - public static readonly DwarfOperationKindEx Reg3 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg3); - - public static readonly DwarfOperationKindEx Reg4 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg4); - - public static readonly DwarfOperationKindEx Reg5 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg5); - - public static readonly DwarfOperationKindEx Reg6 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg6); - - public static readonly DwarfOperationKindEx Reg7 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg7); - - public static readonly DwarfOperationKindEx Reg8 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg8); - - public static readonly DwarfOperationKindEx Reg9 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg9); - - public static readonly DwarfOperationKindEx Reg10 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg10); - - public static readonly DwarfOperationKindEx Reg11 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg11); - - public static readonly DwarfOperationKindEx Reg12 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg12); - - public static readonly DwarfOperationKindEx Reg13 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg13); - - public static readonly DwarfOperationKindEx Reg14 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg14); - - public static readonly DwarfOperationKindEx Reg15 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg15); - - public static readonly DwarfOperationKindEx Reg16 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg16); - - public static readonly DwarfOperationKindEx Reg17 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg17); - - public static readonly DwarfOperationKindEx Reg18 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg18); - - public static readonly DwarfOperationKindEx Reg19 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg19); - - public static readonly DwarfOperationKindEx Reg20 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg20); - - public static readonly DwarfOperationKindEx Reg21 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg21); - - public static readonly DwarfOperationKindEx Reg22 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg22); - - public static readonly DwarfOperationKindEx Reg23 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg23); - - public static readonly DwarfOperationKindEx Reg24 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg24); - - public static readonly DwarfOperationKindEx Reg25 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg25); - - public static readonly DwarfOperationKindEx Reg26 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg26); - - public static readonly DwarfOperationKindEx Reg27 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg27); - - public static readonly DwarfOperationKindEx Reg28 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg28); - - public static readonly DwarfOperationKindEx Reg29 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg29); - - public static readonly DwarfOperationKindEx Reg30 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg30); - - public static readonly DwarfOperationKindEx Reg31 = new DwarfOperationKindEx(DwarfNative.DW_OP_reg31); - - public static readonly DwarfOperationKindEx Breg0 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg0); - - public static readonly DwarfOperationKindEx Breg1 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg1); - - public static readonly DwarfOperationKindEx Breg2 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg2); - - public static readonly DwarfOperationKindEx Breg3 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg3); - - public static readonly DwarfOperationKindEx Breg4 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg4); - - public static readonly DwarfOperationKindEx Breg5 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg5); - - public static readonly DwarfOperationKindEx Breg6 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg6); - - public static readonly DwarfOperationKindEx Breg7 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg7); - - public static readonly DwarfOperationKindEx Breg8 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg8); - - public static readonly DwarfOperationKindEx Breg9 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg9); - - public static readonly DwarfOperationKindEx Breg10 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg10); - - public static readonly DwarfOperationKindEx Breg11 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg11); - - public static readonly DwarfOperationKindEx Breg12 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg12); - - public static readonly DwarfOperationKindEx Breg13 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg13); - - public static readonly DwarfOperationKindEx Breg14 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg14); - - public static readonly DwarfOperationKindEx Breg15 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg15); - - public static readonly DwarfOperationKindEx Breg16 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg16); - - public static readonly DwarfOperationKindEx Breg17 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg17); - - public static readonly DwarfOperationKindEx Breg18 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg18); - - public static readonly DwarfOperationKindEx Breg19 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg19); - - public static readonly DwarfOperationKindEx Breg20 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg20); - - public static readonly DwarfOperationKindEx Breg21 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg21); - - public static readonly DwarfOperationKindEx Breg22 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg22); - - public static readonly DwarfOperationKindEx Breg23 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg23); - - public static readonly DwarfOperationKindEx Breg24 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg24); - - public static readonly DwarfOperationKindEx Breg25 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg25); - - public static readonly DwarfOperationKindEx Breg26 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg26); - - public static readonly DwarfOperationKindEx Breg27 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg27); - - public static readonly DwarfOperationKindEx Breg28 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg28); - - public static readonly DwarfOperationKindEx Breg29 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg29); - - public static readonly DwarfOperationKindEx Breg30 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg30); - - public static readonly DwarfOperationKindEx Breg31 = new DwarfOperationKindEx(DwarfNative.DW_OP_breg31); - - public static readonly DwarfOperationKindEx Regx = new DwarfOperationKindEx(DwarfNative.DW_OP_regx); - - public static readonly DwarfOperationKindEx Fbreg = new DwarfOperationKindEx(DwarfNative.DW_OP_fbreg); - - public static readonly DwarfOperationKindEx Bregx = new DwarfOperationKindEx(DwarfNative.DW_OP_bregx); - - public static readonly DwarfOperationKindEx Piece = new DwarfOperationKindEx(DwarfNative.DW_OP_piece); - - public static readonly DwarfOperationKindEx DerefSize = new DwarfOperationKindEx(DwarfNative.DW_OP_deref_size); - - public static readonly DwarfOperationKindEx XderefSize = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef_size); - - public static readonly DwarfOperationKindEx Nop = new DwarfOperationKindEx(DwarfNative.DW_OP_nop); - - /// - /// DWARF3 - /// - public static readonly DwarfOperationKindEx PushObjectAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_push_object_address); - - /// - /// DWARF3 - /// - public static readonly DwarfOperationKindEx Call2 = new DwarfOperationKindEx(DwarfNative.DW_OP_call2); - - /// - /// DWARF3 - /// - public static readonly DwarfOperationKindEx Call4 = new DwarfOperationKindEx(DwarfNative.DW_OP_call4); - - /// - /// DWARF3 - /// - public static readonly DwarfOperationKindEx CallRef = new DwarfOperationKindEx(DwarfNative.DW_OP_call_ref); - - /// - /// DWARF3f - /// - public static readonly DwarfOperationKindEx FormTlsAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_form_tls_address); - - /// - /// DWARF3f - /// - public static readonly DwarfOperationKindEx CallFrameCfa = new DwarfOperationKindEx(DwarfNative.DW_OP_call_frame_cfa); - - /// - /// DWARF3f - /// - public static readonly DwarfOperationKindEx BitPiece = new DwarfOperationKindEx(DwarfNative.DW_OP_bit_piece); - - /// - /// DWARF4 - /// - public static readonly DwarfOperationKindEx ImplicitValue = new DwarfOperationKindEx(DwarfNative.DW_OP_implicit_value); - - /// - /// DWARF4 - /// - public static readonly DwarfOperationKindEx StackValue = new DwarfOperationKindEx(DwarfNative.DW_OP_stack_value); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx ImplicitPointer = new DwarfOperationKindEx(DwarfNative.DW_OP_implicit_pointer); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx Addrx = new DwarfOperationKindEx(DwarfNative.DW_OP_addrx); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx Constx = new DwarfOperationKindEx(DwarfNative.DW_OP_constx); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx EntryValue = new DwarfOperationKindEx(DwarfNative.DW_OP_entry_value); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx ConstType = new DwarfOperationKindEx(DwarfNative.DW_OP_const_type); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx RegvalType = new DwarfOperationKindEx(DwarfNative.DW_OP_regval_type); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx DerefType = new DwarfOperationKindEx(DwarfNative.DW_OP_deref_type); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx XderefType = new DwarfOperationKindEx(DwarfNative.DW_OP_xderef_type); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx Convert = new DwarfOperationKindEx(DwarfNative.DW_OP_convert); - - /// - /// DWARF5 - /// - public static readonly DwarfOperationKindEx Reinterpret = new DwarfOperationKindEx(DwarfNative.DW_OP_reinterpret); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUPushTlsAddress = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_push_tls_address); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUUninit = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_uninit); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUEncodedAddr = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_encoded_addr); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUImplicitPointer = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_implicit_pointer); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUEntryValue = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_entry_value); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUConstType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_const_type); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNURegvalType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_regval_type); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUDerefType = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_deref_type); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUConvert = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_convert); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUReinterpret = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_reinterpret); - - /// - /// GNU - /// - public static readonly DwarfOperationKindEx GNUParameterRef = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_parameter_ref); - - /// - /// GNU DebugFission - /// - public static readonly DwarfOperationKindEx GNUAddrIndex = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_addr_index); - - /// - /// GNU DebugFission - /// - public static readonly DwarfOperationKindEx GNUConstIndex = new DwarfOperationKindEx(DwarfNative.DW_OP_GNU_const_index); - - /// - /// HP conflict: GNU - /// - public static readonly DwarfOperationKindEx HPUnknown = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_unknown); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPIsValue = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_is_value); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPFltconst4 = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_fltconst4); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPFltconst8 = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_fltconst8); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPModRange = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_mod_range); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPUnmodRange = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_unmod_range); - - /// - /// HP - /// - public static readonly DwarfOperationKindEx HPTls = new DwarfOperationKindEx(DwarfNative.DW_OP_HP_tls); - - /// - /// Intel: made obsolete by DW_OP_bit_piece above. - /// - public static readonly DwarfOperationKindEx INTELBitPiece = new DwarfOperationKindEx(DwarfNative.DW_OP_INTEL_bit_piece); - - /// - /// Apple - /// - public static readonly DwarfOperationKindEx APPLEUninit = new DwarfOperationKindEx(DwarfNative.DW_OP_APPLE_uninit); - - /// - /// PGI (STMicroelectronics) - /// - public static readonly DwarfOperationKindEx PGIOmpThreadNum = new DwarfOperationKindEx(DwarfNative.DW_OP_PGI_omp_thread_num); - - private string ToStringInternal() - { - switch ((byte)Value) - { - case DwarfNative.DW_OP_addr: return "DW_OP_addr"; - case DwarfNative.DW_OP_deref: return "DW_OP_deref"; - case DwarfNative.DW_OP_const1u: return "DW_OP_const1u"; - case DwarfNative.DW_OP_const1s: return "DW_OP_const1s"; - case DwarfNative.DW_OP_const2u: return "DW_OP_const2u"; - case DwarfNative.DW_OP_const2s: return "DW_OP_const2s"; - case DwarfNative.DW_OP_const4u: return "DW_OP_const4u"; - case DwarfNative.DW_OP_const4s: return "DW_OP_const4s"; - case DwarfNative.DW_OP_const8u: return "DW_OP_const8u"; - case DwarfNative.DW_OP_const8s: return "DW_OP_const8s"; - case DwarfNative.DW_OP_constu: return "DW_OP_constu"; - case DwarfNative.DW_OP_consts: return "DW_OP_consts"; - case DwarfNative.DW_OP_dup: return "DW_OP_dup"; - case DwarfNative.DW_OP_drop: return "DW_OP_drop"; - case DwarfNative.DW_OP_over: return "DW_OP_over"; - case DwarfNative.DW_OP_pick: return "DW_OP_pick"; - case DwarfNative.DW_OP_swap: return "DW_OP_swap"; - case DwarfNative.DW_OP_rot: return "DW_OP_rot"; - case DwarfNative.DW_OP_xderef: return "DW_OP_xderef"; - case DwarfNative.DW_OP_abs: return "DW_OP_abs"; - case DwarfNative.DW_OP_and: return "DW_OP_and"; - case DwarfNative.DW_OP_div: return "DW_OP_div"; - case DwarfNative.DW_OP_minus: return "DW_OP_minus"; - case DwarfNative.DW_OP_mod: return "DW_OP_mod"; - case DwarfNative.DW_OP_mul: return "DW_OP_mul"; - case DwarfNative.DW_OP_neg: return "DW_OP_neg"; - case DwarfNative.DW_OP_not: return "DW_OP_not"; - case DwarfNative.DW_OP_or: return "DW_OP_or"; - case DwarfNative.DW_OP_plus: return "DW_OP_plus"; - case DwarfNative.DW_OP_plus_uconst: return "DW_OP_plus_uconst"; - case DwarfNative.DW_OP_shl: return "DW_OP_shl"; - case DwarfNative.DW_OP_shr: return "DW_OP_shr"; - case DwarfNative.DW_OP_shra: return "DW_OP_shra"; - case DwarfNative.DW_OP_xor: return "DW_OP_xor"; - case DwarfNative.DW_OP_bra: return "DW_OP_bra"; - case DwarfNative.DW_OP_eq: return "DW_OP_eq"; - case DwarfNative.DW_OP_ge: return "DW_OP_ge"; - case DwarfNative.DW_OP_gt: return "DW_OP_gt"; - case DwarfNative.DW_OP_le: return "DW_OP_le"; - case DwarfNative.DW_OP_lt: return "DW_OP_lt"; - case DwarfNative.DW_OP_ne: return "DW_OP_ne"; - case DwarfNative.DW_OP_skip: return "DW_OP_skip"; - case DwarfNative.DW_OP_lit0: return "DW_OP_lit0"; - case DwarfNative.DW_OP_lit1: return "DW_OP_lit1"; - case DwarfNative.DW_OP_lit2: return "DW_OP_lit2"; - case DwarfNative.DW_OP_lit3: return "DW_OP_lit3"; - case DwarfNative.DW_OP_lit4: return "DW_OP_lit4"; - case DwarfNative.DW_OP_lit5: return "DW_OP_lit5"; - case DwarfNative.DW_OP_lit6: return "DW_OP_lit6"; - case DwarfNative.DW_OP_lit7: return "DW_OP_lit7"; - case DwarfNative.DW_OP_lit8: return "DW_OP_lit8"; - case DwarfNative.DW_OP_lit9: return "DW_OP_lit9"; - case DwarfNative.DW_OP_lit10: return "DW_OP_lit10"; - case DwarfNative.DW_OP_lit11: return "DW_OP_lit11"; - case DwarfNative.DW_OP_lit12: return "DW_OP_lit12"; - case DwarfNative.DW_OP_lit13: return "DW_OP_lit13"; - case DwarfNative.DW_OP_lit14: return "DW_OP_lit14"; - case DwarfNative.DW_OP_lit15: return "DW_OP_lit15"; - case DwarfNative.DW_OP_lit16: return "DW_OP_lit16"; - case DwarfNative.DW_OP_lit17: return "DW_OP_lit17"; - case DwarfNative.DW_OP_lit18: return "DW_OP_lit18"; - case DwarfNative.DW_OP_lit19: return "DW_OP_lit19"; - case DwarfNative.DW_OP_lit20: return "DW_OP_lit20"; - case DwarfNative.DW_OP_lit21: return "DW_OP_lit21"; - case DwarfNative.DW_OP_lit22: return "DW_OP_lit22"; - case DwarfNative.DW_OP_lit23: return "DW_OP_lit23"; - case DwarfNative.DW_OP_lit24: return "DW_OP_lit24"; - case DwarfNative.DW_OP_lit25: return "DW_OP_lit25"; - case DwarfNative.DW_OP_lit26: return "DW_OP_lit26"; - case DwarfNative.DW_OP_lit27: return "DW_OP_lit27"; - case DwarfNative.DW_OP_lit28: return "DW_OP_lit28"; - case DwarfNative.DW_OP_lit29: return "DW_OP_lit29"; - case DwarfNative.DW_OP_lit30: return "DW_OP_lit30"; - case DwarfNative.DW_OP_lit31: return "DW_OP_lit31"; - case DwarfNative.DW_OP_reg0: return "DW_OP_reg0"; - case DwarfNative.DW_OP_reg1: return "DW_OP_reg1"; - case DwarfNative.DW_OP_reg2: return "DW_OP_reg2"; - case DwarfNative.DW_OP_reg3: return "DW_OP_reg3"; - case DwarfNative.DW_OP_reg4: return "DW_OP_reg4"; - case DwarfNative.DW_OP_reg5: return "DW_OP_reg5"; - case DwarfNative.DW_OP_reg6: return "DW_OP_reg6"; - case DwarfNative.DW_OP_reg7: return "DW_OP_reg7"; - case DwarfNative.DW_OP_reg8: return "DW_OP_reg8"; - case DwarfNative.DW_OP_reg9: return "DW_OP_reg9"; - case DwarfNative.DW_OP_reg10: return "DW_OP_reg10"; - case DwarfNative.DW_OP_reg11: return "DW_OP_reg11"; - case DwarfNative.DW_OP_reg12: return "DW_OP_reg12"; - case DwarfNative.DW_OP_reg13: return "DW_OP_reg13"; - case DwarfNative.DW_OP_reg14: return "DW_OP_reg14"; - case DwarfNative.DW_OP_reg15: return "DW_OP_reg15"; - case DwarfNative.DW_OP_reg16: return "DW_OP_reg16"; - case DwarfNative.DW_OP_reg17: return "DW_OP_reg17"; - case DwarfNative.DW_OP_reg18: return "DW_OP_reg18"; - case DwarfNative.DW_OP_reg19: return "DW_OP_reg19"; - case DwarfNative.DW_OP_reg20: return "DW_OP_reg20"; - case DwarfNative.DW_OP_reg21: return "DW_OP_reg21"; - case DwarfNative.DW_OP_reg22: return "DW_OP_reg22"; - case DwarfNative.DW_OP_reg23: return "DW_OP_reg23"; - case DwarfNative.DW_OP_reg24: return "DW_OP_reg24"; - case DwarfNative.DW_OP_reg25: return "DW_OP_reg25"; - case DwarfNative.DW_OP_reg26: return "DW_OP_reg26"; - case DwarfNative.DW_OP_reg27: return "DW_OP_reg27"; - case DwarfNative.DW_OP_reg28: return "DW_OP_reg28"; - case DwarfNative.DW_OP_reg29: return "DW_OP_reg29"; - case DwarfNative.DW_OP_reg30: return "DW_OP_reg30"; - case DwarfNative.DW_OP_reg31: return "DW_OP_reg31"; - case DwarfNative.DW_OP_breg0: return "DW_OP_breg0"; - case DwarfNative.DW_OP_breg1: return "DW_OP_breg1"; - case DwarfNative.DW_OP_breg2: return "DW_OP_breg2"; - case DwarfNative.DW_OP_breg3: return "DW_OP_breg3"; - case DwarfNative.DW_OP_breg4: return "DW_OP_breg4"; - case DwarfNative.DW_OP_breg5: return "DW_OP_breg5"; - case DwarfNative.DW_OP_breg6: return "DW_OP_breg6"; - case DwarfNative.DW_OP_breg7: return "DW_OP_breg7"; - case DwarfNative.DW_OP_breg8: return "DW_OP_breg8"; - case DwarfNative.DW_OP_breg9: return "DW_OP_breg9"; - case DwarfNative.DW_OP_breg10: return "DW_OP_breg10"; - case DwarfNative.DW_OP_breg11: return "DW_OP_breg11"; - case DwarfNative.DW_OP_breg12: return "DW_OP_breg12"; - case DwarfNative.DW_OP_breg13: return "DW_OP_breg13"; - case DwarfNative.DW_OP_breg14: return "DW_OP_breg14"; - case DwarfNative.DW_OP_breg15: return "DW_OP_breg15"; - case DwarfNative.DW_OP_breg16: return "DW_OP_breg16"; - case DwarfNative.DW_OP_breg17: return "DW_OP_breg17"; - case DwarfNative.DW_OP_breg18: return "DW_OP_breg18"; - case DwarfNative.DW_OP_breg19: return "DW_OP_breg19"; - case DwarfNative.DW_OP_breg20: return "DW_OP_breg20"; - case DwarfNative.DW_OP_breg21: return "DW_OP_breg21"; - case DwarfNative.DW_OP_breg22: return "DW_OP_breg22"; - case DwarfNative.DW_OP_breg23: return "DW_OP_breg23"; - case DwarfNative.DW_OP_breg24: return "DW_OP_breg24"; - case DwarfNative.DW_OP_breg25: return "DW_OP_breg25"; - case DwarfNative.DW_OP_breg26: return "DW_OP_breg26"; - case DwarfNative.DW_OP_breg27: return "DW_OP_breg27"; - case DwarfNative.DW_OP_breg28: return "DW_OP_breg28"; - case DwarfNative.DW_OP_breg29: return "DW_OP_breg29"; - case DwarfNative.DW_OP_breg30: return "DW_OP_breg30"; - case DwarfNative.DW_OP_breg31: return "DW_OP_breg31"; - case DwarfNative.DW_OP_regx: return "DW_OP_regx"; - case DwarfNative.DW_OP_fbreg: return "DW_OP_fbreg"; - case DwarfNative.DW_OP_bregx: return "DW_OP_bregx"; - case DwarfNative.DW_OP_piece: return "DW_OP_piece"; - case DwarfNative.DW_OP_deref_size: return "DW_OP_deref_size"; - case DwarfNative.DW_OP_xderef_size: return "DW_OP_xderef_size"; - case DwarfNative.DW_OP_nop: return "DW_OP_nop"; - case DwarfNative.DW_OP_push_object_address: return "DW_OP_push_object_address"; - case DwarfNative.DW_OP_call2: return "DW_OP_call2"; - case DwarfNative.DW_OP_call4: return "DW_OP_call4"; - case DwarfNative.DW_OP_call_ref: return "DW_OP_call_ref"; - case DwarfNative.DW_OP_form_tls_address: return "DW_OP_form_tls_address"; - case DwarfNative.DW_OP_call_frame_cfa: return "DW_OP_call_frame_cfa"; - case DwarfNative.DW_OP_bit_piece: return "DW_OP_bit_piece"; - case DwarfNative.DW_OP_implicit_value: return "DW_OP_implicit_value"; - case DwarfNative.DW_OP_stack_value: return "DW_OP_stack_value"; - case DwarfNative.DW_OP_implicit_pointer: return "DW_OP_implicit_pointer"; - case DwarfNative.DW_OP_addrx: return "DW_OP_addrx"; - case DwarfNative.DW_OP_constx: return "DW_OP_constx"; - case DwarfNative.DW_OP_entry_value: return "DW_OP_entry_value"; - case DwarfNative.DW_OP_const_type: return "DW_OP_const_type"; - case DwarfNative.DW_OP_regval_type: return "DW_OP_regval_type"; - case DwarfNative.DW_OP_deref_type: return "DW_OP_deref_type"; - case DwarfNative.DW_OP_xderef_type: return "DW_OP_xderef_type"; - case DwarfNative.DW_OP_convert: return "DW_OP_convert"; - case DwarfNative.DW_OP_reinterpret: return "DW_OP_reinterpret"; - case DwarfNative.DW_OP_GNU_push_tls_address: return "DW_OP_GNU_push_tls_address"; - case DwarfNative.DW_OP_GNU_uninit: return "DW_OP_GNU_uninit"; - case DwarfNative.DW_OP_GNU_encoded_addr: return "DW_OP_GNU_encoded_addr"; - case DwarfNative.DW_OP_GNU_implicit_pointer: return "DW_OP_GNU_implicit_pointer"; - case DwarfNative.DW_OP_GNU_entry_value: return "DW_OP_GNU_entry_value"; - case DwarfNative.DW_OP_GNU_const_type: return "DW_OP_GNU_const_type"; - case DwarfNative.DW_OP_GNU_regval_type: return "DW_OP_GNU_regval_type"; - case DwarfNative.DW_OP_GNU_deref_type: return "DW_OP_GNU_deref_type"; - case DwarfNative.DW_OP_GNU_convert: return "DW_OP_GNU_convert"; - case DwarfNative.DW_OP_GNU_reinterpret: return "DW_OP_GNU_reinterpret"; - case DwarfNative.DW_OP_GNU_parameter_ref: return "DW_OP_GNU_parameter_ref"; - case DwarfNative.DW_OP_GNU_addr_index: return "DW_OP_GNU_addr_index"; - case DwarfNative.DW_OP_GNU_const_index: return "DW_OP_GNU_const_index"; - case DwarfNative.DW_OP_HP_is_value: return "DW_OP_HP_is_value"; - case DwarfNative.DW_OP_HP_fltconst4: return "DW_OP_HP_fltconst4"; - case DwarfNative.DW_OP_HP_fltconst8: return "DW_OP_HP_fltconst8"; - case DwarfNative.DW_OP_HP_mod_range: return "DW_OP_HP_mod_range"; - case DwarfNative.DW_OP_HP_unmod_range: return "DW_OP_HP_unmod_range"; - case DwarfNative.DW_OP_HP_tls: return "DW_OP_HP_tls"; - case DwarfNative.DW_OP_INTEL_bit_piece: return "DW_OP_INTEL_bit_piece"; - case DwarfNative.DW_OP_PGI_omp_thread_num: return "DW_OP_PGI_omp_thread_num"; - default: return null; - } - } - } - - public enum DwarfOperationKind : byte - { - Addr = DwarfNative.DW_OP_addr, - - Deref = DwarfNative.DW_OP_deref, - - Const1u = DwarfNative.DW_OP_const1u, - - Const1s = DwarfNative.DW_OP_const1s, - - Const2u = DwarfNative.DW_OP_const2u, - - Const2s = DwarfNative.DW_OP_const2s, - - Const4u = DwarfNative.DW_OP_const4u, - - Const4s = DwarfNative.DW_OP_const4s, - - Const8u = DwarfNative.DW_OP_const8u, - - Const8s = DwarfNative.DW_OP_const8s, - - Constu = DwarfNative.DW_OP_constu, - - Consts = DwarfNative.DW_OP_consts, - - Dup = DwarfNative.DW_OP_dup, - - Drop = DwarfNative.DW_OP_drop, - - Over = DwarfNative.DW_OP_over, - - Pick = DwarfNative.DW_OP_pick, - - Swap = DwarfNative.DW_OP_swap, - - Rot = DwarfNative.DW_OP_rot, - - Xderef = DwarfNative.DW_OP_xderef, - - Abs = DwarfNative.DW_OP_abs, - - And = DwarfNative.DW_OP_and, - - Div = DwarfNative.DW_OP_div, - - Minus = DwarfNative.DW_OP_minus, - - Mod = DwarfNative.DW_OP_mod, - - Mul = DwarfNative.DW_OP_mul, - - Neg = DwarfNative.DW_OP_neg, - - Not = DwarfNative.DW_OP_not, - - Or = DwarfNative.DW_OP_or, - - Plus = DwarfNative.DW_OP_plus, - - PlusUconst = DwarfNative.DW_OP_plus_uconst, - - Shl = DwarfNative.DW_OP_shl, - - Shr = DwarfNative.DW_OP_shr, - - Shra = DwarfNative.DW_OP_shra, - - Xor = DwarfNative.DW_OP_xor, - - Bra = DwarfNative.DW_OP_bra, - - Eq = DwarfNative.DW_OP_eq, - - Ge = DwarfNative.DW_OP_ge, - - Gt = DwarfNative.DW_OP_gt, - - Le = DwarfNative.DW_OP_le, - - Lt = DwarfNative.DW_OP_lt, - - Ne = DwarfNative.DW_OP_ne, - - Skip = DwarfNative.DW_OP_skip, - - Lit0 = DwarfNative.DW_OP_lit0, - - Lit1 = DwarfNative.DW_OP_lit1, - - Lit2 = DwarfNative.DW_OP_lit2, - - Lit3 = DwarfNative.DW_OP_lit3, - - Lit4 = DwarfNative.DW_OP_lit4, - - Lit5 = DwarfNative.DW_OP_lit5, - - Lit6 = DwarfNative.DW_OP_lit6, - - Lit7 = DwarfNative.DW_OP_lit7, - - Lit8 = DwarfNative.DW_OP_lit8, - - Lit9 = DwarfNative.DW_OP_lit9, - - Lit10 = DwarfNative.DW_OP_lit10, - - Lit11 = DwarfNative.DW_OP_lit11, - - Lit12 = DwarfNative.DW_OP_lit12, - - Lit13 = DwarfNative.DW_OP_lit13, - - Lit14 = DwarfNative.DW_OP_lit14, - - Lit15 = DwarfNative.DW_OP_lit15, - - Lit16 = DwarfNative.DW_OP_lit16, - - Lit17 = DwarfNative.DW_OP_lit17, - - Lit18 = DwarfNative.DW_OP_lit18, - - Lit19 = DwarfNative.DW_OP_lit19, - - Lit20 = DwarfNative.DW_OP_lit20, - - Lit21 = DwarfNative.DW_OP_lit21, - - Lit22 = DwarfNative.DW_OP_lit22, - - Lit23 = DwarfNative.DW_OP_lit23, - - Lit24 = DwarfNative.DW_OP_lit24, - - Lit25 = DwarfNative.DW_OP_lit25, - - Lit26 = DwarfNative.DW_OP_lit26, - - Lit27 = DwarfNative.DW_OP_lit27, - - Lit28 = DwarfNative.DW_OP_lit28, - - Lit29 = DwarfNative.DW_OP_lit29, - - Lit30 = DwarfNative.DW_OP_lit30, - - Lit31 = DwarfNative.DW_OP_lit31, - - Reg0 = DwarfNative.DW_OP_reg0, - - Reg1 = DwarfNative.DW_OP_reg1, - - Reg2 = DwarfNative.DW_OP_reg2, - - Reg3 = DwarfNative.DW_OP_reg3, - - Reg4 = DwarfNative.DW_OP_reg4, - - Reg5 = DwarfNative.DW_OP_reg5, - - Reg6 = DwarfNative.DW_OP_reg6, - - Reg7 = DwarfNative.DW_OP_reg7, - - Reg8 = DwarfNative.DW_OP_reg8, - - Reg9 = DwarfNative.DW_OP_reg9, - - Reg10 = DwarfNative.DW_OP_reg10, - - Reg11 = DwarfNative.DW_OP_reg11, - - Reg12 = DwarfNative.DW_OP_reg12, - - Reg13 = DwarfNative.DW_OP_reg13, - - Reg14 = DwarfNative.DW_OP_reg14, - - Reg15 = DwarfNative.DW_OP_reg15, - - Reg16 = DwarfNative.DW_OP_reg16, - - Reg17 = DwarfNative.DW_OP_reg17, - - Reg18 = DwarfNative.DW_OP_reg18, - - Reg19 = DwarfNative.DW_OP_reg19, - - Reg20 = DwarfNative.DW_OP_reg20, - - Reg21 = DwarfNative.DW_OP_reg21, - - Reg22 = DwarfNative.DW_OP_reg22, - - Reg23 = DwarfNative.DW_OP_reg23, - - Reg24 = DwarfNative.DW_OP_reg24, - - Reg25 = DwarfNative.DW_OP_reg25, - - Reg26 = DwarfNative.DW_OP_reg26, - - Reg27 = DwarfNative.DW_OP_reg27, - - Reg28 = DwarfNative.DW_OP_reg28, - - Reg29 = DwarfNative.DW_OP_reg29, - - Reg30 = DwarfNative.DW_OP_reg30, - - Reg31 = DwarfNative.DW_OP_reg31, - - Breg0 = DwarfNative.DW_OP_breg0, - - Breg1 = DwarfNative.DW_OP_breg1, - - Breg2 = DwarfNative.DW_OP_breg2, - - Breg3 = DwarfNative.DW_OP_breg3, - - Breg4 = DwarfNative.DW_OP_breg4, - - Breg5 = DwarfNative.DW_OP_breg5, - - Breg6 = DwarfNative.DW_OP_breg6, - - Breg7 = DwarfNative.DW_OP_breg7, - - Breg8 = DwarfNative.DW_OP_breg8, - - Breg9 = DwarfNative.DW_OP_breg9, - - Breg10 = DwarfNative.DW_OP_breg10, - - Breg11 = DwarfNative.DW_OP_breg11, - - Breg12 = DwarfNative.DW_OP_breg12, - - Breg13 = DwarfNative.DW_OP_breg13, - - Breg14 = DwarfNative.DW_OP_breg14, - - Breg15 = DwarfNative.DW_OP_breg15, - - Breg16 = DwarfNative.DW_OP_breg16, - - Breg17 = DwarfNative.DW_OP_breg17, - - Breg18 = DwarfNative.DW_OP_breg18, - - Breg19 = DwarfNative.DW_OP_breg19, - - Breg20 = DwarfNative.DW_OP_breg20, - - Breg21 = DwarfNative.DW_OP_breg21, - - Breg22 = DwarfNative.DW_OP_breg22, - - Breg23 = DwarfNative.DW_OP_breg23, - - Breg24 = DwarfNative.DW_OP_breg24, - - Breg25 = DwarfNative.DW_OP_breg25, - - Breg26 = DwarfNative.DW_OP_breg26, - - Breg27 = DwarfNative.DW_OP_breg27, - - Breg28 = DwarfNative.DW_OP_breg28, - - Breg29 = DwarfNative.DW_OP_breg29, - - Breg30 = DwarfNative.DW_OP_breg30, - - Breg31 = DwarfNative.DW_OP_breg31, - - Regx = DwarfNative.DW_OP_regx, - - Fbreg = DwarfNative.DW_OP_fbreg, - - Bregx = DwarfNative.DW_OP_bregx, - - Piece = DwarfNative.DW_OP_piece, - - DerefSize = DwarfNative.DW_OP_deref_size, - - XderefSize = DwarfNative.DW_OP_xderef_size, - - Nop = DwarfNative.DW_OP_nop, - - PushObjectAddress = DwarfNative.DW_OP_push_object_address, - - Call2 = DwarfNative.DW_OP_call2, - - Call4 = DwarfNative.DW_OP_call4, - - CallRef = DwarfNative.DW_OP_call_ref, - - FormTlsAddress = DwarfNative.DW_OP_form_tls_address, - - CallFrameCfa = DwarfNative.DW_OP_call_frame_cfa, - - BitPiece = DwarfNative.DW_OP_bit_piece, - - ImplicitValue = DwarfNative.DW_OP_implicit_value, - - StackValue = DwarfNative.DW_OP_stack_value, - - ImplicitPointer = DwarfNative.DW_OP_implicit_pointer, - - Addrx = DwarfNative.DW_OP_addrx, - - Constx = DwarfNative.DW_OP_constx, - - EntryValue = DwarfNative.DW_OP_entry_value, - - ConstType = DwarfNative.DW_OP_const_type, - - RegvalType = DwarfNative.DW_OP_regval_type, - - DerefType = DwarfNative.DW_OP_deref_type, - - XderefType = DwarfNative.DW_OP_xderef_type, - - Convert = DwarfNative.DW_OP_convert, - - Reinterpret = DwarfNative.DW_OP_reinterpret, - - GNUPushTlsAddress = DwarfNative.DW_OP_GNU_push_tls_address, - - GNUUninit = DwarfNative.DW_OP_GNU_uninit, - - GNUEncodedAddr = DwarfNative.DW_OP_GNU_encoded_addr, - - GNUImplicitPointer = DwarfNative.DW_OP_GNU_implicit_pointer, - - GNUEntryValue = DwarfNative.DW_OP_GNU_entry_value, - - GNUConstType = DwarfNative.DW_OP_GNU_const_type, - - GNURegvalType = DwarfNative.DW_OP_GNU_regval_type, - - GNUDerefType = DwarfNative.DW_OP_GNU_deref_type, - - GNUConvert = DwarfNative.DW_OP_GNU_convert, - - GNUReinterpret = DwarfNative.DW_OP_GNU_reinterpret, - - GNUParameterRef = DwarfNative.DW_OP_GNU_parameter_ref, - - GNUAddrIndex = DwarfNative.DW_OP_GNU_addr_index, - - GNUConstIndex = DwarfNative.DW_OP_GNU_const_index, - - HPUnknown = DwarfNative.DW_OP_HP_unknown, - - HPIsValue = DwarfNative.DW_OP_HP_is_value, - - HPFltconst4 = DwarfNative.DW_OP_HP_fltconst4, - - HPFltconst8 = DwarfNative.DW_OP_HP_fltconst8, - - HPModRange = DwarfNative.DW_OP_HP_mod_range, - - HPUnmodRange = DwarfNative.DW_OP_HP_unmod_range, - - HPTls = DwarfNative.DW_OP_HP_tls, - - INTELBitPiece = DwarfNative.DW_OP_INTEL_bit_piece, - - APPLEUninit = DwarfNative.DW_OP_APPLE_uninit, - - PGIOmpThreadNum = DwarfNative.DW_OP_PGI_omp_thread_num, - } - - public readonly partial struct DwarfLanguageKindEx - { - public static readonly DwarfLanguageKindEx C89 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C89); - - public static readonly DwarfLanguageKindEx C = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C); - - public static readonly DwarfLanguageKindEx Ada83 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Ada83); - - public static readonly DwarfLanguageKindEx CPlusPlus = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus); - - public static readonly DwarfLanguageKindEx Cobol74 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Cobol74); - - public static readonly DwarfLanguageKindEx Cobol85 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Cobol85); - - public static readonly DwarfLanguageKindEx Fortran77 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran77); - - public static readonly DwarfLanguageKindEx Fortran90 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran90); - - public static readonly DwarfLanguageKindEx Pascal83 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Pascal83); - - public static readonly DwarfLanguageKindEx Modula2 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Modula2); - - /// - /// DWARF3 - /// - public static readonly DwarfLanguageKindEx Java = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Java); - - /// - /// DWARF3 - /// - public static readonly DwarfLanguageKindEx C99 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C99); - - /// - /// DWARF3 - /// - public static readonly DwarfLanguageKindEx Ada95 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Ada95); - - /// - /// DWARF3 - /// - public static readonly DwarfLanguageKindEx Fortran95 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran95); - - /// - /// DWARF3 - /// - public static readonly DwarfLanguageKindEx PLI = new DwarfLanguageKindEx(DwarfNative.DW_LANG_PLI); - - /// - /// DWARF3f - /// - public static readonly DwarfLanguageKindEx ObjC = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ObjC); - - /// - /// DWARF3f - /// - public static readonly DwarfLanguageKindEx ObjCPlusPlus = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ObjC_plus_plus); - - /// - /// DWARF3f - /// - public static readonly DwarfLanguageKindEx UPC = new DwarfLanguageKindEx(DwarfNative.DW_LANG_UPC); - - /// - /// DWARF3f - /// - public static readonly DwarfLanguageKindEx D = new DwarfLanguageKindEx(DwarfNative.DW_LANG_D); - - /// - /// DWARF4 - /// - public static readonly DwarfLanguageKindEx Python = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Python); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx OpenCL = new DwarfLanguageKindEx(DwarfNative.DW_LANG_OpenCL); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Go = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Go); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Modula3 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Modula3); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Haskel = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Haskel); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx CPlusPlus03 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_03); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx CPlusPlus11 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_11); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx OCaml = new DwarfLanguageKindEx(DwarfNative.DW_LANG_OCaml); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Rust = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Rust); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx C11 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C11); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Swift = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Swift); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Julia = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Julia); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Dylan = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Dylan); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx CPlusPlus14 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_C_plus_plus_14); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Fortran03 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran03); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx Fortran08 = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Fortran08); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx RenderScript = new DwarfLanguageKindEx(DwarfNative.DW_LANG_RenderScript); - - /// - /// DWARF5 - /// - public static readonly DwarfLanguageKindEx BLISS = new DwarfLanguageKindEx(DwarfNative.DW_LANG_BLISS); - - /// - /// MIPS - /// - public static readonly DwarfLanguageKindEx MipsAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Mips_Assembler); - - /// - /// UPC, use - /// DW_LANG_UPC instead. - /// - public static readonly DwarfLanguageKindEx Upc = new DwarfLanguageKindEx(DwarfNative.DW_LANG_Upc); - - /// - /// ALTIUM - /// - public static readonly DwarfLanguageKindEx ALTIUMAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_ALTIUM_Assembler); - - /// - /// SUN - /// - public static readonly DwarfLanguageKindEx SUNAssembler = new DwarfLanguageKindEx(DwarfNative.DW_LANG_SUN_Assembler); - - private string ToStringInternal() - { - switch ((ushort)Value) - { - case DwarfNative.DW_LANG_C89: return "DW_LANG_C89"; - case DwarfNative.DW_LANG_C: return "DW_LANG_C"; - case DwarfNative.DW_LANG_Ada83: return "DW_LANG_Ada83"; - case DwarfNative.DW_LANG_C_plus_plus: return "DW_LANG_C_plus_plus"; - case DwarfNative.DW_LANG_Cobol74: return "DW_LANG_Cobol74"; - case DwarfNative.DW_LANG_Cobol85: return "DW_LANG_Cobol85"; - case DwarfNative.DW_LANG_Fortran77: return "DW_LANG_Fortran77"; - case DwarfNative.DW_LANG_Fortran90: return "DW_LANG_Fortran90"; - case DwarfNative.DW_LANG_Pascal83: return "DW_LANG_Pascal83"; - case DwarfNative.DW_LANG_Modula2: return "DW_LANG_Modula2"; - case DwarfNative.DW_LANG_Java: return "DW_LANG_Java"; - case DwarfNative.DW_LANG_C99: return "DW_LANG_C99"; - case DwarfNative.DW_LANG_Ada95: return "DW_LANG_Ada95"; - case DwarfNative.DW_LANG_Fortran95: return "DW_LANG_Fortran95"; - case DwarfNative.DW_LANG_PLI: return "DW_LANG_PLI"; - case DwarfNative.DW_LANG_ObjC: return "DW_LANG_ObjC"; - case DwarfNative.DW_LANG_ObjC_plus_plus: return "DW_LANG_ObjC_plus_plus"; - case DwarfNative.DW_LANG_UPC: return "DW_LANG_UPC"; - case DwarfNative.DW_LANG_D: return "DW_LANG_D"; - case DwarfNative.DW_LANG_Python: return "DW_LANG_Python"; - case DwarfNative.DW_LANG_OpenCL: return "DW_LANG_OpenCL"; - case DwarfNative.DW_LANG_Go: return "DW_LANG_Go"; - case DwarfNative.DW_LANG_Modula3: return "DW_LANG_Modula3"; - case DwarfNative.DW_LANG_Haskel: return "DW_LANG_Haskel"; - case DwarfNative.DW_LANG_C_plus_plus_03: return "DW_LANG_C_plus_plus_03"; - case DwarfNative.DW_LANG_C_plus_plus_11: return "DW_LANG_C_plus_plus_11"; - case DwarfNative.DW_LANG_OCaml: return "DW_LANG_OCaml"; - case DwarfNative.DW_LANG_Rust: return "DW_LANG_Rust"; - case DwarfNative.DW_LANG_C11: return "DW_LANG_C11"; - case DwarfNative.DW_LANG_Swift: return "DW_LANG_Swift"; - case DwarfNative.DW_LANG_Julia: return "DW_LANG_Julia"; - case DwarfNative.DW_LANG_Dylan: return "DW_LANG_Dylan"; - case DwarfNative.DW_LANG_C_plus_plus_14: return "DW_LANG_C_plus_plus_14"; - case DwarfNative.DW_LANG_Fortran03: return "DW_LANG_Fortran03"; - case DwarfNative.DW_LANG_Fortran08: return "DW_LANG_Fortran08"; - case DwarfNative.DW_LANG_RenderScript: return "DW_LANG_RenderScript"; - case DwarfNative.DW_LANG_BLISS: return "DW_LANG_BLISS"; - case DwarfNative.DW_LANG_Mips_Assembler: return "DW_LANG_Mips_Assembler"; - case DwarfNative.DW_LANG_Upc: return "DW_LANG_Upc"; - case DwarfNative.DW_LANG_ALTIUM_Assembler: return "DW_LANG_ALTIUM_Assembler"; - case DwarfNative.DW_LANG_SUN_Assembler: return "DW_LANG_SUN_Assembler"; - default: return null; - } - } - } - - public enum DwarfLanguageKind : ushort - { - C89 = DwarfNative.DW_LANG_C89, - - C = DwarfNative.DW_LANG_C, - - Ada83 = DwarfNative.DW_LANG_Ada83, - - CPlusPlus = DwarfNative.DW_LANG_C_plus_plus, - - Cobol74 = DwarfNative.DW_LANG_Cobol74, - - Cobol85 = DwarfNative.DW_LANG_Cobol85, - - Fortran77 = DwarfNative.DW_LANG_Fortran77, - - Fortran90 = DwarfNative.DW_LANG_Fortran90, - - Pascal83 = DwarfNative.DW_LANG_Pascal83, - - Modula2 = DwarfNative.DW_LANG_Modula2, - - Java = DwarfNative.DW_LANG_Java, - - C99 = DwarfNative.DW_LANG_C99, - - Ada95 = DwarfNative.DW_LANG_Ada95, - - Fortran95 = DwarfNative.DW_LANG_Fortran95, - - PLI = DwarfNative.DW_LANG_PLI, - - ObjC = DwarfNative.DW_LANG_ObjC, - - ObjCPlusPlus = DwarfNative.DW_LANG_ObjC_plus_plus, - - UPC = DwarfNative.DW_LANG_UPC, - - D = DwarfNative.DW_LANG_D, - - Python = DwarfNative.DW_LANG_Python, - - OpenCL = DwarfNative.DW_LANG_OpenCL, - - Go = DwarfNative.DW_LANG_Go, - - Modula3 = DwarfNative.DW_LANG_Modula3, - - Haskel = DwarfNative.DW_LANG_Haskel, - - CPlusPlus03 = DwarfNative.DW_LANG_C_plus_plus_03, - - CPlusPlus11 = DwarfNative.DW_LANG_C_plus_plus_11, - - OCaml = DwarfNative.DW_LANG_OCaml, - - Rust = DwarfNative.DW_LANG_Rust, - - C11 = DwarfNative.DW_LANG_C11, - - Swift = DwarfNative.DW_LANG_Swift, - - Julia = DwarfNative.DW_LANG_Julia, - - Dylan = DwarfNative.DW_LANG_Dylan, - - CPlusPlus14 = DwarfNative.DW_LANG_C_plus_plus_14, - - Fortran03 = DwarfNative.DW_LANG_Fortran03, - - Fortran08 = DwarfNative.DW_LANG_Fortran08, - - RenderScript = DwarfNative.DW_LANG_RenderScript, - - BLISS = DwarfNative.DW_LANG_BLISS, - - MipsAssembler = DwarfNative.DW_LANG_Mips_Assembler, - - Upc = DwarfNative.DW_LANG_Upc, - - ALTIUMAssembler = DwarfNative.DW_LANG_ALTIUM_Assembler, - - SUNAssembler = DwarfNative.DW_LANG_SUN_Assembler, - } - - public readonly partial struct DwarfCallingConventionEx - { - public static readonly DwarfCallingConventionEx Normal = new DwarfCallingConventionEx(DwarfNative.DW_CC_normal); - - public static readonly DwarfCallingConventionEx Program = new DwarfCallingConventionEx(DwarfNative.DW_CC_program); - - public static readonly DwarfCallingConventionEx Nocall = new DwarfCallingConventionEx(DwarfNative.DW_CC_nocall); - - /// - /// DWARF5 - /// - public static readonly DwarfCallingConventionEx PassByReference = new DwarfCallingConventionEx(DwarfNative.DW_CC_pass_by_reference); - - /// - /// DWARF5 - /// - public static readonly DwarfCallingConventionEx PassByValue = new DwarfCallingConventionEx(DwarfNative.DW_CC_pass_by_value); - - /// - /// GNU - /// - public static readonly DwarfCallingConventionEx GNURenesasSh = new DwarfCallingConventionEx(DwarfNative.DW_CC_GNU_renesas_sh); - - /// - /// GNU - /// - public static readonly DwarfCallingConventionEx GNUBorlandFastcallI386 = new DwarfCallingConventionEx(DwarfNative.DW_CC_GNU_borland_fastcall_i386); - - /// - /// ALTIUM - /// - public static readonly DwarfCallingConventionEx ALTIUMInterrupt = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_interrupt); - - /// - /// ALTIUM - /// - public static readonly DwarfCallingConventionEx ALTIUMNearSystemStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_near_system_stack); - - /// - /// ALTIUM - /// - public static readonly DwarfCallingConventionEx ALTIUMNearUserStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_near_user_stack); - - /// - /// ALTIUM - /// - public static readonly DwarfCallingConventionEx ALTIUMHugeUserStack = new DwarfCallingConventionEx(DwarfNative.DW_CC_ALTIUM_huge_user_stack); - - private string ToStringInternal() - { - switch ((byte)Value) - { - case DwarfNative.DW_CC_normal: return "DW_CC_normal"; - case DwarfNative.DW_CC_program: return "DW_CC_program"; - case DwarfNative.DW_CC_nocall: return "DW_CC_nocall"; - case DwarfNative.DW_CC_pass_by_reference: return "DW_CC_pass_by_reference"; - case DwarfNative.DW_CC_pass_by_value: return "DW_CC_pass_by_value"; - case DwarfNative.DW_CC_GNU_renesas_sh: return "DW_CC_GNU_renesas_sh"; - case DwarfNative.DW_CC_GNU_borland_fastcall_i386: return "DW_CC_GNU_borland_fastcall_i386"; - case DwarfNative.DW_CC_ALTIUM_interrupt: return "DW_CC_ALTIUM_interrupt"; - case DwarfNative.DW_CC_ALTIUM_near_system_stack: return "DW_CC_ALTIUM_near_system_stack"; - case DwarfNative.DW_CC_ALTIUM_near_user_stack: return "DW_CC_ALTIUM_near_user_stack"; - case DwarfNative.DW_CC_ALTIUM_huge_user_stack: return "DW_CC_ALTIUM_huge_user_stack"; - default: return null; - } - } - } - - public enum DwarfCallingConvention : byte - { - Normal = DwarfNative.DW_CC_normal, - - Program = DwarfNative.DW_CC_program, - - Nocall = DwarfNative.DW_CC_nocall, - - PassByReference = DwarfNative.DW_CC_pass_by_reference, - - PassByValue = DwarfNative.DW_CC_pass_by_value, - - GNURenesasSh = DwarfNative.DW_CC_GNU_renesas_sh, - - GNUBorlandFastcallI386 = DwarfNative.DW_CC_GNU_borland_fastcall_i386, - - ALTIUMInterrupt = DwarfNative.DW_CC_ALTIUM_interrupt, - - ALTIUMNearSystemStack = DwarfNative.DW_CC_ALTIUM_near_system_stack, - - ALTIUMNearUserStack = DwarfNative.DW_CC_ALTIUM_near_user_stack, - - ALTIUMHugeUserStack = DwarfNative.DW_CC_ALTIUM_huge_user_stack, - } - - public readonly partial struct DwarfUnitKindEx - { - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx Compile = new DwarfUnitKindEx(DwarfNative.DW_UT_compile); - - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx Type = new DwarfUnitKindEx(DwarfNative.DW_UT_type); - - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx Partial = new DwarfUnitKindEx(DwarfNative.DW_UT_partial); - - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx Skeleton = new DwarfUnitKindEx(DwarfNative.DW_UT_skeleton); - - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx SplitCompile = new DwarfUnitKindEx(DwarfNative.DW_UT_split_compile); - - /// - /// DWARF5 - /// - public static readonly DwarfUnitKindEx SplitType = new DwarfUnitKindEx(DwarfNative.DW_UT_split_type); - - private string ToStringInternal() - { - switch ((byte)Value) - { - case DwarfNative.DW_UT_compile: return "DW_UT_compile"; - case DwarfNative.DW_UT_type: return "DW_UT_type"; - case DwarfNative.DW_UT_partial: return "DW_UT_partial"; - case DwarfNative.DW_UT_skeleton: return "DW_UT_skeleton"; - case DwarfNative.DW_UT_split_compile: return "DW_UT_split_compile"; - case DwarfNative.DW_UT_split_type: return "DW_UT_split_type"; - default: return null; - } - } - } - - public enum DwarfUnitKind : byte - { - Compile = DwarfNative.DW_UT_compile, - - Type = DwarfNative.DW_UT_type, - - Partial = DwarfNative.DW_UT_partial, - - Skeleton = DwarfNative.DW_UT_skeleton, - - SplitCompile = DwarfNative.DW_UT_split_compile, - - SplitType = DwarfNative.DW_UT_split_type, - } - - public static partial class DwarfHelper - { - private static readonly DwarfAttributeEncoding[] AttributeToEncoding = new DwarfAttributeEncoding[] { - DwarfAttributeEncoding.None , // 0x00 (undefined) - DwarfAttributeEncoding.Reference , // 0x01 DW_AT_sibling - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationList , // 0x02 DW_AT_location - DwarfAttributeEncoding.String , // 0x03 DW_AT_name - DwarfAttributeEncoding.None , // 0x04 (undefined) - DwarfAttributeEncoding.None , // 0x05 (undefined) - DwarfAttributeEncoding.None , // 0x06 (undefined) - DwarfAttributeEncoding.None , // 0x07 (undefined) - DwarfAttributeEncoding.None , // 0x08 (undefined) - DwarfAttributeEncoding.Constant , // 0x09 DW_AT_ordering - DwarfAttributeEncoding.None , // 0x0a (undefined) - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x0b DW_AT_byte_size - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x0c DW_AT_bit_offset - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x0d DW_AT_bit_size - DwarfAttributeEncoding.None , // 0x0e (undefined) - DwarfAttributeEncoding.None , // 0x0f (undefined) - DwarfAttributeEncoding.LinePointer , // 0x10 DW_AT_stmt_list - DwarfAttributeEncoding.Address , // 0x11 DW_AT_low_pc - DwarfAttributeEncoding.Address | - DwarfAttributeEncoding.Constant , // 0x12 DW_AT_high_pc - DwarfAttributeEncoding.Constant , // 0x13 DW_AT_language - DwarfAttributeEncoding.None , // 0x14 (undefined) - DwarfAttributeEncoding.Reference , // 0x15 DW_AT_discr - DwarfAttributeEncoding.Constant , // 0x16 DW_AT_discr_value - DwarfAttributeEncoding.Constant , // 0x17 DW_AT_visibility - DwarfAttributeEncoding.Reference , // 0x18 DW_AT_import - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x19 DW_AT_string_length - DwarfAttributeEncoding.Reference , // 0x1a DW_AT_common_reference - DwarfAttributeEncoding.String , // 0x1b DW_AT_comp_dir - DwarfAttributeEncoding.Block | - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.String , // 0x1c DW_AT_const_value - DwarfAttributeEncoding.Reference , // 0x1d DW_AT_containing_type - DwarfAttributeEncoding.Reference , // 0x1e DW_AT_default_value - DwarfAttributeEncoding.None , // 0x1f (undefined) - DwarfAttributeEncoding.Constant , // 0x20 DW_AT_inline - DwarfAttributeEncoding.Flag , // 0x21 DW_AT_is_optional - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x22 DW_AT_lower_bound - DwarfAttributeEncoding.None , // 0x23 (undefined) - DwarfAttributeEncoding.None , // 0x24 (undefined) - DwarfAttributeEncoding.String , // 0x25 DW_AT_producer - DwarfAttributeEncoding.None , // 0x26 (undefined) - DwarfAttributeEncoding.Flag , // 0x27 DW_AT_prototyped - DwarfAttributeEncoding.None , // 0x28 (undefined) - DwarfAttributeEncoding.None , // 0x29 (undefined) - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x2a DW_AT_return_addr - DwarfAttributeEncoding.None , // 0x2b (undefined) - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.RangeListPointer , // 0x2c DW_AT_start_scope - DwarfAttributeEncoding.None , // 0x2d (undefined) - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x2e DW_AT_bit_stride - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x2f DW_AT_upper_bound - DwarfAttributeEncoding.None , // 0x30 (undefined) - DwarfAttributeEncoding.Reference , // 0x31 DW_AT_abstract_origin - DwarfAttributeEncoding.Constant , // 0x32 DW_AT_accessibility - DwarfAttributeEncoding.Constant , // 0x33 DW_AT_address_class - DwarfAttributeEncoding.Flag , // 0x34 DW_AT_artificial - DwarfAttributeEncoding.Reference , // 0x35 DW_AT_base_types - DwarfAttributeEncoding.Constant , // 0x36 DW_AT_calling_convention - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x37 DW_AT_count - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x38 DW_AT_data_member_location - DwarfAttributeEncoding.Constant , // 0x39 DW_AT_decl_column - DwarfAttributeEncoding.Constant , // 0x3a DW_AT_decl_file - DwarfAttributeEncoding.Constant , // 0x3b DW_AT_decl_line - DwarfAttributeEncoding.Flag , // 0x3c DW_AT_declaration - DwarfAttributeEncoding.Block , // 0x3d DW_AT_discr_list - DwarfAttributeEncoding.Constant , // 0x3e DW_AT_encoding - DwarfAttributeEncoding.Flag , // 0x3f DW_AT_external - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x40 DW_AT_frame_base - DwarfAttributeEncoding.Reference , // 0x41 DW_AT_friend - DwarfAttributeEncoding.Constant , // 0x42 DW_AT_identifier_case - DwarfAttributeEncoding.MacroPointer , // 0x43 DW_AT_macro_info - DwarfAttributeEncoding.Reference , // 0x44 DW_AT_namelist_item - DwarfAttributeEncoding.Reference , // 0x45 DW_AT_priority - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x46 DW_AT_segment - DwarfAttributeEncoding.Reference , // 0x47 DW_AT_specification - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x48 DW_AT_static_link - DwarfAttributeEncoding.Reference , // 0x49 DW_AT_type - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x4a DW_AT_use_location - DwarfAttributeEncoding.Flag , // 0x4b DW_AT_variable_parameter - DwarfAttributeEncoding.Constant , // 0x4c DW_AT_virtuality - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.LocationListPointer , // 0x4d DW_AT_vtable_elem_location - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x4e DW_AT_allocated - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x4f DW_AT_associated - DwarfAttributeEncoding.ExpressionLocation , // 0x50 DW_AT_data_location - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation | - DwarfAttributeEncoding.Reference , // 0x51 DW_AT_byte_stride - DwarfAttributeEncoding.Address , // 0x52 DW_AT_entry_pc - DwarfAttributeEncoding.Flag , // 0x53 DW_AT_use_UTF8 - DwarfAttributeEncoding.Reference , // 0x54 DW_AT_extension - DwarfAttributeEncoding.RangeListPointer , // 0x55 DW_AT_ranges - DwarfAttributeEncoding.Address | - DwarfAttributeEncoding.Flag | - DwarfAttributeEncoding.Reference | - DwarfAttributeEncoding.String , // 0x56 DW_AT_trampoline - DwarfAttributeEncoding.Constant , // 0x57 DW_AT_call_column - DwarfAttributeEncoding.Constant , // 0x58 DW_AT_call_file - DwarfAttributeEncoding.Constant , // 0x59 DW_AT_call_line - DwarfAttributeEncoding.String , // 0x5a DW_AT_description - DwarfAttributeEncoding.Constant , // 0x5b DW_AT_binary_scale - DwarfAttributeEncoding.Constant , // 0x5c DW_AT_decimal_scale - DwarfAttributeEncoding.Reference , // 0x5d DW_AT_small - DwarfAttributeEncoding.Constant , // 0x5e DW_AT_decimal_sign - DwarfAttributeEncoding.Constant , // 0x5f DW_AT_digit_count - DwarfAttributeEncoding.String , // 0x60 DW_AT_picture_string - DwarfAttributeEncoding.Flag , // 0x61 DW_AT_mutable - DwarfAttributeEncoding.Flag , // 0x62 DW_AT_threads_scaled - DwarfAttributeEncoding.Flag , // 0x63 DW_AT_explicit - DwarfAttributeEncoding.Reference , // 0x64 DW_AT_object_pointer - DwarfAttributeEncoding.Constant , // 0x65 DW_AT_endianity - DwarfAttributeEncoding.Flag , // 0x66 DW_AT_elemental - DwarfAttributeEncoding.Flag , // 0x67 DW_AT_pure - DwarfAttributeEncoding.Flag , // 0x68 DW_AT_recursive - DwarfAttributeEncoding.Reference , // 0x69 DW_AT_signature - DwarfAttributeEncoding.Flag , // 0x6a DW_AT_main_subprogram - DwarfAttributeEncoding.Constant , // 0x6b DW_AT_data_bit_offset - DwarfAttributeEncoding.Flag , // 0x6c DW_AT_const_expr - DwarfAttributeEncoding.Flag , // 0x6d DW_AT_enum_class - DwarfAttributeEncoding.String , // 0x6e DW_AT_linkage_name - DwarfAttributeEncoding.Constant , // 0x6f DW_AT_string_length_bit_size - DwarfAttributeEncoding.Constant , // 0x70 DW_AT_string_length_byte_size - DwarfAttributeEncoding.Constant | - DwarfAttributeEncoding.ExpressionLocation , // 0x71 DW_AT_rank - DwarfAttributeEncoding.StringOffsetPointer , // 0x72 DW_AT_str_offsets_base - DwarfAttributeEncoding.AddressPointer , // 0x73 DW_AT_addr_base - DwarfAttributeEncoding.RangeListsPointer , // 0x74 DW_AT_rnglists_base - DwarfAttributeEncoding.None , // 0x75 (undefined) - DwarfAttributeEncoding.String , // 0x76 DW_AT_dwo_name - DwarfAttributeEncoding.Flag , // 0x77 DW_AT_reference - DwarfAttributeEncoding.Flag , // 0x78 DW_AT_rvalue_reference - DwarfAttributeEncoding.MacroPointer , // 0x79 DW_AT_macros - DwarfAttributeEncoding.Flag , // 0x7a DW_AT_call_all_calls - DwarfAttributeEncoding.Flag , // 0x7b DW_AT_call_all_source_calls - DwarfAttributeEncoding.Flag , // 0x7c DW_AT_call_all_tail_calls - DwarfAttributeEncoding.Address , // 0x7d DW_AT_call_return_pc - DwarfAttributeEncoding.ExpressionLocation , // 0x7e DW_AT_call_value - DwarfAttributeEncoding.ExpressionLocation , // 0x7f DW_AT_call_origin - DwarfAttributeEncoding.Reference , // 0x80 DW_AT_call_parameter - DwarfAttributeEncoding.Address , // 0x81 DW_AT_call_pc - DwarfAttributeEncoding.Flag , // 0x82 DW_AT_call_tail_call - DwarfAttributeEncoding.ExpressionLocation , // 0x83 DW_AT_call_target - DwarfAttributeEncoding.ExpressionLocation , // 0x84 DW_AT_call_target_clobbered - DwarfAttributeEncoding.ExpressionLocation , // 0x85 DW_AT_call_data_location - DwarfAttributeEncoding.ExpressionLocation , // 0x86 DW_AT_call_data_value - DwarfAttributeEncoding.Flag , // 0x87 DW_AT_noreturn - DwarfAttributeEncoding.Constant , // 0x88 DW_AT_alignment - DwarfAttributeEncoding.Flag , // 0x89 DW_AT_export_symbols - DwarfAttributeEncoding.Flag , // 0x8a DW_AT_deleted - DwarfAttributeEncoding.Constant , // 0x8b DW_AT_defaulted - DwarfAttributeEncoding.LocationListsPointer , // 0x8c DW_AT_loclists_base - }; - } - - public partial class DwarfDIEAccessDeclaration : DwarfDIEDeclaration - { - public DwarfDIEAccessDeclaration() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_access_declaration; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - } - - public partial class DwarfDIEArrayType : DwarfDIEDeclaration - { - public DwarfDIEArrayType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_array_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? BitStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfArrayOrderingKind? Ordering - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ordering); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ordering, value); - } - } - - public DwarfConstant? Rank - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Rank); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Rank, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEAtomicType : DwarfDIEDeclaration - { - public DwarfDIEAtomicType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_atomic_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEBaseType : DwarfDIEDeclaration - { - public DwarfDIEBaseType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_base_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BinaryScale - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BinaryScale); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BinaryScale, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfConstant? DataBitOffset - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public DwarfConstant? DecimalScale - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DecimalScale); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DecimalScale, value); - } - } - - public DwarfConstant? DecimalSign - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DecimalSign); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DecimalSign, value); - } - } - - public DwarfConstant? DigitCount - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DigitCount); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DigitCount, value); - } - } - - public DwarfConstant? Encoding - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Encoding); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Encoding, value); - } - } - - public DwarfConstant? Endianity - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public string PictureString - { - get - { - return GetAttributeValue(DwarfAttributeKind.PictureString); - } - set - { - SetAttributeValue(DwarfAttributeKind.PictureString, value); - } - } - - public DwarfDIE Small - { - get - { - return GetAttributeValue(DwarfAttributeKind.Small); - } - set - { - SetAttributeValue(DwarfAttributeKind.Small, value); - } - } - } - - public partial class DwarfDIECallSite : DwarfDIE - { - public DwarfDIECallSite() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_call_site; - } - - public DwarfConstant? CallColumn - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallColumn); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallColumn, value); - } - } - - public DwarfConstant? CallFile - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallFile); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallFile, value); - } - } - - public DwarfConstant? CallLine - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallLine); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallLine, value); - } - } - - public DwarfExpression CallOrigin - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallOrigin); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallOrigin, value); - } - } - - public ulong? CallPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallPC, value); - } - } - - public ulong? CallReturnPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallReturnPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallReturnPC, value); - } - } - - public bool? CallTailCall - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallTailCall); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallTailCall, value); - } - } - - public DwarfExpression CallTarget - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallTarget); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallTarget, value); - } - } - - public DwarfExpression CallTargetClobbered - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallTargetClobbered); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallTargetClobbered, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIECallSiteParameter : DwarfDIE - { - public DwarfDIECallSiteParameter() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_call_site_parameter; - } - - public DwarfExpression CallDataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallDataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallDataLocation, value); - } - } - - public DwarfExpression CallDataValue - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallDataValue); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallDataValue, value); - } - } - - public DwarfDIE CallParameter - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallParameter); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallParameter, value); - } - } - - public DwarfExpression CallValue - { - get - { - return GetAttributeValue(DwarfAttributeKind.CallValue); - } - set - { - SetAttributeValue(DwarfAttributeKind.CallValue, value); - } - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIECatchBlock : DwarfDIEDeclaration - { - public DwarfDIECatchBlock() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_catch_block; - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - } - - public partial class DwarfDIEClassType : DwarfDIEDeclaration - { - public DwarfDIEClassType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_class_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfCallingConvention? CallingConvention - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public bool? ExportSymbols - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIECoarrayType : DwarfDIEDeclaration - { - public DwarfDIECoarrayType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_coarray_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIECommonBlock : DwarfDIEDeclaration - { - public DwarfDIECommonBlock() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_common_block; - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string LinkageName - { - get - { - return GetAttributeValue(DwarfAttributeKind.LinkageName); - } - set - { - SetAttributeValue(DwarfAttributeKind.LinkageName, value); - } - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIECommonInclusion : DwarfDIEDeclaration - { - public DwarfDIECommonInclusion() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_common_inclusion; - } - - public DwarfDIE CommonReference - { - get - { - return GetAttributeValue(DwarfAttributeKind.CommonReference); - } - set - { - SetAttributeValue(DwarfAttributeKind.CommonReference, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIECompileUnit : DwarfDIE - { - public DwarfDIECompileUnit() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_compile_unit; - } - - public ulong? AddrBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); - } - } - - public DwarfDIE BaseTypes - { - get - { - return GetAttributeValue(DwarfAttributeKind.BaseTypes); - } - set - { - SetAttributeValue(DwarfAttributeKind.BaseTypes, value); - } - } - - public string CompDir - { - get - { - return GetAttributeValue(DwarfAttributeKind.CompDir); - } - set - { - SetAttributeValue(DwarfAttributeKind.CompDir, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfIdentifierCaseKind? IdentifierCase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.IdentifierCase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.IdentifierCase, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public DwarfLanguageKind? Language - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Language); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Language, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Macros - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Macros); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Macros, value); - } - } - - public bool? MainSubprogram - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public string Producer - { - get - { - return GetAttributeValue(DwarfAttributeKind.Producer); - } - set - { - SetAttributeValue(DwarfAttributeKind.Producer, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public ulong? RnglistsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfLineProgramTable StmtList - { - get - { - return GetAttributeValue(DwarfAttributeKind.StmtList); - } - set - { - SetAttributeValue(DwarfAttributeKind.StmtList, value); - } - } - - public ulong? StrOffsetsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); - } - } - - public bool? UseUTF8 - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); - } - } - } - - public partial class DwarfDIECondition : DwarfDIEDeclaration - { - public DwarfDIECondition() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_condition; - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - } - - public partial class DwarfDIEConstType : DwarfDIEDeclaration - { - public DwarfDIEConstType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_const_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEConstant : DwarfDIEDeclaration - { - public DwarfDIEConstant() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_constant; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? ConstValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfConstant? Endianity - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); - } - } - - public bool? External - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.External); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.External, value); - } - } - - public string LinkageName - { - get - { - return GetAttributeValue(DwarfAttributeKind.LinkageName); - } - set - { - SetAttributeValue(DwarfAttributeKind.LinkageName, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEDwarfProcedure : DwarfDIE - { - public DwarfDIEDwarfProcedure() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_dwarf_procedure; - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - } - - public partial class DwarfDIEDynamicType : DwarfDIEDeclaration - { - public DwarfDIEDynamicType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_dynamic_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEEntryPoint : DwarfDIEDeclaration - { - public DwarfDIEEntryPoint() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_entry_point; - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfLocation? FrameBase - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.FrameBase); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.FrameBase, value); - } - } - - public string LinkageName - { - get - { - return GetAttributeValue(DwarfAttributeKind.LinkageName); - } - set - { - SetAttributeValue(DwarfAttributeKind.LinkageName, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfLocation? ReturnAddr - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfLocation? StaticLink - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.StaticLink); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.StaticLink, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEEnumerationType : DwarfDIEDeclaration - { - public DwarfDIEEnumerationType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_enumeration_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? BitStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfConstant? ByteStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public bool? EnumClass - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EnumClass); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EnumClass, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEEnumerator : DwarfDIEDeclaration - { - public DwarfDIEEnumerator() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_enumerator; - } - - public DwarfConstant? ConstValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - } - - public partial class DwarfDIEFileType : DwarfDIEDeclaration - { - public DwarfDIEFileType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_file_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEFormalParameter : DwarfDIEDeclaration - { - public DwarfDIEFormalParameter() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_formal_parameter; - } - - public bool? Artificial - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Artificial); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); - } - } - - public DwarfConstant? ConstValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); - } - } - - public DwarfDIE DefaultValue - { - get - { - return GetAttributeValue(DwarfAttributeKind.DefaultValue); - } - set - { - SetAttributeValue(DwarfAttributeKind.DefaultValue, value); - } - } - - public DwarfConstant? Endianity - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); - } - } - - public bool? IsOptional - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.IsOptional); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.IsOptional, value); - } - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public bool? VariableParameter - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.VariableParameter); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.VariableParameter, value); - } - } - } - - public partial class DwarfDIEFriend : DwarfDIEDeclaration - { - public DwarfDIEFriend() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_friend; - } - - public DwarfDIE Friend - { - get - { - return GetAttributeValue(DwarfAttributeKind.Friend); - } - set - { - SetAttributeValue(DwarfAttributeKind.Friend, value); - } - } - } - - public partial class DwarfDIEGenericSubrange : DwarfDIEDeclaration - { - public DwarfDIEGenericSubrange() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_generic_subrange; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? BitStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfConstant? ByteStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); - } - } - - public DwarfConstant? Count - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Count); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Count, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfConstant? LowerBound - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.LowerBound); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.LowerBound, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public bool? ThreadsScaled - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfConstant? UpperBound - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.UpperBound); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.UpperBound, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEImmutableType : DwarfDIEDeclaration - { - public DwarfDIEImmutableType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_immutable_type; - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEImportedDeclaration : DwarfDIEDeclaration - { - public DwarfDIEImportedDeclaration() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_declaration; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfDIE Import - { - get - { - return GetAttributeValue(DwarfAttributeKind.Import); - } - set - { - SetAttributeValue(DwarfAttributeKind.Import, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - } - - public partial class DwarfDIEImportedModule : DwarfDIEDeclaration - { - public DwarfDIEImportedModule() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_module; - } - - public DwarfDIE Import - { - get - { - return GetAttributeValue(DwarfAttributeKind.Import); - } - set - { - SetAttributeValue(DwarfAttributeKind.Import, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - } - - public partial class DwarfDIEImportedUnit : DwarfDIE - { - public DwarfDIEImportedUnit() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_imported_unit; - } - - public DwarfDIE Import - { - get - { - return GetAttributeValue(DwarfAttributeKind.Import); - } - set - { - SetAttributeValue(DwarfAttributeKind.Import, value); - } - } - } - - public partial class DwarfDIEInheritance : DwarfDIEDeclaration - { - public DwarfDIEInheritance() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_inheritance; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfLocation? DataMemberLocation - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVirtuality? Virtuality - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Virtuality); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Virtuality, value); - } - } - } - - public partial class DwarfDIEInlinedSubroutine : DwarfDIE - { - public DwarfDIEInlinedSubroutine() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_inlined_subroutine; - } - - public DwarfConstant? CallColumn - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallColumn); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallColumn, value); - } - } - - public DwarfConstant? CallFile - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallFile); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallFile, value); - } - } - - public DwarfConstant? CallLine - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.CallLine); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.CallLine, value); - } - } - - public bool? ConstExpr - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ConstExpr); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ConstExpr, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? ReturnAddr - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public object Trampoline - { - get - { - return GetAttributeValue(DwarfAttributeKind.Trampoline); - } - set - { - SetAttributeValue(DwarfAttributeKind.Trampoline, value); - } - } - } - - public partial class DwarfDIEInterfaceType : DwarfDIEDeclaration - { - public DwarfDIEInterfaceType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_interface_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - } - - public partial class DwarfDIELabel : DwarfDIEDeclaration - { - public DwarfDIELabel() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_label; - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - } - - public partial class DwarfDIELexicalBlock : DwarfDIEDeclaration - { - public DwarfDIELexicalBlock() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_lexical_block; - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - } - - public partial class DwarfDIEMember : DwarfDIEDeclaration - { - public DwarfDIEMember() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_member; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public bool? Artificial - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Artificial); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfConstant? DataBitOffset - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DataBitOffset, value); - } - } - - public DwarfLocation? DataMemberLocation - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.DataMemberLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public bool? Mutable - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Mutable); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Mutable, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEModule : DwarfDIEDeclaration - { - public DwarfDIEModule() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_module; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Priority - { - get - { - return GetAttributeValue(DwarfAttributeKind.Priority); - } - set - { - SetAttributeValue(DwarfAttributeKind.Priority, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIENamelist : DwarfDIEDeclaration - { - public DwarfDIENamelist() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_namelist; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIENamelistItem : DwarfDIEDeclaration - { - public DwarfDIENamelistItem() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_namelist_item; - } - - public DwarfDIE NamelistItem - { - get - { - return GetAttributeValue(DwarfAttributeKind.NamelistItem); - } - set - { - SetAttributeValue(DwarfAttributeKind.NamelistItem, value); - } - } - } - - public partial class DwarfDIENamespace : DwarfDIEDeclaration - { - public DwarfDIENamespace() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_namespace; - } - - public bool? ExportSymbols - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); - } - } - - public DwarfDIE Extension - { - get - { - return GetAttributeValue(DwarfAttributeKind.Extension); - } - set - { - SetAttributeValue(DwarfAttributeKind.Extension, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - } - - public partial class DwarfDIEPackedType : DwarfDIEDeclaration - { - public DwarfDIEPackedType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_packed_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEPartialUnit : DwarfDIE - { - public DwarfDIEPartialUnit() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_partial_unit; - } - - public ulong? AddrBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); - } - } - - public DwarfDIE BaseTypes - { - get - { - return GetAttributeValue(DwarfAttributeKind.BaseTypes); - } - set - { - SetAttributeValue(DwarfAttributeKind.BaseTypes, value); - } - } - - public string CompDir - { - get - { - return GetAttributeValue(DwarfAttributeKind.CompDir); - } - set - { - SetAttributeValue(DwarfAttributeKind.CompDir, value); - } - } - - public string DwoName - { - get - { - return GetAttributeValue(DwarfAttributeKind.DwoName); - } - set - { - SetAttributeValue(DwarfAttributeKind.DwoName, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfIdentifierCaseKind? IdentifierCase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.IdentifierCase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.IdentifierCase, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public DwarfLanguageKind? Language - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Language); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Language, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Macros - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Macros); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Macros, value); - } - } - - public bool? MainSubprogram - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public string Producer - { - get - { - return GetAttributeValue(DwarfAttributeKind.Producer); - } - set - { - SetAttributeValue(DwarfAttributeKind.Producer, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public ulong? RnglistsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfLineProgramTable StmtList - { - get - { - return GetAttributeValue(DwarfAttributeKind.StmtList); - } - set - { - SetAttributeValue(DwarfAttributeKind.StmtList, value); - } - } - - public ulong? StrOffsetsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); - } - } - - public bool? UseUTF8 - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); - } - } - } - - public partial class DwarfDIEPointerType : DwarfDIEDeclaration - { - public DwarfDIEPointerType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_pointer_type; - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEPtrToMemberType : DwarfDIEDeclaration - { - public DwarfDIEPtrToMemberType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_ptr_to_member_type; - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfDIE ContainingType - { - get - { - return GetAttributeValue(DwarfAttributeKind.ContainingType); - } - set - { - SetAttributeValue(DwarfAttributeKind.ContainingType, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfLocation? UseLocation - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.UseLocation); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.UseLocation, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEReferenceType : DwarfDIEDeclaration - { - public DwarfDIEReferenceType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_reference_type; - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIERestrictType : DwarfDIEDeclaration - { - public DwarfDIERestrictType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_restrict_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIERvalueReferenceType : DwarfDIEDeclaration - { - public DwarfDIERvalueReferenceType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_rvalue_reference_type; - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIESetType : DwarfDIEDeclaration - { - public DwarfDIESetType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_set_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIESharedType : DwarfDIEDeclaration - { - public DwarfDIESharedType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_shared_type; - } - - public DwarfConstant? Count - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Count); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Count, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIESkeletonUnit : DwarfDIE - { - public DwarfDIESkeletonUnit() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_skeleton_unit; - } - - public ulong? AddrBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.AddrBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.AddrBase, value); - } - } - - public string CompDir - { - get - { - return GetAttributeValue(DwarfAttributeKind.CompDir); - } - set - { - SetAttributeValue(DwarfAttributeKind.CompDir, value); - } - } - - public string DwoName - { - get - { - return GetAttributeValue(DwarfAttributeKind.DwoName); - } - set - { - SetAttributeValue(DwarfAttributeKind.DwoName, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public ulong? RnglistsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.RnglistsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.RnglistsBase, value); - } - } - - public DwarfLineProgramTable StmtList - { - get - { - return GetAttributeValue(DwarfAttributeKind.StmtList); - } - set - { - SetAttributeValue(DwarfAttributeKind.StmtList, value); - } - } - - public ulong? StrOffsetsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); - } - } - - public bool? UseUTF8 - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); - } - } - } - - public partial class DwarfDIEStringType : DwarfDIEDeclaration - { - public DwarfDIEStringType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_string_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfLocation? StringLength - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.StringLength); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.StringLength, value); - } - } - - public DwarfConstant? StringLengthBitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StringLengthBitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StringLengthBitSize, value); - } - } - - public DwarfConstant? StringLengthByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StringLengthByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StringLengthByteSize, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEStructureType : DwarfDIEDeclaration - { - public DwarfDIEStructureType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_structure_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfCallingConvention? CallingConvention - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public bool? ExportSymbols - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIESubprogram : DwarfDIEDeclaration - { - public DwarfDIESubprogram() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_subprogram; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public bool? Artificial - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Artificial); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); - } - } - - public DwarfCallingConvention? CallingConvention - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfConstant? Defaulted - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Defaulted); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Defaulted, value); - } - } - - public bool? Deleted - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Deleted); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Deleted, value); - } - } - - public bool? Elemental - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Elemental); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Elemental, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public bool? Explicit - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Explicit); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Explicit, value); - } - } - - public bool? External - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.External); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.External, value); - } - } - - public DwarfLocation? FrameBase - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.FrameBase); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.FrameBase, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public DwarfInlineKind? Inline - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Inline); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Inline, value); - } - } - - public string LinkageName - { - get - { - return GetAttributeValue(DwarfAttributeKind.LinkageName); - } - set - { - SetAttributeValue(DwarfAttributeKind.LinkageName, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public bool? MainSubprogram - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.MainSubprogram); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.MainSubprogram, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public bool? Noreturn - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Noreturn); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Noreturn, value); - } - } - - public DwarfDIE ObjectPointer - { - get - { - return GetAttributeValue(DwarfAttributeKind.ObjectPointer); - } - set - { - SetAttributeValue(DwarfAttributeKind.ObjectPointer, value); - } - } - - public bool? Prototyped - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Prototyped); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Prototyped, value); - } - } - - public bool? Pure - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Pure); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Pure, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public bool? Recursive - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Recursive); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Recursive, value); - } - } - - public bool? Reference - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Reference); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Reference, value); - } - } - - public DwarfLocation? ReturnAddr - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.ReturnAddr, value); - } - } - - public bool? RvalueReference - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.RvalueReference); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.RvalueReference, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfLocation? StaticLink - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.StaticLink); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.StaticLink, value); - } - } - - public object Trampoline - { - get - { - return GetAttributeValue(DwarfAttributeKind.Trampoline); - } - set - { - SetAttributeValue(DwarfAttributeKind.Trampoline, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - - public DwarfVirtuality? Virtuality - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Virtuality); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Virtuality, value); - } - } - - public DwarfLocation? VtableElemLocation - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.VtableElemLocation); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.VtableElemLocation, value); - } - } - } - - public partial class DwarfDIESubrangeType : DwarfDIEDeclaration - { - public DwarfDIESubrangeType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_subrange_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? BitStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitStride, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfConstant? ByteStride - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteStride); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteStride, value); - } - } - - public DwarfConstant? Count - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Count); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Count, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfConstant? LowerBound - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.LowerBound); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.LowerBound, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public bool? ThreadsScaled - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ThreadsScaled, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfConstant? UpperBound - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.UpperBound); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.UpperBound, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIESubroutineType : DwarfDIEDeclaration - { - public DwarfDIESubroutineType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_subroutine_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public bool? Prototyped - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Prototyped); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Prototyped, value); - } - } - - public bool? Reference - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Reference); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Reference, value); - } - } - - public bool? RvalueReference - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.RvalueReference); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.RvalueReference, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIETemplateAlias : DwarfDIEDeclaration - { - public DwarfDIETemplateAlias() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_alias; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIETemplateTypeParameter : DwarfDIEDeclaration - { - public DwarfDIETemplateTypeParameter() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_type_parameter; - } - - public DwarfDIE DefaultValue - { - get - { - return GetAttributeValue(DwarfAttributeKind.DefaultValue); - } - set - { - SetAttributeValue(DwarfAttributeKind.DefaultValue, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIETemplateValueParameter : DwarfDIEDeclaration - { - public DwarfDIETemplateValueParameter() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_template_value_parameter; - } - - public DwarfConstant? ConstValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); - } - } - - public DwarfDIE DefaultValue - { - get - { - return GetAttributeValue(DwarfAttributeKind.DefaultValue); - } - set - { - SetAttributeValue(DwarfAttributeKind.DefaultValue, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEThrownType : DwarfDIEDeclaration - { - public DwarfDIEThrownType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_thrown_type; - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIETryBlock : DwarfDIEDeclaration - { - public DwarfDIETryBlock() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_try_block; - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - } - - public partial class DwarfDIETypedef : DwarfDIEDeclaration - { - public DwarfDIETypedef() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_typedef; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIETypeUnit : DwarfDIE - { - public DwarfDIETypeUnit() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_type_unit; - } - - public DwarfLanguageKind? Language - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Language); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Language, value); - } - } - - public DwarfLineProgramTable StmtList - { - get - { - return GetAttributeValue(DwarfAttributeKind.StmtList); - } - set - { - SetAttributeValue(DwarfAttributeKind.StmtList, value); - } - } - - public ulong? StrOffsetsBase - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.StrOffsetsBase, value); - } - } - - public bool? UseUTF8 - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.UseUTF8); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.UseUTF8, value); - } - } - } - - public partial class DwarfDIEUnionType : DwarfDIEDeclaration - { - public DwarfDIEUnionType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_union_type; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public DwarfConstant? Allocated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Allocated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Allocated, value); - } - } - - public DwarfConstant? Associated - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Associated); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Associated, value); - } - } - - public DwarfConstant? BitSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.BitSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.BitSize, value); - } - } - - public DwarfConstant? ByteSize - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ByteSize); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ByteSize, value); - } - } - - public DwarfCallingConvention? CallingConvention - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.CallingConvention); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.CallingConvention, value); - } - } - - public DwarfExpression DataLocation - { - get - { - return GetAttributeValue(DwarfAttributeKind.DataLocation); - } - set - { - SetAttributeValue(DwarfAttributeKind.DataLocation, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public bool? ExportSymbols - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ExportSymbols); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ExportSymbols, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Signature - { - get - { - return GetAttributeValue(DwarfAttributeKind.Signature); - } - set - { - SetAttributeValue(DwarfAttributeKind.Signature, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEUnspecifiedParameters : DwarfDIEDeclaration - { - public DwarfDIEUnspecifiedParameters() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_unspecified_parameters; - } - - public bool? Artificial - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Artificial); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); - } - } - } - - public partial class DwarfDIEUnspecifiedType : DwarfDIEDeclaration - { - public DwarfDIEUnspecifiedType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_unspecified_type; - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - } - - public partial class DwarfDIEVariable : DwarfDIEDeclaration - { - public DwarfDIEVariable() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_variable; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? Alignment - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Alignment); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Alignment, value); - } - } - - public bool? Artificial - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Artificial); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Artificial, value); - } - } - - public bool? ConstExpr - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.ConstExpr); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.ConstExpr, value); - } - } - - public DwarfConstant? ConstValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.ConstValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.ConstValue, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfConstant? Endianity - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.Endianity); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.Endianity, value); - } - } - - public bool? External - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.External); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.External, value); - } - } - - public string LinkageName - { - get - { - return GetAttributeValue(DwarfAttributeKind.LinkageName); - } - set - { - SetAttributeValue(DwarfAttributeKind.LinkageName, value); - } - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfDIE Specification - { - get - { - return GetAttributeValue(DwarfAttributeKind.Specification); - } - set - { - SetAttributeValue(DwarfAttributeKind.Specification, value); - } - } - - public DwarfConstant? StartScope - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.StartScope); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.StartScope, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - public partial class DwarfDIEVariant : DwarfDIEDeclaration - { - public DwarfDIEVariant() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_variant; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfDiscriminantListKind? DiscrList - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.DiscrList); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.DiscrList, value); - } - } - - public DwarfConstant? DiscrValue - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.DiscrValue); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.DiscrValue, value); - } - } - } - - public partial class DwarfDIEVariantPart : DwarfDIEDeclaration - { - public DwarfDIEVariantPart() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_variant_part; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public DwarfDIE Discr - { - get - { - return GetAttributeValue(DwarfAttributeKind.Discr); - } - set - { - SetAttributeValue(DwarfAttributeKind.Discr, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEVolatileType : DwarfDIEDeclaration - { - public DwarfDIEVolatileType() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_volatile_type; - } - - public string Name - { - get - { - return GetAttributeValue(DwarfAttributeKind.Name); - } - set - { - SetAttributeValue(DwarfAttributeKind.Name, value); - } - } - - public string Description - { - get - { - return GetAttributeValue(DwarfAttributeKind.Description); - } - set - { - SetAttributeValue(DwarfAttributeKind.Description, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - } - - public partial class DwarfDIEWithStmt : DwarfDIEDeclaration - { - public DwarfDIEWithStmt() - { - this.Tag = (DwarfTag)DwarfNative.DW_TAG_with_stmt; - } - - public DwarfAccessibility? Accessibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Accessibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Accessibility, value); - } - } - - public DwarfConstant? AddressClass - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.AddressClass); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.AddressClass, value); - } - } - - public bool? Declaration - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Declaration); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Declaration, value); - } - } - - public ulong? EntryPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.EntryPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.EntryPC, value); - } - } - - public DwarfConstant? HighPC - { - get - { - return GetAttributeConstantOpt(DwarfAttributeKind.HighPC); - } - set - { - SetAttributeConstantOpt(DwarfAttributeKind.HighPC, value); - } - } - - public DwarfLocation? Location - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Location); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Location, value); - } - } - - public ulong? LowPC - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.LowPC); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.LowPC, value); - } - } - - public ulong? Ranges - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Ranges); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Ranges, value); - } - } - - public DwarfLocation? Segment - { - get - { - return GetAttributeLocationOpt(DwarfAttributeKind.Segment); - } - set - { - SetAttributeLocationOpt(DwarfAttributeKind.Segment, value); - } - } - - public DwarfDIE Type - { - get - { - return GetAttributeValue(DwarfAttributeKind.Type); - } - set - { - SetAttributeValue(DwarfAttributeKind.Type, value); - } - } - - public DwarfVisibility? Visibility - { - get - { - return GetAttributeValueOpt(DwarfAttributeKind.Visibility); - } - set - { - SetAttributeValueOpt(DwarfAttributeKind.Visibility, value); - } - } - } - - internal static partial class DIEHelper - { - public static DwarfDIE ConvertTagToDwarfDIE(ushort tag) - { - switch (tag) - { - case DwarfNative.DW_TAG_access_declaration: - return new DwarfDIEAccessDeclaration(); - case DwarfNative.DW_TAG_array_type: - return new DwarfDIEArrayType(); - case DwarfNative.DW_TAG_atomic_type: - return new DwarfDIEAtomicType(); - case DwarfNative.DW_TAG_base_type: - return new DwarfDIEBaseType(); - case DwarfNative.DW_TAG_call_site: - return new DwarfDIECallSite(); - case DwarfNative.DW_TAG_call_site_parameter: - return new DwarfDIECallSiteParameter(); - case DwarfNative.DW_TAG_catch_block: - return new DwarfDIECatchBlock(); - case DwarfNative.DW_TAG_class_type: - return new DwarfDIEClassType(); - case DwarfNative.DW_TAG_coarray_type: - return new DwarfDIECoarrayType(); - case DwarfNative.DW_TAG_common_block: - return new DwarfDIECommonBlock(); - case DwarfNative.DW_TAG_common_inclusion: - return new DwarfDIECommonInclusion(); - case DwarfNative.DW_TAG_compile_unit: - return new DwarfDIECompileUnit(); - case DwarfNative.DW_TAG_condition: - return new DwarfDIECondition(); - case DwarfNative.DW_TAG_const_type: - return new DwarfDIEConstType(); - case DwarfNative.DW_TAG_constant: - return new DwarfDIEConstant(); - case DwarfNative.DW_TAG_dwarf_procedure: - return new DwarfDIEDwarfProcedure(); - case DwarfNative.DW_TAG_dynamic_type: - return new DwarfDIEDynamicType(); - case DwarfNative.DW_TAG_entry_point: - return new DwarfDIEEntryPoint(); - case DwarfNative.DW_TAG_enumeration_type: - return new DwarfDIEEnumerationType(); - case DwarfNative.DW_TAG_enumerator: - return new DwarfDIEEnumerator(); - case DwarfNative.DW_TAG_file_type: - return new DwarfDIEFileType(); - case DwarfNative.DW_TAG_formal_parameter: - return new DwarfDIEFormalParameter(); - case DwarfNative.DW_TAG_friend: - return new DwarfDIEFriend(); - case DwarfNative.DW_TAG_generic_subrange: - return new DwarfDIEGenericSubrange(); - case DwarfNative.DW_TAG_immutable_type: - return new DwarfDIEImmutableType(); - case DwarfNative.DW_TAG_imported_declaration: - return new DwarfDIEImportedDeclaration(); - case DwarfNative.DW_TAG_imported_module: - return new DwarfDIEImportedModule(); - case DwarfNative.DW_TAG_imported_unit: - return new DwarfDIEImportedUnit(); - case DwarfNative.DW_TAG_inheritance: - return new DwarfDIEInheritance(); - case DwarfNative.DW_TAG_inlined_subroutine: - return new DwarfDIEInlinedSubroutine(); - case DwarfNative.DW_TAG_interface_type: - return new DwarfDIEInterfaceType(); - case DwarfNative.DW_TAG_label: - return new DwarfDIELabel(); - case DwarfNative.DW_TAG_lexical_block: - return new DwarfDIELexicalBlock(); - case DwarfNative.DW_TAG_member: - return new DwarfDIEMember(); - case DwarfNative.DW_TAG_module: - return new DwarfDIEModule(); - case DwarfNative.DW_TAG_namelist: - return new DwarfDIENamelist(); - case DwarfNative.DW_TAG_namelist_item: - return new DwarfDIENamelistItem(); - case DwarfNative.DW_TAG_namespace: - return new DwarfDIENamespace(); - case DwarfNative.DW_TAG_packed_type: - return new DwarfDIEPackedType(); - case DwarfNative.DW_TAG_partial_unit: - return new DwarfDIEPartialUnit(); - case DwarfNative.DW_TAG_pointer_type: - return new DwarfDIEPointerType(); - case DwarfNative.DW_TAG_ptr_to_member_type: - return new DwarfDIEPtrToMemberType(); - case DwarfNative.DW_TAG_reference_type: - return new DwarfDIEReferenceType(); - case DwarfNative.DW_TAG_restrict_type: - return new DwarfDIERestrictType(); - case DwarfNative.DW_TAG_rvalue_reference_type: - return new DwarfDIERvalueReferenceType(); - case DwarfNative.DW_TAG_set_type: - return new DwarfDIESetType(); - case DwarfNative.DW_TAG_shared_type: - return new DwarfDIESharedType(); - case DwarfNative.DW_TAG_skeleton_unit: - return new DwarfDIESkeletonUnit(); - case DwarfNative.DW_TAG_string_type: - return new DwarfDIEStringType(); - case DwarfNative.DW_TAG_structure_type: - return new DwarfDIEStructureType(); - case DwarfNative.DW_TAG_subprogram: - return new DwarfDIESubprogram(); - case DwarfNative.DW_TAG_subrange_type: - return new DwarfDIESubrangeType(); - case DwarfNative.DW_TAG_subroutine_type: - return new DwarfDIESubroutineType(); - case DwarfNative.DW_TAG_template_alias: - return new DwarfDIETemplateAlias(); - case DwarfNative.DW_TAG_template_type_parameter: - return new DwarfDIETemplateTypeParameter(); - case DwarfNative.DW_TAG_template_value_parameter: - return new DwarfDIETemplateValueParameter(); - case DwarfNative.DW_TAG_thrown_type: - return new DwarfDIEThrownType(); - case DwarfNative.DW_TAG_try_block: - return new DwarfDIETryBlock(); - case DwarfNative.DW_TAG_typedef: - return new DwarfDIETypedef(); - case DwarfNative.DW_TAG_type_unit: - return new DwarfDIETypeUnit(); - case DwarfNative.DW_TAG_union_type: - return new DwarfDIEUnionType(); - case DwarfNative.DW_TAG_unspecified_parameters: - return new DwarfDIEUnspecifiedParameters(); - case DwarfNative.DW_TAG_unspecified_type: - return new DwarfDIEUnspecifiedType(); - case DwarfNative.DW_TAG_variable: - return new DwarfDIEVariable(); - case DwarfNative.DW_TAG_variant: - return new DwarfDIEVariant(); - case DwarfNative.DW_TAG_variant_part: - return new DwarfDIEVariantPart(); - case DwarfNative.DW_TAG_volatile_type: - return new DwarfDIEVolatileType(); - case DwarfNative.DW_TAG_with_stmt: - return new DwarfDIEWithStmt(); - } - return new DwarfDIE(); - } - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs deleted file mode 100644 index 983bda8854252d..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/LibObjectFile/generated/LibObjectFile.Elf.generated.cs +++ /dev/null @@ -1,14546 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ -using System; - -#pragma warning disable 1591 - -namespace LibObjectFile.Elf -{ - using System.Runtime.InteropServices; - - public static partial class ElfNative - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe partial struct Elf32_Ehdr - { - /// - /// Magic number and other info - /// - public fixed byte e_ident[16]; - - /// - /// Object file type - /// - public ElfNative.Elf32_Half e_type; - - /// - /// Architecture - /// - public ElfNative.Elf32_Half e_machine; - - /// - /// Object file version - /// - public ElfNative.Elf32_Word e_version; - - /// - /// Entry point virtual address - /// - public ElfNative.Elf32_Addr e_entry; - - /// - /// Program header table file offset - /// - public ElfNative.Elf32_Off e_phoff; - - /// - /// Section header table file offset - /// - public ElfNative.Elf32_Off e_shoff; - - /// - /// Processor-specific flags - /// - public ElfNative.Elf32_Word e_flags; - - /// - /// ELF header size in bytes - /// - public ElfNative.Elf32_Half e_ehsize; - - /// - /// Program header table entry size - /// - public ElfNative.Elf32_Half e_phentsize; - - /// - /// Program header table entry count - /// - public ElfNative.Elf32_Half e_phnum; - - /// - /// Section header table entry size - /// - public ElfNative.Elf32_Half e_shentsize; - - /// - /// Section header table entry count - /// - public ElfNative.Elf32_Half e_shnum; - - /// - /// Section header string table index - /// - public ElfNative.Elf32_Half e_shstrndx; - } - - /// - /// Type for a 16-bit quantity. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Half : IEquatable - { - public Elf32_Half(ushort value) => this.Value = value; - - public readonly ushort Value; - - public bool Equals(Elf32_Half other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Half other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ushort(Elf32_Half from) => from.Value; - - public static implicit operator Elf32_Half(ushort from) => new Elf32_Half(from); - - public static bool operator ==(Elf32_Half left, Elf32_Half right) => left.Equals(right); - - public static bool operator !=(Elf32_Half left, Elf32_Half right) => !left.Equals(right); - } - - /// - /// Types for signed and unsigned 32-bit quantities. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Word : IEquatable - { - public Elf32_Word(uint value) => this.Value = value; - - public readonly uint Value; - - public bool Equals(Elf32_Word other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Word other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator uint(Elf32_Word from) => from.Value; - - public static implicit operator Elf32_Word(uint from) => new Elf32_Word(from); - - public static bool operator ==(Elf32_Word left, Elf32_Word right) => left.Equals(right); - - public static bool operator !=(Elf32_Word left, Elf32_Word right) => !left.Equals(right); - } - - /// - /// Type of addresses. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Addr : IEquatable - { - public Elf32_Addr(uint value) => this.Value = value; - - public readonly uint Value; - - public bool Equals(Elf32_Addr other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Addr other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator uint(Elf32_Addr from) => from.Value; - - public static implicit operator Elf32_Addr(uint from) => new Elf32_Addr(from); - - public static bool operator ==(Elf32_Addr left, Elf32_Addr right) => left.Equals(right); - - public static bool operator !=(Elf32_Addr left, Elf32_Addr right) => !left.Equals(right); - } - - /// - /// Type of file offsets. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Off : IEquatable - { - public Elf32_Off(uint value) => this.Value = value; - - public readonly uint Value; - - public bool Equals(Elf32_Off other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Off other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator uint(Elf32_Off from) => from.Value; - - public static implicit operator Elf32_Off(uint from) => new Elf32_Off(from); - - public static bool operator ==(Elf32_Off left, Elf32_Off right) => left.Equals(right); - - public static bool operator !=(Elf32_Off left, Elf32_Off right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe partial struct Elf64_Ehdr - { - /// - /// Magic number and other info - /// - public fixed byte e_ident[16]; - - /// - /// Object file type - /// - public ElfNative.Elf64_Half e_type; - - /// - /// Architecture - /// - public ElfNative.Elf64_Half e_machine; - - /// - /// Object file version - /// - public ElfNative.Elf64_Word e_version; - - /// - /// Entry point virtual address - /// - public ElfNative.Elf64_Addr e_entry; - - /// - /// Program header table file offset - /// - public ElfNative.Elf64_Off e_phoff; - - /// - /// Section header table file offset - /// - public ElfNative.Elf64_Off e_shoff; - - /// - /// Processor-specific flags - /// - public ElfNative.Elf64_Word e_flags; - - /// - /// ELF header size in bytes - /// - public ElfNative.Elf64_Half e_ehsize; - - /// - /// Program header table entry size - /// - public ElfNative.Elf64_Half e_phentsize; - - /// - /// Program header table entry count - /// - public ElfNative.Elf64_Half e_phnum; - - /// - /// Section header table entry size - /// - public ElfNative.Elf64_Half e_shentsize; - - /// - /// Section header table entry count - /// - public ElfNative.Elf64_Half e_shnum; - - /// - /// Section header string table index - /// - public ElfNative.Elf64_Half e_shstrndx; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Half : IEquatable - { - public Elf64_Half(ushort value) => this.Value = value; - - public readonly ushort Value; - - public bool Equals(Elf64_Half other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Half other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ushort(Elf64_Half from) => from.Value; - - public static implicit operator Elf64_Half(ushort from) => new Elf64_Half(from); - - public static bool operator ==(Elf64_Half left, Elf64_Half right) => left.Equals(right); - - public static bool operator !=(Elf64_Half left, Elf64_Half right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Word : IEquatable - { - public Elf64_Word(uint value) => this.Value = value; - - public readonly uint Value; - - public bool Equals(Elf64_Word other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Word other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator uint(Elf64_Word from) => from.Value; - - public static implicit operator Elf64_Word(uint from) => new Elf64_Word(from); - - public static bool operator ==(Elf64_Word left, Elf64_Word right) => left.Equals(right); - - public static bool operator !=(Elf64_Word left, Elf64_Word right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Addr : IEquatable - { - public Elf64_Addr(ulong value) => this.Value = value; - - public readonly ulong Value; - - public bool Equals(Elf64_Addr other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Addr other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ulong(Elf64_Addr from) => from.Value; - - public static implicit operator Elf64_Addr(ulong from) => new Elf64_Addr(from); - - public static bool operator ==(Elf64_Addr left, Elf64_Addr right) => left.Equals(right); - - public static bool operator !=(Elf64_Addr left, Elf64_Addr right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Off : IEquatable - { - public Elf64_Off(ulong value) => this.Value = value; - - public readonly ulong Value; - - public bool Equals(Elf64_Off other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Off other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ulong(Elf64_Off from) => from.Value; - - public static implicit operator Elf64_Off(ulong from) => new Elf64_Off(from); - - public static bool operator ==(Elf64_Off left, Elf64_Off right) => left.Equals(right); - - public static bool operator !=(Elf64_Off left, Elf64_Off right) => !left.Equals(right); - } - - /// - /// Section header. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Shdr - { - /// - /// Section name (string tbl index) - /// - public ElfNative.Elf32_Word sh_name; - - /// - /// Section type - /// - public ElfNative.Elf32_Word sh_type; - - /// - /// Section flags - /// - public ElfNative.Elf32_Word sh_flags; - - /// - /// Section virtual addr at execution - /// - public ElfNative.Elf32_Addr sh_addr; - - /// - /// Section file offset - /// - public ElfNative.Elf32_Off sh_offset; - - /// - /// Section size in bytes - /// - public ElfNative.Elf32_Word sh_size; - - /// - /// Link to another section - /// - public ElfNative.Elf32_Word sh_link; - - /// - /// Additional section information - /// - public ElfNative.Elf32_Word sh_info; - - /// - /// Section alignment - /// - public ElfNative.Elf32_Word sh_addralign; - - /// - /// Entry size if section holds table - /// - public ElfNative.Elf32_Word sh_entsize; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Shdr - { - /// - /// Section name (string tbl index) - /// - public ElfNative.Elf64_Word sh_name; - - /// - /// Section type - /// - public ElfNative.Elf64_Word sh_type; - - /// - /// Section flags - /// - public ElfNative.Elf64_Xword sh_flags; - - /// - /// Section virtual addr at execution - /// - public ElfNative.Elf64_Addr sh_addr; - - /// - /// Section file offset - /// - public ElfNative.Elf64_Off sh_offset; - - /// - /// Section size in bytes - /// - public ElfNative.Elf64_Xword sh_size; - - /// - /// Link to another section - /// - public ElfNative.Elf64_Word sh_link; - - /// - /// Additional section information - /// - public ElfNative.Elf64_Word sh_info; - - /// - /// Section alignment - /// - public ElfNative.Elf64_Xword sh_addralign; - - /// - /// Entry size if section holds table - /// - public ElfNative.Elf64_Xword sh_entsize; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Xword : IEquatable - { - public Elf64_Xword(ulong value) => this.Value = value; - - public readonly ulong Value; - - public bool Equals(Elf64_Xword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Xword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ulong(Elf64_Xword from) => from.Value; - - public static implicit operator Elf64_Xword(ulong from) => new Elf64_Xword(from); - - public static bool operator ==(Elf64_Xword left, Elf64_Xword right) => left.Equals(right); - - public static bool operator !=(Elf64_Xword left, Elf64_Xword right) => !left.Equals(right); - } - - /// - /// Section compression header. Used when SHF_COMPRESSED is set. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Chdr - { - /// - /// Compression format. - /// - public ElfNative.Elf32_Word ch_type; - - /// - /// Uncompressed data size. - /// - public ElfNative.Elf32_Word ch_size; - - /// - /// Uncompressed data alignment. - /// - public ElfNative.Elf32_Word ch_addralign; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Chdr - { - /// - /// Compression format. - /// - public ElfNative.Elf64_Word ch_type; - - public ElfNative.Elf64_Word ch_reserved; - - /// - /// Uncompressed data size. - /// - public ElfNative.Elf64_Xword ch_size; - - /// - /// Uncompressed data alignment. - /// - public ElfNative.Elf64_Xword ch_addralign; - } - - /// - /// Symbol table entry. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Sym - { - /// - /// Symbol name (string tbl index) - /// - public ElfNative.Elf32_Word st_name; - - /// - /// Symbol value - /// - public ElfNative.Elf32_Addr st_value; - - /// - /// Symbol size - /// - public ElfNative.Elf32_Word st_size; - - /// - /// Symbol type and binding - /// - public byte st_info; - - /// - /// Symbol visibility - /// - public byte st_other; - - /// - /// Section index - /// - public ElfNative.Elf32_Section st_shndx; - } - - /// - /// Type for section indices, which are 16-bit quantities. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Section : IEquatable - { - public Elf32_Section(ushort value) => this.Value = value; - - public readonly ushort Value; - - public bool Equals(Elf32_Section other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Section other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ushort(Elf32_Section from) => from.Value; - - public static implicit operator Elf32_Section(ushort from) => new Elf32_Section(from); - - public static bool operator ==(Elf32_Section left, Elf32_Section right) => left.Equals(right); - - public static bool operator !=(Elf32_Section left, Elf32_Section right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Sym - { - /// - /// Symbol name (string tbl index) - /// - public ElfNative.Elf64_Word st_name; - - /// - /// Symbol type and binding - /// - public byte st_info; - - /// - /// Symbol visibility - /// - public byte st_other; - - /// - /// Section index - /// - public ElfNative.Elf64_Section st_shndx; - - /// - /// Symbol value - /// - public ElfNative.Elf64_Addr st_value; - - /// - /// Symbol size - /// - public ElfNative.Elf64_Xword st_size; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Section : IEquatable - { - public Elf64_Section(ushort value) => this.Value = value; - - public readonly ushort Value; - - public bool Equals(Elf64_Section other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Section other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ushort(Elf64_Section from) => from.Value; - - public static implicit operator Elf64_Section(ushort from) => new Elf64_Section(from); - - public static bool operator ==(Elf64_Section left, Elf64_Section right) => left.Equals(right); - - public static bool operator !=(Elf64_Section left, Elf64_Section right) => !left.Equals(right); - } - - /// - /// The syminfo section if available contains additional information about - /// every dynamic symbol. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Syminfo - { - /// - /// Direct bindings, symbol bound to - /// - public ElfNative.Elf32_Half si_boundto; - - /// - /// Per symbol flags - /// - public ElfNative.Elf32_Half si_flags; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Syminfo - { - /// - /// Direct bindings, symbol bound to - /// - public ElfNative.Elf64_Half si_boundto; - - /// - /// Per symbol flags - /// - public ElfNative.Elf64_Half si_flags; - } - - /// - /// Relocation table entry without addend (in section of type SHT_REL). - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Rel - { - /// - /// Address - /// - public ElfNative.Elf32_Addr r_offset; - - /// - /// Relocation type and symbol index - /// - public ElfNative.Elf32_Word r_info; - } - - /// - /// I have seen two different definitions of the Elf64_Rel and - /// Elf64_Rela structures, so we'll leave them out until Novell (or - /// whoever) gets their act together. - /// - /// - /// The following, at least, is used on Sparc v9, MIPS, and Alpha. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Rel - { - /// - /// Address - /// - public ElfNative.Elf64_Addr r_offset; - - /// - /// Relocation type and symbol index - /// - public ElfNative.Elf64_Xword r_info; - } - - /// - /// Relocation table entry with addend (in section of type SHT_RELA). - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Rela - { - /// - /// Address - /// - public ElfNative.Elf32_Addr r_offset; - - /// - /// Relocation type and symbol index - /// - public ElfNative.Elf32_Word r_info; - - /// - /// Addend - /// - public ElfNative.Elf32_Sword r_addend; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Sword : IEquatable - { - public Elf32_Sword(int value) => this.Value = value; - - public readonly int Value; - - public bool Equals(Elf32_Sword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Sword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator int(Elf32_Sword from) => from.Value; - - public static implicit operator Elf32_Sword(int from) => new Elf32_Sword(from); - - public static bool operator ==(Elf32_Sword left, Elf32_Sword right) => left.Equals(right); - - public static bool operator !=(Elf32_Sword left, Elf32_Sword right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Rela - { - /// - /// Address - /// - public ElfNative.Elf64_Addr r_offset; - - /// - /// Relocation type and symbol index - /// - public ElfNative.Elf64_Xword r_info; - - /// - /// Addend - /// - public ElfNative.Elf64_Sxword r_addend; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Sxword : IEquatable - { - public Elf64_Sxword(long value) => this.Value = value; - - public readonly long Value; - - public bool Equals(Elf64_Sxword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Sxword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator long(Elf64_Sxword from) => from.Value; - - public static implicit operator Elf64_Sxword(long from) => new Elf64_Sxword(from); - - public static bool operator ==(Elf64_Sxword left, Elf64_Sxword right) => left.Equals(right); - - public static bool operator !=(Elf64_Sxword left, Elf64_Sxword right) => !left.Equals(right); - } - - /// - /// Program segment header. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Phdr - { - /// - /// Segment type - /// - public ElfNative.Elf32_Word p_type; - - /// - /// Segment file offset - /// - public ElfNative.Elf32_Off p_offset; - - /// - /// Segment virtual address - /// - public ElfNative.Elf32_Addr p_vaddr; - - /// - /// Segment physical address - /// - public ElfNative.Elf32_Addr p_paddr; - - /// - /// Segment size in file - /// - public ElfNative.Elf32_Word p_filesz; - - /// - /// Segment size in memory - /// - public ElfNative.Elf32_Word p_memsz; - - /// - /// Segment flags - /// - public ElfNative.Elf32_Word p_flags; - - /// - /// Segment alignment - /// - public ElfNative.Elf32_Word p_align; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Phdr - { - /// - /// Segment type - /// - public ElfNative.Elf64_Word p_type; - - /// - /// Segment flags - /// - public ElfNative.Elf64_Word p_flags; - - /// - /// Segment file offset - /// - public ElfNative.Elf64_Off p_offset; - - /// - /// Segment virtual address - /// - public ElfNative.Elf64_Addr p_vaddr; - - /// - /// Segment physical address - /// - public ElfNative.Elf64_Addr p_paddr; - - /// - /// Segment size in file - /// - public ElfNative.Elf64_Xword p_filesz; - - /// - /// Segment size in memory - /// - public ElfNative.Elf64_Xword p_memsz; - - /// - /// Segment alignment - /// - public ElfNative.Elf64_Xword p_align; - } - - /// - /// Dynamic section entry. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Dyn - { - [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - public partial struct Elf32_Dyn_union_d_un - { - /// - /// Integer value - /// - [FieldOffset(0)] - public ElfNative.Elf32_Word d_val; - - /// - /// Address value - /// - [FieldOffset(0)] - public ElfNative.Elf32_Addr d_ptr; - } - - /// - /// Dynamic entry type - /// - public ElfNative.Elf32_Sword d_tag; - - public ElfNative.Elf32_Dyn.Elf32_Dyn_union_d_un d_un; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Dyn - { - [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - public partial struct Elf64_Dyn_union_d_un - { - /// - /// Integer value - /// - [FieldOffset(0)] - public ElfNative.Elf64_Xword d_val; - - /// - /// Address value - /// - [FieldOffset(0)] - public ElfNative.Elf64_Addr d_ptr; - } - - /// - /// Dynamic entry type - /// - public ElfNative.Elf64_Sxword d_tag; - - public ElfNative.Elf64_Dyn.Elf64_Dyn_union_d_un d_un; - } - - /// - /// Version definition sections. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Verdef - { - /// - /// Version revision - /// - public ElfNative.Elf32_Half vd_version; - - /// - /// Version information - /// - public ElfNative.Elf32_Half vd_flags; - - /// - /// Version Index - /// - public ElfNative.Elf32_Half vd_ndx; - - /// - /// Number of associated aux entries - /// - public ElfNative.Elf32_Half vd_cnt; - - /// - /// Version name hash value - /// - public ElfNative.Elf32_Word vd_hash; - - /// - /// Offset in bytes to verdaux array - /// - public ElfNative.Elf32_Word vd_aux; - - /// - /// Offset in bytes to next verdef - /// entry - /// - public ElfNative.Elf32_Word vd_next; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Verdef - { - /// - /// Version revision - /// - public ElfNative.Elf64_Half vd_version; - - /// - /// Version information - /// - public ElfNative.Elf64_Half vd_flags; - - /// - /// Version Index - /// - public ElfNative.Elf64_Half vd_ndx; - - /// - /// Number of associated aux entries - /// - public ElfNative.Elf64_Half vd_cnt; - - /// - /// Version name hash value - /// - public ElfNative.Elf64_Word vd_hash; - - /// - /// Offset in bytes to verdaux array - /// - public ElfNative.Elf64_Word vd_aux; - - /// - /// Offset in bytes to next verdef - /// entry - /// - public ElfNative.Elf64_Word vd_next; - } - - /// - /// Auxialiary version information. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Verdaux - { - /// - /// Version or dependency names - /// - public ElfNative.Elf32_Word vda_name; - - /// - /// Offset in bytes to next verdaux - /// entry - /// - public ElfNative.Elf32_Word vda_next; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Verdaux - { - /// - /// Version or dependency names - /// - public ElfNative.Elf64_Word vda_name; - - /// - /// Offset in bytes to next verdaux - /// entry - /// - public ElfNative.Elf64_Word vda_next; - } - - /// - /// Version dependency section. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Verneed - { - /// - /// Version of structure - /// - public ElfNative.Elf32_Half vn_version; - - /// - /// Number of associated aux entries - /// - public ElfNative.Elf32_Half vn_cnt; - - /// - /// Offset of filename for this - /// dependency - /// - public ElfNative.Elf32_Word vn_file; - - /// - /// Offset in bytes to vernaux array - /// - public ElfNative.Elf32_Word vn_aux; - - /// - /// Offset in bytes to next verneed - /// entry - /// - public ElfNative.Elf32_Word vn_next; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Verneed - { - /// - /// Version of structure - /// - public ElfNative.Elf64_Half vn_version; - - /// - /// Number of associated aux entries - /// - public ElfNative.Elf64_Half vn_cnt; - - /// - /// Offset of filename for this - /// dependency - /// - public ElfNative.Elf64_Word vn_file; - - /// - /// Offset in bytes to vernaux array - /// - public ElfNative.Elf64_Word vn_aux; - - /// - /// Offset in bytes to next verneed - /// entry - /// - public ElfNative.Elf64_Word vn_next; - } - - /// - /// Auxiliary needed version information. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Vernaux - { - /// - /// Hash value of dependency name - /// - public ElfNative.Elf32_Word vna_hash; - - /// - /// Dependency specific information - /// - public ElfNative.Elf32_Half vna_flags; - - /// - /// Unused - /// - public ElfNative.Elf32_Half vna_other; - - /// - /// Dependency name string offset - /// - public ElfNative.Elf32_Word vna_name; - - /// - /// Offset in bytes to next vernaux - /// entry - /// - public ElfNative.Elf32_Word vna_next; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Vernaux - { - /// - /// Hash value of dependency name - /// - public ElfNative.Elf64_Word vna_hash; - - /// - /// Dependency specific information - /// - public ElfNative.Elf64_Half vna_flags; - - /// - /// Unused - /// - public ElfNative.Elf64_Half vna_other; - - /// - /// Dependency name string offset - /// - public ElfNative.Elf64_Word vna_name; - - /// - /// Offset in bytes to next vernaux - /// entry - /// - public ElfNative.Elf64_Word vna_next; - } - - /// - /// This vector is normally only used by the program interpreter. The - /// usual definition in an ABI supplement uses the name auxv_t. The - /// vector is not usually defined in a standard - /// <elf - /// .h> file, but it - /// can't hurt. We rename it to avoid conflicts. The sizes of these - /// types are an arrangement between the exec server and the program - /// interpreter, so we don't fully specify them here. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_auxv_t - { - [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - public partial struct Elf32_auxv_t_union_a_un - { - /// - /// Integer value - /// - [FieldOffset(0)] - public uint a_val; - } - - /// - /// Entry type - /// - public uint a_type; - - public ElfNative.Elf32_auxv_t.Elf32_auxv_t_union_a_un a_un; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_auxv_t - { - [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - public partial struct Elf64_auxv_t_union_a_un - { - /// - /// Integer value - /// - [FieldOffset(0)] - public ulong a_val; - } - - /// - /// Entry type - /// - public ulong a_type; - - public ElfNative.Elf64_auxv_t.Elf64_auxv_t_union_a_un a_un; - } - - /// - /// Note section contents. Each entry in the note section begins with - /// a header of a fixed form. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Nhdr - { - /// - /// Length of the note's name. - /// - public ElfNative.Elf32_Word n_namesz; - - /// - /// Length of the note's descriptor. - /// - public ElfNative.Elf32_Word n_descsz; - - /// - /// Type of the note. - /// - public ElfNative.Elf32_Word n_type; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Nhdr - { - /// - /// Length of the note's name. - /// - public ElfNative.Elf64_Word n_namesz; - - /// - /// Length of the note's descriptor. - /// - public ElfNative.Elf64_Word n_descsz; - - /// - /// Type of the note. - /// - public ElfNative.Elf64_Word n_type; - } - - /// - /// Move records. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Move - { - /// - /// Symbol value. - /// - public ElfNative.Elf32_Xword m_value; - - /// - /// Size and index. - /// - public ElfNative.Elf32_Word m_info; - - /// - /// Symbol offset. - /// - public ElfNative.Elf32_Word m_poffset; - - /// - /// Repeat count. - /// - public ElfNative.Elf32_Half m_repeat; - - /// - /// Stride info. - /// - public ElfNative.Elf32_Half m_stride; - } - - /// - /// Types for signed and unsigned 64-bit quantities. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Xword : IEquatable - { - public Elf32_Xword(ulong value) => this.Value = value; - - public readonly ulong Value; - - public bool Equals(Elf32_Xword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Xword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ulong(Elf32_Xword from) => from.Value; - - public static implicit operator Elf32_Xword(ulong from) => new Elf32_Xword(from); - - public static bool operator ==(Elf32_Xword left, Elf32_Xword right) => left.Equals(right); - - public static bool operator !=(Elf32_Xword left, Elf32_Xword right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Move - { - /// - /// Symbol value. - /// - public ElfNative.Elf64_Xword m_value; - - /// - /// Size and index. - /// - public ElfNative.Elf64_Xword m_info; - - /// - /// Symbol offset. - /// - public ElfNative.Elf64_Xword m_poffset; - - /// - /// Repeat count. - /// - public ElfNative.Elf64_Half m_repeat; - - /// - /// Stride info. - /// - public ElfNative.Elf64_Half m_stride; - } - - /// - /// Entries found in sections of type SHT_MIPS_GPTAB. - /// - [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi)] - public partial struct Elf32_gptab - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_gptab_gt_header - { - /// - /// -G value used for compilation. - /// - public ElfNative.Elf32_Word gt_current_g_value; - - /// - /// Not used. - /// - public ElfNative.Elf32_Word gt_unused; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_gptab_gt_entry - { - /// - /// If this value were used for -G. - /// - public ElfNative.Elf32_Word gt_g_value; - - /// - /// This many bytes would be used. - /// - public ElfNative.Elf32_Word gt_bytes; - } - - /// - /// First entry in section. - /// - [FieldOffset(0)] - public ElfNative.Elf32_gptab.Elf32_gptab_gt_header gt_header; - - /// - /// Subsequent entries in section. - /// - [FieldOffset(0)] - public ElfNative.Elf32_gptab.Elf32_gptab_gt_entry gt_entry; - } - - /// - /// Entry found in sections of type SHT_MIPS_REGINFO. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public unsafe partial struct Elf32_RegInfo - { - /// - /// General registers used. - /// - public ElfNative.Elf32_Word ri_gprmask; - - /// - /// Coprocessor registers used. - /// - public fixed uint ri_cprmask[4]; - - /// - /// $gp register value. - /// - public ElfNative.Elf32_Sword ri_gp_value; - } - - /// - /// Entries found in sections of type SHT_MIPS_OPTIONS. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf_Options - { - /// - /// Determines interpretation of the - /// variable part of descriptor. - /// - public byte kind; - - /// - /// Size of descriptor, including header. - /// - public byte size; - - /// - /// Section header index of section affected, - /// 0 for global options. - /// - public ElfNative.Elf32_Section section; - - /// - /// Kind-specific information. - /// - public ElfNative.Elf32_Word info; - } - - /// - /// Entry found in `.options' section. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf_Options_Hw - { - /// - /// Extra flags. - /// - public ElfNative.Elf32_Word hwp_flags1; - - /// - /// Extra flags. - /// - public ElfNative.Elf32_Word hwp_flags2; - } - - /// - /// Entries found in sections of type SHT_MIPS_LIBLIST. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf32_Lib - { - /// - /// Name (string table index) - /// - public ElfNative.Elf32_Word l_name; - - /// - /// Timestamp - /// - public ElfNative.Elf32_Word l_time_stamp; - - /// - /// Checksum - /// - public ElfNative.Elf32_Word l_checksum; - - /// - /// Interface version - /// - public ElfNative.Elf32_Word l_version; - - /// - /// Flags - /// - public ElfNative.Elf32_Word l_flags; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf64_Lib - { - /// - /// Name (string table index) - /// - public ElfNative.Elf64_Word l_name; - - /// - /// Timestamp - /// - public ElfNative.Elf64_Word l_time_stamp; - - /// - /// Checksum - /// - public ElfNative.Elf64_Word l_checksum; - - /// - /// Interface version - /// - public ElfNative.Elf64_Word l_version; - - /// - /// Flags - /// - public ElfNative.Elf64_Word l_flags; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public partial struct Elf_MIPS_ABIFlags_v0 - { - /// - /// Version of flags structure. - /// - public ElfNative.Elf32_Half version; - - /// - /// The level of the ISA: 1-5, 32, 64. - /// - public byte isa_level; - - /// - /// The revision of ISA: 0 for MIPS V and below, 1-n otherwise. - /// - public byte isa_rev; - - /// - /// The size of general purpose registers. - /// - public byte gpr_size; - - /// - /// The size of co-processor 1 registers. - /// - public byte cpr1_size; - - /// - /// The size of co-processor 2 registers. - /// - public byte cpr2_size; - - /// - /// The floating-point ABI. - /// - public byte fp_abi; - - /// - /// Processor-specific extension. - /// - public ElfNative.Elf32_Word isa_ext; - - /// - /// Mask of ASEs used. - /// - public ElfNative.Elf32_Word ases; - - /// - /// Mask of general flags. - /// - public ElfNative.Elf32_Word flags1; - - public ElfNative.Elf32_Word flags2; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Sword : IEquatable - { - public Elf64_Sword(int value) => this.Value = value; - - public readonly int Value; - - public bool Equals(Elf64_Sword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Sword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator int(Elf64_Sword from) => from.Value; - - public static implicit operator Elf64_Sword(int from) => new Elf64_Sword(from); - - public static bool operator ==(Elf64_Sword left, Elf64_Sword right) => left.Equals(right); - - public static bool operator !=(Elf64_Sword left, Elf64_Sword right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Sxword : IEquatable - { - public Elf32_Sxword(long value) => this.Value = value; - - public readonly long Value; - - public bool Equals(Elf32_Sxword other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Sxword other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator long(Elf32_Sxword from) => from.Value; - - public static implicit operator Elf32_Sxword(long from) => new Elf32_Sxword(from); - - public static bool operator ==(Elf32_Sxword left, Elf32_Sxword right) => left.Equals(right); - - public static bool operator !=(Elf32_Sxword left, Elf32_Sxword right) => !left.Equals(right); - } - - /// - /// Type for version symbol information. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Versym : IEquatable - { - public Elf32_Versym(ElfNative.Elf32_Half value) => this.Value = value; - - public readonly ElfNative.Elf32_Half Value; - - public bool Equals(Elf32_Versym other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Versym other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ElfNative.Elf32_Half(Elf32_Versym from) => from.Value; - - public static implicit operator Elf32_Versym(ElfNative.Elf32_Half from) => new Elf32_Versym(from); - - public static bool operator ==(Elf32_Versym left, Elf32_Versym right) => left.Equals(right); - - public static bool operator !=(Elf32_Versym left, Elf32_Versym right) => !left.Equals(right); - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf64_Versym : IEquatable - { - public Elf64_Versym(ElfNative.Elf64_Half value) => this.Value = value; - - public readonly ElfNative.Elf64_Half Value; - - public bool Equals(Elf64_Versym other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf64_Versym other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ElfNative.Elf64_Half(Elf64_Versym from) => from.Value; - - public static implicit operator Elf64_Versym(ElfNative.Elf64_Half from) => new Elf64_Versym(from); - - public static bool operator ==(Elf64_Versym left, Elf64_Versym right) => left.Equals(right); - - public static bool operator !=(Elf64_Versym left, Elf64_Versym right) => !left.Equals(right); - } - - /// - /// Entries found in sections of type SHT_MIPS_CONFLICT. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public readonly partial struct Elf32_Conflict : IEquatable - { - public Elf32_Conflict(ElfNative.Elf32_Addr value) => this.Value = value; - - public readonly ElfNative.Elf32_Addr Value; - - public bool Equals(Elf32_Conflict other) => Value.Equals(other.Value); - - public override bool Equals(object obj) => obj is Elf32_Conflict other && Equals(other); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public static implicit operator ElfNative.Elf32_Addr(Elf32_Conflict from) => from.Value; - - public static implicit operator Elf32_Conflict(ElfNative.Elf32_Addr from) => new Elf32_Conflict(from); - - public static bool operator ==(Elf32_Conflict left, Elf32_Conflict right) => left.Equals(right); - - public static bool operator !=(Elf32_Conflict left, Elf32_Conflict right) => !left.Equals(right); - } - - public const byte EI_NIDENT = 16; - - /// - /// File identification byte 0 index - /// - public const byte EI_MAG0 = 0; - - /// - /// Magic number byte 0 - /// - public const byte ELFMAG0 = 127; - - /// - /// File identification byte 1 index - /// - public const byte EI_MAG1 = 1; - - /// - /// Magic number byte 1 - /// - public const byte ELFMAG1 = 69; - - /// - /// File identification byte 2 index - /// - public const byte EI_MAG2 = 2; - - /// - /// Magic number byte 2 - /// - public const byte ELFMAG2 = 76; - - /// - /// File identification byte 3 index - /// - public const byte EI_MAG3 = 3; - - /// - /// Magic number byte 3 - /// - public const byte ELFMAG3 = 70; - - /// - /// File class byte index - /// - public const byte EI_CLASS = 4; - - /// - /// Invalid class - /// - public const byte ELFCLASSNONE = 0; - - /// - /// 32-bit objects - /// - public const byte ELFCLASS32 = 1; - - /// - /// 64-bit objects - /// - public const byte ELFCLASS64 = 2; - - public const byte ELFCLASSNUM = 3; - - /// - /// Data encoding byte index - /// - public const byte EI_DATA = 5; - - /// - /// Invalid data encoding - /// - public const byte ELFDATANONE = 0; - - /// - /// 2's complement, little endian - /// - public const byte ELFDATA2LSB = 1; - - /// - /// 2's complement, big endian - /// - public const byte ELFDATA2MSB = 2; - - public const byte ELFDATANUM = 3; - - /// - /// File version byte index - /// - public const byte EI_VERSION = 6; - - /// - /// OS ABI identification - /// - public const byte EI_OSABI = 7; - - /// - /// UNIX System V ABI - /// - public const byte ELFOSABI_NONE = 0; - - /// - /// UNIX System V ABI - /// - public const byte ELFOSABI_SYSV = 0; - - /// - /// HP-UX - /// - public const byte ELFOSABI_HPUX = 1; - - /// - /// NetBSD. - /// - public const byte ELFOSABI_NETBSD = 2; - - /// - /// Object uses GNU ELF extensions. - /// - public const byte ELFOSABI_GNU = 3; - - /// - /// Object uses GNU ELF extensions. - /// - public const byte ELFOSABI_LINUX = 3; - - /// - /// Sun Solaris. - /// - public const byte ELFOSABI_SOLARIS = 6; - - /// - /// IBM AIX. - /// - public const byte ELFOSABI_AIX = 7; - - /// - /// SGI Irix. - /// - public const byte ELFOSABI_IRIX = 8; - - /// - /// FreeBSD. - /// - public const byte ELFOSABI_FREEBSD = 9; - - /// - /// Compaq TRU64 UNIX. - /// - public const byte ELFOSABI_TRU64 = 10; - - /// - /// Novell Modesto. - /// - public const byte ELFOSABI_MODESTO = 11; - - /// - /// OpenBSD. - /// - public const byte ELFOSABI_OPENBSD = 12; - - /// - /// ARM EABI - /// - public const byte ELFOSABI_ARM_AEABI = 64; - - /// - /// ARM - /// - public const byte ELFOSABI_ARM = 97; - - /// - /// Standalone (embedded) application - /// - public const byte ELFOSABI_STANDALONE = 255; - - /// - /// ABI version - /// - public const byte EI_ABIVERSION = 8; - - /// - /// Byte index of padding bytes - /// - public const byte EI_PAD = 9; - - /// - /// No file type - /// - public const ushort ET_NONE = 0; - - /// - /// Relocatable file - /// - public const ushort ET_REL = 1; - - /// - /// Executable file - /// - public const ushort ET_EXEC = 2; - - /// - /// Shared object file - /// - public const ushort ET_DYN = 3; - - /// - /// Core file - /// - public const ushort ET_CORE = 4; - - /// - /// Number of defined types - /// - public const ushort ET_NUM = 5; - - /// - /// OS-specific range start - /// - public const ushort ET_LOOS = 65024; - - /// - /// OS-specific range end - /// - public const ushort ET_HIOS = 65279; - - /// - /// Processor-specific range start - /// - public const ushort ET_LOPROC = 65280; - - /// - /// Processor-specific range end - /// - public const ushort ET_HIPROC = 65535; - - /// - /// No machine - /// - public const ushort EM_NONE = 0; - - /// - /// AT - /// &T - /// WE 32100 - /// - public const ushort EM_M32 = 1; - - /// - /// SUN SPARC - /// - public const ushort EM_SPARC = 2; - - /// - /// Intel 80386 - /// - public const ushort EM_386 = 3; - - /// - /// Motorola m68k family - /// - public const ushort EM_68K = 4; - - /// - /// Motorola m88k family - /// - public const ushort EM_88K = 5; - - /// - /// Intel 80860 - /// - public const ushort EM_860 = 7; - - /// - /// MIPS R3000 big-endian - /// - public const ushort EM_MIPS = 8; - - /// - /// IBM System/370 - /// - public const ushort EM_S370 = 9; - - /// - /// MIPS R3000 little-endian - /// - public const ushort EM_MIPS_RS3_LE = 10; - - /// - /// HPPA - /// - public const ushort EM_PARISC = 15; - - /// - /// Fujitsu VPP500 - /// - public const ushort EM_VPP500 = 17; - - /// - /// Sun's "v8plus" - /// - public const ushort EM_SPARC32PLUS = 18; - - /// - /// Intel 80960 - /// - public const ushort EM_960 = 19; - - /// - /// PowerPC - /// - public const ushort EM_PPC = 20; - - /// - /// PowerPC 64-bit - /// - public const ushort EM_PPC64 = 21; - - /// - /// IBM S390 - /// - public const ushort EM_S390 = 22; - - /// - /// NEC V800 series - /// - public const ushort EM_V800 = 36; - - /// - /// Fujitsu FR20 - /// - public const ushort EM_FR20 = 37; - - /// - /// TRW RH-32 - /// - public const ushort EM_RH32 = 38; - - /// - /// Motorola RCE - /// - public const ushort EM_RCE = 39; - - /// - /// ARM - /// - public const ushort EM_ARM = 40; - - /// - /// Digital Alpha - /// - public const ushort EM_FAKE_ALPHA = 41; - - /// - /// Hitachi SH - /// - public const ushort EM_SH = 42; - - /// - /// SPARC v9 64-bit - /// - public const ushort EM_SPARCV9 = 43; - - /// - /// Siemens Tricore - /// - public const ushort EM_TRICORE = 44; - - /// - /// Argonaut RISC Core - /// - public const ushort EM_ARC = 45; - - /// - /// Hitachi H8/300 - /// - public const ushort EM_H8_300 = 46; - - /// - /// Hitachi H8/300H - /// - public const ushort EM_H8_300H = 47; - - /// - /// Hitachi H8S - /// - public const ushort EM_H8S = 48; - - /// - /// Hitachi H8/500 - /// - public const ushort EM_H8_500 = 49; - - /// - /// Intel Merced - /// - public const ushort EM_IA_64 = 50; - - /// - /// Stanford MIPS-X - /// - public const ushort EM_MIPS_X = 51; - - /// - /// Motorola Coldfire - /// - public const ushort EM_COLDFIRE = 52; - - /// - /// Motorola M68HC12 - /// - public const ushort EM_68HC12 = 53; - - /// - /// Fujitsu MMA Multimedia Accelerator - /// - public const ushort EM_MMA = 54; - - /// - /// Siemens PCP - /// - public const ushort EM_PCP = 55; - - /// - /// Sony nCPU embeeded RISC - /// - public const ushort EM_NCPU = 56; - - /// - /// Denso NDR1 microprocessor - /// - public const ushort EM_NDR1 = 57; - - /// - /// Motorola Start*Core processor - /// - public const ushort EM_STARCORE = 58; - - /// - /// Toyota ME16 processor - /// - public const ushort EM_ME16 = 59; - - /// - /// STMicroelectronic ST100 processor - /// - public const ushort EM_ST100 = 60; - - /// - /// Advanced Logic Corp. Tinyj emb.fam - /// - public const ushort EM_TINYJ = 61; - - /// - /// AMD x86-64 architecture - /// - public const ushort EM_X86_64 = 62; - - /// - /// Sony DSP Processor - /// - public const ushort EM_PDSP = 63; - - /// - /// Siemens FX66 microcontroller - /// - public const ushort EM_FX66 = 66; - - /// - /// STMicroelectronics ST9+ 8/16 mc - /// - public const ushort EM_ST9PLUS = 67; - - /// - /// STmicroelectronics ST7 8 bit mc - /// - public const ushort EM_ST7 = 68; - - /// - /// Motorola MC68HC16 microcontroller - /// - public const ushort EM_68HC16 = 69; - - /// - /// Motorola MC68HC11 microcontroller - /// - public const ushort EM_68HC11 = 70; - - /// - /// Motorola MC68HC08 microcontroller - /// - public const ushort EM_68HC08 = 71; - - /// - /// Motorola MC68HC05 microcontroller - /// - public const ushort EM_68HC05 = 72; - - /// - /// Silicon Graphics SVx - /// - public const ushort EM_SVX = 73; - - /// - /// STMicroelectronics ST19 8 bit mc - /// - public const ushort EM_ST19 = 74; - - /// - /// Digital VAX - /// - public const ushort EM_VAX = 75; - - /// - /// Axis Communications 32-bit embedded processor - /// - public const ushort EM_CRIS = 76; - - /// - /// Infineon Technologies 32-bit embedded processor - /// - public const ushort EM_JAVELIN = 77; - - /// - /// Element 14 64-bit DSP Processor - /// - public const ushort EM_FIREPATH = 78; - - /// - /// LSI Logic 16-bit DSP Processor - /// - public const ushort EM_ZSP = 79; - - /// - /// Donald Knuth's educational 64-bit processor - /// - public const ushort EM_MMIX = 80; - - /// - /// Harvard University machine-independent object files - /// - public const ushort EM_HUANY = 81; - - /// - /// SiTera Prism - /// - public const ushort EM_PRISM = 82; - - /// - /// Atmel AVR 8-bit microcontroller - /// - public const ushort EM_AVR = 83; - - /// - /// Fujitsu FR30 - /// - public const ushort EM_FR30 = 84; - - /// - /// Mitsubishi D10V - /// - public const ushort EM_D10V = 85; - - /// - /// Mitsubishi D30V - /// - public const ushort EM_D30V = 86; - - /// - /// NEC v850 - /// - public const ushort EM_V850 = 87; - - /// - /// Mitsubishi M32R - /// - public const ushort EM_M32R = 88; - - /// - /// Matsushita MN10300 - /// - public const ushort EM_MN10300 = 89; - - /// - /// Matsushita MN10200 - /// - public const ushort EM_MN10200 = 90; - - /// - /// picoJava - /// - public const ushort EM_PJ = 91; - - /// - /// OpenRISC 32-bit embedded processor - /// - public const ushort EM_OPENRISC = 92; - - /// - /// ARC Cores Tangent-A5 - /// - public const ushort EM_ARC_A5 = 93; - - /// - /// Tensilica Xtensa Architecture - /// - public const ushort EM_XTENSA = 94; - - /// - /// Altera Nios II - /// - public const ushort EM_ALTERA_NIOS2 = 113; - - /// - /// ARM AARCH64 - /// - public const ushort EM_AARCH64 = 183; - - /// - /// Tilera TILEPro - /// - public const ushort EM_TILEPRO = 188; - - /// - /// Xilinx MicroBlaze - /// - public const ushort EM_MICROBLAZE = 189; - - /// - /// Tilera TILE-Gx - /// - public const ushort EM_TILEGX = 191; - - public const ushort EM_NUM = 192; - - public const ushort EM_ALPHA = 36902; - - /// - /// Invalid ELF version - /// - public const byte EV_NONE = 0; - - /// - /// Current version - /// - public const byte EV_CURRENT = 1; - - public const byte EV_NUM = 2; - - /// - /// Undefined section - /// - public const uint SHN_UNDEF = 0; - - /// - /// Start of reserved indices *k/ - /// #define SHN_LOPROC 0xff00 /* Start of processor-specific - /// - public const uint SHN_LORESERVE = 65280; - - /// - /// Order section before all others (Solaris). - /// - public const uint SHN_BEFORE = 65280; - - /// - /// Order section after all others (Solaris). - /// - public const uint SHN_AFTER = 65281; - - /// - /// End of processor-specific - /// - public const uint SHN_HIPROC = 65311; - - /// - /// Start of OS-specific - /// - public const uint SHN_LOOS = 65312; - - /// - /// End of OS-specific - /// - public const uint SHN_HIOS = 65343; - - /// - /// Associated symbol is absolute - /// - public const uint SHN_ABS = 65521; - - /// - /// Associated symbol is common - /// - public const uint SHN_COMMON = 65522; - - /// - /// Index is in extra table. - /// - public const uint SHN_XINDEX = 65535; - - /// - /// End of reserved indices - /// - public const uint SHN_HIRESERVE = 65535; - - /// - /// Section header table entry unused - /// - public const uint SHT_NULL = 0; - - /// - /// Program data - /// - public const uint SHT_PROGBITS = 1; - - /// - /// Symbol table - /// - public const uint SHT_SYMTAB = 2; - - /// - /// String table - /// - public const uint SHT_STRTAB = 3; - - /// - /// Relocation entries with addends - /// - public const uint SHT_RELA = 4; - - /// - /// Symbol hash table - /// - public const uint SHT_HASH = 5; - - /// - /// Dynamic linking information - /// - public const uint SHT_DYNAMIC = 6; - - /// - /// Notes - /// - public const uint SHT_NOTE = 7; - - /// - /// Program space with no data (bss) - /// - public const uint SHT_NOBITS = 8; - - /// - /// Relocation entries, no addends - /// - public const uint SHT_REL = 9; - - /// - /// Reserved - /// - public const uint SHT_SHLIB = 10; - - /// - /// Dynamic linker symbol table - /// - public const uint SHT_DYNSYM = 11; - - /// - /// Array of constructors - /// - public const uint SHT_INIT_ARRAY = 14; - - /// - /// Array of destructors - /// - public const uint SHT_FINI_ARRAY = 15; - - /// - /// Array of pre-constructors - /// - public const uint SHT_PREINIT_ARRAY = 16; - - /// - /// Section group - /// - public const uint SHT_GROUP = 17; - - /// - /// Extended section indeces - /// - public const uint SHT_SYMTAB_SHNDX = 18; - - /// - /// Number of defined types. - /// - public const uint SHT_NUM = 19; - - /// - /// Start OS-specific. - /// - public const uint SHT_LOOS = 1610612736; - - /// - /// Object attributes. - /// - public const uint SHT_GNU_ATTRIBUTES = 1879048181; - - /// - /// GNU-style hash table. - /// - public const uint SHT_GNU_HASH = 1879048182; - - /// - /// Prelink library list - /// - public const uint SHT_GNU_LIBLIST = 1879048183; - - /// - /// Checksum for DSO content. - /// - public const uint SHT_CHECKSUM = 1879048184; - - /// - /// Sun-specific low bound. - /// - public const uint SHT_LOSUNW = 1879048186; - - public const uint SHT_SUNW_move = 1879048186; - - public const uint SHT_SUNW_COMDAT = 1879048187; - - public const uint SHT_SUNW_syminfo = 1879048188; - - /// - /// Version definition section. - /// - public const uint SHT_GNU_verdef = 1879048189; - - /// - /// Version needs section. - /// - public const uint SHT_GNU_verneed = 1879048190; - - /// - /// Version symbol table. - /// - public const uint SHT_GNU_versym = 1879048191; - - /// - /// Sun-specific high bound. - /// - public const uint SHT_HISUNW = 1879048191; - - /// - /// End OS-specific type - /// - public const uint SHT_HIOS = 1879048191; - - /// - /// Start of processor-specific - /// - public const uint SHT_LOPROC = 1879048192; - - /// - /// End of processor-specific - /// - public const uint SHT_HIPROC = 2147483647; - - /// - /// Start of application-specific - /// - public const uint SHT_LOUSER = 0x80000000; - - /// - /// End of application-specific - /// - public const uint SHT_HIUSER = 0x8fffffff; - - /// - /// Writable - /// - public const uint SHF_WRITE = 1; - - /// - /// Occupies memory during execution - /// - public const uint SHF_ALLOC = 2; - - /// - /// Executable - /// - public const uint SHF_EXECINSTR = 4; - - /// - /// Might be merged - /// - public const uint SHF_MERGE = 16; - - /// - /// Contains nul-terminated strings - /// - public const uint SHF_STRINGS = 32; - - /// - /// `sh_info' contains SHT index - /// - public const uint SHF_INFO_LINK = 64; - - /// - /// Preserve order after combining - /// - public const uint SHF_LINK_ORDER = 128; - - /// - /// Non-standard OS specific handling required - /// - public const uint SHF_OS_NONCONFORMING = 256; - - /// - /// Section is member of a group. - /// - public const uint SHF_GROUP = 512; - - /// - /// Section hold thread-local data. - /// - public const uint SHF_TLS = 1024; - - /// - /// Section with compressed data. - /// - public const uint SHF_COMPRESSED = 2048; - - /// - /// OS-specific. - /// - public const uint SHF_MASKOS = 267386880; - - /// - /// Processor-specific - /// - public const uint SHF_MASKPROC = 0xf0000000; - - /// - /// Special ordering requirement (Solaris). - /// - public const uint SHF_ORDERED = 1073741824; - - /// - /// Section is excluded unless referenced or allocated (Solaris). - /// - public const uint SHF_EXCLUDE = (1U << 31); - - /// - /// ZLIB/DEFLATE algorithm. - /// - public const int ELFCOMPRESS_ZLIB = 1; - - /// - /// Start of OS-specific. - /// - public const int ELFCOMPRESS_LOOS = 0x60000000; - - /// - /// End of OS-specific. - /// - public const int ELFCOMPRESS_HIOS = 0x6fffffff; - - /// - /// Start of processor-specific. - /// - public const int ELFCOMPRESS_LOPROC = 0x70000000; - - /// - /// End of processor-specific. - /// - public const int ELFCOMPRESS_HIPROC = 0x7fffffff; - - /// - /// Symbol bound to self - /// - public const ushort SYMINFO_BT_SELF = 65535; - - /// - /// Symbol bound to parent - /// - public const ushort SYMINFO_BT_PARENT = 65534; - - /// - /// Beginning of reserved entries - /// - public const ushort SYMINFO_BT_LOWRESERVE = 65280; - - /// - /// Direct bound symbol - /// - public const ushort SYMINFO_FLG_DIRECT = 1; - - /// - /// Pass-thru symbol for translator - /// - public const ushort SYMINFO_FLG_PASSTHRU = 2; - - /// - /// Symbol is a copy-reloc - /// - public const ushort SYMINFO_FLG_COPY = 4; - - /// - /// Symbol bound to object to be lazy loaded - /// - public const ushort SYMINFO_FLG_LAZYLOAD = 8; - - public const ushort SYMINFO_NONE = 0; - - public const ushort SYMINFO_CURRENT = 1; - - public const ushort SYMINFO_NUM = 2; - - /// - /// Local symbol - /// - public const byte STB_LOCAL = 0; - - /// - /// Global symbol - /// - public const byte STB_GLOBAL = 1; - - /// - /// Weak symbol - /// - public const byte STB_WEAK = 2; - - /// - /// Number of defined types. - /// - public const byte STB_NUM = 3; - - /// - /// Start of OS-specific - /// - public const byte STB_LOOS = 10; - - /// - /// Unique symbol. - /// - public const byte STB_GNU_UNIQUE = 10; - - /// - /// End of OS-specific - /// - public const byte STB_HIOS = 12; - - /// - /// Start of processor-specific - /// - public const byte STB_LOPROC = 13; - - /// - /// End of processor-specific - /// - public const byte STB_HIPROC = 15; - - /// - /// Symbol type is unspecified - /// - public const byte STT_NOTYPE = 0; - - /// - /// Symbol is a data object - /// - public const byte STT_OBJECT = 1; - - /// - /// Symbol is a code object - /// - public const byte STT_FUNC = 2; - - /// - /// Symbol associated with a section - /// - public const byte STT_SECTION = 3; - - /// - /// Symbol's name is file name - /// - public const byte STT_FILE = 4; - - /// - /// Symbol is a common data object - /// - public const byte STT_COMMON = 5; - - /// - /// Symbol is thread-local data object - /// - public const byte STT_TLS = 6; - - /// - /// Number of defined types. - /// - public const byte STT_NUM = 7; - - /// - /// Start of OS-specific - /// - public const byte STT_LOOS = 10; - - /// - /// Symbol is indirect code object - /// - public const byte STT_GNU_IFUNC = 10; - - /// - /// End of OS-specific - /// - public const byte STT_HIOS = 12; - - /// - /// Start of processor-specific - /// - public const byte STT_LOPROC = 13; - - /// - /// End of processor-specific - /// - public const byte STT_HIPROC = 15; - - /// - /// End of a chain. - /// - public const byte STN_UNDEF = 0; - - /// - /// Default symbol visibility rules - /// - public const byte STV_DEFAULT = 0; - - /// - /// Processor specific hidden class - /// - public const byte STV_INTERNAL = 1; - - /// - /// Sym unavailable in other modules - /// - public const byte STV_HIDDEN = 2; - - /// - /// Not preemptible, not exported - /// - public const byte STV_PROTECTED = 3; - - /// - /// Program header table entry unused - /// - public const uint PT_NULL = 0; - - /// - /// Loadable program segment - /// - public const uint PT_LOAD = 1; - - /// - /// Dynamic linking information - /// - public const uint PT_DYNAMIC = 2; - - /// - /// Program interpreter - /// - public const uint PT_INTERP = 3; - - /// - /// Auxiliary information - /// - public const uint PT_NOTE = 4; - - /// - /// Reserved - /// - public const uint PT_SHLIB = 5; - - /// - /// Entry for header table itself - /// - public const uint PT_PHDR = 6; - - /// - /// Thread-local storage segment - /// - public const uint PT_TLS = 7; - - /// - /// Number of defined types - /// - public const uint PT_NUM = 8; - - /// - /// Start of OS-specific - /// - public const uint PT_LOOS = 1610612736; - - /// - /// GCC .eh_frame_hdr segment - /// - public const uint PT_GNU_EH_FRAME = 1685382480; - - /// - /// Indicates stack executability - /// - public const uint PT_GNU_STACK = 1685382481; - - /// - /// Read-only after relocation - /// - public const uint PT_GNU_RELRO = 1685382482; - - public const uint PT_LOSUNW = 1879048186; - - /// - /// Sun Specific segment - /// - public const uint PT_SUNWBSS = 1879048186; - - /// - /// Stack segment - /// - public const uint PT_SUNWSTACK = 1879048187; - - public const uint PT_HISUNW = 1879048191; - - /// - /// End of OS-specific - /// - public const uint PT_HIOS = 1879048191; - - /// - /// Start of processor-specific - /// - public const uint PT_LOPROC = 1879048192; - - /// - /// End of processor-specific - /// - public const uint PT_HIPROC = 2147483647; - - /// - /// Segment is executable - /// - public const uint PF_X = 1; - - /// - /// Segment is writable - /// - public const uint PF_W = 2; - - /// - /// Segment is readable - /// - public const uint PF_R = 4; - - /// - /// OS-specific - /// - public const uint PF_MASKOS = 267386880; - - /// - /// Processor-specific - /// - public const uint PF_MASKPROC = 0xf0000000; - - /// - /// Contains copy of prstatus struct - /// - public const uint NT_PRSTATUS = 1; - - /// - /// Contains copy of fpregset struct - /// - public const uint NT_FPREGSET = 2; - - /// - /// Contains copy of prpsinfo struct - /// - public const uint NT_PRPSINFO = 3; - - /// - /// Contains copy of prxregset struct - /// - public const uint NT_PRXREG = 4; - - /// - /// Contains copy of task structure - /// - public const uint NT_TASKSTRUCT = 4; - - /// - /// String from sysinfo(SI_PLATFORM) - /// - public const uint NT_PLATFORM = 5; - - /// - /// Contains copy of auxv array - /// - public const uint NT_AUXV = 6; - - /// - /// Contains copy of gwindows struct - /// - public const uint NT_GWINDOWS = 7; - - /// - /// Contains copy of asrset struct - /// - public const uint NT_ASRS = 8; - - /// - /// Contains copy of pstatus struct - /// - public const uint NT_PSTATUS = 10; - - /// - /// Contains copy of psinfo struct - /// - public const uint NT_PSINFO = 13; - - /// - /// Contains copy of prcred struct - /// - public const uint NT_PRCRED = 14; - - /// - /// Contains copy of utsname struct - /// - public const uint NT_UTSNAME = 15; - - /// - /// Contains copy of lwpstatus struct - /// - public const uint NT_LWPSTATUS = 16; - - /// - /// Contains copy of lwpinfo struct - /// - public const uint NT_LWPSINFO = 17; - - /// - /// Contains copy of fprxregset struct - /// - public const uint NT_PRFPXREG = 20; - - /// - /// Contains copy of siginfo_t, size might increase - /// - public const uint NT_SIGINFO = 1397311305; - - /// - /// Contains information about mapped files - /// - public const uint NT_FILE = 1179208773; - - /// - /// Contains copy of user_fxsr_struct - /// - public const uint NT_PRXFPREG = 1189489535; - - /// - /// PowerPC Altivec/VMX registers - /// - public const uint NT_PPC_VMX = 256; - - /// - /// PowerPC SPE/EVR registers - /// - public const uint NT_PPC_SPE = 257; - - /// - /// PowerPC VSX registers - /// - public const uint NT_PPC_VSX = 258; - - /// - /// i386 TLS slots (struct user_desc) - /// - public const uint NT_386_TLS = 512; - - /// - /// x86 io permission bitmap (1=deny) - /// - public const uint NT_386_IOPERM = 513; - - /// - /// x86 extended state using xsave - /// - public const uint NT_X86_XSTATE = 514; - - /// - /// s390 upper register halves - /// - public const uint NT_S390_HIGH_GPRS = 768; - - /// - /// s390 timer register - /// - public const uint NT_S390_TIMER = 769; - - /// - /// s390 TOD clock comparator register - /// - public const uint NT_S390_TODCMP = 770; - - /// - /// s390 TOD programmable register - /// - public const uint NT_S390_TODPREG = 771; - - /// - /// s390 control registers - /// - public const uint NT_S390_CTRS = 772; - - /// - /// s390 prefix register - /// - public const uint NT_S390_PREFIX = 773; - - /// - /// s390 breaking event address - /// - public const uint NT_S390_LAST_BREAK = 774; - - /// - /// s390 system call restart data - /// - public const uint NT_S390_SYSTEM_CALL = 775; - - /// - /// s390 transaction diagnostic block - /// - public const uint NT_S390_TDB = 776; - - /// - /// ARM VFP/NEON registers - /// - public const uint NT_ARM_VFP = 1024; - - /// - /// ARM TLS register - /// - public const uint NT_ARM_TLS = 1025; - - /// - /// ARM hardware breakpoint registers - /// - public const uint NT_ARM_HW_BREAK = 1026; - - /// - /// ARM hardware watchpoint registers - /// - public const uint NT_ARM_HW_WATCH = 1027; - - /// - /// Contains a version string. - /// - public const uint NT_VERSION = 1; - - /// - /// Marks end of dynamic section - /// - public const int DT_NULL = 0; - - /// - /// Name of needed library - /// - public const int DT_NEEDED = 1; - - /// - /// Size in bytes of PLT relocs - /// - public const int DT_PLTRELSZ = 2; - - /// - /// Processor defined value - /// - public const int DT_PLTGOT = 3; - - /// - /// Address of symbol hash table - /// - public const int DT_HASH = 4; - - /// - /// Address of string table - /// - public const int DT_STRTAB = 5; - - /// - /// Address of symbol table - /// - public const int DT_SYMTAB = 6; - - /// - /// Address of Rela relocs - /// - public const int DT_RELA = 7; - - /// - /// Total size of Rela relocs - /// - public const int DT_RELASZ = 8; - - /// - /// Size of one Rela reloc - /// - public const int DT_RELAENT = 9; - - /// - /// Size of string table - /// - public const int DT_STRSZ = 10; - - /// - /// Size of one symbol table entry - /// - public const int DT_SYMENT = 11; - - /// - /// Address of init function - /// - public const int DT_INIT = 12; - - /// - /// Address of termination function - /// - public const int DT_FINI = 13; - - /// - /// Name of shared object - /// - public const int DT_SONAME = 14; - - /// - /// Library search path (deprecated) - /// - public const int DT_RPATH = 15; - - /// - /// Start symbol search here - /// - public const int DT_SYMBOLIC = 16; - - /// - /// Address of Rel relocs - /// - public const int DT_REL = 17; - - /// - /// Total size of Rel relocs - /// - public const int DT_RELSZ = 18; - - /// - /// Size of one Rel reloc - /// - public const int DT_RELENT = 19; - - /// - /// Type of reloc in PLT - /// - public const int DT_PLTREL = 20; - - /// - /// For debugging; unspecified - /// - public const int DT_DEBUG = 21; - - /// - /// Reloc might modify .text - /// - public const int DT_TEXTREL = 22; - - /// - /// Address of PLT relocs - /// - public const int DT_JMPREL = 23; - - /// - /// Process relocations of object - /// - public const int DT_BIND_NOW = 24; - - /// - /// Array with addresses of init fct - /// - public const int DT_INIT_ARRAY = 25; - - /// - /// Array with addresses of fini fct - /// - public const int DT_FINI_ARRAY = 26; - - /// - /// Size in bytes of DT_INIT_ARRAY - /// - public const int DT_INIT_ARRAYSZ = 27; - - /// - /// Size in bytes of DT_FINI_ARRAY - /// - public const int DT_FINI_ARRAYSZ = 28; - - /// - /// Library search path - /// - public const int DT_RUNPATH = 29; - - /// - /// Flags for the object being loaded - /// - public const int DT_FLAGS = 30; - - /// - /// Start of encoded range - /// - public const int DT_ENCODING = 32; - - /// - /// Array with addresses of preinit fct - /// - public const int DT_PREINIT_ARRAY = 32; - - /// - /// size in bytes of DT_PREINIT_ARRAY - /// - public const int DT_PREINIT_ARRAYSZ = 33; - - /// - /// Number used - /// - public const int DT_NUM = 34; - - /// - /// Start of OS-specific - /// - public const int DT_LOOS = 0x6000000d; - - /// - /// End of OS-specific - /// - public const int DT_HIOS = 0x6ffff000; - - /// - /// Start of processor-specific - /// - public const int DT_LOPROC = 0x70000000; - - /// - /// End of processor-specific - /// - public const int DT_HIPROC = 0x7fffffff; - - /// - /// Most used by any processor - /// - public const int DT_PROCNUM = 0x36; - - public const int DT_VALRNGLO = 0x6ffffd00; - - /// - /// Prelinking timestamp - /// - public const int DT_GNU_PRELINKED = 0x6ffffdf5; - - /// - /// Size of conflict section - /// - public const int DT_GNU_CONFLICTSZ = 0x6ffffdf6; - - /// - /// Size of library list - /// - public const int DT_GNU_LIBLISTSZ = 0x6ffffdf7; - - public const int DT_CHECKSUM = 0x6ffffdf8; - - public const int DT_PLTPADSZ = 0x6ffffdf9; - - public const int DT_MOVEENT = 0x6ffffdfa; - - public const int DT_MOVESZ = 0x6ffffdfb; - - /// - /// Feature selection (DTF_*). - /// - public const int DT_FEATURE_1 = 0x6ffffdfc; - - /// - /// Flags for DT_* entries, effecting the following DT_* entry. - /// - public const int DT_POSFLAG_1 = 0x6ffffdfd; - - /// - /// Size of syminfo table (in bytes) - /// - public const int DT_SYMINSZ = 0x6ffffdfe; - - /// - /// Entry size of syminfo - /// - public const int DT_SYMINENT = 0x6ffffdff; - - public const int DT_VALRNGHI = 0x6ffffdff; - - public const int DT_VALNUM = 12; - - public const int DT_ADDRRNGLO = 0x6ffffe00; - - /// - /// GNU-style hash table. - /// - public const int DT_GNU_HASH = 0x6ffffef5; - - public const int DT_TLSDESC_PLT = 0x6ffffef6; - - public const int DT_TLSDESC_GOT = 0x6ffffef7; - - /// - /// Start of conflict section - /// - public const int DT_GNU_CONFLICT = 0x6ffffef8; - - /// - /// Library list - /// - public const int DT_GNU_LIBLIST = 0x6ffffef9; - - /// - /// Configuration information. - /// - public const int DT_CONFIG = 0x6ffffefa; - - /// - /// Dependency auditing. - /// - public const int DT_DEPAUDIT = 0x6ffffefb; - - /// - /// Object auditing. - /// - public const int DT_AUDIT = 0x6ffffefc; - - /// - /// PLT padding. - /// - public const int DT_PLTPAD = 0x6ffffefd; - - /// - /// Move table. - /// - public const int DT_MOVETAB = 0x6ffffefe; - - /// - /// Syminfo table. - /// - public const int DT_SYMINFO = 0x6ffffeff; - - public const int DT_ADDRRNGHI = 0x6ffffeff; - - public const int DT_ADDRNUM = 11; - - public const int DT_VERSYM = 0x6ffffff0; - - public const int DT_RELACOUNT = 0x6ffffff9; - - public const int DT_RELCOUNT = 0x6ffffffa; - - /// - /// State flags, see DF_1_* below. - /// - public const int DT_FLAGS_1 = 0x6ffffffb; - - /// - /// Address of version definition table - /// - public const int DT_VERDEF = 0x6ffffffc; - - /// - /// Number of version definitions - /// - public const int DT_VERDEFNUM = 0x6ffffffd; - - /// - /// Address of table with needed versions - /// - public const int DT_VERNEED = 0x6ffffffe; - - /// - /// Number of needed versions - /// - public const int DT_VERNEEDNUM = 0x6fffffff; - - public const int DT_VERSIONTAGNUM = 16; - - /// - /// Shared object to load before self - /// - public const int DT_AUXILIARY = 0x7ffffffd; - - /// - /// Shared object to get values from - /// - public const int DT_FILTER = 0x7fffffff; - - public const int DT_EXTRANUM = 3; - - /// - /// Object may use DF_ORIGIN - /// - public const uint DF_ORIGIN = 1; - - /// - /// Symbol resolutions starts here - /// - public const uint DF_SYMBOLIC = 2; - - /// - /// Object contains text relocations - /// - public const uint DF_TEXTREL = 4; - - /// - /// No lazy binding for this object - /// - public const uint DF_BIND_NOW = 8; - - /// - /// Module uses the static TLS model - /// - public const uint DF_STATIC_TLS = 16; - - /// - /// Set RTLD_NOW for this object. - /// - public const uint DF_1_NOW = 1; - - /// - /// Set RTLD_GLOBAL for this object. - /// - public const uint DF_1_GLOBAL = 2; - - /// - /// Set RTLD_GROUP for this object. - /// - public const uint DF_1_GROUP = 4; - - /// - /// Set RTLD_NODELETE for this object. - /// - public const uint DF_1_NODELETE = 8; - - /// - /// Trigger filtee loading at runtime. - /// - public const uint DF_1_LOADFLTR = 16; - - /// - /// Set RTLD_INITFIRST for this object - /// - public const uint DF_1_INITFIRST = 32; - - /// - /// Set RTLD_NOOPEN for this object. - /// - public const uint DF_1_NOOPEN = 64; - - /// - /// $ORIGIN must be handled. - /// - public const uint DF_1_ORIGIN = 128; - - /// - /// Direct binding enabled. - /// - public const uint DF_1_DIRECT = 256; - - public const uint DF_1_TRANS = 512; - - /// - /// Object is used to interpose. - /// - public const uint DF_1_INTERPOSE = 1024; - - /// - /// Ignore default lib search path. - /// - public const uint DF_1_NODEFLIB = 2048; - - /// - /// Object can't be dldump'ed. - /// - public const uint DF_1_NODUMP = 4096; - - /// - /// Configuration alternative created. - /// - public const uint DF_1_CONFALT = 8192; - - /// - /// Filtee terminates filters search. - /// - public const uint DF_1_ENDFILTEE = 16384; - - /// - /// Disp reloc applied at build time. - /// - public const uint DF_1_DISPRELDNE = 32768; - - /// - /// Disp reloc applied at run-time. - /// - public const uint DF_1_DISPRELPND = 65536; - - /// - /// Object has no-direct binding. - /// - public const uint DF_1_NODIRECT = 131072; - - public const uint DF_1_IGNMULDEF = 262144; - - public const uint DF_1_NOKSYMS = 524288; - - public const uint DF_1_NOHDR = 1048576; - - /// - /// Object is modified after built. - /// - public const uint DF_1_EDITED = 2097152; - - public const uint DF_1_NORELOC = 4194304; - - /// - /// Object has individual interposers. - /// - public const uint DF_1_SYMINTPOSE = 8388608; - - /// - /// Global auditing required. - /// - public const uint DF_1_GLOBAUDIT = 16777216; - - /// - /// Singleton symbols are used. - /// - public const uint DF_1_SINGLETON = 33554432; - - public const uint DTF_1_PARINIT = 1; - - public const uint DTF_1_CONFEXP = 2; - - /// - /// Lazyload following object. - /// - public const uint DF_P1_LAZYLOAD = 1; - - /// - /// Symbols from next object are not generally available. - /// - public const uint DF_P1_GROUPPERM = 2; - - /// - /// No version - /// - public const ushort VER_DEF_NONE = 0; - - /// - /// Current version - /// - public const ushort VER_DEF_CURRENT = 1; - - /// - /// Given version number - /// - public const ushort VER_DEF_NUM = 2; - - /// - /// Version definition of file itself - /// - public const ushort VER_FLG_BASE = 1; - - /// - /// Weak version identifier - /// - public const ushort VER_FLG_WEAK = 2; - - /// - /// Symbol is local. - /// - public const ushort VER_NDX_LOCAL = 0; - - /// - /// Symbol is global. - /// - public const ushort VER_NDX_GLOBAL = 1; - - /// - /// Beginning of reserved entries. - /// - public const ushort VER_NDX_LORESERVE = 65280; - - /// - /// Symbol is to be eliminated. - /// - public const ushort VER_NDX_ELIMINATE = 65281; - - /// - /// No version - /// - public const ushort VER_NEED_NONE = 0; - - /// - /// Current version - /// - public const ushort VER_NEED_CURRENT = 1; - - /// - /// Given version number - /// - public const ushort VER_NEED_NUM = 2; - - public const uint NT_GNU_ABI_TAG = 1; - - public const uint ELF_NOTE_OS_LINUX = 0; - - public const uint ELF_NOTE_OS_GNU = 1; - - public const uint ELF_NOTE_OS_SOLARIS2 = 2; - - public const uint ELF_NOTE_OS_FREEBSD = 3; - - public const uint NT_GNU_HWCAP = 2; - - public const uint NT_GNU_BUILD_ID = 3; - - public const uint NT_GNU_GOLD_VERSION = 4; - - public const uint EF_CPU32 = 8454144; - - /// - /// No reloc - /// - public const uint R_68K_NONE = 0; - - /// - /// Direct 32 bit - /// - public const uint R_68K_32 = 1; - - /// - /// Direct 16 bit - /// - public const uint R_68K_16 = 2; - - /// - /// Direct 8 bit - /// - public const uint R_68K_8 = 3; - - /// - /// PC relative 32 bit - /// - public const uint R_68K_PC32 = 4; - - /// - /// PC relative 16 bit - /// - public const uint R_68K_PC16 = 5; - - /// - /// PC relative 8 bit - /// - public const uint R_68K_PC8 = 6; - - /// - /// 32 bit PC relative GOT entry - /// - public const uint R_68K_GOT32 = 7; - - /// - /// 16 bit PC relative GOT entry - /// - public const uint R_68K_GOT16 = 8; - - /// - /// 8 bit PC relative GOT entry - /// - public const uint R_68K_GOT8 = 9; - - /// - /// 32 bit GOT offset - /// - public const uint R_68K_GOT32O = 10; - - /// - /// 16 bit GOT offset - /// - public const uint R_68K_GOT16O = 11; - - /// - /// 8 bit GOT offset - /// - public const uint R_68K_GOT8O = 12; - - /// - /// 32 bit PC relative PLT address - /// - public const uint R_68K_PLT32 = 13; - - /// - /// 16 bit PC relative PLT address - /// - public const uint R_68K_PLT16 = 14; - - /// - /// 8 bit PC relative PLT address - /// - public const uint R_68K_PLT8 = 15; - - /// - /// 32 bit PLT offset - /// - public const uint R_68K_PLT32O = 16; - - /// - /// 16 bit PLT offset - /// - public const uint R_68K_PLT16O = 17; - - /// - /// 8 bit PLT offset - /// - public const uint R_68K_PLT8O = 18; - - /// - /// Copy symbol at runtime - /// - public const uint R_68K_COPY = 19; - - /// - /// Create GOT entry - /// - public const uint R_68K_GLOB_DAT = 20; - - /// - /// Create PLT entry - /// - public const uint R_68K_JMP_SLOT = 21; - - /// - /// Adjust by program base - /// - public const uint R_68K_RELATIVE = 22; - - /// - /// 32 bit GOT offset for GD - /// - public const uint R_68K_TLS_GD32 = 25; - - /// - /// 16 bit GOT offset for GD - /// - public const uint R_68K_TLS_GD16 = 26; - - /// - /// 8 bit GOT offset for GD - /// - public const uint R_68K_TLS_GD8 = 27; - - /// - /// 32 bit GOT offset for LDM - /// - public const uint R_68K_TLS_LDM32 = 28; - - /// - /// 16 bit GOT offset for LDM - /// - public const uint R_68K_TLS_LDM16 = 29; - - /// - /// 8 bit GOT offset for LDM - /// - public const uint R_68K_TLS_LDM8 = 30; - - /// - /// 32 bit module-relative offset - /// - public const uint R_68K_TLS_LDO32 = 31; - - /// - /// 16 bit module-relative offset - /// - public const uint R_68K_TLS_LDO16 = 32; - - /// - /// 8 bit module-relative offset - /// - public const uint R_68K_TLS_LDO8 = 33; - - /// - /// 32 bit GOT offset for IE - /// - public const uint R_68K_TLS_IE32 = 34; - - /// - /// 16 bit GOT offset for IE - /// - public const uint R_68K_TLS_IE16 = 35; - - /// - /// 8 bit GOT offset for IE - /// - public const uint R_68K_TLS_IE8 = 36; - - /// - /// 32 bit offset relative to static TLS block - /// - public const uint R_68K_TLS_LE32 = 37; - - /// - /// 16 bit offset relative to static TLS block - /// - public const uint R_68K_TLS_LE16 = 38; - - /// - /// 8 bit offset relative to static TLS block - /// - public const uint R_68K_TLS_LE8 = 39; - - /// - /// 32 bit module number - /// - public const uint R_68K_TLS_DTPMOD32 = 40; - - /// - /// 32 bit module-relative offset - /// - public const uint R_68K_TLS_DTPREL32 = 41; - - /// - /// 32 bit TP-relative offset - /// - public const uint R_68K_TLS_TPREL32 = 42; - - public const uint R_68K_NUM = 43; - - /// - /// No reloc - /// - public const uint R_386_NONE = 0; - - /// - /// Direct 32 bit - /// - public const uint R_386_32 = 1; - - /// - /// PC relative 32 bit - /// - public const uint R_386_PC32 = 2; - - /// - /// 32 bit GOT entry - /// - public const uint R_386_GOT32 = 3; - - /// - /// 32 bit PLT address - /// - public const uint R_386_PLT32 = 4; - - /// - /// Copy symbol at runtime - /// - public const uint R_386_COPY = 5; - - /// - /// Create GOT entry - /// - public const uint R_386_GLOB_DAT = 6; - - /// - /// Create PLT entry - /// - public const uint R_386_JMP_SLOT = 7; - - /// - /// Adjust by program base - /// - public const uint R_386_RELATIVE = 8; - - /// - /// 32 bit offset to GOT - /// - public const uint R_386_GOTOFF = 9; - - /// - /// 32 bit PC relative offset to GOT - /// - public const uint R_386_GOTPC = 10; - - public const uint R_386_32PLT = 11; - - /// - /// Offset in static TLS block - /// - public const uint R_386_TLS_TPOFF = 14; - - /// - /// Address of GOT entry for static TLS block offset - /// - public const uint R_386_TLS_IE = 15; - - /// - /// GOT entry for static TLS block offset - /// - public const uint R_386_TLS_GOTIE = 16; - - /// - /// Offset relative to static TLS block - /// - public const uint R_386_TLS_LE = 17; - - /// - /// Direct 32 bit for GNU version of general dynamic thread local data - /// - public const uint R_386_TLS_GD = 18; - - /// - /// Direct 32 bit for GNU version of local dynamic thread local data in LE code - /// - public const uint R_386_TLS_LDM = 19; - - public const uint R_386_16 = 20; - - public const uint R_386_PC16 = 21; - - public const uint R_386_8 = 22; - - public const uint R_386_PC8 = 23; - - /// - /// Direct 32 bit for general dynamic - /// thread local data - /// - public const uint R_386_TLS_GD_32 = 24; - - /// - /// Tag for pushl in GD TLS code - /// - public const uint R_386_TLS_GD_PUSH = 25; - - /// - /// Relocation for call to - /// __tls_get_addr() - /// - public const uint R_386_TLS_GD_CALL = 26; - - /// - /// Tag for popl in GD TLS code - /// - public const uint R_386_TLS_GD_POP = 27; - - /// - /// Direct 32 bit for local dynamic - /// thread local data in LE code - /// - public const uint R_386_TLS_LDM_32 = 28; - - /// - /// Tag for pushl in LDM TLS code - /// - public const uint R_386_TLS_LDM_PUSH = 29; - - /// - /// Relocation for call to - /// __tls_get_addr() in LDM code - /// - public const uint R_386_TLS_LDM_CALL = 30; - - /// - /// Tag for popl in LDM TLS code - /// - public const uint R_386_TLS_LDM_POP = 31; - - /// - /// Offset relative to TLS block - /// - public const uint R_386_TLS_LDO_32 = 32; - - /// - /// GOT entry for negated static TLS - /// block offset - /// - public const uint R_386_TLS_IE_32 = 33; - - /// - /// Negated offset relative to static - /// TLS block - /// - public const uint R_386_TLS_LE_32 = 34; - - /// - /// ID of module containing symbol - /// - public const uint R_386_TLS_DTPMOD32 = 35; - - /// - /// Offset in TLS block - /// - public const uint R_386_TLS_DTPOFF32 = 36; - - /// - /// Negated offset in static TLS block - /// - public const uint R_386_TLS_TPOFF32 = 37; - - /// - /// 32-bit symbol size - /// - public const uint R_386_SIZE32 = 38; - - /// - /// GOT offset for TLS descriptor. - /// - public const uint R_386_TLS_GOTDESC = 39; - - /// - /// Marker of call through TLS - /// descriptor for - /// relaxation. - /// - public const uint R_386_TLS_DESC_CALL = 40; - - /// - /// TLS descriptor containing - /// pointer to code and to - /// argument, returning the TLS - /// offset for the symbol. - /// - public const uint R_386_TLS_DESC = 41; - - /// - /// Adjust indirectly by program base - /// - public const uint R_386_IRELATIVE = 42; - - public const uint R_386_NUM = 43; - - /// - /// Global register reserved to app. - /// - public const byte STT_SPARC_REGISTER = 13; - - public const uint EF_SPARCV9_MM = 3; - - public const uint EF_SPARCV9_TSO = 0; - - public const uint EF_SPARCV9_PSO = 1; - - public const uint EF_SPARCV9_RMO = 2; - - /// - /// little endian data - /// - public const uint EF_SPARC_LEDATA = 8388608; - - public const uint EF_SPARC_EXT_MASK = 16776960; - - /// - /// generic V8+ features - /// - public const uint EF_SPARC_32PLUS = 256; - - /// - /// Sun UltraSPARC1 extensions - /// - public const uint EF_SPARC_SUN_US1 = 512; - - /// - /// HAL R1 extensions - /// - public const uint EF_SPARC_HAL_R1 = 1024; - - /// - /// Sun UltraSPARCIII extensions - /// - public const uint EF_SPARC_SUN_US3 = 2048; - - /// - /// No reloc - /// - public const uint R_SPARC_NONE = 0; - - /// - /// Direct 8 bit - /// - public const uint R_SPARC_8 = 1; - - /// - /// Direct 16 bit - /// - public const uint R_SPARC_16 = 2; - - /// - /// Direct 32 bit - /// - public const uint R_SPARC_32 = 3; - - /// - /// PC relative 8 bit - /// - public const uint R_SPARC_DISP8 = 4; - - /// - /// PC relative 16 bit - /// - public const uint R_SPARC_DISP16 = 5; - - /// - /// PC relative 32 bit - /// - public const uint R_SPARC_DISP32 = 6; - - /// - /// PC relative 30 bit shifted - /// - public const uint R_SPARC_WDISP30 = 7; - - /// - /// PC relative 22 bit shifted - /// - public const uint R_SPARC_WDISP22 = 8; - - /// - /// High 22 bit - /// - public const uint R_SPARC_HI22 = 9; - - /// - /// Direct 22 bit - /// - public const uint R_SPARC_22 = 10; - - /// - /// Direct 13 bit - /// - public const uint R_SPARC_13 = 11; - - /// - /// Truncated 10 bit - /// - public const uint R_SPARC_LO10 = 12; - - /// - /// Truncated 10 bit GOT entry - /// - public const uint R_SPARC_GOT10 = 13; - - /// - /// 13 bit GOT entry - /// - public const uint R_SPARC_GOT13 = 14; - - /// - /// 22 bit GOT entry shifted - /// - public const uint R_SPARC_GOT22 = 15; - - /// - /// PC relative 10 bit truncated - /// - public const uint R_SPARC_PC10 = 16; - - /// - /// PC relative 22 bit shifted - /// - public const uint R_SPARC_PC22 = 17; - - /// - /// 30 bit PC relative PLT address - /// - public const uint R_SPARC_WPLT30 = 18; - - /// - /// Copy symbol at runtime - /// - public const uint R_SPARC_COPY = 19; - - /// - /// Create GOT entry - /// - public const uint R_SPARC_GLOB_DAT = 20; - - /// - /// Create PLT entry - /// - public const uint R_SPARC_JMP_SLOT = 21; - - /// - /// Adjust by program base - /// - public const uint R_SPARC_RELATIVE = 22; - - /// - /// Direct 32 bit unaligned - /// - public const uint R_SPARC_UA32 = 23; - - /// - /// Direct 32 bit ref to PLT entry - /// - public const uint R_SPARC_PLT32 = 24; - - /// - /// High 22 bit PLT entry - /// - public const uint R_SPARC_HIPLT22 = 25; - - /// - /// Truncated 10 bit PLT entry - /// - public const uint R_SPARC_LOPLT10 = 26; - - /// - /// PC rel 32 bit ref to PLT entry - /// - public const uint R_SPARC_PCPLT32 = 27; - - /// - /// PC rel high 22 bit PLT entry - /// - public const uint R_SPARC_PCPLT22 = 28; - - /// - /// PC rel trunc 10 bit PLT entry - /// - public const uint R_SPARC_PCPLT10 = 29; - - /// - /// Direct 10 bit - /// - public const uint R_SPARC_10 = 30; - - /// - /// Direct 11 bit - /// - public const uint R_SPARC_11 = 31; - - /// - /// Direct 64 bit - /// - public const uint R_SPARC_64 = 32; - - /// - /// 10bit with secondary 13bit addend - /// - public const uint R_SPARC_OLO10 = 33; - - /// - /// Top 22 bits of direct 64 bit - /// - public const uint R_SPARC_HH22 = 34; - - /// - /// High middle 10 bits of ... - /// - public const uint R_SPARC_HM10 = 35; - - /// - /// Low middle 22 bits of ... - /// - public const uint R_SPARC_LM22 = 36; - - /// - /// Top 22 bits of pc rel 64 bit - /// - public const uint R_SPARC_PC_HH22 = 37; - - /// - /// High middle 10 bit of ... - /// - public const uint R_SPARC_PC_HM10 = 38; - - /// - /// Low miggle 22 bits of ... - /// - public const uint R_SPARC_PC_LM22 = 39; - - /// - /// PC relative 16 bit shifted - /// - public const uint R_SPARC_WDISP16 = 40; - - /// - /// PC relative 19 bit shifted - /// - public const uint R_SPARC_WDISP19 = 41; - - /// - /// was part of v9 ABI but was removed - /// - public const uint R_SPARC_GLOB_JMP = 42; - - /// - /// Direct 7 bit - /// - public const uint R_SPARC_7 = 43; - - /// - /// Direct 5 bit - /// - public const uint R_SPARC_5 = 44; - - /// - /// Direct 6 bit - /// - public const uint R_SPARC_6 = 45; - - /// - /// PC relative 64 bit - /// - public const uint R_SPARC_DISP64 = 46; - - /// - /// Direct 64 bit ref to PLT entry - /// - public const uint R_SPARC_PLT64 = 47; - - /// - /// High 22 bit complemented - /// - public const uint R_SPARC_HIX22 = 48; - - /// - /// Truncated 11 bit complemented - /// - public const uint R_SPARC_LOX10 = 49; - - /// - /// Direct high 12 of 44 bit - /// - public const uint R_SPARC_H44 = 50; - - /// - /// Direct mid 22 of 44 bit - /// - public const uint R_SPARC_M44 = 51; - - /// - /// Direct low 10 of 44 bit - /// - public const uint R_SPARC_L44 = 52; - - /// - /// Global register usage - /// - public const uint R_SPARC_REGISTER = 53; - - /// - /// Direct 64 bit unaligned - /// - public const uint R_SPARC_UA64 = 54; - - /// - /// Direct 16 bit unaligned - /// - public const uint R_SPARC_UA16 = 55; - - public const uint R_SPARC_TLS_GD_HI22 = 56; - - public const uint R_SPARC_TLS_GD_LO10 = 57; - - public const uint R_SPARC_TLS_GD_ADD = 58; - - public const uint R_SPARC_TLS_GD_CALL = 59; - - public const uint R_SPARC_TLS_LDM_HI22 = 60; - - public const uint R_SPARC_TLS_LDM_LO10 = 61; - - public const uint R_SPARC_TLS_LDM_ADD = 62; - - public const uint R_SPARC_TLS_LDM_CALL = 63; - - public const uint R_SPARC_TLS_LDO_HIX22 = 64; - - public const uint R_SPARC_TLS_LDO_LOX10 = 65; - - public const uint R_SPARC_TLS_LDO_ADD = 66; - - public const uint R_SPARC_TLS_IE_HI22 = 67; - - public const uint R_SPARC_TLS_IE_LO10 = 68; - - public const uint R_SPARC_TLS_IE_LD = 69; - - public const uint R_SPARC_TLS_IE_LDX = 70; - - public const uint R_SPARC_TLS_IE_ADD = 71; - - public const uint R_SPARC_TLS_LE_HIX22 = 72; - - public const uint R_SPARC_TLS_LE_LOX10 = 73; - - public const uint R_SPARC_TLS_DTPMOD32 = 74; - - public const uint R_SPARC_TLS_DTPMOD64 = 75; - - public const uint R_SPARC_TLS_DTPOFF32 = 76; - - public const uint R_SPARC_TLS_DTPOFF64 = 77; - - public const uint R_SPARC_TLS_TPOFF32 = 78; - - public const uint R_SPARC_TLS_TPOFF64 = 79; - - public const uint R_SPARC_GOTDATA_HIX22 = 80; - - public const uint R_SPARC_GOTDATA_LOX10 = 81; - - public const uint R_SPARC_GOTDATA_OP_HIX22 = 82; - - public const uint R_SPARC_GOTDATA_OP_LOX10 = 83; - - public const uint R_SPARC_GOTDATA_OP = 84; - - public const uint R_SPARC_H34 = 85; - - public const uint R_SPARC_SIZE32 = 86; - - public const uint R_SPARC_SIZE64 = 87; - - public const uint R_SPARC_WDISP10 = 88; - - public const uint R_SPARC_JMP_IREL = 248; - - public const uint R_SPARC_IRELATIVE = 249; - - public const uint R_SPARC_GNU_VTINHERIT = 250; - - public const uint R_SPARC_GNU_VTENTRY = 251; - - public const uint R_SPARC_REV32 = 252; - - public const uint R_SPARC_NUM = 253; - - public const int DT_SPARC_REGISTER = 0x70000001; - - public const int DT_SPARC_NUM = 2; - - /// - /// A .noreorder directive was used. - /// - public const uint EF_MIPS_NOREORDER = 1; - - /// - /// Contains PIC code. - /// - public const uint EF_MIPS_PIC = 2; - - /// - /// Uses PIC calling sequence. - /// - public const uint EF_MIPS_CPIC = 4; - - public const uint EF_MIPS_XGOT = 8; - - public const uint EF_MIPS_64BIT_WHIRL = 16; - - public const uint EF_MIPS_ABI2 = 32; - - public const uint EF_MIPS_ABI_ON32 = 64; - - /// - /// Uses FP64 (12 callee-saved). - /// - public const uint EF_MIPS_FP64 = 512; - - /// - /// Uses IEEE 754-2008 NaN encoding. - /// - public const uint EF_MIPS_NAN2008 = 1024; - - /// - /// MIPS architecture level. - /// - public const uint EF_MIPS_ARCH = 0xf0000000; - - /// - /// -mips1 code. - /// - public const uint EF_MIPS_ARCH_1 = 0; - - /// - /// -mips2 code. - /// - public const uint EF_MIPS_ARCH_2 = 268435456; - - /// - /// -mips3 code. - /// - public const uint EF_MIPS_ARCH_3 = 536870912; - - /// - /// -mips4 code. - /// - public const uint EF_MIPS_ARCH_4 = 805306368; - - /// - /// -mips5 code. - /// - public const uint EF_MIPS_ARCH_5 = 1073741824; - - /// - /// MIPS32 code. - /// - public const uint EF_MIPS_ARCH_32 = 1342177280; - - /// - /// MIPS64 code. - /// - public const uint EF_MIPS_ARCH_64 = 1610612736; - - /// - /// MIPS32r2 code. - /// - public const uint EF_MIPS_ARCH_32R2 = 1879048192; - - /// - /// MIPS64r2 code. - /// - public const uint EF_MIPS_ARCH_64R2 = 0x80000000; - - /// - /// Allocated common symbols. - /// - public const uint SHN_MIPS_ACOMMON = 65280; - - /// - /// Allocated test symbols. - /// - public const uint SHN_MIPS_TEXT = 65281; - - /// - /// Allocated data symbols. - /// - public const uint SHN_MIPS_DATA = 65282; - - /// - /// Small common symbols. - /// - public const uint SHN_MIPS_SCOMMON = 65283; - - /// - /// Small undefined symbols. - /// - public const uint SHN_MIPS_SUNDEFINED = 65284; - - /// - /// Shared objects used in link. - /// - public const uint SHT_MIPS_LIBLIST = 1879048192; - - public const uint SHT_MIPS_MSYM = 1879048193; - - /// - /// Conflicting symbols. - /// - public const uint SHT_MIPS_CONFLICT = 1879048194; - - /// - /// Global data area sizes. - /// - public const uint SHT_MIPS_GPTAB = 1879048195; - - /// - /// Reserved for SGI/MIPS compilers - /// - public const uint SHT_MIPS_UCODE = 1879048196; - - /// - /// MIPS ECOFF debugging info. - /// - public const uint SHT_MIPS_DEBUG = 1879048197; - - /// - /// Register usage information. - /// - public const uint SHT_MIPS_REGINFO = 1879048198; - - public const uint SHT_MIPS_PACKAGE = 1879048199; - - public const uint SHT_MIPS_PACKSYM = 1879048200; - - public const uint SHT_MIPS_RELD = 1879048201; - - public const uint SHT_MIPS_IFACE = 1879048203; - - public const uint SHT_MIPS_CONTENT = 1879048204; - - /// - /// Miscellaneous options. - /// - public const uint SHT_MIPS_OPTIONS = 1879048205; - - public const uint SHT_MIPS_SHDR = 1879048208; - - public const uint SHT_MIPS_FDESC = 1879048209; - - public const uint SHT_MIPS_EXTSYM = 1879048210; - - public const uint SHT_MIPS_DENSE = 1879048211; - - public const uint SHT_MIPS_PDESC = 1879048212; - - public const uint SHT_MIPS_LOCSYM = 1879048213; - - public const uint SHT_MIPS_AUXSYM = 1879048214; - - public const uint SHT_MIPS_OPTSYM = 1879048215; - - public const uint SHT_MIPS_LOCSTR = 1879048216; - - public const uint SHT_MIPS_LINE = 1879048217; - - public const uint SHT_MIPS_RFDESC = 1879048218; - - public const uint SHT_MIPS_DELTASYM = 1879048219; - - public const uint SHT_MIPS_DELTAINST = 1879048220; - - public const uint SHT_MIPS_DELTACLASS = 1879048221; - - /// - /// DWARF debugging information. - /// - public const uint SHT_MIPS_DWARF = 1879048222; - - public const uint SHT_MIPS_DELTADECL = 1879048223; - - public const uint SHT_MIPS_SYMBOL_LIB = 1879048224; - - /// - /// Event section. - /// - public const uint SHT_MIPS_EVENTS = 1879048225; - - public const uint SHT_MIPS_TRANSLATE = 1879048226; - - public const uint SHT_MIPS_PIXIE = 1879048227; - - public const uint SHT_MIPS_XLATE = 1879048228; - - public const uint SHT_MIPS_XLATE_DEBUG = 1879048229; - - public const uint SHT_MIPS_WHIRL = 1879048230; - - public const uint SHT_MIPS_EH_REGION = 1879048231; - - public const uint SHT_MIPS_XLATE_OLD = 1879048232; - - public const uint SHT_MIPS_PDR_EXCEPTION = 1879048233; - - /// - /// Must be in global data area. - /// - public const uint SHF_MIPS_GPREL = 268435456; - - public const uint SHF_MIPS_MERGE = 536870912; - - public const uint SHF_MIPS_ADDR = 1073741824; - - public const uint SHF_MIPS_STRINGS = 0x80000000; - - public const uint SHF_MIPS_NOSTRIP = 134217728; - - public const uint SHF_MIPS_LOCAL = 67108864; - - public const uint SHF_MIPS_NAMES = 33554432; - - public const uint SHF_MIPS_NODUPE = 16777216; - - public const byte STB_MIPS_SPLIT_COMMON = 13; - - /// - /// No reloc - /// - public const uint R_MIPS_NONE = 0; - - /// - /// Direct 16 bit - /// - public const uint R_MIPS_16 = 1; - - /// - /// Direct 32 bit - /// - public const uint R_MIPS_32 = 2; - - /// - /// PC relative 32 bit - /// - public const uint R_MIPS_REL32 = 3; - - /// - /// Direct 26 bit shifted - /// - public const uint R_MIPS_26 = 4; - - /// - /// High 16 bit - /// - public const uint R_MIPS_HI16 = 5; - - /// - /// Low 16 bit - /// - public const uint R_MIPS_LO16 = 6; - - /// - /// GP relative 16 bit - /// - public const uint R_MIPS_GPREL16 = 7; - - /// - /// 16 bit literal entry - /// - public const uint R_MIPS_LITERAL = 8; - - /// - /// 16 bit GOT entry - /// - public const uint R_MIPS_GOT16 = 9; - - /// - /// PC relative 16 bit - /// - public const uint R_MIPS_PC16 = 10; - - /// - /// 16 bit GOT entry for function - /// - public const uint R_MIPS_CALL16 = 11; - - /// - /// GP relative 32 bit - /// - public const uint R_MIPS_GPREL32 = 12; - - public const uint R_MIPS_SHIFT5 = 16; - - public const uint R_MIPS_SHIFT6 = 17; - - public const uint R_MIPS_64 = 18; - - public const uint R_MIPS_GOT_DISP = 19; - - public const uint R_MIPS_GOT_PAGE = 20; - - public const uint R_MIPS_GOT_OFST = 21; - - public const uint R_MIPS_GOT_HI16 = 22; - - public const uint R_MIPS_GOT_LO16 = 23; - - public const uint R_MIPS_SUB = 24; - - public const uint R_MIPS_INSERT_A = 25; - - public const uint R_MIPS_INSERT_B = 26; - - public const uint R_MIPS_DELETE = 27; - - public const uint R_MIPS_HIGHER = 28; - - public const uint R_MIPS_HIGHEST = 29; - - public const uint R_MIPS_CALL_HI16 = 30; - - public const uint R_MIPS_CALL_LO16 = 31; - - public const uint R_MIPS_SCN_DISP = 32; - - public const uint R_MIPS_REL16 = 33; - - public const uint R_MIPS_ADD_IMMEDIATE = 34; - - public const uint R_MIPS_PJUMP = 35; - - public const uint R_MIPS_RELGOT = 36; - - public const uint R_MIPS_JALR = 37; - - /// - /// Module number 32 bit - /// - public const uint R_MIPS_TLS_DTPMOD32 = 38; - - /// - /// Module-relative offset 32 bit - /// - public const uint R_MIPS_TLS_DTPREL32 = 39; - - /// - /// Module number 64 bit - /// - public const uint R_MIPS_TLS_DTPMOD64 = 40; - - /// - /// Module-relative offset 64 bit - /// - public const uint R_MIPS_TLS_DTPREL64 = 41; - - /// - /// 16 bit GOT offset for GD - /// - public const uint R_MIPS_TLS_GD = 42; - - /// - /// 16 bit GOT offset for LDM - /// - public const uint R_MIPS_TLS_LDM = 43; - - /// - /// Module-relative offset, high 16 bits - /// - public const uint R_MIPS_TLS_DTPREL_HI16 = 44; - - /// - /// Module-relative offset, low 16 bits - /// - public const uint R_MIPS_TLS_DTPREL_LO16 = 45; - - /// - /// 16 bit GOT offset for IE - /// - public const uint R_MIPS_TLS_GOTTPREL = 46; - - /// - /// TP-relative offset, 32 bit - /// - public const uint R_MIPS_TLS_TPREL32 = 47; - - /// - /// TP-relative offset, 64 bit - /// - public const uint R_MIPS_TLS_TPREL64 = 48; - - /// - /// TP-relative offset, high 16 bits - /// - public const uint R_MIPS_TLS_TPREL_HI16 = 49; - - /// - /// TP-relative offset, low 16 bits - /// - public const uint R_MIPS_TLS_TPREL_LO16 = 50; - - public const uint R_MIPS_GLOB_DAT = 51; - - public const uint R_MIPS_COPY = 126; - - public const uint R_MIPS_JUMP_SLOT = 127; - - public const uint R_MIPS_NUM = 128; - - /// - /// Register usage information. - /// - public const uint PT_MIPS_REGINFO = 1879048192; - - /// - /// Runtime procedure table. - /// - public const uint PT_MIPS_RTPROC = 1879048193; - - public const uint PT_MIPS_OPTIONS = 1879048194; - - /// - /// FP mode requirement. - /// - public const uint PT_MIPS_ABIFLAGS = 1879048195; - - public const uint PF_MIPS_LOCAL = 268435456; - - /// - /// Runtime linker interface version - /// - public const int DT_MIPS_RLD_VERSION = 0x70000001; - - /// - /// Timestamp - /// - public const int DT_MIPS_TIME_STAMP = 0x70000002; - - /// - /// Checksum - /// - public const int DT_MIPS_ICHECKSUM = 0x70000003; - - /// - /// Version string (string tbl index) - /// - public const int DT_MIPS_IVERSION = 0x70000004; - - /// - /// Flags - /// - public const int DT_MIPS_FLAGS = 0x70000005; - - /// - /// Base address - /// - public const int DT_MIPS_BASE_ADDRESS = 0x70000006; - - public const int DT_MIPS_MSYM = 0x70000007; - - /// - /// Address of CONFLICT section - /// - public const int DT_MIPS_CONFLICT = 0x70000008; - - /// - /// Address of LIBLIST section - /// - public const int DT_MIPS_LIBLIST = 0x70000009; - - /// - /// Number of local GOT entries - /// - public const int DT_MIPS_LOCAL_GOTNO = 0x7000000a; - - /// - /// Number of CONFLICT entries - /// - public const int DT_MIPS_CONFLICTNO = 0x7000000b; - - /// - /// Number of LIBLIST entries - /// - public const int DT_MIPS_LIBLISTNO = 0x70000010; - - /// - /// Number of DYNSYM entries - /// - public const int DT_MIPS_SYMTABNO = 0x70000011; - - /// - /// First external DYNSYM - /// - public const int DT_MIPS_UNREFEXTNO = 0x70000012; - - /// - /// First GOT entry in DYNSYM - /// - public const int DT_MIPS_GOTSYM = 0x70000013; - - /// - /// Number of GOT page table entries - /// - public const int DT_MIPS_HIPAGENO = 0x70000014; - - /// - /// Address of run time loader map. - /// - public const int DT_MIPS_RLD_MAP = 0x70000016; - - /// - /// Delta C++ class definition. - /// - public const int DT_MIPS_DELTA_CLASS = 0x70000017; - - /// - /// Number of entries in - /// DT_MIPS_DELTA_CLASS. - /// - public const int DT_MIPS_DELTA_CLASS_NO = 0x70000018; - - /// - /// Delta C++ class instances. - /// - public const int DT_MIPS_DELTA_INSTANCE = 0x70000019; - - /// - /// Number of entries in - /// DT_MIPS_DELTA_INSTANCE. - /// - public const int DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a; - - /// - /// Delta relocations. - /// - public const int DT_MIPS_DELTA_RELOC = 0x7000001b; - - /// - /// Number of entries in - /// DT_MIPS_DELTA_RELOC. - /// - public const int DT_MIPS_DELTA_RELOC_NO = 0x7000001c; - - /// - /// Delta symbols that Delta - /// relocations refer to. - /// - public const int DT_MIPS_DELTA_SYM = 0x7000001d; - - /// - /// Number of entries in - /// DT_MIPS_DELTA_SYM. - /// - public const int DT_MIPS_DELTA_SYM_NO = 0x7000001e; - - /// - /// Delta symbols that hold the - /// class declaration. - /// - public const int DT_MIPS_DELTA_CLASSSYM = 0x70000020; - - /// - /// Number of entries in - /// DT_MIPS_DELTA_CLASSSYM. - /// - public const int DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021; - - /// - /// Flags indicating for C++ flavor. - /// - public const int DT_MIPS_CXX_FLAGS = 0x70000022; - - public const int DT_MIPS_PIXIE_INIT = 0x70000023; - - public const int DT_MIPS_SYMBOL_LIB = 0x70000024; - - public const int DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025; - - public const int DT_MIPS_LOCAL_GOTIDX = 0x70000026; - - public const int DT_MIPS_HIDDEN_GOTIDX = 0x70000027; - - public const int DT_MIPS_PROTECTED_GOTIDX = 0x70000028; - - /// - /// Address of .options. - /// - public const int DT_MIPS_OPTIONS = 0x70000029; - - /// - /// Address of .interface. - /// - public const int DT_MIPS_INTERFACE = 0x7000002a; - - public const int DT_MIPS_DYNSTR_ALIGN = 0x7000002b; - - /// - /// Size of the .interface section. - /// - public const int DT_MIPS_INTERFACE_SIZE = 0x7000002c; - - /// - /// Address of rld_text_rsolve - /// function stored in GOT. - /// - public const int DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d; - - /// - /// Default suffix of dso to be added - /// by rld on dlopen() calls. - /// - public const int DT_MIPS_PERF_SUFFIX = 0x7000002e; - - /// - /// (O32)Size of compact rel section. - /// - public const int DT_MIPS_COMPACT_SIZE = 0x7000002f; - - /// - /// GP value for aux GOTs. - /// - public const int DT_MIPS_GP_VALUE = 0x70000030; - - /// - /// Address of aux .dynamic. - /// - public const int DT_MIPS_AUX_DYNAMIC = 0x70000031; - - public const int DT_MIPS_PLTGOT = 0x70000032; - - public const int DT_MIPS_RWPLT = 0x70000034; - - public const int DT_MIPS_RLD_MAP_REL = 0x70000035; - - public const int DT_MIPS_NUM = 0x36; - - /// - /// Trap nil pointer dereference. - /// - public const uint EF_PARISC_TRAPNIL = 65536; - - /// - /// Program uses arch. extensions. - /// - public const uint EF_PARISC_EXT = 131072; - - /// - /// Program expects little endian. - /// - public const uint EF_PARISC_LSB = 262144; - - /// - /// Program expects wide mode. - /// - public const uint EF_PARISC_WIDE = 524288; - - /// - /// No kernel assisted branch - /// prediction. - /// - public const uint EF_PARISC_NO_KABP = 1048576; - - /// - /// Allow lazy swapping. - /// - public const uint EF_PARISC_LAZYSWAP = 4194304; - - /// - /// Architecture version. - /// - public const uint EF_PARISC_ARCH = 65535; - - /// - /// Section for tenatively declared - /// symbols in ANSI C. - /// - public const uint SHN_PARISC_ANSI_COMMON = 65280; - - /// - /// Common blocks in huge model. - /// - public const uint SHN_PARISC_HUGE_COMMON = 65281; - - /// - /// Contains product specific ext. - /// - public const uint SHT_PARISC_EXT = 1879048192; - - /// - /// Unwind information. - /// - public const uint SHT_PARISC_UNWIND = 1879048193; - - /// - /// Debug info for optimized code. - /// - public const uint SHT_PARISC_DOC = 1879048194; - - /// - /// Section with short addressing. - /// - public const uint SHF_PARISC_SHORT = 536870912; - - /// - /// Section far from gp. - /// - public const uint SHF_PARISC_HUGE = 1073741824; - - /// - /// Static branch prediction code. - /// - public const uint SHF_PARISC_SBP = 0x80000000; - - /// - /// Millicode function entry point. - /// - public const byte STT_PARISC_MILLICODE = 13; - - public const byte STT_HP_OPAQUE = 11; - - public const byte STT_HP_STUB = 12; - - /// - /// No reloc. - /// - public const uint R_PARISC_NONE = 0; - - /// - /// Direct 32-bit reference. - /// - public const uint R_PARISC_DIR32 = 1; - - /// - /// Left 21 bits of eff. address. - /// - public const uint R_PARISC_DIR21L = 2; - - /// - /// Right 17 bits of eff. address. - /// - public const uint R_PARISC_DIR17R = 3; - - /// - /// 17 bits of eff. address. - /// - public const uint R_PARISC_DIR17F = 4; - - /// - /// Right 14 bits of eff. address. - /// - public const uint R_PARISC_DIR14R = 6; - - /// - /// 32-bit rel. address. - /// - public const uint R_PARISC_PCREL32 = 9; - - /// - /// Left 21 bits of rel. address. - /// - public const uint R_PARISC_PCREL21L = 10; - - /// - /// Right 17 bits of rel. address. - /// - public const uint R_PARISC_PCREL17R = 11; - - /// - /// 17 bits of rel. address. - /// - public const uint R_PARISC_PCREL17F = 12; - - /// - /// Right 14 bits of rel. address. - /// - public const uint R_PARISC_PCREL14R = 14; - - /// - /// Left 21 bits of rel. address. - /// - public const uint R_PARISC_DPREL21L = 18; - - /// - /// Right 14 bits of rel. address. - /// - public const uint R_PARISC_DPREL14R = 22; - - /// - /// GP-relative, left 21 bits. - /// - public const uint R_PARISC_GPREL21L = 26; - - /// - /// GP-relative, right 14 bits. - /// - public const uint R_PARISC_GPREL14R = 30; - - /// - /// LT-relative, left 21 bits. - /// - public const uint R_PARISC_LTOFF21L = 34; - - /// - /// LT-relative, right 14 bits. - /// - public const uint R_PARISC_LTOFF14R = 38; - - /// - /// 32 bits section rel. address. - /// - public const uint R_PARISC_SECREL32 = 41; - - /// - /// No relocation, set segment base. - /// - public const uint R_PARISC_SEGBASE = 48; - - /// - /// 32 bits segment rel. address. - /// - public const uint R_PARISC_SEGREL32 = 49; - - /// - /// PLT rel. address, left 21 bits. - /// - public const uint R_PARISC_PLTOFF21L = 50; - - /// - /// PLT rel. address, right 14 bits. - /// - public const uint R_PARISC_PLTOFF14R = 54; - - /// - /// 32 bits LT-rel. function pointer. - /// - public const uint R_PARISC_LTOFF_FPTR32 = 57; - - /// - /// LT-rel. fct ptr, left 21 bits. - /// - public const uint R_PARISC_LTOFF_FPTR21L = 58; - - /// - /// LT-rel. fct ptr, right 14 bits. - /// - public const uint R_PARISC_LTOFF_FPTR14R = 62; - - /// - /// 64 bits function address. - /// - public const uint R_PARISC_FPTR64 = 64; - - /// - /// 32 bits function address. - /// - public const uint R_PARISC_PLABEL32 = 65; - - /// - /// Left 21 bits of fdesc address. - /// - public const uint R_PARISC_PLABEL21L = 66; - - /// - /// Right 14 bits of fdesc address. - /// - public const uint R_PARISC_PLABEL14R = 70; - - /// - /// 64 bits PC-rel. address. - /// - public const uint R_PARISC_PCREL64 = 72; - - /// - /// 22 bits PC-rel. address. - /// - public const uint R_PARISC_PCREL22F = 74; - - /// - /// PC-rel. address, right 14 bits. - /// - public const uint R_PARISC_PCREL14WR = 75; - - /// - /// PC rel. address, right 14 bits. - /// - public const uint R_PARISC_PCREL14DR = 76; - - /// - /// 16 bits PC-rel. address. - /// - public const uint R_PARISC_PCREL16F = 77; - - /// - /// 16 bits PC-rel. address. - /// - public const uint R_PARISC_PCREL16WF = 78; - - /// - /// 16 bits PC-rel. address. - /// - public const uint R_PARISC_PCREL16DF = 79; - - /// - /// 64 bits of eff. address. - /// - public const uint R_PARISC_DIR64 = 80; - - /// - /// 14 bits of eff. address. - /// - public const uint R_PARISC_DIR14WR = 83; - - /// - /// 14 bits of eff. address. - /// - public const uint R_PARISC_DIR14DR = 84; - - /// - /// 16 bits of eff. address. - /// - public const uint R_PARISC_DIR16F = 85; - - /// - /// 16 bits of eff. address. - /// - public const uint R_PARISC_DIR16WF = 86; - - /// - /// 16 bits of eff. address. - /// - public const uint R_PARISC_DIR16DF = 87; - - /// - /// 64 bits of GP-rel. address. - /// - public const uint R_PARISC_GPREL64 = 88; - - /// - /// GP-rel. address, right 14 bits. - /// - public const uint R_PARISC_GPREL14WR = 91; - - /// - /// GP-rel. address, right 14 bits. - /// - public const uint R_PARISC_GPREL14DR = 92; - - /// - /// 16 bits GP-rel. address. - /// - public const uint R_PARISC_GPREL16F = 93; - - /// - /// 16 bits GP-rel. address. - /// - public const uint R_PARISC_GPREL16WF = 94; - - /// - /// 16 bits GP-rel. address. - /// - public const uint R_PARISC_GPREL16DF = 95; - - /// - /// 64 bits LT-rel. address. - /// - public const uint R_PARISC_LTOFF64 = 96; - - /// - /// LT-rel. address, right 14 bits. - /// - public const uint R_PARISC_LTOFF14WR = 99; - - /// - /// LT-rel. address, right 14 bits. - /// - public const uint R_PARISC_LTOFF14DR = 100; - - /// - /// 16 bits LT-rel. address. - /// - public const uint R_PARISC_LTOFF16F = 101; - - /// - /// 16 bits LT-rel. address. - /// - public const uint R_PARISC_LTOFF16WF = 102; - - /// - /// 16 bits LT-rel. address. - /// - public const uint R_PARISC_LTOFF16DF = 103; - - /// - /// 64 bits section rel. address. - /// - public const uint R_PARISC_SECREL64 = 104; - - /// - /// 64 bits segment rel. address. - /// - public const uint R_PARISC_SEGREL64 = 112; - - /// - /// PLT-rel. address, right 14 bits. - /// - public const uint R_PARISC_PLTOFF14WR = 115; - - /// - /// PLT-rel. address, right 14 bits. - /// - public const uint R_PARISC_PLTOFF14DR = 116; - - /// - /// 16 bits LT-rel. address. - /// - public const uint R_PARISC_PLTOFF16F = 117; - - /// - /// 16 bits PLT-rel. address. - /// - public const uint R_PARISC_PLTOFF16WF = 118; - - /// - /// 16 bits PLT-rel. address. - /// - public const uint R_PARISC_PLTOFF16DF = 119; - - /// - /// 64 bits LT-rel. function ptr. - /// - public const uint R_PARISC_LTOFF_FPTR64 = 120; - - /// - /// LT-rel. fct. ptr., right 14 bits. - /// - public const uint R_PARISC_LTOFF_FPTR14WR = 123; - - /// - /// LT-rel. fct. ptr., right 14 bits. - /// - public const uint R_PARISC_LTOFF_FPTR14DR = 124; - - /// - /// 16 bits LT-rel. function ptr. - /// - public const uint R_PARISC_LTOFF_FPTR16F = 125; - - /// - /// 16 bits LT-rel. function ptr. - /// - public const uint R_PARISC_LTOFF_FPTR16WF = 126; - - /// - /// 16 bits LT-rel. function ptr. - /// - public const uint R_PARISC_LTOFF_FPTR16DF = 127; - - public const uint R_PARISC_LORESERVE = 128; - - /// - /// Copy relocation. - /// - public const uint R_PARISC_COPY = 128; - - /// - /// Dynamic reloc, imported PLT - /// - public const uint R_PARISC_IPLT = 129; - - /// - /// Dynamic reloc, exported PLT - /// - public const uint R_PARISC_EPLT = 130; - - /// - /// 32 bits TP-rel. address. - /// - public const uint R_PARISC_TPREL32 = 153; - - /// - /// TP-rel. address, left 21 bits. - /// - public const uint R_PARISC_TPREL21L = 154; - - /// - /// TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_TPREL14R = 158; - - /// - /// LT-TP-rel. address, left 21 bits. - /// - public const uint R_PARISC_LTOFF_TP21L = 162; - - /// - /// LT-TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_LTOFF_TP14R = 166; - - /// - /// 14 bits LT-TP-rel. address. - /// - public const uint R_PARISC_LTOFF_TP14F = 167; - - /// - /// 64 bits TP-rel. address. - /// - public const uint R_PARISC_TPREL64 = 216; - - /// - /// TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_TPREL14WR = 219; - - /// - /// TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_TPREL14DR = 220; - - /// - /// 16 bits TP-rel. address. - /// - public const uint R_PARISC_TPREL16F = 221; - - /// - /// 16 bits TP-rel. address. - /// - public const uint R_PARISC_TPREL16WF = 222; - - /// - /// 16 bits TP-rel. address. - /// - public const uint R_PARISC_TPREL16DF = 223; - - /// - /// 64 bits LT-TP-rel. address. - /// - public const uint R_PARISC_LTOFF_TP64 = 224; - - /// - /// LT-TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_LTOFF_TP14WR = 227; - - /// - /// LT-TP-rel. address, right 14 bits. - /// - public const uint R_PARISC_LTOFF_TP14DR = 228; - - /// - /// 16 bits LT-TP-rel. address. - /// - public const uint R_PARISC_LTOFF_TP16F = 229; - - /// - /// 16 bits LT-TP-rel. address. - /// - public const uint R_PARISC_LTOFF_TP16WF = 230; - - /// - /// 16 bits LT-TP-rel. address. - /// - public const uint R_PARISC_LTOFF_TP16DF = 231; - - public const uint R_PARISC_GNU_VTENTRY = 232; - - public const uint R_PARISC_GNU_VTINHERIT = 233; - - /// - /// GD 21-bit left. - /// - public const uint R_PARISC_TLS_GD21L = 234; - - /// - /// GD 14-bit right. - /// - public const uint R_PARISC_TLS_GD14R = 235; - - /// - /// GD call to __t_g_a. - /// - public const uint R_PARISC_TLS_GDCALL = 236; - - /// - /// LD module 21-bit left. - /// - public const uint R_PARISC_TLS_LDM21L = 237; - - /// - /// LD module 14-bit right. - /// - public const uint R_PARISC_TLS_LDM14R = 238; - - /// - /// LD module call to __t_g_a. - /// - public const uint R_PARISC_TLS_LDMCALL = 239; - - /// - /// LD offset 21-bit left. - /// - public const uint R_PARISC_TLS_LDO21L = 240; - - /// - /// LD offset 14-bit right. - /// - public const uint R_PARISC_TLS_LDO14R = 241; - - /// - /// DTP module 32-bit. - /// - public const uint R_PARISC_TLS_DTPMOD32 = 242; - - /// - /// DTP module 64-bit. - /// - public const uint R_PARISC_TLS_DTPMOD64 = 243; - - /// - /// DTP offset 32-bit. - /// - public const uint R_PARISC_TLS_DTPOFF32 = 244; - - /// - /// DTP offset 32-bit. - /// - public const uint R_PARISC_TLS_DTPOFF64 = 245; - - public const uint R_PARISC_TLS_LE21L = 154; - - public const uint R_PARISC_TLS_LE14R = 158; - - public const uint R_PARISC_TLS_IE21L = 162; - - public const uint R_PARISC_TLS_IE14R = 166; - - public const uint R_PARISC_TLS_TPREL32 = 153; - - public const uint R_PARISC_TLS_TPREL64 = 216; - - public const uint R_PARISC_HIRESERVE = 255; - - public const uint PT_HP_TLS = 1610612736; - - public const uint PT_HP_CORE_NONE = 1610612737; - - public const uint PT_HP_CORE_VERSION = 1610612738; - - public const uint PT_HP_CORE_KERNEL = 1610612739; - - public const uint PT_HP_CORE_COMM = 1610612740; - - public const uint PT_HP_CORE_PROC = 1610612741; - - public const uint PT_HP_CORE_LOADABLE = 1610612742; - - public const uint PT_HP_CORE_STACK = 1610612743; - - public const uint PT_HP_CORE_SHM = 1610612744; - - public const uint PT_HP_CORE_MMF = 1610612745; - - public const uint PT_HP_PARALLEL = 1610612752; - - public const uint PT_HP_FASTBIND = 1610612753; - - public const uint PT_HP_OPT_ANNOT = 1610612754; - - public const uint PT_HP_HSL_ANNOT = 1610612755; - - public const uint PT_HP_STACK = 1610612756; - - public const uint PT_PARISC_ARCHEXT = 1879048192; - - public const uint PT_PARISC_UNWIND = 1879048193; - - public const uint PF_PARISC_SBP = 134217728; - - public const uint PF_HP_PAGE_SIZE = 1048576; - - public const uint PF_HP_FAR_SHARED = 2097152; - - public const uint PF_HP_NEAR_SHARED = 4194304; - - public const uint PF_HP_CODE = 16777216; - - public const uint PF_HP_MODIFY = 33554432; - - public const uint PF_HP_LAZYSWAP = 67108864; - - public const uint PF_HP_SBP = 134217728; - - /// - /// All addresses must be - /// < - /// 2GB. - /// - public const uint EF_ALPHA_32BIT = 1; - - /// - /// Relocations for relaxing exist. - /// - public const uint EF_ALPHA_CANRELAX = 2; - - public const uint SHT_ALPHA_DEBUG = 1879048193; - - public const uint SHT_ALPHA_REGINFO = 1879048194; - - public const uint SHF_ALPHA_GPREL = 268435456; - - /// - /// No reloc - /// - public const uint R_ALPHA_NONE = 0; - - /// - /// Direct 32 bit - /// - public const uint R_ALPHA_REFLONG = 1; - - /// - /// Direct 64 bit - /// - public const uint R_ALPHA_REFQUAD = 2; - - /// - /// GP relative 32 bit - /// - public const uint R_ALPHA_GPREL32 = 3; - - /// - /// GP relative 16 bit w/optimization - /// - public const uint R_ALPHA_LITERAL = 4; - - /// - /// Optimization hint for LITERAL - /// - public const uint R_ALPHA_LITUSE = 5; - - /// - /// Add displacement to GP - /// - public const uint R_ALPHA_GPDISP = 6; - - /// - /// PC+4 relative 23 bit shifted - /// - public const uint R_ALPHA_BRADDR = 7; - - /// - /// PC+4 relative 16 bit shifted - /// - public const uint R_ALPHA_HINT = 8; - - /// - /// PC relative 16 bit - /// - public const uint R_ALPHA_SREL16 = 9; - - /// - /// PC relative 32 bit - /// - public const uint R_ALPHA_SREL32 = 10; - - /// - /// PC relative 64 bit - /// - public const uint R_ALPHA_SREL64 = 11; - - /// - /// GP relative 32 bit, high 16 bits - /// - public const uint R_ALPHA_GPRELHIGH = 17; - - /// - /// GP relative 32 bit, low 16 bits - /// - public const uint R_ALPHA_GPRELLOW = 18; - - /// - /// GP relative 16 bit - /// - public const uint R_ALPHA_GPREL16 = 19; - - /// - /// Copy symbol at runtime - /// - public const uint R_ALPHA_COPY = 24; - - /// - /// Create GOT entry - /// - public const uint R_ALPHA_GLOB_DAT = 25; - - /// - /// Create PLT entry - /// - public const uint R_ALPHA_JMP_SLOT = 26; - - /// - /// Adjust by program base - /// - public const uint R_ALPHA_RELATIVE = 27; - - public const uint R_ALPHA_TLS_GD_HI = 28; - - public const uint R_ALPHA_TLSGD = 29; - - public const uint R_ALPHA_TLS_LDM = 30; - - public const uint R_ALPHA_DTPMOD64 = 31; - - public const uint R_ALPHA_GOTDTPREL = 32; - - public const uint R_ALPHA_DTPREL64 = 33; - - public const uint R_ALPHA_DTPRELHI = 34; - - public const uint R_ALPHA_DTPRELLO = 35; - - public const uint R_ALPHA_DTPREL16 = 36; - - public const uint R_ALPHA_GOTTPREL = 37; - - public const uint R_ALPHA_TPREL64 = 38; - - public const uint R_ALPHA_TPRELHI = 39; - - public const uint R_ALPHA_TPRELLO = 40; - - public const uint R_ALPHA_TPREL16 = 41; - - public const uint R_ALPHA_NUM = 46; - - public const int DT_ALPHA_PLTRO = ( 0); - - public const int DT_ALPHA_NUM = 1; - - /// - /// PowerPC embedded flag - /// - public const uint EF_PPC_EMB = 0x80000000; - - /// - /// PowerPC -mrelocatable flag - /// - public const uint EF_PPC_RELOCATABLE = 65536; - - /// - /// PowerPC -mrelocatable-lib - /// flag - /// - public const uint EF_PPC_RELOCATABLE_LIB = 32768; - - public const uint R_PPC_NONE = 0; - - /// - /// 32bit absolute address - /// - public const uint R_PPC_ADDR32 = 1; - - /// - /// 26bit address, 2 bits ignored. - /// - public const uint R_PPC_ADDR24 = 2; - - /// - /// 16bit absolute address - /// - public const uint R_PPC_ADDR16 = 3; - - /// - /// lower 16bit of absolute address - /// - public const uint R_PPC_ADDR16_LO = 4; - - /// - /// high 16bit of absolute address - /// - public const uint R_PPC_ADDR16_HI = 5; - - /// - /// adjusted high 16bit - /// - public const uint R_PPC_ADDR16_HA = 6; - - /// - /// 16bit address, 2 bits ignored - /// - public const uint R_PPC_ADDR14 = 7; - - public const uint R_PPC_ADDR14_BRTAKEN = 8; - - public const uint R_PPC_ADDR14_BRNTAKEN = 9; - - /// - /// PC relative 26 bit - /// - public const uint R_PPC_REL24 = 10; - - /// - /// PC relative 16 bit - /// - public const uint R_PPC_REL14 = 11; - - public const uint R_PPC_REL14_BRTAKEN = 12; - - public const uint R_PPC_REL14_BRNTAKEN = 13; - - public const uint R_PPC_GOT16 = 14; - - public const uint R_PPC_GOT16_LO = 15; - - public const uint R_PPC_GOT16_HI = 16; - - public const uint R_PPC_GOT16_HA = 17; - - public const uint R_PPC_PLTREL24 = 18; - - public const uint R_PPC_COPY = 19; - - public const uint R_PPC_GLOB_DAT = 20; - - public const uint R_PPC_JMP_SLOT = 21; - - public const uint R_PPC_RELATIVE = 22; - - public const uint R_PPC_LOCAL24PC = 23; - - public const uint R_PPC_UADDR32 = 24; - - public const uint R_PPC_UADDR16 = 25; - - public const uint R_PPC_REL32 = 26; - - public const uint R_PPC_PLT32 = 27; - - public const uint R_PPC_PLTREL32 = 28; - - public const uint R_PPC_PLT16_LO = 29; - - public const uint R_PPC_PLT16_HI = 30; - - public const uint R_PPC_PLT16_HA = 31; - - public const uint R_PPC_SDAREL16 = 32; - - public const uint R_PPC_SECTOFF = 33; - - public const uint R_PPC_SECTOFF_LO = 34; - - public const uint R_PPC_SECTOFF_HI = 35; - - public const uint R_PPC_SECTOFF_HA = 36; - - /// - /// none (sym+add)@tls - /// - public const uint R_PPC_TLS = 67; - - /// - /// word32 (sym+add)@dtpmod - /// - public const uint R_PPC_DTPMOD32 = 68; - - /// - /// half16* (sym+add)@tprel - /// - public const uint R_PPC_TPREL16 = 69; - - /// - /// half16 (sym+add)@tprel @l - /// - public const uint R_PPC_TPREL16_LO = 70; - - /// - /// half16 (sym+add)@tprel @h - /// - public const uint R_PPC_TPREL16_HI = 71; - - /// - /// half16 (sym+add)@tprel @ha - /// - public const uint R_PPC_TPREL16_HA = 72; - - /// - /// word32 (sym+add)@tprel - /// - public const uint R_PPC_TPREL32 = 73; - - /// - /// half16* (sym+add)@dtprel - /// - public const uint R_PPC_DTPREL16 = 74; - - /// - /// half16 (sym+add)@dtprel @l - /// - public const uint R_PPC_DTPREL16_LO = 75; - - /// - /// half16 (sym+add)@dtprel @h - /// - public const uint R_PPC_DTPREL16_HI = 76; - - /// - /// half16 (sym+add)@dtprel @ha - /// - public const uint R_PPC_DTPREL16_HA = 77; - - /// - /// word32 (sym+add)@dtprel - /// - public const uint R_PPC_DTPREL32 = 78; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @tlsgd - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSGD16 = 79; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@l - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSGD16_LO = 80; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@h - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSGD16_HI = 81; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@ha - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSGD16_HA = 82; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @tlsld - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSLD16 = 83; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@l - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSLD16_LO = 84; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@h - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSLD16_HI = 85; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@ha - /// - /// @enddot - /// - public const uint R_PPC_GOT_TLSLD16_HA = 86; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @tprel - /// - /// @enddot - /// - public const uint R_PPC_GOT_TPREL16 = 87; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tprel@l - /// - /// @enddot - /// - public const uint R_PPC_GOT_TPREL16_LO = 88; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tprel@h - /// - /// @enddot - /// - public const uint R_PPC_GOT_TPREL16_HI = 89; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tprel@ha - /// - /// @enddot - /// - public const uint R_PPC_GOT_TPREL16_HA = 90; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @dtprel - /// - /// @enddot - /// - public const uint R_PPC_GOT_DTPREL16 = 91; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @dtprel@l - /// - /// @enddot - /// - public const uint R_PPC_GOT_DTPREL16_LO = 92; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @dtprel@h - /// - /// @enddot - /// - public const uint R_PPC_GOT_DTPREL16_HI = 93; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @dtprel@ha - /// - /// @enddot - /// - public const uint R_PPC_GOT_DTPREL16_HA = 94; - - /// - /// none (sym+add)@tlsgd - /// - public const uint R_PPC_TLSGD = 95; - - /// - /// none (sym+add)@tlsld - /// - public const uint R_PPC_TLSLD = 96; - - public const uint R_PPC_EMB_NADDR32 = 101; - - public const uint R_PPC_EMB_NADDR16 = 102; - - public const uint R_PPC_EMB_NADDR16_LO = 103; - - public const uint R_PPC_EMB_NADDR16_HI = 104; - - public const uint R_PPC_EMB_NADDR16_HA = 105; - - public const uint R_PPC_EMB_SDAI16 = 106; - - public const uint R_PPC_EMB_SDA2I16 = 107; - - public const uint R_PPC_EMB_SDA2REL = 108; - - /// - /// 16 bit offset in SDA - /// - public const uint R_PPC_EMB_SDA21 = 109; - - public const uint R_PPC_EMB_MRKREF = 110; - - public const uint R_PPC_EMB_RELSEC16 = 111; - - public const uint R_PPC_EMB_RELST_LO = 112; - - public const uint R_PPC_EMB_RELST_HI = 113; - - public const uint R_PPC_EMB_RELST_HA = 114; - - public const uint R_PPC_EMB_BIT_FLD = 115; - - /// - /// 16 bit relative offset in SDA - /// - public const uint R_PPC_EMB_RELSDA = 116; - - /// - /// like EMB_SDA21, but lower 16 bit - /// - public const uint R_PPC_DIAB_SDA21_LO = 180; - - /// - /// like EMB_SDA21, but high 16 bit - /// - public const uint R_PPC_DIAB_SDA21_HI = 181; - - /// - /// like EMB_SDA21, adjusted high 16 - /// - public const uint R_PPC_DIAB_SDA21_HA = 182; - - /// - /// like EMB_RELSDA, but lower 16 bit - /// - public const uint R_PPC_DIAB_RELSDA_LO = 183; - - /// - /// like EMB_RELSDA, but high 16 bit - /// - public const uint R_PPC_DIAB_RELSDA_HI = 184; - - /// - /// like EMB_RELSDA, adjusted high 16 - /// - public const uint R_PPC_DIAB_RELSDA_HA = 185; - - public const uint R_PPC_IRELATIVE = 248; - - /// - /// half16 (sym+add-.) - /// - public const uint R_PPC_REL16 = 249; - - /// - /// half16 (sym+add-.)@l - /// - public const uint R_PPC_REL16_LO = 250; - - /// - /// half16 (sym+add-.)@h - /// - public const uint R_PPC_REL16_HI = 251; - - /// - /// half16 (sym+add-.)@ha - /// - public const uint R_PPC_REL16_HA = 252; - - public const uint R_PPC_TOC16 = 255; - - public const int DT_PPC_GOT = ( 0); - - public const int DT_PPC_OPT = ( 1); - - public const int DT_PPC_NUM = 2; - - public const uint R_PPC64_NONE = 0; - - /// - /// 32bit absolute address - /// - public const uint R_PPC64_ADDR32 = 1; - - /// - /// 26bit address, word aligned - /// - public const uint R_PPC64_ADDR24 = 2; - - /// - /// 16bit absolute address - /// - public const uint R_PPC64_ADDR16 = 3; - - /// - /// lower 16bits of address - /// - public const uint R_PPC64_ADDR16_LO = 4; - - /// - /// high 16bits of address. - /// - public const uint R_PPC64_ADDR16_HI = 5; - - /// - /// adjusted high 16bits. - /// - public const uint R_PPC64_ADDR16_HA = 6; - - /// - /// 16bit address, word aligned - /// - public const uint R_PPC64_ADDR14 = 7; - - public const uint R_PPC64_ADDR14_BRTAKEN = 8; - - public const uint R_PPC64_ADDR14_BRNTAKEN = 9; - - /// - /// PC-rel. 26 bit, word aligned - /// - public const uint R_PPC64_REL24 = 10; - - /// - /// PC relative 16 bit - /// - public const uint R_PPC64_REL14 = 11; - - public const uint R_PPC64_REL14_BRTAKEN = 12; - - public const uint R_PPC64_REL14_BRNTAKEN = 13; - - public const uint R_PPC64_GOT16 = 14; - - public const uint R_PPC64_GOT16_LO = 15; - - public const uint R_PPC64_GOT16_HI = 16; - - public const uint R_PPC64_GOT16_HA = 17; - - public const uint R_PPC64_COPY = 19; - - public const uint R_PPC64_GLOB_DAT = 20; - - public const uint R_PPC64_JMP_SLOT = 21; - - public const uint R_PPC64_RELATIVE = 22; - - public const uint R_PPC64_UADDR32 = 24; - - public const uint R_PPC64_UADDR16 = 25; - - public const uint R_PPC64_REL32 = 26; - - public const uint R_PPC64_PLT32 = 27; - - public const uint R_PPC64_PLTREL32 = 28; - - public const uint R_PPC64_PLT16_LO = 29; - - public const uint R_PPC64_PLT16_HI = 30; - - public const uint R_PPC64_PLT16_HA = 31; - - public const uint R_PPC64_SECTOFF = 33; - - public const uint R_PPC64_SECTOFF_LO = 34; - - public const uint R_PPC64_SECTOFF_HI = 35; - - public const uint R_PPC64_SECTOFF_HA = 36; - - /// - /// word30 (S + A - P) >> 2 - /// - public const uint R_PPC64_ADDR30 = 37; - - /// - /// doubleword64 S + A - /// - public const uint R_PPC64_ADDR64 = 38; - - /// - /// half16 #higher(S + A) - /// - public const uint R_PPC64_ADDR16_HIGHER = 39; - - /// - /// half16 #highera(S + A) - /// - public const uint R_PPC64_ADDR16_HIGHERA = 40; - - /// - /// half16 #highest(S + A) - /// - public const uint R_PPC64_ADDR16_HIGHEST = 41; - - /// - /// half16 #highesta(S + A) - /// - public const uint R_PPC64_ADDR16_HIGHESTA = 42; - - /// - /// doubleword64 S + A - /// - public const uint R_PPC64_UADDR64 = 43; - - /// - /// doubleword64 S + A - P - /// - public const uint R_PPC64_REL64 = 44; - - /// - /// doubleword64 L + A - /// - public const uint R_PPC64_PLT64 = 45; - - /// - /// doubleword64 L + A - P - /// - public const uint R_PPC64_PLTREL64 = 46; - - /// - /// half16* S + A - .TOC - /// - public const uint R_PPC64_TOC16 = 47; - - /// - /// half16 #lo(S + A - .TOC.) - /// - public const uint R_PPC64_TOC16_LO = 48; - - /// - /// half16 #hi(S + A - .TOC.) - /// - public const uint R_PPC64_TOC16_HI = 49; - - /// - /// half16 #ha(S + A - .TOC.) - /// - public const uint R_PPC64_TOC16_HA = 50; - - /// - /// doubleword64 .TOC - /// - public const uint R_PPC64_TOC = 51; - - /// - /// half16* M + A - /// - public const uint R_PPC64_PLTGOT16 = 52; - - /// - /// half16 #lo(M + A) - /// - public const uint R_PPC64_PLTGOT16_LO = 53; - - /// - /// half16 #hi(M + A) - /// - public const uint R_PPC64_PLTGOT16_HI = 54; - - /// - /// half16 #ha(M + A) - /// - public const uint R_PPC64_PLTGOT16_HA = 55; - - /// - /// half16ds* (S + A) >> 2 - /// - public const uint R_PPC64_ADDR16_DS = 56; - - /// - /// half16ds #lo(S + A) >> 2 - /// - public const uint R_PPC64_ADDR16_LO_DS = 57; - - /// - /// half16ds* (G + A) >> 2 - /// - public const uint R_PPC64_GOT16_DS = 58; - - /// - /// half16ds #lo(G + A) >> 2 - /// - public const uint R_PPC64_GOT16_LO_DS = 59; - - /// - /// half16ds #lo(L + A) >> 2 - /// - public const uint R_PPC64_PLT16_LO_DS = 60; - - /// - /// half16ds* (R + A) >> 2 - /// - public const uint R_PPC64_SECTOFF_DS = 61; - - /// - /// half16ds #lo(R + A) >> 2 - /// - public const uint R_PPC64_SECTOFF_LO_DS = 62; - - /// - /// half16ds* (S + A - .TOC.) >> 2 - /// - public const uint R_PPC64_TOC16_DS = 63; - - /// - /// half16ds #lo(S + A - .TOC.) >> 2 - /// - public const uint R_PPC64_TOC16_LO_DS = 64; - - /// - /// half16ds* (M + A) >> 2 - /// - public const uint R_PPC64_PLTGOT16_DS = 65; - - /// - /// half16ds #lo(M + A) >> 2 - /// - public const uint R_PPC64_PLTGOT16_LO_DS = 66; - - /// - /// none (sym+add)@tls - /// - public const uint R_PPC64_TLS = 67; - - /// - /// doubleword64 (sym+add)@dtpmod - /// - public const uint R_PPC64_DTPMOD64 = 68; - - /// - /// half16* (sym+add)@tprel - /// - public const uint R_PPC64_TPREL16 = 69; - - /// - /// half16 (sym+add)@tprel @l - /// - public const uint R_PPC64_TPREL16_LO = 70; - - /// - /// half16 (sym+add)@tprel @h - /// - public const uint R_PPC64_TPREL16_HI = 71; - - /// - /// half16 (sym+add)@tprel @ha - /// - public const uint R_PPC64_TPREL16_HA = 72; - - /// - /// doubleword64 (sym+add)@tprel - /// - public const uint R_PPC64_TPREL64 = 73; - - /// - /// half16* (sym+add)@dtprel - /// - public const uint R_PPC64_DTPREL16 = 74; - - /// - /// half16 (sym+add)@dtprel @l - /// - public const uint R_PPC64_DTPREL16_LO = 75; - - /// - /// half16 (sym+add)@dtprel @h - /// - public const uint R_PPC64_DTPREL16_HI = 76; - - /// - /// half16 (sym+add)@dtprel @ha - /// - public const uint R_PPC64_DTPREL16_HA = 77; - - /// - /// doubleword64 (sym+add)@dtprel - /// - public const uint R_PPC64_DTPREL64 = 78; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @tlsgd - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSGD16 = 79; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@l - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSGD16_LO = 80; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@h - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSGD16_HI = 81; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsgd@ha - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSGD16_HA = 82; - - /// - /// half16* (sym+add) - /// - /// - /// @dot @tlsld - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSLD16 = 83; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@l - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSLD16_LO = 84; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@h - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSLD16_HI = 85; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tlsld@ha - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TLSLD16_HA = 86; - - /// - /// half16ds* (sym+add) - /// - /// - /// @dot @tprel - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TPREL16_DS = 87; - - /// - /// half16ds (sym+add) - /// - /// - /// @dot @tprel@l - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TPREL16_LO_DS = 88; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tprel@h - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TPREL16_HI = 89; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @tprel@ha - /// - /// @enddot - /// - public const uint R_PPC64_GOT_TPREL16_HA = 90; - - /// - /// half16ds* (sym+add) - /// - /// - /// @dot @dtprel - /// - /// @enddot - /// - public const uint R_PPC64_GOT_DTPREL16_DS = 91; - - /// - /// half16ds (sym+add) - /// - /// - /// @dot @dtprel@l - /// - /// @enddot - /// - public const uint R_PPC64_GOT_DTPREL16_LO_DS = 92; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @dtprel@h - /// - /// @enddot - /// - public const uint R_PPC64_GOT_DTPREL16_HI = 93; - - /// - /// half16 (sym+add) - /// - /// - /// @dot @dtprel@ha - /// - /// @enddot - /// - public const uint R_PPC64_GOT_DTPREL16_HA = 94; - - /// - /// half16ds* (sym+add)@tprel - /// - public const uint R_PPC64_TPREL16_DS = 95; - - /// - /// half16ds (sym+add)@tprel @l - /// - public const uint R_PPC64_TPREL16_LO_DS = 96; - - /// - /// half16 (sym+add)@tprel @higher - /// - public const uint R_PPC64_TPREL16_HIGHER = 97; - - /// - /// half16 (sym+add)@tprel @highera - /// - public const uint R_PPC64_TPREL16_HIGHERA = 98; - - /// - /// half16 (sym+add)@tprel @highest - /// - public const uint R_PPC64_TPREL16_HIGHEST = 99; - - /// - /// half16 (sym+add)@tprel @highesta - /// - public const uint R_PPC64_TPREL16_HIGHESTA = 100; - - /// - /// half16ds* (sym+add)@dtprel - /// - public const uint R_PPC64_DTPREL16_DS = 101; - - /// - /// half16ds (sym+add)@dtprel @l - /// - public const uint R_PPC64_DTPREL16_LO_DS = 102; - - /// - /// half16 (sym+add)@dtprel @higher - /// - public const uint R_PPC64_DTPREL16_HIGHER = 103; - - /// - /// half16 (sym+add)@dtprel @highera - /// - public const uint R_PPC64_DTPREL16_HIGHERA = 104; - - /// - /// half16 (sym+add)@dtprel @highest - /// - public const uint R_PPC64_DTPREL16_HIGHEST = 105; - - /// - /// half16 (sym+add)@dtprel @highesta - /// - public const uint R_PPC64_DTPREL16_HIGHESTA = 106; - - /// - /// none (sym+add)@tlsgd - /// - public const uint R_PPC64_TLSGD = 107; - - /// - /// none (sym+add)@tlsld - /// - public const uint R_PPC64_TLSLD = 108; - - /// - /// none - /// - public const uint R_PPC64_TOCSAVE = 109; - - public const uint R_PPC64_ADDR16_HIGH = 110; - - public const uint R_PPC64_ADDR16_HIGHA = 111; - - public const uint R_PPC64_TPREL16_HIGH = 112; - - public const uint R_PPC64_TPREL16_HIGHA = 113; - - public const uint R_PPC64_DTPREL16_HIGH = 114; - - public const uint R_PPC64_DTPREL16_HIGHA = 115; - - public const uint R_PPC64_JMP_IREL = 247; - - public const uint R_PPC64_IRELATIVE = 248; - - /// - /// half16 (sym+add-.) - /// - public const uint R_PPC64_REL16 = 249; - - /// - /// half16 (sym+add-.)@l - /// - public const uint R_PPC64_REL16_LO = 250; - - /// - /// half16 (sym+add-.)@h - /// - public const uint R_PPC64_REL16_HI = 251; - - /// - /// half16 (sym+add-.)@ha - /// - public const uint R_PPC64_REL16_HA = 252; - - public const uint EF_PPC64_ABI = 3; - - public const int DT_PPC64_GLINK = ( 0); - - public const int DT_PPC64_OPD = ( 1); - - public const int DT_PPC64_OPDSZ = ( 2); - - public const int DT_PPC64_OPT = ( 3); - - public const int DT_PPC64_NUM = 4; - - public const uint EF_ARM_RELEXEC = 1; - - public const uint EF_ARM_HASENTRY = 2; - - public const uint EF_ARM_INTERWORK = 4; - - public const uint EF_ARM_APCS_26 = 8; - - public const uint EF_ARM_APCS_FLOAT = 16; - - public const uint EF_ARM_PIC = 32; - - /// - /// 8-bit structure alignment is in use - /// - public const uint EF_ARM_ALIGN8 = 64; - - public const uint EF_ARM_NEW_ABI = 128; - - public const uint EF_ARM_OLD_ABI = 256; - - public const uint EF_ARM_SOFT_FLOAT = 512; - - public const uint EF_ARM_VFP_FLOAT = 1024; - - public const uint EF_ARM_MAVERICK_FLOAT = 2048; - - /// - /// NB conflicts with EF_ARM_SOFT_FLOAT - /// - public const uint EF_ARM_ABI_FLOAT_SOFT = 512; - - /// - /// NB conflicts with EF_ARM_VFP_FLOAT - /// - public const uint EF_ARM_ABI_FLOAT_HARD = 1024; - - public const uint EF_ARM_SYMSARESORTED = 4; - - public const uint EF_ARM_DYNSYMSUSESEGIDX = 8; - - public const uint EF_ARM_MAPSYMSFIRST = 16; - - public const uint EF_ARM_EABIMASK = 0XFF000000; - - public const uint EF_ARM_BE8 = 8388608; - - public const uint EF_ARM_LE8 = 4194304; - - public const uint EF_ARM_EABI_UNKNOWN = 0; - - public const uint EF_ARM_EABI_VER1 = 16777216; - - public const uint EF_ARM_EABI_VER2 = 33554432; - - public const uint EF_ARM_EABI_VER3 = 50331648; - - public const uint EF_ARM_EABI_VER4 = 67108864; - - public const uint EF_ARM_EABI_VER5 = 83886080; - - /// - /// A Thumb function. - /// - public const byte STT_ARM_TFUNC = 13; - - /// - /// A Thumb label. - /// - public const byte STT_ARM_16BIT = 15; - - /// - /// Section contains an entry point - /// - public const uint SHF_ARM_ENTRYSECT = 268435456; - - /// - /// Section may be multiply defined - /// in the input to a link step. - /// - public const uint SHF_ARM_COMDEF = 0x80000000; - - /// - /// Segment contains the location - /// addressed by the static base. - /// - public const uint PF_ARM_SB = 268435456; - - /// - /// Position-independent segment. - /// - public const uint PF_ARM_PI = 536870912; - - /// - /// Absolute segment. - /// - public const uint PF_ARM_ABS = 1073741824; - - /// - /// ARM unwind segment. - /// - public const uint PT_ARM_EXIDX = 1879048193; - - /// - /// ARM unwind section. - /// - public const uint SHT_ARM_EXIDX = 1879048193; - - /// - /// Preemption details. - /// - public const uint SHT_ARM_PREEMPTMAP = 1879048194; - - /// - /// ARM attributes section. - /// - public const uint SHT_ARM_ATTRIBUTES = 1879048195; - - /// - /// No relocation. - /// - public const uint R_AARCH64_NONE = 0; - - /// - /// Direct 32 bit. - /// - public const uint R_AARCH64_P32_ABS32 = 1; - - /// - /// Copy symbol at runtime. - /// - public const uint R_AARCH64_P32_COPY = 180; - - /// - /// Create GOT entry. - /// - public const uint R_AARCH64_P32_GLOB_DAT = 181; - - /// - /// Create PLT entry. - /// - public const uint R_AARCH64_P32_JUMP_SLOT = 182; - - /// - /// Adjust by program base. - /// - public const uint R_AARCH64_P32_RELATIVE = 183; - - /// - /// Module number, 32 bit. - /// - public const uint R_AARCH64_P32_TLS_DTPMOD = 184; - - /// - /// Module-relative offset, 32 bit. - /// - public const uint R_AARCH64_P32_TLS_DTPREL = 185; - - /// - /// TP-relative offset, 32 bit. - /// - public const uint R_AARCH64_P32_TLS_TPREL = 186; - - /// - /// TLS Descriptor. - /// - public const uint R_AARCH64_P32_TLSDESC = 187; - - /// - /// STT_GNU_IFUNC relocation. - /// - public const uint R_AARCH64_P32_IRELATIVE = 188; - - /// - /// Direct 64 bit. - /// - public const uint R_AARCH64_ABS64 = 257; - - /// - /// Direct 32 bit. - /// - public const uint R_AARCH64_ABS32 = 258; - - /// - /// Direct 16-bit. - /// - public const uint R_AARCH64_ABS16 = 259; - - /// - /// PC-relative 64-bit. - /// - public const uint R_AARCH64_PREL64 = 260; - - /// - /// PC-relative 32-bit. - /// - public const uint R_AARCH64_PREL32 = 261; - - /// - /// PC-relative 16-bit. - /// - public const uint R_AARCH64_PREL16 = 262; - - /// - /// Dir. MOVZ imm. from bits 15:0. - /// - public const uint R_AARCH64_MOVW_UABS_G0 = 263; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_UABS_G0_NC = 264; - - /// - /// Dir. MOVZ imm. from bits 31:16. - /// - public const uint R_AARCH64_MOVW_UABS_G1 = 265; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_UABS_G1_NC = 266; - - /// - /// Dir. MOVZ imm. from bits 47:32. - /// - public const uint R_AARCH64_MOVW_UABS_G2 = 267; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_UABS_G2_NC = 268; - - /// - /// Dir. MOV{K,Z} imm. from 63:48. - /// - public const uint R_AARCH64_MOVW_UABS_G3 = 269; - - /// - /// Dir. MOV{N,Z} imm. from 15:0. - /// - public const uint R_AARCH64_MOVW_SABS_G0 = 270; - - /// - /// Dir. MOV{N,Z} imm. from 31:16. - /// - public const uint R_AARCH64_MOVW_SABS_G1 = 271; - - /// - /// Dir. MOV{N,Z} imm. from 47:32. - /// - public const uint R_AARCH64_MOVW_SABS_G2 = 272; - - /// - /// PC-rel. LD imm. from bits 20:2. - /// - public const uint R_AARCH64_LD_PREL_LO19 = 273; - - /// - /// PC-rel. ADR imm. from bits 20:0. - /// - public const uint R_AARCH64_ADR_PREL_LO21 = 274; - - /// - /// Page-rel. ADRP imm. from 32:12. - /// - public const uint R_AARCH64_ADR_PREL_PG_HI21 = 275; - - /// - /// Likewise; no overflow check. - /// - public const uint R_AARCH64_ADR_PREL_PG_HI21_NC = 276; - - /// - /// Dir. ADD imm. from bits 11:0. - /// - public const uint R_AARCH64_ADD_ABS_LO12_NC = 277; - - /// - /// Likewise for LD/ST; no check. - /// - public const uint R_AARCH64_LDST8_ABS_LO12_NC = 278; - - /// - /// PC-rel. TBZ/TBNZ imm. from 15:2. - /// - public const uint R_AARCH64_TSTBR14 = 279; - - /// - /// PC-rel. cond. br. imm. from 20:2. - /// - public const uint R_AARCH64_CONDBR19 = 280; - - /// - /// PC-rel. B imm. from bits 27:2. - /// - public const uint R_AARCH64_JUMP26 = 282; - - /// - /// Likewise for CALL. - /// - public const uint R_AARCH64_CALL26 = 283; - - /// - /// Dir. ADD imm. from bits 11:1. - /// - public const uint R_AARCH64_LDST16_ABS_LO12_NC = 284; - - /// - /// Likewise for bits 11:2. - /// - public const uint R_AARCH64_LDST32_ABS_LO12_NC = 285; - - /// - /// Likewise for bits 11:3. - /// - public const uint R_AARCH64_LDST64_ABS_LO12_NC = 286; - - /// - /// PC-rel. MOV{N,Z} imm. from 15:0. - /// - public const uint R_AARCH64_MOVW_PREL_G0 = 287; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_PREL_G0_NC = 288; - - /// - /// PC-rel. MOV{N,Z} imm. from 31:16. - /// - public const uint R_AARCH64_MOVW_PREL_G1 = 289; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_PREL_G1_NC = 290; - - /// - /// PC-rel. MOV{N,Z} imm. from 47:32. - /// - public const uint R_AARCH64_MOVW_PREL_G2 = 291; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_PREL_G2_NC = 292; - - /// - /// PC-rel. MOV{N,Z} imm. from 63:48. - /// - public const uint R_AARCH64_MOVW_PREL_G3 = 293; - - /// - /// Dir. ADD imm. from bits 11:4. - /// - public const uint R_AARCH64_LDST128_ABS_LO12_NC = 299; - - /// - /// GOT-rel. off. MOV{N,Z} imm. 15:0. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G0 = 300; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G0_NC = 301; - - /// - /// GOT-rel. o. MOV{N,Z} imm. 31:16. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G1 = 302; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G1_NC = 303; - - /// - /// GOT-rel. o. MOV{N,Z} imm. 47:32. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G2 = 304; - - /// - /// Likewise for MOVK; no check. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G2_NC = 305; - - /// - /// GOT-rel. o. MOV{N,Z} imm. 63:48. - /// - public const uint R_AARCH64_MOVW_GOTOFF_G3 = 306; - - /// - /// GOT-relative 64-bit. - /// - public const uint R_AARCH64_GOTREL64 = 307; - - /// - /// GOT-relative 32-bit. - /// - public const uint R_AARCH64_GOTREL32 = 308; - - /// - /// PC-rel. GOT off. load imm. 20:2. - /// - public const uint R_AARCH64_GOT_LD_PREL19 = 309; - - /// - /// GOT-rel. off. LD/ST imm. 14:3. - /// - public const uint R_AARCH64_LD64_GOTOFF_LO15 = 310; - - /// - /// P-page-rel. GOT off. ADRP 32:12. - /// - public const uint R_AARCH64_ADR_GOT_PAGE = 311; - - /// - /// Dir. GOT off. LD/ST imm. 11:3. - /// - public const uint R_AARCH64_LD64_GOT_LO12_NC = 312; - - /// - /// GOT-page-rel. GOT off. LD/ST 14:3 - /// - public const uint R_AARCH64_LD64_GOTPAGE_LO15 = 313; - - /// - /// PC-relative ADR imm. 20:0. - /// - public const uint R_AARCH64_TLSGD_ADR_PREL21 = 512; - - /// - /// page-rel. ADRP imm. 32:12. - /// - public const uint R_AARCH64_TLSGD_ADR_PAGE21 = 513; - - /// - /// direct ADD imm. from 11:0. - /// - public const uint R_AARCH64_TLSGD_ADD_LO12_NC = 514; - - /// - /// GOT-rel. MOV{N,Z} 31:16. - /// - public const uint R_AARCH64_TLSGD_MOVW_G1 = 515; - - /// - /// GOT-rel. MOVK imm. 15:0. - /// - public const uint R_AARCH64_TLSGD_MOVW_G0_NC = 516; - - /// - /// Like 512; local dynamic model. - /// - public const uint R_AARCH64_TLSLD_ADR_PREL21 = 517; - - /// - /// Like 513; local dynamic model. - /// - public const uint R_AARCH64_TLSLD_ADR_PAGE21 = 518; - - /// - /// Like 514; local dynamic model. - /// - public const uint R_AARCH64_TLSLD_ADD_LO12_NC = 519; - - /// - /// Like 515; local dynamic model. - /// - public const uint R_AARCH64_TLSLD_MOVW_G1 = 520; - - /// - /// Like 516; local dynamic model. - /// - public const uint R_AARCH64_TLSLD_MOVW_G0_NC = 521; - - /// - /// TLS PC-rel. load imm. 20:2. - /// - public const uint R_AARCH64_TLSLD_LD_PREL19 = 522; - - /// - /// TLS DTP-rel. MOV{N,Z} 47:32. - /// - public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 523; - - /// - /// TLS DTP-rel. MOV{N,Z} 31:16. - /// - public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 524; - - /// - /// Likewise; MOVK; no check. - /// - public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 525; - - /// - /// TLS DTP-rel. MOV{N,Z} 15:0. - /// - public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 526; - - /// - /// Likewise; MOVK; no check. - /// - public const uint R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 527; - - /// - /// DTP-rel. ADD imm. from 23:12. - /// - public const uint R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 528; - - /// - /// DTP-rel. ADD imm. from 11:0. - /// - public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 529; - - /// - /// Likewise; no ovfl. check. - /// - public const uint R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 530; - - /// - /// DTP-rel. LD/ST imm. 11:0. - /// - public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 531; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 532; - - /// - /// DTP-rel. LD/ST imm. 11:1. - /// - public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 533; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 534; - - /// - /// DTP-rel. LD/ST imm. 11:2. - /// - public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 535; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 536; - - /// - /// DTP-rel. LD/ST imm. 11:3. - /// - public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 537; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 538; - - /// - /// GOT-rel. MOV{N,Z} 31:16. - /// - public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 539; - - /// - /// GOT-rel. MOVK 15:0. - /// - public const uint R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 540; - - /// - /// Page-rel. ADRP 32:12. - /// - public const uint R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 541; - - /// - /// Direct LD off. 11:3. - /// - public const uint R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 542; - - /// - /// PC-rel. load imm. 20:2. - /// - public const uint R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 543; - - /// - /// TLS TP-rel. MOV{N,Z} 47:32. - /// - public const uint R_AARCH64_TLSLE_MOVW_TPREL_G2 = 544; - - /// - /// TLS TP-rel. MOV{N,Z} 31:16. - /// - public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1 = 545; - - /// - /// Likewise; MOVK; no check. - /// - public const uint R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 546; - - /// - /// TLS TP-rel. MOV{N,Z} 15:0. - /// - public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0 = 547; - - /// - /// Likewise; MOVK; no check. - /// - public const uint R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 548; - - /// - /// TP-rel. ADD imm. 23:12. - /// - public const uint R_AARCH64_TLSLE_ADD_TPREL_HI12 = 549; - - /// - /// TP-rel. ADD imm. 11:0. - /// - public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12 = 550; - - /// - /// Likewise; no ovfl. check. - /// - public const uint R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 551; - - /// - /// TP-rel. LD/ST off. 11:0. - /// - public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 552; - - /// - /// Likewise; no ovfl. check. - /// - public const uint R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 553; - - /// - /// TP-rel. LD/ST off. 11:1. - /// - public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 554; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 555; - - /// - /// TP-rel. LD/ST off. 11:2. - /// - public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 556; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 557; - - /// - /// TP-rel. LD/ST off. 11:3. - /// - public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 558; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 559; - - /// - /// PC-rel. load immediate 20:2. - /// - public const uint R_AARCH64_TLSDESC_LD_PREL19 = 560; - - /// - /// PC-rel. ADR immediate 20:0. - /// - public const uint R_AARCH64_TLSDESC_ADR_PREL21 = 561; - - /// - /// Page-rel. ADRP imm. 32:12. - /// - public const uint R_AARCH64_TLSDESC_ADR_PAGE21 = 562; - - /// - /// Direct LD off. from 11:3. - /// - public const uint R_AARCH64_TLSDESC_LD64_LO12 = 563; - - /// - /// Direct ADD imm. from 11:0. - /// - public const uint R_AARCH64_TLSDESC_ADD_LO12 = 564; - - /// - /// GOT-rel. MOV{N,Z} imm. 31:16. - /// - public const uint R_AARCH64_TLSDESC_OFF_G1 = 565; - - /// - /// GOT-rel. MOVK imm. 15:0; no ck. - /// - public const uint R_AARCH64_TLSDESC_OFF_G0_NC = 566; - - /// - /// Relax LDR. - /// - public const uint R_AARCH64_TLSDESC_LDR = 567; - - /// - /// Relax ADD. - /// - public const uint R_AARCH64_TLSDESC_ADD = 568; - - /// - /// Relax BLR. - /// - public const uint R_AARCH64_TLSDESC_CALL = 569; - - /// - /// TP-rel. LD/ST off. 11:4. - /// - public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12 = 570; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = 571; - - /// - /// DTP-rel. LD/ST imm. 11:4. - /// - public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = 572; - - /// - /// Likewise; no check. - /// - public const uint R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = 573; - - /// - /// Copy symbol at runtime. - /// - public const uint R_AARCH64_COPY = 1024; - - /// - /// Create GOT entry. - /// - public const uint R_AARCH64_GLOB_DAT = 1025; - - /// - /// Create PLT entry. - /// - public const uint R_AARCH64_JUMP_SLOT = 1026; - - /// - /// Adjust by program base. - /// - public const uint R_AARCH64_RELATIVE = 1027; - - /// - /// Module number, 64 bit. - /// - public const uint R_AARCH64_TLS_DTPMOD = 1028; - - /// - /// Module-relative offset, 64 bit. - /// - public const uint R_AARCH64_TLS_DTPREL = 1029; - - /// - /// TP-relative offset, 64 bit. - /// - public const uint R_AARCH64_TLS_TPREL = 1030; - - /// - /// TLS Descriptor. - /// - public const uint R_AARCH64_TLSDESC = 1031; - - /// - /// STT_GNU_IFUNC relocation. - /// - public const uint R_AARCH64_IRELATIVE = 1032; - - /// - /// No reloc - /// - public const uint R_ARM_NONE = 0; - - /// - /// Deprecated PC relative 26 bit branch. - /// - public const uint R_ARM_PC24 = 1; - - /// - /// Direct 32 bit - /// - public const uint R_ARM_ABS32 = 2; - - /// - /// PC relative 32 bit - /// - public const uint R_ARM_REL32 = 3; - - public const uint R_ARM_PC13 = 4; - - /// - /// Direct 16 bit - /// - public const uint R_ARM_ABS16 = 5; - - /// - /// Direct 12 bit - /// - public const uint R_ARM_ABS12 = 6; - - /// - /// Direct - /// & - /// 0x7C (LDR, STR). - /// - public const uint R_ARM_THM_ABS5 = 7; - - /// - /// Direct 8 bit - /// - public const uint R_ARM_ABS8 = 8; - - public const uint R_ARM_SBREL32 = 9; - - /// - /// PC relative 24 bit (Thumb32 BL). - /// - public const uint R_ARM_THM_PC22 = 10; - - /// - /// PC relative - /// & - /// 0x3FC (Thumb16 LDR, ADD, ADR). - /// - public const uint R_ARM_THM_PC8 = 11; - - public const uint R_ARM_AMP_VCALL9 = 12; - - /// - /// Obsolete static relocation. - /// - public const uint R_ARM_SWI24 = 13; - - /// - /// Dynamic relocation. - /// - public const uint R_ARM_TLS_DESC = 13; - - /// - /// Reserved. - /// - public const uint R_ARM_THM_SWI8 = 14; - - /// - /// Reserved. - /// - public const uint R_ARM_XPC25 = 15; - - /// - /// Reserved. - /// - public const uint R_ARM_THM_XPC22 = 16; - - /// - /// ID of module containing symbol - /// - public const uint R_ARM_TLS_DTPMOD32 = 17; - - /// - /// Offset in TLS block - /// - public const uint R_ARM_TLS_DTPOFF32 = 18; - - /// - /// Offset in static TLS block - /// - public const uint R_ARM_TLS_TPOFF32 = 19; - - /// - /// Copy symbol at runtime - /// - public const uint R_ARM_COPY = 20; - - /// - /// Create GOT entry - /// - public const uint R_ARM_GLOB_DAT = 21; - - /// - /// Create PLT entry - /// - public const uint R_ARM_JUMP_SLOT = 22; - - /// - /// Adjust by program base - /// - public const uint R_ARM_RELATIVE = 23; - - /// - /// 32 bit offset to GOT - /// - public const uint R_ARM_GOTOFF = 24; - - /// - /// 32 bit PC relative offset to GOT - /// - public const uint R_ARM_GOTPC = 25; - - /// - /// 32 bit GOT entry - /// - public const uint R_ARM_GOT32 = 26; - - /// - /// Deprecated, 32 bit PLT address. - /// - public const uint R_ARM_PLT32 = 27; - - /// - /// PC relative 24 bit (BL, BLX). - /// - public const uint R_ARM_CALL = 28; - - /// - /// PC relative 24 bit (B, BL - /// <cond - /// >). - /// - public const uint R_ARM_JUMP24 = 29; - - /// - /// PC relative 24 bit (Thumb32 B.W). - /// - public const uint R_ARM_THM_JUMP24 = 30; - - /// - /// Adjust by program base. - /// - public const uint R_ARM_BASE_ABS = 31; - - /// - /// Obsolete. - /// - public const uint R_ARM_ALU_PCREL_7_0 = 32; - - /// - /// Obsolete. - /// - public const uint R_ARM_ALU_PCREL_15_8 = 33; - - /// - /// Obsolete. - /// - public const uint R_ARM_ALU_PCREL_23_15 = 34; - - /// - /// Deprecated, prog. base relative. - /// - public const uint R_ARM_LDR_SBREL_11_0 = 35; - - /// - /// Deprecated, prog. base relative. - /// - public const uint R_ARM_ALU_SBREL_19_12 = 36; - - /// - /// Deprecated, prog. base relative. - /// - public const uint R_ARM_ALU_SBREL_27_20 = 37; - - public const uint R_ARM_TARGET1 = 38; - - /// - /// Program base relative. - /// - public const uint R_ARM_SBREL31 = 39; - - public const uint R_ARM_V4BX = 40; - - public const uint R_ARM_TARGET2 = 41; - - /// - /// 32 bit PC relative. - /// - public const uint R_ARM_PREL31 = 42; - - /// - /// Direct 16-bit (MOVW). - /// - public const uint R_ARM_MOVW_ABS_NC = 43; - - /// - /// Direct high 16-bit (MOVT). - /// - public const uint R_ARM_MOVT_ABS = 44; - - /// - /// PC relative 16-bit (MOVW). - /// - public const uint R_ARM_MOVW_PREL_NC = 45; - - /// - /// PC relative (MOVT). - /// - public const uint R_ARM_MOVT_PREL = 46; - - /// - /// Direct 16 bit (Thumb32 MOVW). - /// - public const uint R_ARM_THM_MOVW_ABS_NC = 47; - - /// - /// Direct high 16 bit (Thumb32 MOVT). - /// - public const uint R_ARM_THM_MOVT_ABS = 48; - - /// - /// PC relative 16 bit (Thumb32 MOVW). - /// - public const uint R_ARM_THM_MOVW_PREL_NC = 49; - - /// - /// PC relative high 16 bit (Thumb32 MOVT). - /// - public const uint R_ARM_THM_MOVT_PREL = 50; - - /// - /// PC relative 20 bit (Thumb32 B - /// <cond - /// >.W). - /// - public const uint R_ARM_THM_JUMP19 = 51; - - /// - /// PC relative X - /// & - /// 0x7E (Thumb16 CBZ, CBNZ). - /// - public const uint R_ARM_THM_JUMP6 = 52; - - /// - /// PC relative 12 bit (Thumb32 ADR.W). - /// - public const uint R_ARM_THM_ALU_PREL_11_0 = 53; - - /// - /// PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). - /// - public const uint R_ARM_THM_PC12 = 54; - - /// - /// Direct 32-bit. - /// - public const uint R_ARM_ABS32_NOI = 55; - - /// - /// PC relative 32-bit. - /// - public const uint R_ARM_REL32_NOI = 56; - - /// - /// PC relative (ADD, SUB). - /// - public const uint R_ARM_ALU_PC_G0_NC = 57; - - /// - /// PC relative (ADD, SUB). - /// - public const uint R_ARM_ALU_PC_G0 = 58; - - /// - /// PC relative (ADD, SUB). - /// - public const uint R_ARM_ALU_PC_G1_NC = 59; - - /// - /// PC relative (ADD, SUB). - /// - public const uint R_ARM_ALU_PC_G1 = 60; - - /// - /// PC relative (ADD, SUB). - /// - public const uint R_ARM_ALU_PC_G2 = 61; - - /// - /// PC relative (LDR,STR,LDRB,STRB). - /// - public const uint R_ARM_LDR_PC_G1 = 62; - - /// - /// PC relative (LDR,STR,LDRB,STRB). - /// - public const uint R_ARM_LDR_PC_G2 = 63; - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public const uint R_ARM_LDRS_PC_G0 = 64; - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public const uint R_ARM_LDRS_PC_G1 = 65; - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public const uint R_ARM_LDRS_PC_G2 = 66; - - /// - /// PC relative (LDC, STC). - /// - public const uint R_ARM_LDC_PC_G0 = 67; - - /// - /// PC relative (LDC, STC). - /// - public const uint R_ARM_LDC_PC_G1 = 68; - - /// - /// PC relative (LDC, STC). - /// - public const uint R_ARM_LDC_PC_G2 = 69; - - /// - /// Program base relative (ADD,SUB). - /// - public const uint R_ARM_ALU_SB_G0_NC = 70; - - /// - /// Program base relative (ADD,SUB). - /// - public const uint R_ARM_ALU_SB_G0 = 71; - - /// - /// Program base relative (ADD,SUB). - /// - public const uint R_ARM_ALU_SB_G1_NC = 72; - - /// - /// Program base relative (ADD,SUB). - /// - public const uint R_ARM_ALU_SB_G1 = 73; - - /// - /// Program base relative (ADD,SUB). - /// - public const uint R_ARM_ALU_SB_G2 = 74; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDR_SB_G0 = 75; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDR_SB_G1 = 76; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDR_SB_G2 = 77; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDRS_SB_G0 = 78; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDRS_SB_G1 = 79; - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public const uint R_ARM_LDRS_SB_G2 = 80; - - /// - /// Program base relative (LDC,STC). - /// - public const uint R_ARM_LDC_SB_G0 = 81; - - /// - /// Program base relative (LDC,STC). - /// - public const uint R_ARM_LDC_SB_G1 = 82; - - /// - /// Program base relative (LDC,STC). - /// - public const uint R_ARM_LDC_SB_G2 = 83; - - /// - /// Program base relative 16 bit (MOVW). - /// - public const uint R_ARM_MOVW_BREL_NC = 84; - - /// - /// Program base relative high 16 bit (MOVT). - /// - public const uint R_ARM_MOVT_BREL = 85; - - /// - /// Program base relative 16 bit (MOVW). - /// - public const uint R_ARM_MOVW_BREL = 86; - - /// - /// Program base relative 16 bit (Thumb32 MOVW). - /// - public const uint R_ARM_THM_MOVW_BREL_NC = 87; - - /// - /// Program base relative high 16 bit (Thumb32 MOVT). - /// - public const uint R_ARM_THM_MOVT_BREL = 88; - - /// - /// Program base relative 16 bit (Thumb32 MOVW). - /// - public const uint R_ARM_THM_MOVW_BREL = 89; - - public const uint R_ARM_TLS_GOTDESC = 90; - - public const uint R_ARM_TLS_CALL = 91; - - /// - /// TLS relaxation. - /// - public const uint R_ARM_TLS_DESCSEQ = 92; - - public const uint R_ARM_THM_TLS_CALL = 93; - - public const uint R_ARM_PLT32_ABS = 94; - - /// - /// GOT entry. - /// - public const uint R_ARM_GOT_ABS = 95; - - /// - /// PC relative GOT entry. - /// - public const uint R_ARM_GOT_PREL = 96; - - /// - /// GOT entry relative to GOT origin (LDR). - /// - public const uint R_ARM_GOT_BREL12 = 97; - - /// - /// 12 bit, GOT entry relative to GOT origin (LDR, STR). - /// - public const uint R_ARM_GOTOFF12 = 98; - - public const uint R_ARM_GOTRELAX = 99; - - public const uint R_ARM_GNU_VTENTRY = 100; - - public const uint R_ARM_GNU_VTINHERIT = 101; - - /// - /// PC relative - /// & - /// 0xFFE (Thumb16 B). - /// - public const uint R_ARM_THM_PC11 = 102; - - /// - /// PC relative - /// & - /// 0x1FE (Thumb16 B/B - /// <cond - /// >). - /// - public const uint R_ARM_THM_PC9 = 103; - - /// - /// PC-rel 32 bit for global dynamic thread local data - /// - public const uint R_ARM_TLS_GD32 = 104; - - /// - /// PC-rel 32 bit for local dynamic thread local data - /// - public const uint R_ARM_TLS_LDM32 = 105; - - /// - /// 32 bit offset relative to TLS block - /// - public const uint R_ARM_TLS_LDO32 = 106; - - /// - /// PC-rel 32 bit for GOT entry of static TLS block offset - /// - public const uint R_ARM_TLS_IE32 = 107; - - /// - /// 32 bit offset relative to static TLS block - /// - public const uint R_ARM_TLS_LE32 = 108; - - /// - /// 12 bit relative to TLS block (LDR, STR). - /// - public const uint R_ARM_TLS_LDO12 = 109; - - /// - /// 12 bit relative to static TLS block (LDR, STR). - /// - public const uint R_ARM_TLS_LE12 = 110; - - /// - /// 12 bit GOT entry relative to GOT origin (LDR). - /// - public const uint R_ARM_TLS_IE12GP = 111; - - /// - /// Obsolete. - /// - public const uint R_ARM_ME_TOO = 128; - - public const uint R_ARM_THM_TLS_DESCSEQ = 129; - - public const uint R_ARM_THM_TLS_DESCSEQ16 = 129; - - public const uint R_ARM_THM_TLS_DESCSEQ32 = 130; - - /// - /// GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). - /// - public const uint R_ARM_THM_GOT_BREL12 = 131; - - public const uint R_ARM_IRELATIVE = 160; - - public const uint R_ARM_RXPC25 = 249; - - public const uint R_ARM_RSBREL32 = 250; - - public const uint R_ARM_THM_RPC22 = 251; - - public const uint R_ARM_RREL32 = 252; - - public const uint R_ARM_RABS22 = 253; - - public const uint R_ARM_RPC24 = 254; - - public const uint R_ARM_RBASE = 255; - - public const uint R_ARM_NUM = 256; - - /// - /// os-specific flags - /// - public const uint EF_IA_64_MASKOS = 15; - - /// - /// 64-bit ABI - /// - public const uint EF_IA_64_ABI64 = 16; - - /// - /// arch. version mask - /// - public const uint EF_IA_64_ARCH = 0xff000000; - - /// - /// arch extension bits - /// - public const uint PT_IA_64_ARCHEXT = 1879048192; - - /// - /// ia64 unwind bits - /// - public const uint PT_IA_64_UNWIND = 1879048193; - - public const uint PT_IA_64_HP_OPT_ANOT = 1610612754; - - public const uint PT_IA_64_HP_HSL_ANOT = 1610612755; - - public const uint PT_IA_64_HP_STACK = 1610612756; - - /// - /// spec insns w/o recovery - /// - public const uint PF_IA_64_NORECOV = 0x80000000; - - /// - /// extension bits - /// - public const uint SHT_IA_64_EXT = 1879048192; - - /// - /// unwind bits - /// - public const uint SHT_IA_64_UNWIND = 1879048193; - - /// - /// section near gp - /// - public const uint SHF_IA_64_SHORT = 268435456; - - /// - /// spec insns w/o recovery - /// - public const uint SHF_IA_64_NORECOV = 536870912; - - public const int DT_IA_64_PLT_RESERVE = ( 0); - - public const int DT_IA_64_NUM = 1; - - /// - /// none - /// - public const uint R_IA64_NONE = 0; - - /// - /// symbol + addend, add imm14 - /// - public const uint R_IA64_IMM14 = 33; - - /// - /// symbol + addend, add imm22 - /// - public const uint R_IA64_IMM22 = 34; - - /// - /// symbol + addend, mov imm64 - /// - public const uint R_IA64_IMM64 = 35; - - /// - /// symbol + addend, data4 MSB - /// - public const uint R_IA64_DIR32MSB = 36; - - /// - /// symbol + addend, data4 LSB - /// - public const uint R_IA64_DIR32LSB = 37; - - /// - /// symbol + addend, data8 MSB - /// - public const uint R_IA64_DIR64MSB = 38; - - /// - /// symbol + addend, data8 LSB - /// - public const uint R_IA64_DIR64LSB = 39; - - /// - /// @gprel (sym + add), add imm22 - /// - public const uint R_IA64_GPREL22 = 42; - - /// - /// @gprel (sym + add), mov imm64 - /// - public const uint R_IA64_GPREL64I = 43; - - /// - /// @gprel (sym + add), data4 MSB - /// - public const uint R_IA64_GPREL32MSB = 44; - - /// - /// @gprel (sym + add), data4 LSB - /// - public const uint R_IA64_GPREL32LSB = 45; - - /// - /// @gprel (sym + add), data8 MSB - /// - public const uint R_IA64_GPREL64MSB = 46; - - /// - /// @gprel (sym + add), data8 LSB - /// - public const uint R_IA64_GPREL64LSB = 47; - - /// - /// @ltoff (sym + add), add imm22 - /// - public const uint R_IA64_LTOFF22 = 50; - - /// - /// @ltoff (sym + add), mov imm64 - /// - public const uint R_IA64_LTOFF64I = 51; - - /// - /// @pltoff (sym + add), add imm22 - /// - public const uint R_IA64_PLTOFF22 = 58; - - /// - /// @pltoff (sym + add), mov imm64 - /// - public const uint R_IA64_PLTOFF64I = 59; - - /// - /// @pltoff (sym + add), data8 MSB - /// - public const uint R_IA64_PLTOFF64MSB = 62; - - /// - /// @pltoff (sym + add), data8 LSB - /// - public const uint R_IA64_PLTOFF64LSB = 63; - - /// - /// @fptr (sym + add), mov imm64 - /// - public const uint R_IA64_FPTR64I = 67; - - /// - /// @fptr (sym + add), data4 MSB - /// - public const uint R_IA64_FPTR32MSB = 68; - - /// - /// @fptr (sym + add), data4 LSB - /// - public const uint R_IA64_FPTR32LSB = 69; - - /// - /// @fptr (sym + add), data8 MSB - /// - public const uint R_IA64_FPTR64MSB = 70; - - /// - /// @fptr (sym + add), data8 LSB - /// - public const uint R_IA64_FPTR64LSB = 71; - - /// - /// @pcrel (sym + add), brl - /// - public const uint R_IA64_PCREL60B = 72; - - /// - /// @pcrel (sym + add), ptb, call - /// - public const uint R_IA64_PCREL21B = 73; - - /// - /// @pcrel (sym + add), chk.s - /// - public const uint R_IA64_PCREL21M = 74; - - /// - /// @pcrel (sym + add), fchkf - /// - public const uint R_IA64_PCREL21F = 75; - - /// - /// @pcrel (sym + add), data4 MSB - /// - public const uint R_IA64_PCREL32MSB = 76; - - /// - /// @pcrel (sym + add), data4 LSB - /// - public const uint R_IA64_PCREL32LSB = 77; - - /// - /// @pcrel (sym + add), data8 MSB - /// - public const uint R_IA64_PCREL64MSB = 78; - - /// - /// @pcrel (sym + add), data8 LSB - /// - public const uint R_IA64_PCREL64LSB = 79; - - /// - /// @ltoff (@fptr (s+a)), imm22 - /// - public const uint R_IA64_LTOFF_FPTR22 = 82; - - /// - /// @ltoff (@fptr (s+a)), imm64 - /// - public const uint R_IA64_LTOFF_FPTR64I = 83; - - /// - /// @ltoff (@fptr (s+a)), data4 MSB - /// - public const uint R_IA64_LTOFF_FPTR32MSB = 84; - - /// - /// @ltoff (@fptr (s+a)), data4 LSB - /// - public const uint R_IA64_LTOFF_FPTR32LSB = 85; - - /// - /// @ltoff (@fptr (s+a)), data8 MSB - /// - public const uint R_IA64_LTOFF_FPTR64MSB = 86; - - /// - /// @ltoff (@fptr (s+a)), data8 LSB - /// - public const uint R_IA64_LTOFF_FPTR64LSB = 87; - - /// - /// @segrel (sym + add), data4 MSB - /// - public const uint R_IA64_SEGREL32MSB = 92; - - /// - /// @segrel (sym + add), data4 LSB - /// - public const uint R_IA64_SEGREL32LSB = 93; - - /// - /// @segrel (sym + add), data8 MSB - /// - public const uint R_IA64_SEGREL64MSB = 94; - - /// - /// @segrel (sym + add), data8 LSB - /// - public const uint R_IA64_SEGREL64LSB = 95; - - /// - /// @secrel (sym + add), data4 MSB - /// - public const uint R_IA64_SECREL32MSB = 100; - - /// - /// @secrel (sym + add), data4 LSB - /// - public const uint R_IA64_SECREL32LSB = 101; - - /// - /// @secrel (sym + add), data8 MSB - /// - public const uint R_IA64_SECREL64MSB = 102; - - /// - /// @secrel (sym + add), data8 LSB - /// - public const uint R_IA64_SECREL64LSB = 103; - - /// - /// data 4 + REL - /// - public const uint R_IA64_REL32MSB = 108; - - /// - /// data 4 + REL - /// - public const uint R_IA64_REL32LSB = 109; - - /// - /// data 8 + REL - /// - public const uint R_IA64_REL64MSB = 110; - - /// - /// data 8 + REL - /// - public const uint R_IA64_REL64LSB = 111; - - /// - /// symbol + addend, data4 MSB - /// - public const uint R_IA64_LTV32MSB = 116; - - /// - /// symbol + addend, data4 LSB - /// - public const uint R_IA64_LTV32LSB = 117; - - /// - /// symbol + addend, data8 MSB - /// - public const uint R_IA64_LTV64MSB = 118; - - /// - /// symbol + addend, data8 LSB - /// - public const uint R_IA64_LTV64LSB = 119; - - /// - /// @pcrel (sym + add), 21bit inst - /// - public const uint R_IA64_PCREL21BI = 121; - - /// - /// @pcrel (sym + add), 22bit inst - /// - public const uint R_IA64_PCREL22 = 122; - - /// - /// @pcrel (sym + add), 64bit inst - /// - public const uint R_IA64_PCREL64I = 123; - - /// - /// dynamic reloc, imported PLT, MSB - /// - public const uint R_IA64_IPLTMSB = 128; - - /// - /// dynamic reloc, imported PLT, LSB - /// - public const uint R_IA64_IPLTLSB = 129; - - /// - /// copy relocation - /// - public const uint R_IA64_COPY = 132; - - /// - /// Addend and symbol difference - /// - public const uint R_IA64_SUB = 133; - - /// - /// LTOFF22, relaxable. - /// - public const uint R_IA64_LTOFF22X = 134; - - /// - /// Use of LTOFF22X. - /// - public const uint R_IA64_LDXMOV = 135; - - /// - /// @tprel (sym + add), imm14 - /// - public const uint R_IA64_TPREL14 = 145; - - /// - /// @tprel (sym + add), imm22 - /// - public const uint R_IA64_TPREL22 = 146; - - /// - /// @tprel (sym + add), imm64 - /// - public const uint R_IA64_TPREL64I = 147; - - /// - /// @tprel (sym + add), data8 MSB - /// - public const uint R_IA64_TPREL64MSB = 150; - - /// - /// @tprel (sym + add), data8 LSB - /// - public const uint R_IA64_TPREL64LSB = 151; - - /// - /// @ltoff (@tprel (s+a)), imm2 - /// - public const uint R_IA64_LTOFF_TPREL22 = 154; - - /// - /// @dtpmod (sym + add), data8 MSB - /// - public const uint R_IA64_DTPMOD64MSB = 166; - - /// - /// @dtpmod (sym + add), data8 LSB - /// - public const uint R_IA64_DTPMOD64LSB = 167; - - /// - /// @ltoff (@dtpmod (sym + add)), imm22 - /// - public const uint R_IA64_LTOFF_DTPMOD22 = 170; - - /// - /// @dtprel (sym + add), imm14 - /// - public const uint R_IA64_DTPREL14 = 177; - - /// - /// @dtprel (sym + add), imm22 - /// - public const uint R_IA64_DTPREL22 = 178; - - /// - /// @dtprel (sym + add), imm64 - /// - public const uint R_IA64_DTPREL64I = 179; - - /// - /// @dtprel (sym + add), data4 MSB - /// - public const uint R_IA64_DTPREL32MSB = 180; - - /// - /// @dtprel (sym + add), data4 LSB - /// - public const uint R_IA64_DTPREL32LSB = 181; - - /// - /// @dtprel (sym + add), data8 MSB - /// - public const uint R_IA64_DTPREL64MSB = 182; - - /// - /// @dtprel (sym + add), data8 LSB - /// - public const uint R_IA64_DTPREL64LSB = 183; - - /// - /// @ltoff (@dtprel (s+a)), imm22 - /// - public const uint R_IA64_LTOFF_DTPREL22 = 186; - - public const uint EF_SH_MACH_MASK = 31; - - public const uint EF_SH_UNKNOWN = 0; - - public const uint EF_SH1 = 1; - - public const uint EF_SH2 = 2; - - public const uint EF_SH3 = 3; - - public const uint EF_SH_DSP = 4; - - public const uint EF_SH3_DSP = 5; - - public const uint EF_SH4AL_DSP = 6; - - public const uint EF_SH3E = 8; - - public const uint EF_SH4 = 9; - - public const uint EF_SH2E = 11; - - public const uint EF_SH4A = 12; - - public const uint EF_SH2A = 13; - - public const uint EF_SH4_NOFPU = 16; - - public const uint EF_SH4A_NOFPU = 17; - - public const uint EF_SH4_NOMMU_NOFPU = 18; - - public const uint EF_SH2A_NOFPU = 19; - - public const uint EF_SH3_NOMMU = 20; - - public const uint EF_SH2A_SH4_NOFPU = 21; - - public const uint EF_SH2A_SH3_NOFPU = 22; - - public const uint EF_SH2A_SH4 = 23; - - public const uint EF_SH2A_SH3E = 24; - - public const uint R_SH_NONE = 0; - - public const uint R_SH_DIR32 = 1; - - public const uint R_SH_REL32 = 2; - - public const uint R_SH_DIR8WPN = 3; - - public const uint R_SH_IND12W = 4; - - public const uint R_SH_DIR8WPL = 5; - - public const uint R_SH_DIR8WPZ = 6; - - public const uint R_SH_DIR8BP = 7; - - public const uint R_SH_DIR8W = 8; - - public const uint R_SH_DIR8L = 9; - - public const uint R_SH_SWITCH16 = 25; - - public const uint R_SH_SWITCH32 = 26; - - public const uint R_SH_USES = 27; - - public const uint R_SH_COUNT = 28; - - public const uint R_SH_ALIGN = 29; - - public const uint R_SH_CODE = 30; - - public const uint R_SH_DATA = 31; - - public const uint R_SH_LABEL = 32; - - public const uint R_SH_SWITCH8 = 33; - - public const uint R_SH_GNU_VTINHERIT = 34; - - public const uint R_SH_GNU_VTENTRY = 35; - - public const uint R_SH_TLS_GD_32 = 144; - - public const uint R_SH_TLS_LD_32 = 145; - - public const uint R_SH_TLS_LDO_32 = 146; - - public const uint R_SH_TLS_IE_32 = 147; - - public const uint R_SH_TLS_LE_32 = 148; - - public const uint R_SH_TLS_DTPMOD32 = 149; - - public const uint R_SH_TLS_DTPOFF32 = 150; - - public const uint R_SH_TLS_TPOFF32 = 151; - - public const uint R_SH_GOT32 = 160; - - public const uint R_SH_PLT32 = 161; - - public const uint R_SH_COPY = 162; - - public const uint R_SH_GLOB_DAT = 163; - - public const uint R_SH_JMP_SLOT = 164; - - public const uint R_SH_RELATIVE = 165; - - public const uint R_SH_GOTOFF = 166; - - public const uint R_SH_GOTPC = 167; - - public const uint R_SH_NUM = 256; - - /// - /// High GPRs kernel facility needed. - /// - public const uint EF_S390_HIGH_GPRS = 1; - - /// - /// No reloc. - /// - public const uint R_390_NONE = 0; - - /// - /// Direct 8 bit. - /// - public const uint R_390_8 = 1; - - /// - /// Direct 12 bit. - /// - public const uint R_390_12 = 2; - - /// - /// Direct 16 bit. - /// - public const uint R_390_16 = 3; - - /// - /// Direct 32 bit. - /// - public const uint R_390_32 = 4; - - /// - /// PC relative 32 bit. - /// - public const uint R_390_PC32 = 5; - - /// - /// 12 bit GOT offset. - /// - public const uint R_390_GOT12 = 6; - - /// - /// 32 bit GOT offset. - /// - public const uint R_390_GOT32 = 7; - - /// - /// 32 bit PC relative PLT address. - /// - public const uint R_390_PLT32 = 8; - - /// - /// Copy symbol at runtime. - /// - public const uint R_390_COPY = 9; - - /// - /// Create GOT entry. - /// - public const uint R_390_GLOB_DAT = 10; - - /// - /// Create PLT entry. - /// - public const uint R_390_JMP_SLOT = 11; - - /// - /// Adjust by program base. - /// - public const uint R_390_RELATIVE = 12; - - /// - /// 32 bit offset to GOT. - /// - public const uint R_390_GOTOFF32 = 13; - - /// - /// 32 bit PC relative offset to GOT. - /// - public const uint R_390_GOTPC = 14; - - /// - /// 16 bit GOT offset. - /// - public const uint R_390_GOT16 = 15; - - /// - /// PC relative 16 bit. - /// - public const uint R_390_PC16 = 16; - - /// - /// PC relative 16 bit shifted by 1. - /// - public const uint R_390_PC16DBL = 17; - - /// - /// 16 bit PC rel. PLT shifted by 1. - /// - public const uint R_390_PLT16DBL = 18; - - /// - /// PC relative 32 bit shifted by 1. - /// - public const uint R_390_PC32DBL = 19; - - /// - /// 32 bit PC rel. PLT shifted by 1. - /// - public const uint R_390_PLT32DBL = 20; - - /// - /// 32 bit PC rel. GOT shifted by 1. - /// - public const uint R_390_GOTPCDBL = 21; - - /// - /// Direct 64 bit. - /// - public const uint R_390_64 = 22; - - /// - /// PC relative 64 bit. - /// - public const uint R_390_PC64 = 23; - - /// - /// 64 bit GOT offset. - /// - public const uint R_390_GOT64 = 24; - - /// - /// 64 bit PC relative PLT address. - /// - public const uint R_390_PLT64 = 25; - - /// - /// 32 bit PC rel. to GOT entry >> 1. - /// - public const uint R_390_GOTENT = 26; - - /// - /// 16 bit offset to GOT. - /// - public const uint R_390_GOTOFF16 = 27; - - /// - /// 64 bit offset to GOT. - /// - public const uint R_390_GOTOFF64 = 28; - - /// - /// 12 bit offset to jump slot. - /// - public const uint R_390_GOTPLT12 = 29; - - /// - /// 16 bit offset to jump slot. - /// - public const uint R_390_GOTPLT16 = 30; - - /// - /// 32 bit offset to jump slot. - /// - public const uint R_390_GOTPLT32 = 31; - - /// - /// 64 bit offset to jump slot. - /// - public const uint R_390_GOTPLT64 = 32; - - /// - /// 32 bit rel. offset to jump slot. - /// - public const uint R_390_GOTPLTENT = 33; - - /// - /// 16 bit offset from GOT to PLT. - /// - public const uint R_390_PLTOFF16 = 34; - - /// - /// 32 bit offset from GOT to PLT. - /// - public const uint R_390_PLTOFF32 = 35; - - /// - /// 16 bit offset from GOT to PLT. - /// - public const uint R_390_PLTOFF64 = 36; - - /// - /// Tag for load insn in TLS code. - /// - public const uint R_390_TLS_LOAD = 37; - - /// - /// Tag for function call in general dynamic TLS code. - /// - public const uint R_390_TLS_GDCALL = 38; - - /// - /// Tag for function call in local dynamic TLS code. - /// - public const uint R_390_TLS_LDCALL = 39; - - /// - /// Direct 32 bit for general dynamic thread local data. - /// - public const uint R_390_TLS_GD32 = 40; - - /// - /// Direct 64 bit for general dynamic thread local data. - /// - public const uint R_390_TLS_GD64 = 41; - - /// - /// 12 bit GOT offset for static TLS block offset. - /// - public const uint R_390_TLS_GOTIE12 = 42; - - /// - /// 32 bit GOT offset for static TLS block offset. - /// - public const uint R_390_TLS_GOTIE32 = 43; - - /// - /// 64 bit GOT offset for static TLS block offset. - /// - public const uint R_390_TLS_GOTIE64 = 44; - - /// - /// Direct 32 bit for local dynamic thread local data in LE code. - /// - public const uint R_390_TLS_LDM32 = 45; - - /// - /// Direct 64 bit for local dynamic thread local data in LE code. - /// - public const uint R_390_TLS_LDM64 = 46; - - /// - /// 32 bit address of GOT entry for negated static TLS block offset. - /// - public const uint R_390_TLS_IE32 = 47; - - /// - /// 64 bit address of GOT entry for negated static TLS block offset. - /// - public const uint R_390_TLS_IE64 = 48; - - /// - /// 32 bit rel. offset to GOT entry for negated static TLS block offset. - /// - public const uint R_390_TLS_IEENT = 49; - - /// - /// 32 bit negated offset relative to static TLS block. - /// - public const uint R_390_TLS_LE32 = 50; - - /// - /// 64 bit negated offset relative to static TLS block. - /// - public const uint R_390_TLS_LE64 = 51; - - /// - /// 32 bit offset relative to TLS block. - /// - public const uint R_390_TLS_LDO32 = 52; - - /// - /// 64 bit offset relative to TLS block. - /// - public const uint R_390_TLS_LDO64 = 53; - - /// - /// ID of module containing symbol. - /// - public const uint R_390_TLS_DTPMOD = 54; - - /// - /// Offset in TLS block. - /// - public const uint R_390_TLS_DTPOFF = 55; - - /// - /// Negated offset in static TLS block. - /// - public const uint R_390_TLS_TPOFF = 56; - - /// - /// Direct 20 bit. - /// - public const uint R_390_20 = 57; - - /// - /// 20 bit GOT offset. - /// - public const uint R_390_GOT20 = 58; - - /// - /// 20 bit offset to jump slot. - /// - public const uint R_390_GOTPLT20 = 59; - - /// - /// 20 bit GOT offset for static TLS block offset. - /// - public const uint R_390_TLS_GOTIE20 = 60; - - /// - /// STT_GNU_IFUNC relocation. - /// - public const uint R_390_IRELATIVE = 61; - - public const uint R_390_NUM = 62; - - public const uint R_CRIS_NONE = 0; - - public const uint R_CRIS_8 = 1; - - public const uint R_CRIS_16 = 2; - - public const uint R_CRIS_32 = 3; - - public const uint R_CRIS_8_PCREL = 4; - - public const uint R_CRIS_16_PCREL = 5; - - public const uint R_CRIS_32_PCREL = 6; - - public const uint R_CRIS_GNU_VTINHERIT = 7; - - public const uint R_CRIS_GNU_VTENTRY = 8; - - public const uint R_CRIS_COPY = 9; - - public const uint R_CRIS_GLOB_DAT = 10; - - public const uint R_CRIS_JUMP_SLOT = 11; - - public const uint R_CRIS_RELATIVE = 12; - - public const uint R_CRIS_16_GOT = 13; - - public const uint R_CRIS_32_GOT = 14; - - public const uint R_CRIS_16_GOTPLT = 15; - - public const uint R_CRIS_32_GOTPLT = 16; - - public const uint R_CRIS_32_GOTREL = 17; - - public const uint R_CRIS_32_PLT_GOTREL = 18; - - public const uint R_CRIS_32_PLT_PCREL = 19; - - public const uint R_CRIS_NUM = 20; - - /// - /// No reloc - /// - public const uint R_X86_64_NONE = 0; - - /// - /// Direct 64 bit - /// - public const uint R_X86_64_64 = 1; - - /// - /// PC relative 32 bit signed - /// - public const uint R_X86_64_PC32 = 2; - - /// - /// 32 bit GOT entry - /// - public const uint R_X86_64_GOT32 = 3; - - /// - /// 32 bit PLT address - /// - public const uint R_X86_64_PLT32 = 4; - - /// - /// Copy symbol at runtime - /// - public const uint R_X86_64_COPY = 5; - - /// - /// Create GOT entry - /// - public const uint R_X86_64_GLOB_DAT = 6; - - /// - /// Create PLT entry - /// - public const uint R_X86_64_JUMP_SLOT = 7; - - /// - /// Adjust by program base - /// - public const uint R_X86_64_RELATIVE = 8; - - /// - /// 32 bit signed PC relative offset to GOT - /// - public const uint R_X86_64_GOTPCREL = 9; - - /// - /// Direct 32 bit zero extended - /// - public const uint R_X86_64_32 = 10; - - /// - /// Direct 32 bit sign extended - /// - public const uint R_X86_64_32S = 11; - - /// - /// Direct 16 bit zero extended - /// - public const uint R_X86_64_16 = 12; - - /// - /// 16 bit sign extended pc relative - /// - public const uint R_X86_64_PC16 = 13; - - /// - /// Direct 8 bit sign extended - /// - public const uint R_X86_64_8 = 14; - - /// - /// 8 bit sign extended pc relative - /// - public const uint R_X86_64_PC8 = 15; - - /// - /// ID of module containing symbol - /// - public const uint R_X86_64_DTPMOD64 = 16; - - /// - /// Offset in module's TLS block - /// - public const uint R_X86_64_DTPOFF64 = 17; - - /// - /// Offset in initial TLS block - /// - public const uint R_X86_64_TPOFF64 = 18; - - /// - /// 32 bit signed PC relative offset to two GOT entries for GD symbol - /// - public const uint R_X86_64_TLSGD = 19; - - /// - /// 32 bit signed PC relative offset to two GOT entries for LD symbol - /// - public const uint R_X86_64_TLSLD = 20; - - /// - /// Offset in TLS block - /// - public const uint R_X86_64_DTPOFF32 = 21; - - /// - /// 32 bit signed PC relative offset to GOT entry for IE symbol - /// - public const uint R_X86_64_GOTTPOFF = 22; - - /// - /// Offset in initial TLS block - /// - public const uint R_X86_64_TPOFF32 = 23; - - /// - /// PC relative 64 bit - /// - public const uint R_X86_64_PC64 = 24; - - /// - /// 64 bit offset to GOT - /// - public const uint R_X86_64_GOTOFF64 = 25; - - /// - /// 32 bit signed pc relative offset to GOT - /// - public const uint R_X86_64_GOTPC32 = 26; - - /// - /// 64-bit GOT entry offset - /// - public const uint R_X86_64_GOT64 = 27; - - /// - /// 64-bit PC relative offset to GOT entry - /// - public const uint R_X86_64_GOTPCREL64 = 28; - - /// - /// 64-bit PC relative offset to GOT - /// - public const uint R_X86_64_GOTPC64 = 29; - - /// - /// like GOT64, says PLT entry needed - /// - public const uint R_X86_64_GOTPLT64 = 30; - - /// - /// 64-bit GOT relative offset to PLT entry - /// - public const uint R_X86_64_PLTOFF64 = 31; - - /// - /// Size of symbol plus 32-bit addend - /// - public const uint R_X86_64_SIZE32 = 32; - - /// - /// Size of symbol plus 64-bit addend - /// - public const uint R_X86_64_SIZE64 = 33; - - /// - /// GOT offset for TLS descriptor. - /// - public const uint R_X86_64_GOTPC32_TLSDESC = 34; - - /// - /// Marker for call through TLS descriptor. - /// - public const uint R_X86_64_TLSDESC_CALL = 35; - - /// - /// TLS descriptor. - /// - public const uint R_X86_64_TLSDESC = 36; - - /// - /// Adjust indirectly by program base - /// - public const uint R_X86_64_IRELATIVE = 37; - - /// - /// 64-bit adjust by program base - /// - public const uint R_X86_64_RELATIVE64 = 38; - - public const uint R_X86_64_NUM = 39; - - /// - /// No reloc. - /// - public const uint R_MN10300_NONE = 0; - - /// - /// Direct 32 bit. - /// - public const uint R_MN10300_32 = 1; - - /// - /// Direct 16 bit. - /// - public const uint R_MN10300_16 = 2; - - /// - /// Direct 8 bit. - /// - public const uint R_MN10300_8 = 3; - - /// - /// PC-relative 32-bit. - /// - public const uint R_MN10300_PCREL32 = 4; - - /// - /// PC-relative 16-bit signed. - /// - public const uint R_MN10300_PCREL16 = 5; - - /// - /// PC-relative 8-bit signed. - /// - public const uint R_MN10300_PCREL8 = 6; - - /// - /// Ancient C++ vtable garbage... - /// - public const uint R_MN10300_GNU_VTINHERIT = 7; - - /// - /// ... collection annotation. - /// - public const uint R_MN10300_GNU_VTENTRY = 8; - - /// - /// Direct 24 bit. - /// - public const uint R_MN10300_24 = 9; - - /// - /// 32-bit PCrel offset to GOT. - /// - public const uint R_MN10300_GOTPC32 = 10; - - /// - /// 16-bit PCrel offset to GOT. - /// - public const uint R_MN10300_GOTPC16 = 11; - - /// - /// 32-bit offset from GOT. - /// - public const uint R_MN10300_GOTOFF32 = 12; - - /// - /// 24-bit offset from GOT. - /// - public const uint R_MN10300_GOTOFF24 = 13; - - /// - /// 16-bit offset from GOT. - /// - public const uint R_MN10300_GOTOFF16 = 14; - - /// - /// 32-bit PCrel to PLT entry. - /// - public const uint R_MN10300_PLT32 = 15; - - /// - /// 16-bit PCrel to PLT entry. - /// - public const uint R_MN10300_PLT16 = 16; - - /// - /// 32-bit offset to GOT entry. - /// - public const uint R_MN10300_GOT32 = 17; - - /// - /// 24-bit offset to GOT entry. - /// - public const uint R_MN10300_GOT24 = 18; - - /// - /// 16-bit offset to GOT entry. - /// - public const uint R_MN10300_GOT16 = 19; - - /// - /// Copy symbol at runtime. - /// - public const uint R_MN10300_COPY = 20; - - /// - /// Create GOT entry. - /// - public const uint R_MN10300_GLOB_DAT = 21; - - /// - /// Create PLT entry. - /// - public const uint R_MN10300_JMP_SLOT = 22; - - /// - /// Adjust by program base. - /// - public const uint R_MN10300_RELATIVE = 23; - - /// - /// 32-bit offset for global dynamic. - /// - public const uint R_MN10300_TLS_GD = 24; - - /// - /// 32-bit offset for local dynamic. - /// - public const uint R_MN10300_TLS_LD = 25; - - /// - /// Module-relative offset. - /// - public const uint R_MN10300_TLS_LDO = 26; - - /// - /// GOT offset for static TLS block offset. - /// - public const uint R_MN10300_TLS_GOTIE = 27; - - /// - /// GOT address for static TLS block offset. - /// - public const uint R_MN10300_TLS_IE = 28; - - /// - /// Offset relative to static TLS block. - /// - public const uint R_MN10300_TLS_LE = 29; - - /// - /// ID of module containing symbol. - /// - public const uint R_MN10300_TLS_DTPMOD = 30; - - /// - /// Offset in module TLS block. - /// - public const uint R_MN10300_TLS_DTPOFF = 31; - - /// - /// Offset in static TLS block. - /// - public const uint R_MN10300_TLS_TPOFF = 32; - - /// - /// Adjustment for next reloc as needed by linker relaxation. - /// - public const uint R_MN10300_SYM_DIFF = 33; - - /// - /// Alignment requirement for linker relaxation. - /// - public const uint R_MN10300_ALIGN = 34; - - public const uint R_MN10300_NUM = 35; - - /// - /// No reloc. - /// - public const uint R_M32R_NONE = 0; - - /// - /// Direct 16 bit. - /// - public const uint R_M32R_16 = 1; - - /// - /// Direct 32 bit. - /// - public const uint R_M32R_32 = 2; - - /// - /// Direct 24 bit. - /// - public const uint R_M32R_24 = 3; - - /// - /// PC relative 10 bit shifted. - /// - public const uint R_M32R_10_PCREL = 4; - - /// - /// PC relative 18 bit shifted. - /// - public const uint R_M32R_18_PCREL = 5; - - /// - /// PC relative 26 bit shifted. - /// - public const uint R_M32R_26_PCREL = 6; - - /// - /// High 16 bit with unsigned low. - /// - public const uint R_M32R_HI16_ULO = 7; - - /// - /// High 16 bit with signed low. - /// - public const uint R_M32R_HI16_SLO = 8; - - /// - /// Low 16 bit. - /// - public const uint R_M32R_LO16 = 9; - - /// - /// 16 bit offset in SDA. - /// - public const uint R_M32R_SDA16 = 10; - - public const uint R_M32R_GNU_VTINHERIT = 11; - - public const uint R_M32R_GNU_VTENTRY = 12; - - /// - /// Direct 16 bit. - /// - public const uint R_M32R_16_RELA = 33; - - /// - /// Direct 32 bit. - /// - public const uint R_M32R_32_RELA = 34; - - /// - /// Direct 24 bit. - /// - public const uint R_M32R_24_RELA = 35; - - /// - /// PC relative 10 bit shifted. - /// - public const uint R_M32R_10_PCREL_RELA = 36; - - /// - /// PC relative 18 bit shifted. - /// - public const uint R_M32R_18_PCREL_RELA = 37; - - /// - /// PC relative 26 bit shifted. - /// - public const uint R_M32R_26_PCREL_RELA = 38; - - /// - /// High 16 bit with unsigned low - /// - public const uint R_M32R_HI16_ULO_RELA = 39; - - /// - /// High 16 bit with signed low - /// - public const uint R_M32R_HI16_SLO_RELA = 40; - - /// - /// Low 16 bit - /// - public const uint R_M32R_LO16_RELA = 41; - - /// - /// 16 bit offset in SDA - /// - public const uint R_M32R_SDA16_RELA = 42; - - public const uint R_M32R_RELA_GNU_VTINHERIT = 43; - - public const uint R_M32R_RELA_GNU_VTENTRY = 44; - - /// - /// PC relative 32 bit. - /// - public const uint R_M32R_REL32 = 45; - - /// - /// 24 bit GOT entry - /// - public const uint R_M32R_GOT24 = 48; - - /// - /// 26 bit PC relative to PLT shifted - /// - public const uint R_M32R_26_PLTREL = 49; - - /// - /// Copy symbol at runtime - /// - public const uint R_M32R_COPY = 50; - - /// - /// Create GOT entry - /// - public const uint R_M32R_GLOB_DAT = 51; - - /// - /// Create PLT entry - /// - public const uint R_M32R_JMP_SLOT = 52; - - /// - /// Adjust by program base - /// - public const uint R_M32R_RELATIVE = 53; - - /// - /// 24 bit offset to GOT - /// - public const uint R_M32R_GOTOFF = 54; - - /// - /// 24 bit PC relative offset to GOT - /// - public const uint R_M32R_GOTPC24 = 55; - - /// - /// High 16 bit GOT entry with unsigned low - /// - public const uint R_M32R_GOT16_HI_ULO = 56; - - /// - /// High 16 bit GOT entry with signed low - /// - public const uint R_M32R_GOT16_HI_SLO = 57; - - /// - /// Low 16 bit GOT entry - /// - public const uint R_M32R_GOT16_LO = 58; - - /// - /// High 16 bit PC relative offset to GOT with unsigned low - /// - public const uint R_M32R_GOTPC_HI_ULO = 59; - - /// - /// High 16 bit PC relative offset to GOT with signed low - /// - public const uint R_M32R_GOTPC_HI_SLO = 60; - - /// - /// Low 16 bit PC relative offset to GOT - /// - public const uint R_M32R_GOTPC_LO = 61; - - /// - /// High 16 bit offset to GOT with unsigned low - /// - public const uint R_M32R_GOTOFF_HI_ULO = 62; - - /// - /// High 16 bit offset to GOT with signed low - /// - public const uint R_M32R_GOTOFF_HI_SLO = 63; - - /// - /// Low 16 bit offset to GOT - /// - public const uint R_M32R_GOTOFF_LO = 64; - - /// - /// Keep this the last entry. - /// - public const uint R_M32R_NUM = 256; - - /// - /// No reloc. - /// - public const uint R_MICROBLAZE_NONE = 0; - - /// - /// Direct 32 bit. - /// - public const uint R_MICROBLAZE_32 = 1; - - /// - /// PC relative 32 bit. - /// - public const uint R_MICROBLAZE_32_PCREL = 2; - - /// - /// PC relative 64 bit. - /// - public const uint R_MICROBLAZE_64_PCREL = 3; - - /// - /// Low 16 bits of PCREL32. - /// - public const uint R_MICROBLAZE_32_PCREL_LO = 4; - - /// - /// Direct 64 bit. - /// - public const uint R_MICROBLAZE_64 = 5; - - /// - /// Low 16 bit. - /// - public const uint R_MICROBLAZE_32_LO = 6; - - /// - /// Read-only small data area. - /// - public const uint R_MICROBLAZE_SRO32 = 7; - - /// - /// Read-write small data area. - /// - public const uint R_MICROBLAZE_SRW32 = 8; - - /// - /// No reloc. - /// - public const uint R_MICROBLAZE_64_NONE = 9; - - /// - /// Symbol Op Symbol relocation. - /// - public const uint R_MICROBLAZE_32_SYM_OP_SYM = 10; - - /// - /// GNU C++ vtable hierarchy. - /// - public const uint R_MICROBLAZE_GNU_VTINHERIT = 11; - - /// - /// GNU C++ vtable member usage. - /// - public const uint R_MICROBLAZE_GNU_VTENTRY = 12; - - /// - /// PC-relative GOT offset. - /// - public const uint R_MICROBLAZE_GOTPC_64 = 13; - - /// - /// GOT entry offset. - /// - public const uint R_MICROBLAZE_GOT_64 = 14; - - /// - /// PLT offset (PC-relative). - /// - public const uint R_MICROBLAZE_PLT_64 = 15; - - /// - /// Adjust by program base. - /// - public const uint R_MICROBLAZE_REL = 16; - - /// - /// Create PLT entry. - /// - public const uint R_MICROBLAZE_JUMP_SLOT = 17; - - /// - /// Create GOT entry. - /// - public const uint R_MICROBLAZE_GLOB_DAT = 18; - - /// - /// 64 bit offset to GOT. - /// - public const uint R_MICROBLAZE_GOTOFF_64 = 19; - - /// - /// 32 bit offset to GOT. - /// - public const uint R_MICROBLAZE_GOTOFF_32 = 20; - - /// - /// Runtime copy. - /// - public const uint R_MICROBLAZE_COPY = 21; - - /// - /// TLS Reloc. - /// - public const uint R_MICROBLAZE_TLS = 22; - - /// - /// TLS General Dynamic. - /// - public const uint R_MICROBLAZE_TLSGD = 23; - - /// - /// TLS Local Dynamic. - /// - public const uint R_MICROBLAZE_TLSLD = 24; - - /// - /// TLS Module ID. - /// - public const uint R_MICROBLAZE_TLSDTPMOD32 = 25; - - /// - /// TLS Offset Within TLS Block. - /// - public const uint R_MICROBLAZE_TLSDTPREL32 = 26; - - /// - /// TLS Offset Within TLS Block. - /// - public const uint R_MICROBLAZE_TLSDTPREL64 = 27; - - /// - /// TLS Offset From Thread Pointer. - /// - public const uint R_MICROBLAZE_TLSGOTTPREL32 = 28; - - /// - /// TLS Offset From Thread Pointer. - /// - public const uint R_MICROBLAZE_TLSTPREL32 = 29; - - /// - /// Address of _gp. - /// - public const int DT_NIOS2_GP = 0x70000002; - - /// - /// No reloc. - /// - public const uint R_NIOS2_NONE = 0; - - /// - /// Direct signed 16 bit. - /// - public const uint R_NIOS2_S16 = 1; - - /// - /// Direct unsigned 16 bit. - /// - public const uint R_NIOS2_U16 = 2; - - /// - /// PC relative 16 bit. - /// - public const uint R_NIOS2_PCREL16 = 3; - - /// - /// Direct call. - /// - public const uint R_NIOS2_CALL26 = 4; - - /// - /// 5 bit constant expression. - /// - public const uint R_NIOS2_IMM5 = 5; - - /// - /// 5 bit expression, shift 22. - /// - public const uint R_NIOS2_CACHE_OPX = 6; - - /// - /// 6 bit constant expression. - /// - public const uint R_NIOS2_IMM6 = 7; - - /// - /// 8 bit constant expression. - /// - public const uint R_NIOS2_IMM8 = 8; - - /// - /// High 16 bit. - /// - public const uint R_NIOS2_HI16 = 9; - - /// - /// Low 16 bit. - /// - public const uint R_NIOS2_LO16 = 10; - - /// - /// High 16 bit, adjusted. - /// - public const uint R_NIOS2_HIADJ16 = 11; - - /// - /// 32 bit symbol value + addend. - /// - public const uint R_NIOS2_BFD_RELOC_32 = 12; - - /// - /// 16 bit symbol value + addend. - /// - public const uint R_NIOS2_BFD_RELOC_16 = 13; - - /// - /// 8 bit symbol value + addend. - /// - public const uint R_NIOS2_BFD_RELOC_8 = 14; - - /// - /// 16 bit GP pointer offset. - /// - public const uint R_NIOS2_GPREL = 15; - - /// - /// GNU C++ vtable hierarchy. - /// - public const uint R_NIOS2_GNU_VTINHERIT = 16; - - /// - /// GNU C++ vtable member usage. - /// - public const uint R_NIOS2_GNU_VTENTRY = 17; - - /// - /// Unconditional branch. - /// - public const uint R_NIOS2_UJMP = 18; - - /// - /// Conditional branch. - /// - public const uint R_NIOS2_CJMP = 19; - - /// - /// Indirect call through register. - /// - public const uint R_NIOS2_CALLR = 20; - - /// - /// Alignment requirement for linker relaxation. - /// - public const uint R_NIOS2_ALIGN = 21; - - /// - /// 16 bit GOT entry. - /// - public const uint R_NIOS2_GOT16 = 22; - - /// - /// 16 bit GOT entry for function. - /// - public const uint R_NIOS2_CALL16 = 23; - - /// - /// %lo of offset to GOT pointer. - /// - public const uint R_NIOS2_GOTOFF_LO = 24; - - /// - /// %hiadj of offset to GOT pointer. - /// - public const uint R_NIOS2_GOTOFF_HA = 25; - - /// - /// %lo of PC relative offset. - /// - public const uint R_NIOS2_PCREL_LO = 26; - - /// - /// %hiadj of PC relative offset. - /// - public const uint R_NIOS2_PCREL_HA = 27; - - /// - /// 16 bit GOT offset for TLS GD. - /// - public const uint R_NIOS2_TLS_GD16 = 28; - - /// - /// 16 bit GOT offset for TLS LDM. - /// - public const uint R_NIOS2_TLS_LDM16 = 29; - - /// - /// 16 bit module relative offset. - /// - public const uint R_NIOS2_TLS_LDO16 = 30; - - /// - /// 16 bit GOT offset for TLS IE. - /// - public const uint R_NIOS2_TLS_IE16 = 31; - - /// - /// 16 bit LE TP-relative offset. - /// - public const uint R_NIOS2_TLS_LE16 = 32; - - /// - /// Module number. - /// - public const uint R_NIOS2_TLS_DTPMOD = 33; - - /// - /// Module-relative offset. - /// - public const uint R_NIOS2_TLS_DTPREL = 34; - - /// - /// TP-relative offset. - /// - public const uint R_NIOS2_TLS_TPREL = 35; - - /// - /// Copy symbol at runtime. - /// - public const uint R_NIOS2_COPY = 36; - - /// - /// Create GOT entry. - /// - public const uint R_NIOS2_GLOB_DAT = 37; - - /// - /// Create PLT entry. - /// - public const uint R_NIOS2_JUMP_SLOT = 38; - - /// - /// Adjust by program base. - /// - public const uint R_NIOS2_RELATIVE = 39; - - /// - /// 16 bit offset to GOT pointer. - /// - public const uint R_NIOS2_GOTOFF = 40; - - /// - /// Direct call in .noat section. - /// - public const uint R_NIOS2_CALL26_NOAT = 41; - - /// - /// %lo() of GOT entry. - /// - public const uint R_NIOS2_GOT_LO = 42; - - /// - /// %hiadj() of GOT entry. - /// - public const uint R_NIOS2_GOT_HA = 43; - - /// - /// %lo() of function GOT entry. - /// - public const uint R_NIOS2_CALL_LO = 44; - - /// - /// %hiadj() of function GOT entry. - /// - public const uint R_NIOS2_CALL_HA = 45; - - /// - /// No reloc - /// - public const uint R_TILEPRO_NONE = 0; - - /// - /// Direct 32 bit - /// - public const uint R_TILEPRO_32 = 1; - - /// - /// Direct 16 bit - /// - public const uint R_TILEPRO_16 = 2; - - /// - /// Direct 8 bit - /// - public const uint R_TILEPRO_8 = 3; - - /// - /// PC relative 32 bit - /// - public const uint R_TILEPRO_32_PCREL = 4; - - /// - /// PC relative 16 bit - /// - public const uint R_TILEPRO_16_PCREL = 5; - - /// - /// PC relative 8 bit - /// - public const uint R_TILEPRO_8_PCREL = 6; - - /// - /// Low 16 bit - /// - public const uint R_TILEPRO_LO16 = 7; - - /// - /// High 16 bit - /// - public const uint R_TILEPRO_HI16 = 8; - - /// - /// High 16 bit, adjusted - /// - public const uint R_TILEPRO_HA16 = 9; - - /// - /// Copy relocation - /// - public const uint R_TILEPRO_COPY = 10; - - /// - /// Create GOT entry - /// - public const uint R_TILEPRO_GLOB_DAT = 11; - - /// - /// Create PLT entry - /// - public const uint R_TILEPRO_JMP_SLOT = 12; - - /// - /// Adjust by program base - /// - public const uint R_TILEPRO_RELATIVE = 13; - - /// - /// X1 pipe branch offset - /// - public const uint R_TILEPRO_BROFF_X1 = 14; - - /// - /// X1 pipe jump offset - /// - public const uint R_TILEPRO_JOFFLONG_X1 = 15; - - /// - /// X1 pipe jump offset to PLT - /// - public const uint R_TILEPRO_JOFFLONG_X1_PLT = 16; - - /// - /// X0 pipe 8-bit - /// - public const uint R_TILEPRO_IMM8_X0 = 17; - - /// - /// Y0 pipe 8-bit - /// - public const uint R_TILEPRO_IMM8_Y0 = 18; - - /// - /// X1 pipe 8-bit - /// - public const uint R_TILEPRO_IMM8_X1 = 19; - - /// - /// Y1 pipe 8-bit - /// - public const uint R_TILEPRO_IMM8_Y1 = 20; - - /// - /// X1 pipe mtspr - /// - public const uint R_TILEPRO_MT_IMM15_X1 = 21; - - /// - /// X1 pipe mfspr - /// - public const uint R_TILEPRO_MF_IMM15_X1 = 22; - - /// - /// X0 pipe 16-bit - /// - public const uint R_TILEPRO_IMM16_X0 = 23; - - /// - /// X1 pipe 16-bit - /// - public const uint R_TILEPRO_IMM16_X1 = 24; - - /// - /// X0 pipe low 16-bit - /// - public const uint R_TILEPRO_IMM16_X0_LO = 25; - - /// - /// X1 pipe low 16-bit - /// - public const uint R_TILEPRO_IMM16_X1_LO = 26; - - /// - /// X0 pipe high 16-bit - /// - public const uint R_TILEPRO_IMM16_X0_HI = 27; - - /// - /// X1 pipe high 16-bit - /// - public const uint R_TILEPRO_IMM16_X1_HI = 28; - - /// - /// X0 pipe high 16-bit, adjusted - /// - public const uint R_TILEPRO_IMM16_X0_HA = 29; - - /// - /// X1 pipe high 16-bit, adjusted - /// - public const uint R_TILEPRO_IMM16_X1_HA = 30; - - /// - /// X0 pipe PC relative 16 bit - /// - public const uint R_TILEPRO_IMM16_X0_PCREL = 31; - - /// - /// X1 pipe PC relative 16 bit - /// - public const uint R_TILEPRO_IMM16_X1_PCREL = 32; - - /// - /// X0 pipe PC relative low 16 bit - /// - public const uint R_TILEPRO_IMM16_X0_LO_PCREL = 33; - - /// - /// X1 pipe PC relative low 16 bit - /// - public const uint R_TILEPRO_IMM16_X1_LO_PCREL = 34; - - /// - /// X0 pipe PC relative high 16 bit - /// - public const uint R_TILEPRO_IMM16_X0_HI_PCREL = 35; - - /// - /// X1 pipe PC relative high 16 bit - /// - public const uint R_TILEPRO_IMM16_X1_HI_PCREL = 36; - - /// - /// X0 pipe PC relative ha() 16 bit - /// - public const uint R_TILEPRO_IMM16_X0_HA_PCREL = 37; - - /// - /// X1 pipe PC relative ha() 16 bit - /// - public const uint R_TILEPRO_IMM16_X1_HA_PCREL = 38; - - /// - /// X0 pipe 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X0_GOT = 39; - - /// - /// X1 pipe 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X1_GOT = 40; - - /// - /// X0 pipe low 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X0_GOT_LO = 41; - - /// - /// X1 pipe low 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X1_GOT_LO = 42; - - /// - /// X0 pipe high 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X0_GOT_HI = 43; - - /// - /// X1 pipe high 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X1_GOT_HI = 44; - - /// - /// X0 pipe ha() 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X0_GOT_HA = 45; - - /// - /// X1 pipe ha() 16-bit GOT offset - /// - public const uint R_TILEPRO_IMM16_X1_GOT_HA = 46; - - /// - /// X0 pipe mm "start" - /// - public const uint R_TILEPRO_MMSTART_X0 = 47; - - /// - /// X0 pipe mm "end" - /// - public const uint R_TILEPRO_MMEND_X0 = 48; - - /// - /// X1 pipe mm "start" - /// - public const uint R_TILEPRO_MMSTART_X1 = 49; - - /// - /// X1 pipe mm "end" - /// - public const uint R_TILEPRO_MMEND_X1 = 50; - - /// - /// X0 pipe shift amount - /// - public const uint R_TILEPRO_SHAMT_X0 = 51; - - /// - /// X1 pipe shift amount - /// - public const uint R_TILEPRO_SHAMT_X1 = 52; - - /// - /// Y0 pipe shift amount - /// - public const uint R_TILEPRO_SHAMT_Y0 = 53; - - /// - /// Y1 pipe shift amount - /// - public const uint R_TILEPRO_SHAMT_Y1 = 54; - - /// - /// X1 pipe destination 8-bit - /// - public const uint R_TILEPRO_DEST_IMM8_X1 = 55; - - /// - /// "jal" for TLS GD - /// - public const uint R_TILEPRO_TLS_GD_CALL = 60; - - /// - /// X0 pipe "addi" for TLS GD - /// - public const uint R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61; - - /// - /// X1 pipe "addi" for TLS GD - /// - public const uint R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62; - - /// - /// Y0 pipe "addi" for TLS GD - /// - public const uint R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63; - - /// - /// Y1 pipe "addi" for TLS GD - /// - public const uint R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64; - - /// - /// "lw_tls" for TLS IE - /// - public const uint R_TILEPRO_TLS_IE_LOAD = 65; - - /// - /// X0 pipe 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_GD = 66; - - /// - /// X1 pipe 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_GD = 67; - - /// - /// X0 pipe low 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_GD_LO = 68; - - /// - /// X1 pipe low 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_GD_LO = 69; - - /// - /// X0 pipe high 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_GD_HI = 70; - - /// - /// X1 pipe high 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_GD_HI = 71; - - /// - /// X0 pipe ha() 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_GD_HA = 72; - - /// - /// X1 pipe ha() 16-bit TLS GD offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_GD_HA = 73; - - /// - /// X0 pipe 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_IE = 74; - - /// - /// X1 pipe 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_IE = 75; - - /// - /// X0 pipe low 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_IE_LO = 76; - - /// - /// X1 pipe low 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_IE_LO = 77; - - /// - /// X0 pipe high 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_IE_HI = 78; - - /// - /// X1 pipe high 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_IE_HI = 79; - - /// - /// X0 pipe ha() 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_IE_HA = 80; - - /// - /// X1 pipe ha() 16-bit TLS IE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_IE_HA = 81; - - /// - /// ID of module containing symbol - /// - public const uint R_TILEPRO_TLS_DTPMOD32 = 82; - - /// - /// Offset in TLS block - /// - public const uint R_TILEPRO_TLS_DTPOFF32 = 83; - - /// - /// Offset in static TLS block - /// - public const uint R_TILEPRO_TLS_TPOFF32 = 84; - - /// - /// X0 pipe 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_LE = 85; - - /// - /// X1 pipe 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_LE = 86; - - /// - /// X0 pipe low 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_LE_LO = 87; - - /// - /// X1 pipe low 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_LE_LO = 88; - - /// - /// X0 pipe high 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_LE_HI = 89; - - /// - /// X1 pipe high 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_LE_HI = 90; - - /// - /// X0 pipe ha() 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X0_TLS_LE_HA = 91; - - /// - /// X1 pipe ha() 16-bit TLS LE offset - /// - public const uint R_TILEPRO_IMM16_X1_TLS_LE_HA = 92; - - /// - /// GNU C++ vtable hierarchy - /// - public const uint R_TILEPRO_GNU_VTINHERIT = 128; - - /// - /// GNU C++ vtable member usage - /// - public const uint R_TILEPRO_GNU_VTENTRY = 129; - - public const uint R_TILEPRO_NUM = 130; - - /// - /// No reloc - /// - public const uint R_TILEGX_NONE = 0; - - /// - /// Direct 64 bit - /// - public const uint R_TILEGX_64 = 1; - - /// - /// Direct 32 bit - /// - public const uint R_TILEGX_32 = 2; - - /// - /// Direct 16 bit - /// - public const uint R_TILEGX_16 = 3; - - /// - /// Direct 8 bit - /// - public const uint R_TILEGX_8 = 4; - - /// - /// PC relative 64 bit - /// - public const uint R_TILEGX_64_PCREL = 5; - - /// - /// PC relative 32 bit - /// - public const uint R_TILEGX_32_PCREL = 6; - - /// - /// PC relative 16 bit - /// - public const uint R_TILEGX_16_PCREL = 7; - - /// - /// PC relative 8 bit - /// - public const uint R_TILEGX_8_PCREL = 8; - - /// - /// hword 0 16-bit - /// - public const uint R_TILEGX_HW0 = 9; - - /// - /// hword 1 16-bit - /// - public const uint R_TILEGX_HW1 = 10; - - /// - /// hword 2 16-bit - /// - public const uint R_TILEGX_HW2 = 11; - - /// - /// hword 3 16-bit - /// - public const uint R_TILEGX_HW3 = 12; - - /// - /// last hword 0 16-bit - /// - public const uint R_TILEGX_HW0_LAST = 13; - - /// - /// last hword 1 16-bit - /// - public const uint R_TILEGX_HW1_LAST = 14; - - /// - /// last hword 2 16-bit - /// - public const uint R_TILEGX_HW2_LAST = 15; - - /// - /// Copy relocation - /// - public const uint R_TILEGX_COPY = 16; - - /// - /// Create GOT entry - /// - public const uint R_TILEGX_GLOB_DAT = 17; - - /// - /// Create PLT entry - /// - public const uint R_TILEGX_JMP_SLOT = 18; - - /// - /// Adjust by program base - /// - public const uint R_TILEGX_RELATIVE = 19; - - /// - /// X1 pipe branch offset - /// - public const uint R_TILEGX_BROFF_X1 = 20; - - /// - /// X1 pipe jump offset - /// - public const uint R_TILEGX_JUMPOFF_X1 = 21; - - /// - /// X1 pipe jump offset to PLT - /// - public const uint R_TILEGX_JUMPOFF_X1_PLT = 22; - - /// - /// X0 pipe 8-bit - /// - public const uint R_TILEGX_IMM8_X0 = 23; - - /// - /// Y0 pipe 8-bit - /// - public const uint R_TILEGX_IMM8_Y0 = 24; - - /// - /// X1 pipe 8-bit - /// - public const uint R_TILEGX_IMM8_X1 = 25; - - /// - /// Y1 pipe 8-bit - /// - public const uint R_TILEGX_IMM8_Y1 = 26; - - /// - /// X1 pipe destination 8-bit - /// - public const uint R_TILEGX_DEST_IMM8_X1 = 27; - - /// - /// X1 pipe mtspr - /// - public const uint R_TILEGX_MT_IMM14_X1 = 28; - - /// - /// X1 pipe mfspr - /// - public const uint R_TILEGX_MF_IMM14_X1 = 29; - - /// - /// X0 pipe mm "start" - /// - public const uint R_TILEGX_MMSTART_X0 = 30; - - /// - /// X0 pipe mm "end" - /// - public const uint R_TILEGX_MMEND_X0 = 31; - - /// - /// X0 pipe shift amount - /// - public const uint R_TILEGX_SHAMT_X0 = 32; - - /// - /// X1 pipe shift amount - /// - public const uint R_TILEGX_SHAMT_X1 = 33; - - /// - /// Y0 pipe shift amount - /// - public const uint R_TILEGX_SHAMT_Y0 = 34; - - /// - /// Y1 pipe shift amount - /// - public const uint R_TILEGX_SHAMT_Y1 = 35; - - /// - /// X0 pipe hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0 = 36; - - /// - /// X1 pipe hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0 = 37; - - /// - /// X0 pipe hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1 = 38; - - /// - /// X1 pipe hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1 = 39; - - /// - /// X0 pipe hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2 = 40; - - /// - /// X1 pipe hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2 = 41; - - /// - /// X0 pipe hword 3 - /// - public const uint R_TILEGX_IMM16_X0_HW3 = 42; - - /// - /// X1 pipe hword 3 - /// - public const uint R_TILEGX_IMM16_X1_HW3 = 43; - - /// - /// X0 pipe last hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST = 44; - - /// - /// X1 pipe last hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST = 45; - - /// - /// X0 pipe last hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST = 46; - - /// - /// X1 pipe last hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST = 47; - - /// - /// X0 pipe last hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2_LAST = 48; - - /// - /// X1 pipe last hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2_LAST = 49; - - /// - /// X0 pipe PC relative hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0_PCREL = 50; - - /// - /// X1 pipe PC relative hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0_PCREL = 51; - - /// - /// X0 pipe PC relative hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1_PCREL = 52; - - /// - /// X1 pipe PC relative hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1_PCREL = 53; - - /// - /// X0 pipe PC relative hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2_PCREL = 54; - - /// - /// X1 pipe PC relative hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2_PCREL = 55; - - /// - /// X0 pipe PC relative hword 3 - /// - public const uint R_TILEGX_IMM16_X0_HW3_PCREL = 56; - - /// - /// X1 pipe PC relative hword 3 - /// - public const uint R_TILEGX_IMM16_X1_HW3_PCREL = 57; - - /// - /// X0 pipe PC-rel last hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58; - - /// - /// X1 pipe PC-rel last hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59; - - /// - /// X0 pipe PC-rel last hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60; - - /// - /// X1 pipe PC-rel last hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61; - - /// - /// X0 pipe PC-rel last hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62; - - /// - /// X1 pipe PC-rel last hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63; - - /// - /// X0 pipe hword 0 GOT offset - /// - public const uint R_TILEGX_IMM16_X0_HW0_GOT = 64; - - /// - /// X1 pipe hword 0 GOT offset - /// - public const uint R_TILEGX_IMM16_X1_HW0_GOT = 65; - - /// - /// X0 pipe PC-rel PLT hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66; - - /// - /// X1 pipe PC-rel PLT hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67; - - /// - /// X0 pipe PC-rel PLT hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68; - - /// - /// X1 pipe PC-rel PLT hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69; - - /// - /// X0 pipe PC-rel PLT hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70; - - /// - /// X1 pipe PC-rel PLT hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71; - - /// - /// X0 pipe last hword 0 GOT offset - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72; - - /// - /// X1 pipe last hword 0 GOT offset - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73; - - /// - /// X0 pipe last hword 1 GOT offset - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74; - - /// - /// X1 pipe last hword 1 GOT offset - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75; - - /// - /// X0 pipe PC-rel PLT hword 3 - /// - public const uint R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76; - - /// - /// X1 pipe PC-rel PLT hword 3 - /// - public const uint R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77; - - /// - /// X0 pipe hword 0 TLS GD offset - /// - public const uint R_TILEGX_IMM16_X0_HW0_TLS_GD = 78; - - /// - /// X1 pipe hword 0 TLS GD offset - /// - public const uint R_TILEGX_IMM16_X1_HW0_TLS_GD = 79; - - /// - /// X0 pipe hword 0 TLS LE offset - /// - public const uint R_TILEGX_IMM16_X0_HW0_TLS_LE = 80; - - /// - /// X1 pipe hword 0 TLS LE offset - /// - public const uint R_TILEGX_IMM16_X1_HW0_TLS_LE = 81; - - /// - /// X0 pipe last hword 0 LE off - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82; - - /// - /// X1 pipe last hword 0 LE off - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83; - - /// - /// X0 pipe last hword 1 LE off - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84; - - /// - /// X1 pipe last hword 1 LE off - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85; - - /// - /// X0 pipe last hword 0 GD off - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86; - - /// - /// X1 pipe last hword 0 GD off - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87; - - /// - /// X0 pipe last hword 1 GD off - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88; - - /// - /// X1 pipe last hword 1 GD off - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89; - - /// - /// X0 pipe hword 0 TLS IE offset - /// - public const uint R_TILEGX_IMM16_X0_HW0_TLS_IE = 92; - - /// - /// X1 pipe hword 0 TLS IE offset - /// - public const uint R_TILEGX_IMM16_X1_HW0_TLS_IE = 93; - - /// - /// X0 pipe PC-rel PLT last hword 0 - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94; - - /// - /// X1 pipe PC-rel PLT last hword 0 - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95; - - /// - /// X0 pipe PC-rel PLT last hword 1 - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96; - - /// - /// X1 pipe PC-rel PLT last hword 1 - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97; - - /// - /// X0 pipe PC-rel PLT last hword 2 - /// - public const uint R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98; - - /// - /// X1 pipe PC-rel PLT last hword 2 - /// - public const uint R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99; - - /// - /// X0 pipe last hword 0 IE off - /// - public const uint R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100; - - /// - /// X1 pipe last hword 0 IE off - /// - public const uint R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101; - - /// - /// X0 pipe last hword 1 IE off - /// - public const uint R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102; - - /// - /// X1 pipe last hword 1 IE off - /// - public const uint R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103; - - /// - /// 64-bit ID of symbol's module - /// - public const uint R_TILEGX_TLS_DTPMOD64 = 106; - - /// - /// 64-bit offset in TLS block - /// - public const uint R_TILEGX_TLS_DTPOFF64 = 107; - - /// - /// 64-bit offset in static TLS block - /// - public const uint R_TILEGX_TLS_TPOFF64 = 108; - - /// - /// 32-bit ID of symbol's module - /// - public const uint R_TILEGX_TLS_DTPMOD32 = 109; - - /// - /// 32-bit offset in TLS block - /// - public const uint R_TILEGX_TLS_DTPOFF32 = 110; - - /// - /// 32-bit offset in static TLS block - /// - public const uint R_TILEGX_TLS_TPOFF32 = 111; - - /// - /// "jal" for TLS GD - /// - public const uint R_TILEGX_TLS_GD_CALL = 112; - - /// - /// X0 pipe "addi" for TLS GD - /// - public const uint R_TILEGX_IMM8_X0_TLS_GD_ADD = 113; - - /// - /// X1 pipe "addi" for TLS GD - /// - public const uint R_TILEGX_IMM8_X1_TLS_GD_ADD = 114; - - /// - /// Y0 pipe "addi" for TLS GD - /// - public const uint R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115; - - /// - /// Y1 pipe "addi" for TLS GD - /// - public const uint R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116; - - /// - /// "ld_tls" for TLS IE - /// - public const uint R_TILEGX_TLS_IE_LOAD = 117; - - /// - /// X0 pipe "addi" for TLS GD/IE - /// - public const uint R_TILEGX_IMM8_X0_TLS_ADD = 118; - - /// - /// X1 pipe "addi" for TLS GD/IE - /// - public const uint R_TILEGX_IMM8_X1_TLS_ADD = 119; - - /// - /// Y0 pipe "addi" for TLS GD/IE - /// - public const uint R_TILEGX_IMM8_Y0_TLS_ADD = 120; - - /// - /// Y1 pipe "addi" for TLS GD/IE - /// - public const uint R_TILEGX_IMM8_Y1_TLS_ADD = 121; - - /// - /// GNU C++ vtable hierarchy - /// - public const uint R_TILEGX_GNU_VTINHERIT = 128; - - /// - /// GNU C++ vtable member usage - /// - public const uint R_TILEGX_GNU_VTENTRY = 129; - - public const uint R_TILEGX_NUM = 130; - } - - public readonly partial struct ElfArchEx - { - /// - /// No machine - /// - public static readonly ElfArchEx NONE = new ElfArchEx(ElfNative.EM_NONE); - - /// - /// AT - /// &T - /// WE 32100 - /// - public static readonly ElfArchEx M32 = new ElfArchEx(ElfNative.EM_M32); - - /// - /// SUN SPARC - /// - public static readonly ElfArchEx SPARC = new ElfArchEx(ElfNative.EM_SPARC); - - /// - /// Intel 80386 - /// - public static readonly ElfArchEx I386 = new ElfArchEx(ElfNative.EM_386); - - /// - /// Motorola m68k family - /// - public static readonly ElfArchEx M68K = new ElfArchEx(ElfNative.EM_68K); - - /// - /// Motorola m88k family - /// - public static readonly ElfArchEx M88K = new ElfArchEx(ElfNative.EM_88K); - - /// - /// Intel 80860 - /// - public static readonly ElfArchEx I860 = new ElfArchEx(ElfNative.EM_860); - - /// - /// MIPS R3000 big-endian - /// - public static readonly ElfArchEx MIPS = new ElfArchEx(ElfNative.EM_MIPS); - - /// - /// IBM System/370 - /// - public static readonly ElfArchEx S370 = new ElfArchEx(ElfNative.EM_S370); - - /// - /// MIPS R3000 little-endian - /// - public static readonly ElfArchEx MIPS_RS3_LE = new ElfArchEx(ElfNative.EM_MIPS_RS3_LE); - - /// - /// HPPA - /// - public static readonly ElfArchEx PARISC = new ElfArchEx(ElfNative.EM_PARISC); - - /// - /// Fujitsu VPP500 - /// - public static readonly ElfArchEx VPP500 = new ElfArchEx(ElfNative.EM_VPP500); - - /// - /// Sun's "v8plus" - /// - public static readonly ElfArchEx SPARC32PLUS = new ElfArchEx(ElfNative.EM_SPARC32PLUS); - - /// - /// Intel 80960 - /// - public static readonly ElfArchEx I960 = new ElfArchEx(ElfNative.EM_960); - - /// - /// PowerPC - /// - public static readonly ElfArchEx PPC = new ElfArchEx(ElfNative.EM_PPC); - - /// - /// PowerPC 64-bit - /// - public static readonly ElfArchEx PPC64 = new ElfArchEx(ElfNative.EM_PPC64); - - /// - /// IBM S390 - /// - public static readonly ElfArchEx S390 = new ElfArchEx(ElfNative.EM_S390); - - /// - /// NEC V800 series - /// - public static readonly ElfArchEx V800 = new ElfArchEx(ElfNative.EM_V800); - - /// - /// Fujitsu FR20 - /// - public static readonly ElfArchEx FR20 = new ElfArchEx(ElfNative.EM_FR20); - - /// - /// TRW RH-32 - /// - public static readonly ElfArchEx RH32 = new ElfArchEx(ElfNative.EM_RH32); - - /// - /// Motorola RCE - /// - public static readonly ElfArchEx RCE = new ElfArchEx(ElfNative.EM_RCE); - - /// - /// ARM - /// - public static readonly ElfArchEx ARM = new ElfArchEx(ElfNative.EM_ARM); - - /// - /// Digital Alpha - /// - public static readonly ElfArchEx FAKE_ALPHA = new ElfArchEx(ElfNative.EM_FAKE_ALPHA); - - /// - /// Hitachi SH - /// - public static readonly ElfArchEx SH = new ElfArchEx(ElfNative.EM_SH); - - /// - /// SPARC v9 64-bit - /// - public static readonly ElfArchEx SPARCV9 = new ElfArchEx(ElfNative.EM_SPARCV9); - - /// - /// Siemens Tricore - /// - public static readonly ElfArchEx TRICORE = new ElfArchEx(ElfNative.EM_TRICORE); - - /// - /// Argonaut RISC Core - /// - public static readonly ElfArchEx ARC = new ElfArchEx(ElfNative.EM_ARC); - - /// - /// Hitachi H8/300 - /// - public static readonly ElfArchEx H8_300 = new ElfArchEx(ElfNative.EM_H8_300); - - /// - /// Hitachi H8/300H - /// - public static readonly ElfArchEx H8_300H = new ElfArchEx(ElfNative.EM_H8_300H); - - /// - /// Hitachi H8S - /// - public static readonly ElfArchEx H8S = new ElfArchEx(ElfNative.EM_H8S); - - /// - /// Hitachi H8/500 - /// - public static readonly ElfArchEx H8_500 = new ElfArchEx(ElfNative.EM_H8_500); - - /// - /// Intel Merced - /// - public static readonly ElfArchEx IA_64 = new ElfArchEx(ElfNative.EM_IA_64); - - /// - /// Stanford MIPS-X - /// - public static readonly ElfArchEx MIPS_X = new ElfArchEx(ElfNative.EM_MIPS_X); - - /// - /// Motorola Coldfire - /// - public static readonly ElfArchEx COLDFIRE = new ElfArchEx(ElfNative.EM_COLDFIRE); - - /// - /// Motorola M68HC12 - /// - public static readonly ElfArchEx M68HC12 = new ElfArchEx(ElfNative.EM_68HC12); - - /// - /// Fujitsu MMA Multimedia Accelerator - /// - public static readonly ElfArchEx MMA = new ElfArchEx(ElfNative.EM_MMA); - - /// - /// Siemens PCP - /// - public static readonly ElfArchEx PCP = new ElfArchEx(ElfNative.EM_PCP); - - /// - /// Sony nCPU embeeded RISC - /// - public static readonly ElfArchEx NCPU = new ElfArchEx(ElfNative.EM_NCPU); - - /// - /// Denso NDR1 microprocessor - /// - public static readonly ElfArchEx NDR1 = new ElfArchEx(ElfNative.EM_NDR1); - - /// - /// Motorola Start*Core processor - /// - public static readonly ElfArchEx STARCORE = new ElfArchEx(ElfNative.EM_STARCORE); - - /// - /// Toyota ME16 processor - /// - public static readonly ElfArchEx ME16 = new ElfArchEx(ElfNative.EM_ME16); - - /// - /// STMicroelectronic ST100 processor - /// - public static readonly ElfArchEx ST100 = new ElfArchEx(ElfNative.EM_ST100); - - /// - /// Advanced Logic Corp. Tinyj emb.fam - /// - public static readonly ElfArchEx TINYJ = new ElfArchEx(ElfNative.EM_TINYJ); - - /// - /// AMD x86-64 architecture - /// - public static readonly ElfArchEx X86_64 = new ElfArchEx(ElfNative.EM_X86_64); - - /// - /// Sony DSP Processor - /// - public static readonly ElfArchEx PDSP = new ElfArchEx(ElfNative.EM_PDSP); - - /// - /// Siemens FX66 microcontroller - /// - public static readonly ElfArchEx FX66 = new ElfArchEx(ElfNative.EM_FX66); - - /// - /// STMicroelectronics ST9+ 8/16 mc - /// - public static readonly ElfArchEx ST9PLUS = new ElfArchEx(ElfNative.EM_ST9PLUS); - - /// - /// STmicroelectronics ST7 8 bit mc - /// - public static readonly ElfArchEx ST7 = new ElfArchEx(ElfNative.EM_ST7); - - /// - /// Motorola MC68HC16 microcontroller - /// - public static readonly ElfArchEx M68HC16 = new ElfArchEx(ElfNative.EM_68HC16); - - /// - /// Motorola MC68HC11 microcontroller - /// - public static readonly ElfArchEx M68HC11 = new ElfArchEx(ElfNative.EM_68HC11); - - /// - /// Motorola MC68HC08 microcontroller - /// - public static readonly ElfArchEx M68HC08 = new ElfArchEx(ElfNative.EM_68HC08); - - /// - /// Motorola MC68HC05 microcontroller - /// - public static readonly ElfArchEx M68HC05 = new ElfArchEx(ElfNative.EM_68HC05); - - /// - /// Silicon Graphics SVx - /// - public static readonly ElfArchEx SVX = new ElfArchEx(ElfNative.EM_SVX); - - /// - /// STMicroelectronics ST19 8 bit mc - /// - public static readonly ElfArchEx ST19 = new ElfArchEx(ElfNative.EM_ST19); - - /// - /// Digital VAX - /// - public static readonly ElfArchEx VAX = new ElfArchEx(ElfNative.EM_VAX); - - /// - /// Axis Communications 32-bit embedded processor - /// - public static readonly ElfArchEx CRIS = new ElfArchEx(ElfNative.EM_CRIS); - - /// - /// Infineon Technologies 32-bit embedded processor - /// - public static readonly ElfArchEx JAVELIN = new ElfArchEx(ElfNative.EM_JAVELIN); - - /// - /// Element 14 64-bit DSP Processor - /// - public static readonly ElfArchEx FIREPATH = new ElfArchEx(ElfNative.EM_FIREPATH); - - /// - /// LSI Logic 16-bit DSP Processor - /// - public static readonly ElfArchEx ZSP = new ElfArchEx(ElfNative.EM_ZSP); - - /// - /// Donald Knuth's educational 64-bit processor - /// - public static readonly ElfArchEx MMIX = new ElfArchEx(ElfNative.EM_MMIX); - - /// - /// Harvard University machine-independent object files - /// - public static readonly ElfArchEx HUANY = new ElfArchEx(ElfNative.EM_HUANY); - - /// - /// SiTera Prism - /// - public static readonly ElfArchEx PRISM = new ElfArchEx(ElfNative.EM_PRISM); - - /// - /// Atmel AVR 8-bit microcontroller - /// - public static readonly ElfArchEx AVR = new ElfArchEx(ElfNative.EM_AVR); - - /// - /// Fujitsu FR30 - /// - public static readonly ElfArchEx FR30 = new ElfArchEx(ElfNative.EM_FR30); - - /// - /// Mitsubishi D10V - /// - public static readonly ElfArchEx D10V = new ElfArchEx(ElfNative.EM_D10V); - - /// - /// Mitsubishi D30V - /// - public static readonly ElfArchEx D30V = new ElfArchEx(ElfNative.EM_D30V); - - /// - /// NEC v850 - /// - public static readonly ElfArchEx V850 = new ElfArchEx(ElfNative.EM_V850); - - /// - /// Mitsubishi M32R - /// - public static readonly ElfArchEx M32R = new ElfArchEx(ElfNative.EM_M32R); - - /// - /// Matsushita MN10300 - /// - public static readonly ElfArchEx MN10300 = new ElfArchEx(ElfNative.EM_MN10300); - - /// - /// Matsushita MN10200 - /// - public static readonly ElfArchEx MN10200 = new ElfArchEx(ElfNative.EM_MN10200); - - /// - /// picoJava - /// - public static readonly ElfArchEx PJ = new ElfArchEx(ElfNative.EM_PJ); - - /// - /// OpenRISC 32-bit embedded processor - /// - public static readonly ElfArchEx OPENRISC = new ElfArchEx(ElfNative.EM_OPENRISC); - - /// - /// ARC Cores Tangent-A5 - /// - public static readonly ElfArchEx ARC_A5 = new ElfArchEx(ElfNative.EM_ARC_A5); - - /// - /// Tensilica Xtensa Architecture - /// - public static readonly ElfArchEx XTENSA = new ElfArchEx(ElfNative.EM_XTENSA); - - /// - /// Altera Nios II - /// - public static readonly ElfArchEx ALTERA_NIOS2 = new ElfArchEx(ElfNative.EM_ALTERA_NIOS2); - - /// - /// ARM AARCH64 - /// - public static readonly ElfArchEx AARCH64 = new ElfArchEx(ElfNative.EM_AARCH64); - - /// - /// Tilera TILEPro - /// - public static readonly ElfArchEx TILEPRO = new ElfArchEx(ElfNative.EM_TILEPRO); - - /// - /// Xilinx MicroBlaze - /// - public static readonly ElfArchEx MICROBLAZE = new ElfArchEx(ElfNative.EM_MICROBLAZE); - - /// - /// Tilera TILE-Gx - /// - public static readonly ElfArchEx TILEGX = new ElfArchEx(ElfNative.EM_TILEGX); - - public static readonly ElfArchEx ALPHA = new ElfArchEx(ElfNative.EM_ALPHA); - - private string ToStringInternal() - { - switch ((ushort)Value) - { - case ElfNative.EM_NONE: return "EM_NONE"; - case ElfNative.EM_M32: return "EM_M32"; - case ElfNative.EM_SPARC: return "EM_SPARC"; - case ElfNative.EM_386: return "EM_386"; - case ElfNative.EM_68K: return "EM_68K"; - case ElfNative.EM_88K: return "EM_88K"; - case ElfNative.EM_860: return "EM_860"; - case ElfNative.EM_MIPS: return "EM_MIPS"; - case ElfNative.EM_S370: return "EM_S370"; - case ElfNative.EM_MIPS_RS3_LE: return "EM_MIPS_RS3_LE"; - case ElfNative.EM_PARISC: return "EM_PARISC"; - case ElfNative.EM_VPP500: return "EM_VPP500"; - case ElfNative.EM_SPARC32PLUS: return "EM_SPARC32PLUS"; - case ElfNative.EM_960: return "EM_960"; - case ElfNative.EM_PPC: return "EM_PPC"; - case ElfNative.EM_PPC64: return "EM_PPC64"; - case ElfNative.EM_S390: return "EM_S390"; - case ElfNative.EM_V800: return "EM_V800"; - case ElfNative.EM_FR20: return "EM_FR20"; - case ElfNative.EM_RH32: return "EM_RH32"; - case ElfNative.EM_RCE: return "EM_RCE"; - case ElfNative.EM_ARM: return "EM_ARM"; - case ElfNative.EM_FAKE_ALPHA: return "EM_FAKE_ALPHA"; - case ElfNative.EM_SH: return "EM_SH"; - case ElfNative.EM_SPARCV9: return "EM_SPARCV9"; - case ElfNative.EM_TRICORE: return "EM_TRICORE"; - case ElfNative.EM_ARC: return "EM_ARC"; - case ElfNative.EM_H8_300: return "EM_H8_300"; - case ElfNative.EM_H8_300H: return "EM_H8_300H"; - case ElfNative.EM_H8S: return "EM_H8S"; - case ElfNative.EM_H8_500: return "EM_H8_500"; - case ElfNative.EM_IA_64: return "EM_IA_64"; - case ElfNative.EM_MIPS_X: return "EM_MIPS_X"; - case ElfNative.EM_COLDFIRE: return "EM_COLDFIRE"; - case ElfNative.EM_68HC12: return "EM_68HC12"; - case ElfNative.EM_MMA: return "EM_MMA"; - case ElfNative.EM_PCP: return "EM_PCP"; - case ElfNative.EM_NCPU: return "EM_NCPU"; - case ElfNative.EM_NDR1: return "EM_NDR1"; - case ElfNative.EM_STARCORE: return "EM_STARCORE"; - case ElfNative.EM_ME16: return "EM_ME16"; - case ElfNative.EM_ST100: return "EM_ST100"; - case ElfNative.EM_TINYJ: return "EM_TINYJ"; - case ElfNative.EM_X86_64: return "EM_X86_64"; - case ElfNative.EM_PDSP: return "EM_PDSP"; - case ElfNative.EM_FX66: return "EM_FX66"; - case ElfNative.EM_ST9PLUS: return "EM_ST9PLUS"; - case ElfNative.EM_ST7: return "EM_ST7"; - case ElfNative.EM_68HC16: return "EM_68HC16"; - case ElfNative.EM_68HC11: return "EM_68HC11"; - case ElfNative.EM_68HC08: return "EM_68HC08"; - case ElfNative.EM_68HC05: return "EM_68HC05"; - case ElfNative.EM_SVX: return "EM_SVX"; - case ElfNative.EM_ST19: return "EM_ST19"; - case ElfNative.EM_VAX: return "EM_VAX"; - case ElfNative.EM_CRIS: return "EM_CRIS"; - case ElfNative.EM_JAVELIN: return "EM_JAVELIN"; - case ElfNative.EM_FIREPATH: return "EM_FIREPATH"; - case ElfNative.EM_ZSP: return "EM_ZSP"; - case ElfNative.EM_MMIX: return "EM_MMIX"; - case ElfNative.EM_HUANY: return "EM_HUANY"; - case ElfNative.EM_PRISM: return "EM_PRISM"; - case ElfNative.EM_AVR: return "EM_AVR"; - case ElfNative.EM_FR30: return "EM_FR30"; - case ElfNative.EM_D10V: return "EM_D10V"; - case ElfNative.EM_D30V: return "EM_D30V"; - case ElfNative.EM_V850: return "EM_V850"; - case ElfNative.EM_M32R: return "EM_M32R"; - case ElfNative.EM_MN10300: return "EM_MN10300"; - case ElfNative.EM_MN10200: return "EM_MN10200"; - case ElfNative.EM_PJ: return "EM_PJ"; - case ElfNative.EM_OPENRISC: return "EM_OPENRISC"; - case ElfNative.EM_ARC_A5: return "EM_ARC_A5"; - case ElfNative.EM_XTENSA: return "EM_XTENSA"; - case ElfNative.EM_ALTERA_NIOS2: return "EM_ALTERA_NIOS2"; - case ElfNative.EM_AARCH64: return "EM_AARCH64"; - case ElfNative.EM_TILEPRO: return "EM_TILEPRO"; - case ElfNative.EM_MICROBLAZE: return "EM_MICROBLAZE"; - case ElfNative.EM_TILEGX: return "EM_TILEGX"; - case ElfNative.EM_ALPHA: return "EM_ALPHA"; - default: return null; - } - } - } - - public enum ElfArch : ushort - { - NONE = ElfNative.EM_NONE, - - M32 = ElfNative.EM_M32, - - SPARC = ElfNative.EM_SPARC, - - I386 = ElfNative.EM_386, - - M68K = ElfNative.EM_68K, - - M88K = ElfNative.EM_88K, - - I860 = ElfNative.EM_860, - - MIPS = ElfNative.EM_MIPS, - - S370 = ElfNative.EM_S370, - - MIPS_RS3_LE = ElfNative.EM_MIPS_RS3_LE, - - PARISC = ElfNative.EM_PARISC, - - VPP500 = ElfNative.EM_VPP500, - - SPARC32PLUS = ElfNative.EM_SPARC32PLUS, - - I960 = ElfNative.EM_960, - - PPC = ElfNative.EM_PPC, - - PPC64 = ElfNative.EM_PPC64, - - S390 = ElfNative.EM_S390, - - V800 = ElfNative.EM_V800, - - FR20 = ElfNative.EM_FR20, - - RH32 = ElfNative.EM_RH32, - - RCE = ElfNative.EM_RCE, - - ARM = ElfNative.EM_ARM, - - FAKE_ALPHA = ElfNative.EM_FAKE_ALPHA, - - SH = ElfNative.EM_SH, - - SPARCV9 = ElfNative.EM_SPARCV9, - - TRICORE = ElfNative.EM_TRICORE, - - ARC = ElfNative.EM_ARC, - - H8_300 = ElfNative.EM_H8_300, - - H8_300H = ElfNative.EM_H8_300H, - - H8S = ElfNative.EM_H8S, - - H8_500 = ElfNative.EM_H8_500, - - IA_64 = ElfNative.EM_IA_64, - - MIPS_X = ElfNative.EM_MIPS_X, - - COLDFIRE = ElfNative.EM_COLDFIRE, - - M68HC12 = ElfNative.EM_68HC12, - - MMA = ElfNative.EM_MMA, - - PCP = ElfNative.EM_PCP, - - NCPU = ElfNative.EM_NCPU, - - NDR1 = ElfNative.EM_NDR1, - - STARCORE = ElfNative.EM_STARCORE, - - ME16 = ElfNative.EM_ME16, - - ST100 = ElfNative.EM_ST100, - - TINYJ = ElfNative.EM_TINYJ, - - X86_64 = ElfNative.EM_X86_64, - - PDSP = ElfNative.EM_PDSP, - - FX66 = ElfNative.EM_FX66, - - ST9PLUS = ElfNative.EM_ST9PLUS, - - ST7 = ElfNative.EM_ST7, - - M68HC16 = ElfNative.EM_68HC16, - - M68HC11 = ElfNative.EM_68HC11, - - M68HC08 = ElfNative.EM_68HC08, - - M68HC05 = ElfNative.EM_68HC05, - - SVX = ElfNative.EM_SVX, - - ST19 = ElfNative.EM_ST19, - - VAX = ElfNative.EM_VAX, - - CRIS = ElfNative.EM_CRIS, - - JAVELIN = ElfNative.EM_JAVELIN, - - FIREPATH = ElfNative.EM_FIREPATH, - - ZSP = ElfNative.EM_ZSP, - - MMIX = ElfNative.EM_MMIX, - - HUANY = ElfNative.EM_HUANY, - - PRISM = ElfNative.EM_PRISM, - - AVR = ElfNative.EM_AVR, - - FR30 = ElfNative.EM_FR30, - - D10V = ElfNative.EM_D10V, - - D30V = ElfNative.EM_D30V, - - V850 = ElfNative.EM_V850, - - M32R = ElfNative.EM_M32R, - - MN10300 = ElfNative.EM_MN10300, - - MN10200 = ElfNative.EM_MN10200, - - PJ = ElfNative.EM_PJ, - - OPENRISC = ElfNative.EM_OPENRISC, - - ARC_A5 = ElfNative.EM_ARC_A5, - - XTENSA = ElfNative.EM_XTENSA, - - ALTERA_NIOS2 = ElfNative.EM_ALTERA_NIOS2, - - AARCH64 = ElfNative.EM_AARCH64, - - TILEPRO = ElfNative.EM_TILEPRO, - - MICROBLAZE = ElfNative.EM_MICROBLAZE, - - TILEGX = ElfNative.EM_TILEGX, - - ALPHA = ElfNative.EM_ALPHA, - } - - public readonly partial struct ElfOSABIEx - { - /// - /// UNIX System V ABI - /// - public static readonly ElfOSABIEx NONE = new ElfOSABIEx(ElfNative.ELFOSABI_NONE); - - /// - /// UNIX System V ABI - /// - public static readonly ElfOSABIEx SYSV = new ElfOSABIEx(ElfNative.ELFOSABI_SYSV); - - /// - /// HP-UX - /// - public static readonly ElfOSABIEx HPUX = new ElfOSABIEx(ElfNative.ELFOSABI_HPUX); - - /// - /// NetBSD. - /// - public static readonly ElfOSABIEx NETBSD = new ElfOSABIEx(ElfNative.ELFOSABI_NETBSD); - - /// - /// Object uses GNU ELF extensions. - /// - public static readonly ElfOSABIEx GNU = new ElfOSABIEx(ElfNative.ELFOSABI_GNU); - - /// - /// Object uses GNU ELF extensions. - /// - public static readonly ElfOSABIEx LINUX = new ElfOSABIEx(ElfNative.ELFOSABI_LINUX); - - /// - /// Sun Solaris. - /// - public static readonly ElfOSABIEx SOLARIS = new ElfOSABIEx(ElfNative.ELFOSABI_SOLARIS); - - /// - /// IBM AIX. - /// - public static readonly ElfOSABIEx AIX = new ElfOSABIEx(ElfNative.ELFOSABI_AIX); - - /// - /// SGI Irix. - /// - public static readonly ElfOSABIEx IRIX = new ElfOSABIEx(ElfNative.ELFOSABI_IRIX); - - /// - /// FreeBSD. - /// - public static readonly ElfOSABIEx FREEBSD = new ElfOSABIEx(ElfNative.ELFOSABI_FREEBSD); - - /// - /// Compaq TRU64 UNIX. - /// - public static readonly ElfOSABIEx TRU64 = new ElfOSABIEx(ElfNative.ELFOSABI_TRU64); - - /// - /// Novell Modesto. - /// - public static readonly ElfOSABIEx MODESTO = new ElfOSABIEx(ElfNative.ELFOSABI_MODESTO); - - /// - /// OpenBSD. - /// - public static readonly ElfOSABIEx OPENBSD = new ElfOSABIEx(ElfNative.ELFOSABI_OPENBSD); - - /// - /// ARM EABI - /// - public static readonly ElfOSABIEx ARM_AEABI = new ElfOSABIEx(ElfNative.ELFOSABI_ARM_AEABI); - - /// - /// ARM - /// - public static readonly ElfOSABIEx ARM = new ElfOSABIEx(ElfNative.ELFOSABI_ARM); - - /// - /// Standalone (embedded) application - /// - public static readonly ElfOSABIEx STANDALONE = new ElfOSABIEx(ElfNative.ELFOSABI_STANDALONE); - - private string ToStringInternal() - { - switch ((byte)Value) - { - case ElfNative.ELFOSABI_NONE: return "ELFOSABI_NONE"; - case ElfNative.ELFOSABI_HPUX: return "ELFOSABI_HPUX"; - case ElfNative.ELFOSABI_NETBSD: return "ELFOSABI_NETBSD"; - case ElfNative.ELFOSABI_GNU: return "ELFOSABI_GNU"; - case ElfNative.ELFOSABI_SOLARIS: return "ELFOSABI_SOLARIS"; - case ElfNative.ELFOSABI_AIX: return "ELFOSABI_AIX"; - case ElfNative.ELFOSABI_IRIX: return "ELFOSABI_IRIX"; - case ElfNative.ELFOSABI_FREEBSD: return "ELFOSABI_FREEBSD"; - case ElfNative.ELFOSABI_TRU64: return "ELFOSABI_TRU64"; - case ElfNative.ELFOSABI_MODESTO: return "ELFOSABI_MODESTO"; - case ElfNative.ELFOSABI_OPENBSD: return "ELFOSABI_OPENBSD"; - case ElfNative.ELFOSABI_ARM_AEABI: return "ELFOSABI_ARM_AEABI"; - case ElfNative.ELFOSABI_ARM: return "ELFOSABI_ARM"; - case ElfNative.ELFOSABI_STANDALONE: return "ELFOSABI_STANDALONE"; - default: return null; - } - } - } - - public enum ElfOSABI : byte - { - NONE = ElfNative.ELFOSABI_NONE, - - SYSV = ElfNative.ELFOSABI_SYSV, - - HPUX = ElfNative.ELFOSABI_HPUX, - - NETBSD = ElfNative.ELFOSABI_NETBSD, - - GNU = ElfNative.ELFOSABI_GNU, - - LINUX = ElfNative.ELFOSABI_LINUX, - - SOLARIS = ElfNative.ELFOSABI_SOLARIS, - - AIX = ElfNative.ELFOSABI_AIX, - - IRIX = ElfNative.ELFOSABI_IRIX, - - FREEBSD = ElfNative.ELFOSABI_FREEBSD, - - TRU64 = ElfNative.ELFOSABI_TRU64, - - MODESTO = ElfNative.ELFOSABI_MODESTO, - - OPENBSD = ElfNative.ELFOSABI_OPENBSD, - - ARM_AEABI = ElfNative.ELFOSABI_ARM_AEABI, - - ARM = ElfNative.ELFOSABI_ARM, - - STANDALONE = ElfNative.ELFOSABI_STANDALONE, - } - - public readonly partial struct ElfRelocationType - { - /// - /// No reloc - /// - public static readonly ElfRelocationType R_386_NONE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_NONE); - - /// - /// Direct 32 bit - /// - public static readonly ElfRelocationType R_386_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_32); - - /// - /// PC relative 32 bit - /// - public static readonly ElfRelocationType R_386_PC32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC32); - - /// - /// 32 bit GOT entry - /// - public static readonly ElfRelocationType R_386_GOT32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOT32); - - /// - /// 32 bit PLT address - /// - public static readonly ElfRelocationType R_386_PLT32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PLT32); - - /// - /// Copy symbol at runtime - /// - public static readonly ElfRelocationType R_386_COPY = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_COPY); - - /// - /// Create GOT entry - /// - public static readonly ElfRelocationType R_386_GLOB_DAT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GLOB_DAT); - - /// - /// Create PLT entry - /// - public static readonly ElfRelocationType R_386_JMP_SLOT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_JMP_SLOT); - - /// - /// Adjust by program base - /// - public static readonly ElfRelocationType R_386_RELATIVE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_RELATIVE); - - /// - /// 32 bit offset to GOT - /// - public static readonly ElfRelocationType R_386_GOTOFF = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOTOFF); - - /// - /// 32 bit PC relative offset to GOT - /// - public static readonly ElfRelocationType R_386_GOTPC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_GOTPC); - - public static readonly ElfRelocationType R_386_32PLT = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_32PLT); - - /// - /// Offset in static TLS block - /// - public static readonly ElfRelocationType R_386_TLS_TPOFF = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_TPOFF); - - /// - /// Address of GOT entry for static TLS block offset - /// - public static readonly ElfRelocationType R_386_TLS_IE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_IE); - - /// - /// GOT entry for static TLS block offset - /// - public static readonly ElfRelocationType R_386_TLS_GOTIE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GOTIE); - - /// - /// Offset relative to static TLS block - /// - public static readonly ElfRelocationType R_386_TLS_LE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LE); - - /// - /// Direct 32 bit for GNU version of general dynamic thread local data - /// - public static readonly ElfRelocationType R_386_TLS_GD = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD); - - /// - /// Direct 32 bit for GNU version of local dynamic thread local data in LE code - /// - public static readonly ElfRelocationType R_386_TLS_LDM = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM); - - public static readonly ElfRelocationType R_386_16 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_16); - - public static readonly ElfRelocationType R_386_PC16 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC16); - - public static readonly ElfRelocationType R_386_8 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_8); - - public static readonly ElfRelocationType R_386_PC8 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_PC8); - - /// - /// Direct 32 bit for general dynamic - /// thread local data - /// - public static readonly ElfRelocationType R_386_TLS_GD_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_32); - - /// - /// Tag for pushl in GD TLS code - /// - public static readonly ElfRelocationType R_386_TLS_GD_PUSH = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_PUSH); - - /// - /// Relocation for call to - /// __tls_get_addr() - /// - public static readonly ElfRelocationType R_386_TLS_GD_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_CALL); - - /// - /// Tag for popl in GD TLS code - /// - public static readonly ElfRelocationType R_386_TLS_GD_POP = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GD_POP); - - /// - /// Direct 32 bit for local dynamic - /// thread local data in LE code - /// - public static readonly ElfRelocationType R_386_TLS_LDM_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_32); - - /// - /// Tag for pushl in LDM TLS code - /// - public static readonly ElfRelocationType R_386_TLS_LDM_PUSH = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_PUSH); - - /// - /// Relocation for call to - /// __tls_get_addr() in LDM code - /// - public static readonly ElfRelocationType R_386_TLS_LDM_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_CALL); - - /// - /// Tag for popl in LDM TLS code - /// - public static readonly ElfRelocationType R_386_TLS_LDM_POP = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDM_POP); - - /// - /// Offset relative to TLS block - /// - public static readonly ElfRelocationType R_386_TLS_LDO_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LDO_32); - - /// - /// GOT entry for negated static TLS - /// block offset - /// - public static readonly ElfRelocationType R_386_TLS_IE_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_IE_32); - - /// - /// Negated offset relative to static - /// TLS block - /// - public static readonly ElfRelocationType R_386_TLS_LE_32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_LE_32); - - /// - /// ID of module containing symbol - /// - public static readonly ElfRelocationType R_386_TLS_DTPMOD32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DTPMOD32); - - /// - /// Offset in TLS block - /// - public static readonly ElfRelocationType R_386_TLS_DTPOFF32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DTPOFF32); - - /// - /// Negated offset in static TLS block - /// - public static readonly ElfRelocationType R_386_TLS_TPOFF32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_TPOFF32); - - /// - /// 32-bit symbol size - /// - public static readonly ElfRelocationType R_386_SIZE32 = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_SIZE32); - - /// - /// GOT offset for TLS descriptor. - /// - public static readonly ElfRelocationType R_386_TLS_GOTDESC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_GOTDESC); - - /// - /// Marker of call through TLS - /// descriptor for - /// relaxation. - /// - public static readonly ElfRelocationType R_386_TLS_DESC_CALL = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DESC_CALL); - - /// - /// TLS descriptor containing - /// pointer to code and to - /// argument, returning the TLS - /// offset for the symbol. - /// - public static readonly ElfRelocationType R_386_TLS_DESC = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_TLS_DESC); - - /// - /// Adjust indirectly by program base - /// - public static readonly ElfRelocationType R_386_IRELATIVE = new ElfRelocationType(ElfArch.I386, ElfNative.R_386_IRELATIVE); - - /// - /// No relocation. - /// - public static readonly ElfRelocationType R_AARCH64_NONE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_NONE); - - /// - /// Direct 32 bit. - /// - public static readonly ElfRelocationType R_AARCH64_P32_ABS32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_ABS32); - - /// - /// Copy symbol at runtime. - /// - public static readonly ElfRelocationType R_AARCH64_P32_COPY = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_COPY); - - /// - /// Create GOT entry. - /// - public static readonly ElfRelocationType R_AARCH64_P32_GLOB_DAT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_GLOB_DAT); - - /// - /// Create PLT entry. - /// - public static readonly ElfRelocationType R_AARCH64_P32_JUMP_SLOT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_JUMP_SLOT); - - /// - /// Adjust by program base. - /// - public static readonly ElfRelocationType R_AARCH64_P32_RELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_RELATIVE); - - /// - /// Module number, 32 bit. - /// - public static readonly ElfRelocationType R_AARCH64_P32_TLS_DTPMOD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_DTPMOD); - - /// - /// Module-relative offset, 32 bit. - /// - public static readonly ElfRelocationType R_AARCH64_P32_TLS_DTPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_DTPREL); - - /// - /// TP-relative offset, 32 bit. - /// - public static readonly ElfRelocationType R_AARCH64_P32_TLS_TPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLS_TPREL); - - /// - /// TLS Descriptor. - /// - public static readonly ElfRelocationType R_AARCH64_P32_TLSDESC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_TLSDESC); - - /// - /// STT_GNU_IFUNC relocation. - /// - public static readonly ElfRelocationType R_AARCH64_P32_IRELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_P32_IRELATIVE); - - /// - /// Direct 64 bit. - /// - public static readonly ElfRelocationType R_AARCH64_ABS64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS64); - - /// - /// Direct 32 bit. - /// - public static readonly ElfRelocationType R_AARCH64_ABS32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS32); - - /// - /// Direct 16-bit. - /// - public static readonly ElfRelocationType R_AARCH64_ABS16 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ABS16); - - /// - /// PC-relative 64-bit. - /// - public static readonly ElfRelocationType R_AARCH64_PREL64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL64); - - /// - /// PC-relative 32-bit. - /// - public static readonly ElfRelocationType R_AARCH64_PREL32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL32); - - /// - /// PC-relative 16-bit. - /// - public static readonly ElfRelocationType R_AARCH64_PREL16 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_PREL16); - - /// - /// Dir. MOVZ imm. from bits 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G0); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G0_NC); - - /// - /// Dir. MOVZ imm. from bits 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G1); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G1_NC); - - /// - /// Dir. MOVZ imm. from bits 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G2); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G2_NC); - - /// - /// Dir. MOV{K,Z} imm. from 63:48. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_UABS_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_UABS_G3); - - /// - /// Dir. MOV{N,Z} imm. from 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G0); - - /// - /// Dir. MOV{N,Z} imm. from 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G1); - - /// - /// Dir. MOV{N,Z} imm. from 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_SABS_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_SABS_G2); - - /// - /// PC-rel. LD imm. from bits 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_LD_PREL_LO19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD_PREL_LO19); - - /// - /// PC-rel. ADR imm. from bits 20:0. - /// - public static readonly ElfRelocationType R_AARCH64_ADR_PREL_LO21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_LO21); - - /// - /// Page-rel. ADRP imm. from 32:12. - /// - public static readonly ElfRelocationType R_AARCH64_ADR_PREL_PG_HI21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_PG_HI21); - - /// - /// Likewise; no overflow check. - /// - public static readonly ElfRelocationType R_AARCH64_ADR_PREL_PG_HI21_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_PREL_PG_HI21_NC); - - /// - /// Dir. ADD imm. from bits 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_ADD_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADD_ABS_LO12_NC); - - /// - /// Likewise for LD/ST; no check. - /// - public static readonly ElfRelocationType R_AARCH64_LDST8_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST8_ABS_LO12_NC); - - /// - /// PC-rel. TBZ/TBNZ imm. from 15:2. - /// - public static readonly ElfRelocationType R_AARCH64_TSTBR14 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TSTBR14); - - /// - /// PC-rel. cond. br. imm. from 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_CONDBR19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_CONDBR19); - - /// - /// PC-rel. B imm. from bits 27:2. - /// - public static readonly ElfRelocationType R_AARCH64_JUMP26 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_JUMP26); - - /// - /// Likewise for CALL. - /// - public static readonly ElfRelocationType R_AARCH64_CALL26 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_CALL26); - - /// - /// Dir. ADD imm. from bits 11:1. - /// - public static readonly ElfRelocationType R_AARCH64_LDST16_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST16_ABS_LO12_NC); - - /// - /// Likewise for bits 11:2. - /// - public static readonly ElfRelocationType R_AARCH64_LDST32_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST32_ABS_LO12_NC); - - /// - /// Likewise for bits 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_LDST64_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST64_ABS_LO12_NC); - - /// - /// PC-rel. MOV{N,Z} imm. from 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G0); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G0_NC); - - /// - /// PC-rel. MOV{N,Z} imm. from 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G1); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G1_NC); - - /// - /// PC-rel. MOV{N,Z} imm. from 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G2); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G2_NC); - - /// - /// PC-rel. MOV{N,Z} imm. from 63:48. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_PREL_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_PREL_G3); - - /// - /// Dir. ADD imm. from bits 11:4. - /// - public static readonly ElfRelocationType R_AARCH64_LDST128_ABS_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LDST128_ABS_LO12_NC); - - /// - /// GOT-rel. off. MOV{N,Z} imm. 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G0); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G0_NC); - - /// - /// GOT-rel. o. MOV{N,Z} imm. 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G1); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G1_NC); - - /// - /// GOT-rel. o. MOV{N,Z} imm. 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G2); - - /// - /// Likewise for MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G2_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G2_NC); - - /// - /// GOT-rel. o. MOV{N,Z} imm. 63:48. - /// - public static readonly ElfRelocationType R_AARCH64_MOVW_GOTOFF_G3 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_MOVW_GOTOFF_G3); - - /// - /// GOT-relative 64-bit. - /// - public static readonly ElfRelocationType R_AARCH64_GOTREL64 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOTREL64); - - /// - /// GOT-relative 32-bit. - /// - public static readonly ElfRelocationType R_AARCH64_GOTREL32 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOTREL32); - - /// - /// PC-rel. GOT off. load imm. 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_GOT_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GOT_LD_PREL19); - - /// - /// GOT-rel. off. LD/ST imm. 14:3. - /// - public static readonly ElfRelocationType R_AARCH64_LD64_GOTOFF_LO15 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOTOFF_LO15); - - /// - /// P-page-rel. GOT off. ADRP 32:12. - /// - public static readonly ElfRelocationType R_AARCH64_ADR_GOT_PAGE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_ADR_GOT_PAGE); - - /// - /// Dir. GOT off. LD/ST imm. 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_LD64_GOT_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOT_LO12_NC); - - /// - /// GOT-page-rel. GOT off. LD/ST 14:3 - /// - public static readonly ElfRelocationType R_AARCH64_LD64_GOTPAGE_LO15 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_LD64_GOTPAGE_LO15); - - /// - /// PC-relative ADR imm. 20:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSGD_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADR_PREL21); - - /// - /// page-rel. ADRP imm. 32:12. - /// - public static readonly ElfRelocationType R_AARCH64_TLSGD_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADR_PAGE21); - - /// - /// direct ADD imm. from 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSGD_ADD_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_ADD_LO12_NC); - - /// - /// GOT-rel. MOV{N,Z} 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_TLSGD_MOVW_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_MOVW_G1); - - /// - /// GOT-rel. MOVK imm. 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSGD_MOVW_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSGD_MOVW_G0_NC); - - /// - /// Like 512; local dynamic model. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADR_PREL21); - - /// - /// Like 513; local dynamic model. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADR_PAGE21); - - /// - /// Like 514; local dynamic model. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_LO12_NC); - - /// - /// Like 515; local dynamic model. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_G1); - - /// - /// Like 516; local dynamic model. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_G0_NC); - - /// - /// TLS PC-rel. load imm. 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LD_PREL19); - - /// - /// TLS DTP-rel. MOV{N,Z} 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G2); - - /// - /// TLS DTP-rel. MOV{N,Z} 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1); - - /// - /// Likewise; MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC); - - /// - /// TLS DTP-rel. MOV{N,Z} 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0); - - /// - /// Likewise; MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC); - - /// - /// DTP-rel. ADD imm. from 23:12. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_HI12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_HI12); - - /// - /// DTP-rel. ADD imm. from 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12); - - /// - /// Likewise; no ovfl. check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC); - - /// - /// DTP-rel. LD/ST imm. 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC); - - /// - /// DTP-rel. LD/ST imm. 11:1. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC); - - /// - /// DTP-rel. LD/ST imm. 11:2. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC); - - /// - /// DTP-rel. LD/ST imm. 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC); - - /// - /// GOT-rel. MOV{N,Z} 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G1); - - /// - /// GOT-rel. MOVK 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC); - - /// - /// Page-rel. ADRP 32:12. - /// - public static readonly ElfRelocationType R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21); - - /// - /// Direct LD off. 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC); - - /// - /// PC-rel. load imm. 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSIE_LD_GOTTPREL_PREL19); - - /// - /// TLS TP-rel. MOV{N,Z} 47:32. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G2 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G2); - - /// - /// TLS TP-rel. MOV{N,Z} 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1); - - /// - /// Likewise; MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1_NC); - - /// - /// TLS TP-rel. MOV{N,Z} 15:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G0 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0); - - /// - /// Likewise; MOVK; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0_NC); - - /// - /// TP-rel. ADD imm. 23:12. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_HI12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12); - - /// - /// TP-rel. ADD imm. 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12); - - /// - /// Likewise; no ovfl. check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC); - - /// - /// TP-rel. LD/ST off. 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST8_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12); - - /// - /// Likewise; no ovfl. check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC); - - /// - /// TP-rel. LD/ST off. 11:1. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST16_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC); - - /// - /// TP-rel. LD/ST off. 11:2. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST32_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC); - - /// - /// TP-rel. LD/ST off. 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST64_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC); - - /// - /// PC-rel. load immediate 20:2. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_LD_PREL19 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LD_PREL19); - - /// - /// PC-rel. ADR immediate 20:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADR_PREL21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADR_PREL21); - - /// - /// Page-rel. ADRP imm. 32:12. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADR_PAGE21 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21); - - /// - /// Direct LD off. from 11:3. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_LD64_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LD64_LO12); - - /// - /// Direct ADD imm. from 11:0. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADD_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADD_LO12); - - /// - /// GOT-rel. MOV{N,Z} imm. 31:16. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_OFF_G1 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_OFF_G1); - - /// - /// GOT-rel. MOVK imm. 15:0; no ck. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_OFF_G0_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_OFF_G0_NC); - - /// - /// Relax LDR. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_LDR = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_LDR); - - /// - /// Relax ADD. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_ADD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_ADD); - - /// - /// Relax BLR. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC_CALL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC_CALL); - - /// - /// TP-rel. LD/ST off. 11:4. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST128_TPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC); - - /// - /// DTP-rel. LD/ST imm. 11:4. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST128_DTPREL_LO12 = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12); - - /// - /// Likewise; no check. - /// - public static readonly ElfRelocationType R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC); - - /// - /// Copy symbol at runtime. - /// - public static readonly ElfRelocationType R_AARCH64_COPY = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_COPY); - - /// - /// Create GOT entry. - /// - public static readonly ElfRelocationType R_AARCH64_GLOB_DAT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_GLOB_DAT); - - /// - /// Create PLT entry. - /// - public static readonly ElfRelocationType R_AARCH64_JUMP_SLOT = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_JUMP_SLOT); - - /// - /// Adjust by program base. - /// - public static readonly ElfRelocationType R_AARCH64_RELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_RELATIVE); - - /// - /// Module number, 64 bit. - /// - public static readonly ElfRelocationType R_AARCH64_TLS_DTPMOD = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_DTPMOD); - - /// - /// Module-relative offset, 64 bit. - /// - public static readonly ElfRelocationType R_AARCH64_TLS_DTPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_DTPREL); - - /// - /// TP-relative offset, 64 bit. - /// - public static readonly ElfRelocationType R_AARCH64_TLS_TPREL = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLS_TPREL); - - /// - /// TLS Descriptor. - /// - public static readonly ElfRelocationType R_AARCH64_TLSDESC = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_TLSDESC); - - /// - /// STT_GNU_IFUNC relocation. - /// - public static readonly ElfRelocationType R_AARCH64_IRELATIVE = new ElfRelocationType(ElfArch.AARCH64, ElfNative.R_AARCH64_IRELATIVE); - - /// - /// No reloc - /// - public static readonly ElfRelocationType R_ARM_NONE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_NONE); - - /// - /// Deprecated PC relative 26 bit branch. - /// - public static readonly ElfRelocationType R_ARM_PC24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PC24); - - /// - /// Direct 32 bit - /// - public static readonly ElfRelocationType R_ARM_ABS32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS32); - - /// - /// PC relative 32 bit - /// - public static readonly ElfRelocationType R_ARM_REL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_REL32); - - public static readonly ElfRelocationType R_ARM_PC13 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PC13); - - /// - /// Direct 16 bit - /// - public static readonly ElfRelocationType R_ARM_ABS16 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS16); - - /// - /// Direct 12 bit - /// - public static readonly ElfRelocationType R_ARM_ABS12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS12); - - /// - /// Direct - /// & - /// 0x7C (LDR, STR). - /// - public static readonly ElfRelocationType R_ARM_THM_ABS5 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_ABS5); - - /// - /// Direct 8 bit - /// - public static readonly ElfRelocationType R_ARM_ABS8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS8); - - public static readonly ElfRelocationType R_ARM_SBREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SBREL32); - - /// - /// PC relative 24 bit (Thumb32 BL). - /// - public static readonly ElfRelocationType R_ARM_THM_PC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC22); - - /// - /// PC relative - /// & - /// 0x3FC (Thumb16 LDR, ADD, ADR). - /// - public static readonly ElfRelocationType R_ARM_THM_PC8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC8); - - public static readonly ElfRelocationType R_ARM_AMP_VCALL9 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_AMP_VCALL9); - - /// - /// Obsolete static relocation. - /// - public static readonly ElfRelocationType R_ARM_SWI24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SWI24); - - /// - /// Dynamic relocation. - /// - public static readonly ElfRelocationType R_ARM_TLS_DESC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DESC); - - /// - /// Reserved. - /// - public static readonly ElfRelocationType R_ARM_THM_SWI8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_SWI8); - - /// - /// Reserved. - /// - public static readonly ElfRelocationType R_ARM_XPC25 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_XPC25); - - /// - /// Reserved. - /// - public static readonly ElfRelocationType R_ARM_THM_XPC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_XPC22); - - /// - /// ID of module containing symbol - /// - public static readonly ElfRelocationType R_ARM_TLS_DTPMOD32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DTPMOD32); - - /// - /// Offset in TLS block - /// - public static readonly ElfRelocationType R_ARM_TLS_DTPOFF32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DTPOFF32); - - /// - /// Offset in static TLS block - /// - public static readonly ElfRelocationType R_ARM_TLS_TPOFF32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_TPOFF32); - - /// - /// Copy symbol at runtime - /// - public static readonly ElfRelocationType R_ARM_COPY = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_COPY); - - /// - /// Create GOT entry - /// - public static readonly ElfRelocationType R_ARM_GLOB_DAT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GLOB_DAT); - - /// - /// Create PLT entry - /// - public static readonly ElfRelocationType R_ARM_JUMP_SLOT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_JUMP_SLOT); - - /// - /// Adjust by program base - /// - public static readonly ElfRelocationType R_ARM_RELATIVE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RELATIVE); - - /// - /// 32 bit offset to GOT - /// - public static readonly ElfRelocationType R_ARM_GOTOFF = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTOFF); - - /// - /// 32 bit PC relative offset to GOT - /// - public static readonly ElfRelocationType R_ARM_GOTPC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTPC); - - /// - /// 32 bit GOT entry - /// - public static readonly ElfRelocationType R_ARM_GOT32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT32); - - /// - /// Deprecated, 32 bit PLT address. - /// - public static readonly ElfRelocationType R_ARM_PLT32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PLT32); - - /// - /// PC relative 24 bit (BL, BLX). - /// - public static readonly ElfRelocationType R_ARM_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_CALL); - - /// - /// PC relative 24 bit (B, BL - /// <cond - /// >). - /// - public static readonly ElfRelocationType R_ARM_JUMP24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_JUMP24); - - /// - /// PC relative 24 bit (Thumb32 B.W). - /// - public static readonly ElfRelocationType R_ARM_THM_JUMP24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP24); - - /// - /// Adjust by program base. - /// - public static readonly ElfRelocationType R_ARM_BASE_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_BASE_ABS); - - /// - /// Obsolete. - /// - public static readonly ElfRelocationType R_ARM_ALU_PCREL_7_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_7_0); - - /// - /// Obsolete. - /// - public static readonly ElfRelocationType R_ARM_ALU_PCREL_15_8 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_15_8); - - /// - /// Obsolete. - /// - public static readonly ElfRelocationType R_ARM_ALU_PCREL_23_15 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PCREL_23_15); - - /// - /// Deprecated, prog. base relative. - /// - public static readonly ElfRelocationType R_ARM_LDR_SBREL_11_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SBREL_11_0); - - /// - /// Deprecated, prog. base relative. - /// - public static readonly ElfRelocationType R_ARM_ALU_SBREL_19_12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SBREL_19_12); - - /// - /// Deprecated, prog. base relative. - /// - public static readonly ElfRelocationType R_ARM_ALU_SBREL_27_20 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SBREL_27_20); - - public static readonly ElfRelocationType R_ARM_TARGET1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TARGET1); - - /// - /// Program base relative. - /// - public static readonly ElfRelocationType R_ARM_SBREL31 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_SBREL31); - - public static readonly ElfRelocationType R_ARM_V4BX = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_V4BX); - - public static readonly ElfRelocationType R_ARM_TARGET2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TARGET2); - - /// - /// 32 bit PC relative. - /// - public static readonly ElfRelocationType R_ARM_PREL31 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PREL31); - - /// - /// Direct 16-bit (MOVW). - /// - public static readonly ElfRelocationType R_ARM_MOVW_ABS_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_ABS_NC); - - /// - /// Direct high 16-bit (MOVT). - /// - public static readonly ElfRelocationType R_ARM_MOVT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_ABS); - - /// - /// PC relative 16-bit (MOVW). - /// - public static readonly ElfRelocationType R_ARM_MOVW_PREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_PREL_NC); - - /// - /// PC relative (MOVT). - /// - public static readonly ElfRelocationType R_ARM_MOVT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_PREL); - - /// - /// Direct 16 bit (Thumb32 MOVW). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVW_ABS_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_ABS_NC); - - /// - /// Direct high 16 bit (Thumb32 MOVT). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_ABS); - - /// - /// PC relative 16 bit (Thumb32 MOVW). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVW_PREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_PREL_NC); - - /// - /// PC relative high 16 bit (Thumb32 MOVT). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_PREL); - - /// - /// PC relative 20 bit (Thumb32 B - /// <cond - /// >.W). - /// - public static readonly ElfRelocationType R_ARM_THM_JUMP19 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP19); - - /// - /// PC relative X - /// & - /// 0x7E (Thumb16 CBZ, CBNZ). - /// - public static readonly ElfRelocationType R_ARM_THM_JUMP6 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_JUMP6); - - /// - /// PC relative 12 bit (Thumb32 ADR.W). - /// - public static readonly ElfRelocationType R_ARM_THM_ALU_PREL_11_0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_ALU_PREL_11_0); - - /// - /// PC relative 12 bit (Thumb32 LDR{D,SB,H,SH}). - /// - public static readonly ElfRelocationType R_ARM_THM_PC12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC12); - - /// - /// Direct 32-bit. - /// - public static readonly ElfRelocationType R_ARM_ABS32_NOI = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ABS32_NOI); - - /// - /// PC relative 32-bit. - /// - public static readonly ElfRelocationType R_ARM_REL32_NOI = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_REL32_NOI); - - /// - /// PC relative (ADD, SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_PC_G0_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G0_NC); - - /// - /// PC relative (ADD, SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G0); - - /// - /// PC relative (ADD, SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_PC_G1_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G1_NC); - - /// - /// PC relative (ADD, SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G1); - - /// - /// PC relative (ADD, SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_PC_G2); - - /// - /// PC relative (LDR,STR,LDRB,STRB). - /// - public static readonly ElfRelocationType R_ARM_LDR_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_PC_G1); - - /// - /// PC relative (LDR,STR,LDRB,STRB). - /// - public static readonly ElfRelocationType R_ARM_LDR_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_PC_G2); - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public static readonly ElfRelocationType R_ARM_LDRS_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G0); - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public static readonly ElfRelocationType R_ARM_LDRS_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G1); - - /// - /// PC relative (STR{D,H}, LDR{D,SB,H,SH}). - /// - public static readonly ElfRelocationType R_ARM_LDRS_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_PC_G2); - - /// - /// PC relative (LDC, STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_PC_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G0); - - /// - /// PC relative (LDC, STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_PC_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G1); - - /// - /// PC relative (LDC, STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_PC_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_PC_G2); - - /// - /// Program base relative (ADD,SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_SB_G0_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G0_NC); - - /// - /// Program base relative (ADD,SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G0); - - /// - /// Program base relative (ADD,SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_SB_G1_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G1_NC); - - /// - /// Program base relative (ADD,SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G1); - - /// - /// Program base relative (ADD,SUB). - /// - public static readonly ElfRelocationType R_ARM_ALU_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ALU_SB_G2); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDR_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G0); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDR_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G1); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDR_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDR_SB_G2); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDRS_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G0); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDRS_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G1); - - /// - /// Program base relative (LDR, STR, LDRB, STRB). - /// - public static readonly ElfRelocationType R_ARM_LDRS_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDRS_SB_G2); - - /// - /// Program base relative (LDC,STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_SB_G0 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G0); - - /// - /// Program base relative (LDC,STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_SB_G1 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G1); - - /// - /// Program base relative (LDC,STC). - /// - public static readonly ElfRelocationType R_ARM_LDC_SB_G2 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_LDC_SB_G2); - - /// - /// Program base relative 16 bit (MOVW). - /// - public static readonly ElfRelocationType R_ARM_MOVW_BREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_BREL_NC); - - /// - /// Program base relative high 16 bit (MOVT). - /// - public static readonly ElfRelocationType R_ARM_MOVT_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVT_BREL); - - /// - /// Program base relative 16 bit (MOVW). - /// - public static readonly ElfRelocationType R_ARM_MOVW_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_MOVW_BREL); - - /// - /// Program base relative 16 bit (Thumb32 MOVW). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVW_BREL_NC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_BREL_NC); - - /// - /// Program base relative high 16 bit (Thumb32 MOVT). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVT_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVT_BREL); - - /// - /// Program base relative 16 bit (Thumb32 MOVW). - /// - public static readonly ElfRelocationType R_ARM_THM_MOVW_BREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_MOVW_BREL); - - public static readonly ElfRelocationType R_ARM_TLS_GOTDESC = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_GOTDESC); - - public static readonly ElfRelocationType R_ARM_TLS_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_CALL); - - /// - /// TLS relaxation. - /// - public static readonly ElfRelocationType R_ARM_TLS_DESCSEQ = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_DESCSEQ); - - public static readonly ElfRelocationType R_ARM_THM_TLS_CALL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_CALL); - - public static readonly ElfRelocationType R_ARM_PLT32_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_PLT32_ABS); - - /// - /// GOT entry. - /// - public static readonly ElfRelocationType R_ARM_GOT_ABS = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_ABS); - - /// - /// PC relative GOT entry. - /// - public static readonly ElfRelocationType R_ARM_GOT_PREL = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_PREL); - - /// - /// GOT entry relative to GOT origin (LDR). - /// - public static readonly ElfRelocationType R_ARM_GOT_BREL12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOT_BREL12); - - /// - /// 12 bit, GOT entry relative to GOT origin (LDR, STR). - /// - public static readonly ElfRelocationType R_ARM_GOTOFF12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTOFF12); - - public static readonly ElfRelocationType R_ARM_GOTRELAX = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GOTRELAX); - - public static readonly ElfRelocationType R_ARM_GNU_VTENTRY = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GNU_VTENTRY); - - public static readonly ElfRelocationType R_ARM_GNU_VTINHERIT = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_GNU_VTINHERIT); - - /// - /// PC relative - /// & - /// 0xFFE (Thumb16 B). - /// - public static readonly ElfRelocationType R_ARM_THM_PC11 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC11); - - /// - /// PC relative - /// & - /// 0x1FE (Thumb16 B/B - /// <cond - /// >). - /// - public static readonly ElfRelocationType R_ARM_THM_PC9 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_PC9); - - /// - /// PC-rel 32 bit for global dynamic thread local data - /// - public static readonly ElfRelocationType R_ARM_TLS_GD32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_GD32); - - /// - /// PC-rel 32 bit for local dynamic thread local data - /// - public static readonly ElfRelocationType R_ARM_TLS_LDM32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDM32); - - /// - /// 32 bit offset relative to TLS block - /// - public static readonly ElfRelocationType R_ARM_TLS_LDO32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDO32); - - /// - /// PC-rel 32 bit for GOT entry of static TLS block offset - /// - public static readonly ElfRelocationType R_ARM_TLS_IE32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_IE32); - - /// - /// 32 bit offset relative to static TLS block - /// - public static readonly ElfRelocationType R_ARM_TLS_LE32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LE32); - - /// - /// 12 bit relative to TLS block (LDR, STR). - /// - public static readonly ElfRelocationType R_ARM_TLS_LDO12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LDO12); - - /// - /// 12 bit relative to static TLS block (LDR, STR). - /// - public static readonly ElfRelocationType R_ARM_TLS_LE12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_LE12); - - /// - /// 12 bit GOT entry relative to GOT origin (LDR). - /// - public static readonly ElfRelocationType R_ARM_TLS_IE12GP = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_TLS_IE12GP); - - /// - /// Obsolete. - /// - public static readonly ElfRelocationType R_ARM_ME_TOO = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_ME_TOO); - - public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ); - - public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ16 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ16); - - public static readonly ElfRelocationType R_ARM_THM_TLS_DESCSEQ32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_TLS_DESCSEQ32); - - /// - /// GOT entry relative to GOT origin, 12 bit (Thumb32 LDR). - /// - public static readonly ElfRelocationType R_ARM_THM_GOT_BREL12 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_GOT_BREL12); - - public static readonly ElfRelocationType R_ARM_IRELATIVE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_IRELATIVE); - - public static readonly ElfRelocationType R_ARM_RXPC25 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RXPC25); - - public static readonly ElfRelocationType R_ARM_RSBREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RSBREL32); - - public static readonly ElfRelocationType R_ARM_THM_RPC22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_THM_RPC22); - - public static readonly ElfRelocationType R_ARM_RREL32 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RREL32); - - public static readonly ElfRelocationType R_ARM_RABS22 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RABS22); - - public static readonly ElfRelocationType R_ARM_RPC24 = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RPC24); - - public static readonly ElfRelocationType R_ARM_RBASE = new ElfRelocationType(ElfArch.ARM, ElfNative.R_ARM_RBASE); - - /// - /// No reloc - /// - public static readonly ElfRelocationType R_X86_64_NONE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_NONE); - - /// - /// Direct 64 bit - /// - public static readonly ElfRelocationType R_X86_64_64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_64); - - /// - /// PC relative 32 bit signed - /// - public static readonly ElfRelocationType R_X86_64_PC32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC32); - - /// - /// 32 bit GOT entry - /// - public static readonly ElfRelocationType R_X86_64_GOT32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOT32); - - /// - /// 32 bit PLT address - /// - public static readonly ElfRelocationType R_X86_64_PLT32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PLT32); - - /// - /// Copy symbol at runtime - /// - public static readonly ElfRelocationType R_X86_64_COPY = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_COPY); - - /// - /// Create GOT entry - /// - public static readonly ElfRelocationType R_X86_64_GLOB_DAT = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GLOB_DAT); - - /// - /// Create PLT entry - /// - public static readonly ElfRelocationType R_X86_64_JUMP_SLOT = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_JUMP_SLOT); - - /// - /// Adjust by program base - /// - public static readonly ElfRelocationType R_X86_64_RELATIVE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_RELATIVE); - - /// - /// 32 bit signed PC relative offset to GOT - /// - public static readonly ElfRelocationType R_X86_64_GOTPCREL = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPCREL); - - /// - /// Direct 32 bit zero extended - /// - public static readonly ElfRelocationType R_X86_64_32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_32); - - /// - /// Direct 32 bit sign extended - /// - public static readonly ElfRelocationType R_X86_64_32S = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_32S); - - /// - /// Direct 16 bit zero extended - /// - public static readonly ElfRelocationType R_X86_64_16 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_16); - - /// - /// 16 bit sign extended pc relative - /// - public static readonly ElfRelocationType R_X86_64_PC16 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC16); - - /// - /// Direct 8 bit sign extended - /// - public static readonly ElfRelocationType R_X86_64_8 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_8); - - /// - /// 8 bit sign extended pc relative - /// - public static readonly ElfRelocationType R_X86_64_PC8 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC8); - - /// - /// ID of module containing symbol - /// - public static readonly ElfRelocationType R_X86_64_DTPMOD64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPMOD64); - - /// - /// Offset in module's TLS block - /// - public static readonly ElfRelocationType R_X86_64_DTPOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPOFF64); - - /// - /// Offset in initial TLS block - /// - public static readonly ElfRelocationType R_X86_64_TPOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TPOFF64); - - /// - /// 32 bit signed PC relative offset to two GOT entries for GD symbol - /// - public static readonly ElfRelocationType R_X86_64_TLSGD = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSGD); - - /// - /// 32 bit signed PC relative offset to two GOT entries for LD symbol - /// - public static readonly ElfRelocationType R_X86_64_TLSLD = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSLD); - - /// - /// Offset in TLS block - /// - public static readonly ElfRelocationType R_X86_64_DTPOFF32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_DTPOFF32); - - /// - /// 32 bit signed PC relative offset to GOT entry for IE symbol - /// - public static readonly ElfRelocationType R_X86_64_GOTTPOFF = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTTPOFF); - - /// - /// Offset in initial TLS block - /// - public static readonly ElfRelocationType R_X86_64_TPOFF32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TPOFF32); - - /// - /// PC relative 64 bit - /// - public static readonly ElfRelocationType R_X86_64_PC64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PC64); - - /// - /// 64 bit offset to GOT - /// - public static readonly ElfRelocationType R_X86_64_GOTOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTOFF64); - - /// - /// 32 bit signed pc relative offset to GOT - /// - public static readonly ElfRelocationType R_X86_64_GOTPC32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC32); - - /// - /// 64-bit GOT entry offset - /// - public static readonly ElfRelocationType R_X86_64_GOT64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOT64); - - /// - /// 64-bit PC relative offset to GOT entry - /// - public static readonly ElfRelocationType R_X86_64_GOTPCREL64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPCREL64); - - /// - /// 64-bit PC relative offset to GOT - /// - public static readonly ElfRelocationType R_X86_64_GOTPC64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC64); - - /// - /// like GOT64, says PLT entry needed - /// - public static readonly ElfRelocationType R_X86_64_GOTPLT64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPLT64); - - /// - /// 64-bit GOT relative offset to PLT entry - /// - public static readonly ElfRelocationType R_X86_64_PLTOFF64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_PLTOFF64); - - /// - /// Size of symbol plus 32-bit addend - /// - public static readonly ElfRelocationType R_X86_64_SIZE32 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_SIZE32); - - /// - /// Size of symbol plus 64-bit addend - /// - public static readonly ElfRelocationType R_X86_64_SIZE64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_SIZE64); - - /// - /// GOT offset for TLS descriptor. - /// - public static readonly ElfRelocationType R_X86_64_GOTPC32_TLSDESC = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_GOTPC32_TLSDESC); - - /// - /// Marker for call through TLS descriptor. - /// - public static readonly ElfRelocationType R_X86_64_TLSDESC_CALL = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSDESC_CALL); - - /// - /// TLS descriptor. - /// - public static readonly ElfRelocationType R_X86_64_TLSDESC = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_TLSDESC); - - /// - /// Adjust indirectly by program base - /// - public static readonly ElfRelocationType R_X86_64_IRELATIVE = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_IRELATIVE); - - /// - /// 64-bit adjust by program base - /// - public static readonly ElfRelocationType R_X86_64_RELATIVE64 = new ElfRelocationType(ElfArch.X86_64, ElfNative.R_X86_64_RELATIVE64); - - private string ToStringInternal() - { - switch (((ulong)Value << 16) | (ulong)Arch.Value) - { - case ((ulong)ElfNative.R_386_NONE << 16) | ElfNative.EM_386 : return "R_386_NONE"; - case ((ulong)ElfNative.R_386_32 << 16) | ElfNative.EM_386 : return "R_386_32"; - case ((ulong)ElfNative.R_386_PC32 << 16) | ElfNative.EM_386 : return "R_386_PC32"; - case ((ulong)ElfNative.R_386_GOT32 << 16) | ElfNative.EM_386 : return "R_386_GOT32"; - case ((ulong)ElfNative.R_386_PLT32 << 16) | ElfNative.EM_386 : return "R_386_PLT32"; - case ((ulong)ElfNative.R_386_COPY << 16) | ElfNative.EM_386 : return "R_386_COPY"; - case ((ulong)ElfNative.R_386_GLOB_DAT << 16) | ElfNative.EM_386 : return "R_386_GLOB_DAT"; - case ((ulong)ElfNative.R_386_JMP_SLOT << 16) | ElfNative.EM_386 : return "R_386_JMP_SLOT"; - case ((ulong)ElfNative.R_386_RELATIVE << 16) | ElfNative.EM_386 : return "R_386_RELATIVE"; - case ((ulong)ElfNative.R_386_GOTOFF << 16) | ElfNative.EM_386 : return "R_386_GOTOFF"; - case ((ulong)ElfNative.R_386_GOTPC << 16) | ElfNative.EM_386 : return "R_386_GOTPC"; - case ((ulong)ElfNative.R_386_32PLT << 16) | ElfNative.EM_386 : return "R_386_32PLT"; - case ((ulong)ElfNative.R_386_TLS_TPOFF << 16) | ElfNative.EM_386 : return "R_386_TLS_TPOFF"; - case ((ulong)ElfNative.R_386_TLS_IE << 16) | ElfNative.EM_386 : return "R_386_TLS_IE"; - case ((ulong)ElfNative.R_386_TLS_GOTIE << 16) | ElfNative.EM_386 : return "R_386_TLS_GOTIE"; - case ((ulong)ElfNative.R_386_TLS_LE << 16) | ElfNative.EM_386 : return "R_386_TLS_LE"; - case ((ulong)ElfNative.R_386_TLS_GD << 16) | ElfNative.EM_386 : return "R_386_TLS_GD"; - case ((ulong)ElfNative.R_386_TLS_LDM << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM"; - case ((ulong)ElfNative.R_386_16 << 16) | ElfNative.EM_386 : return "R_386_16"; - case ((ulong)ElfNative.R_386_PC16 << 16) | ElfNative.EM_386 : return "R_386_PC16"; - case ((ulong)ElfNative.R_386_8 << 16) | ElfNative.EM_386 : return "R_386_8"; - case ((ulong)ElfNative.R_386_PC8 << 16) | ElfNative.EM_386 : return "R_386_PC8"; - case ((ulong)ElfNative.R_386_TLS_GD_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_32"; - case ((ulong)ElfNative.R_386_TLS_GD_PUSH << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_PUSH"; - case ((ulong)ElfNative.R_386_TLS_GD_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_CALL"; - case ((ulong)ElfNative.R_386_TLS_GD_POP << 16) | ElfNative.EM_386 : return "R_386_TLS_GD_POP"; - case ((ulong)ElfNative.R_386_TLS_LDM_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_32"; - case ((ulong)ElfNative.R_386_TLS_LDM_PUSH << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_PUSH"; - case ((ulong)ElfNative.R_386_TLS_LDM_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_CALL"; - case ((ulong)ElfNative.R_386_TLS_LDM_POP << 16) | ElfNative.EM_386 : return "R_386_TLS_LDM_POP"; - case ((ulong)ElfNative.R_386_TLS_LDO_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LDO_32"; - case ((ulong)ElfNative.R_386_TLS_IE_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_IE_32"; - case ((ulong)ElfNative.R_386_TLS_LE_32 << 16) | ElfNative.EM_386 : return "R_386_TLS_LE_32"; - case ((ulong)ElfNative.R_386_TLS_DTPMOD32 << 16) | ElfNative.EM_386 : return "R_386_TLS_DTPMOD32"; - case ((ulong)ElfNative.R_386_TLS_DTPOFF32 << 16) | ElfNative.EM_386 : return "R_386_TLS_DTPOFF32"; - case ((ulong)ElfNative.R_386_TLS_TPOFF32 << 16) | ElfNative.EM_386 : return "R_386_TLS_TPOFF32"; - case ((ulong)ElfNative.R_386_SIZE32 << 16) | ElfNative.EM_386 : return "R_386_SIZE32"; - case ((ulong)ElfNative.R_386_TLS_GOTDESC << 16) | ElfNative.EM_386 : return "R_386_TLS_GOTDESC"; - case ((ulong)ElfNative.R_386_TLS_DESC_CALL << 16) | ElfNative.EM_386 : return "R_386_TLS_DESC_CALL"; - case ((ulong)ElfNative.R_386_TLS_DESC << 16) | ElfNative.EM_386 : return "R_386_TLS_DESC"; - case ((ulong)ElfNative.R_386_IRELATIVE << 16) | ElfNative.EM_386 : return "R_386_IRELATIVE"; - case ((ulong)ElfNative.R_AARCH64_NONE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_NONE"; - case ((ulong)ElfNative.R_AARCH64_P32_ABS32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_ABS32"; - case ((ulong)ElfNative.R_AARCH64_P32_COPY << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_COPY"; - case ((ulong)ElfNative.R_AARCH64_P32_GLOB_DAT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_GLOB_DAT"; - case ((ulong)ElfNative.R_AARCH64_P32_JUMP_SLOT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_JUMP_SLOT"; - case ((ulong)ElfNative.R_AARCH64_P32_RELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_RELATIVE"; - case ((ulong)ElfNative.R_AARCH64_P32_TLS_DTPMOD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_DTPMOD"; - case ((ulong)ElfNative.R_AARCH64_P32_TLS_DTPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_DTPREL"; - case ((ulong)ElfNative.R_AARCH64_P32_TLS_TPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLS_TPREL"; - case ((ulong)ElfNative.R_AARCH64_P32_TLSDESC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_TLSDESC"; - case ((ulong)ElfNative.R_AARCH64_P32_IRELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_P32_IRELATIVE"; - case ((ulong)ElfNative.R_AARCH64_ABS64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS64"; - case ((ulong)ElfNative.R_AARCH64_ABS32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS32"; - case ((ulong)ElfNative.R_AARCH64_ABS16 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ABS16"; - case ((ulong)ElfNative.R_AARCH64_PREL64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL64"; - case ((ulong)ElfNative.R_AARCH64_PREL32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL32"; - case ((ulong)ElfNative.R_AARCH64_PREL16 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_PREL16"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G0"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G1"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G1_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G2"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G2_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_UABS_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_UABS_G3"; - case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G0"; - case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G1"; - case ((ulong)ElfNative.R_AARCH64_MOVW_SABS_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_SABS_G2"; - case ((ulong)ElfNative.R_AARCH64_LD_PREL_LO19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD_PREL_LO19"; - case ((ulong)ElfNative.R_AARCH64_ADR_PREL_LO21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_LO21"; - case ((ulong)ElfNative.R_AARCH64_ADR_PREL_PG_HI21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_PG_HI21"; - case ((ulong)ElfNative.R_AARCH64_ADR_PREL_PG_HI21_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_PREL_PG_HI21_NC"; - case ((ulong)ElfNative.R_AARCH64_ADD_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADD_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_LDST8_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST8_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TSTBR14 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TSTBR14"; - case ((ulong)ElfNative.R_AARCH64_CONDBR19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_CONDBR19"; - case ((ulong)ElfNative.R_AARCH64_JUMP26 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_JUMP26"; - case ((ulong)ElfNative.R_AARCH64_CALL26 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_CALL26"; - case ((ulong)ElfNative.R_AARCH64_LDST16_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST16_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_LDST32_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST32_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_LDST64_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST64_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G0"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G1"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G1_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G2"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G2_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_PREL_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_PREL_G3"; - case ((ulong)ElfNative.R_AARCH64_LDST128_ABS_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LDST128_ABS_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G0"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G1"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G1_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G2"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G2_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G2_NC"; - case ((ulong)ElfNative.R_AARCH64_MOVW_GOTOFF_G3 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_MOVW_GOTOFF_G3"; - case ((ulong)ElfNative.R_AARCH64_GOTREL64 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOTREL64"; - case ((ulong)ElfNative.R_AARCH64_GOTREL32 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOTREL32"; - case ((ulong)ElfNative.R_AARCH64_GOT_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GOT_LD_PREL19"; - case ((ulong)ElfNative.R_AARCH64_LD64_GOTOFF_LO15 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOTOFF_LO15"; - case ((ulong)ElfNative.R_AARCH64_ADR_GOT_PAGE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_ADR_GOT_PAGE"; - case ((ulong)ElfNative.R_AARCH64_LD64_GOT_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOT_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_LD64_GOTPAGE_LO15 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_LD64_GOTPAGE_LO15"; - case ((ulong)ElfNative.R_AARCH64_TLSGD_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADR_PREL21"; - case ((ulong)ElfNative.R_AARCH64_TLSGD_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADR_PAGE21"; - case ((ulong)ElfNative.R_AARCH64_TLSGD_ADD_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_ADD_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSGD_MOVW_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_MOVW_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSGD_MOVW_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSGD_MOVW_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADR_PREL21"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADR_PAGE21"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LD_PREL19"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G2"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G0"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_HI12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_HI12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST8_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST16_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST32_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST64_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_MOVW_GOTTPREL_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21"; - case ((ulong)ElfNative.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSIE_LD_GOTTPREL_PREL19"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G2 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G2"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G1_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G1_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G0"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_MOVW_TPREL_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_MOVW_TPREL_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_HI12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_ADD_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST8_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST16_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST32_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST64_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_LD_PREL19 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LD_PREL19"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADR_PREL21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADR_PREL21"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADR_PAGE21"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_LD64_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LD64_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADD_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADD_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_OFF_G1 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_OFF_G1"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_OFF_G0_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_OFF_G0_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_LDR << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_LDR"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_ADD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_ADD"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC_CALL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC_CALL"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST128_TPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12 << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST128_DTPREL_LO12"; - case ((ulong)ElfNative.R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC"; - case ((ulong)ElfNative.R_AARCH64_COPY << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_COPY"; - case ((ulong)ElfNative.R_AARCH64_GLOB_DAT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_GLOB_DAT"; - case ((ulong)ElfNative.R_AARCH64_JUMP_SLOT << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_JUMP_SLOT"; - case ((ulong)ElfNative.R_AARCH64_RELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_RELATIVE"; - case ((ulong)ElfNative.R_AARCH64_TLS_DTPMOD << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_DTPMOD"; - case ((ulong)ElfNative.R_AARCH64_TLS_DTPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_DTPREL"; - case ((ulong)ElfNative.R_AARCH64_TLS_TPREL << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLS_TPREL"; - case ((ulong)ElfNative.R_AARCH64_TLSDESC << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_TLSDESC"; - case ((ulong)ElfNative.R_AARCH64_IRELATIVE << 16) | ElfNative.EM_AARCH64 : return "R_AARCH64_IRELATIVE"; - case ((ulong)ElfNative.R_ARM_NONE << 16) | ElfNative.EM_ARM : return "R_ARM_NONE"; - case ((ulong)ElfNative.R_ARM_PC24 << 16) | ElfNative.EM_ARM : return "R_ARM_PC24"; - case ((ulong)ElfNative.R_ARM_ABS32 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS32"; - case ((ulong)ElfNative.R_ARM_REL32 << 16) | ElfNative.EM_ARM : return "R_ARM_REL32"; - case ((ulong)ElfNative.R_ARM_PC13 << 16) | ElfNative.EM_ARM : return "R_ARM_PC13"; - case ((ulong)ElfNative.R_ARM_ABS16 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS16"; - case ((ulong)ElfNative.R_ARM_ABS12 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS12"; - case ((ulong)ElfNative.R_ARM_THM_ABS5 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_ABS5"; - case ((ulong)ElfNative.R_ARM_ABS8 << 16) | ElfNative.EM_ARM : return "R_ARM_ABS8"; - case ((ulong)ElfNative.R_ARM_SBREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_SBREL32"; - case ((ulong)ElfNative.R_ARM_THM_PC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC22"; - case ((ulong)ElfNative.R_ARM_THM_PC8 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC8"; - case ((ulong)ElfNative.R_ARM_AMP_VCALL9 << 16) | ElfNative.EM_ARM : return "R_ARM_AMP_VCALL9"; - case ((ulong)ElfNative.R_ARM_SWI24 << 16) | ElfNative.EM_ARM : return "R_ARM_SWI24"; - case ((ulong)ElfNative.R_ARM_THM_SWI8 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_SWI8"; - case ((ulong)ElfNative.R_ARM_XPC25 << 16) | ElfNative.EM_ARM : return "R_ARM_XPC25"; - case ((ulong)ElfNative.R_ARM_THM_XPC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_XPC22"; - case ((ulong)ElfNative.R_ARM_TLS_DTPMOD32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DTPMOD32"; - case ((ulong)ElfNative.R_ARM_TLS_DTPOFF32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DTPOFF32"; - case ((ulong)ElfNative.R_ARM_TLS_TPOFF32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_TPOFF32"; - case ((ulong)ElfNative.R_ARM_COPY << 16) | ElfNative.EM_ARM : return "R_ARM_COPY"; - case ((ulong)ElfNative.R_ARM_GLOB_DAT << 16) | ElfNative.EM_ARM : return "R_ARM_GLOB_DAT"; - case ((ulong)ElfNative.R_ARM_JUMP_SLOT << 16) | ElfNative.EM_ARM : return "R_ARM_JUMP_SLOT"; - case ((ulong)ElfNative.R_ARM_RELATIVE << 16) | ElfNative.EM_ARM : return "R_ARM_RELATIVE"; - case ((ulong)ElfNative.R_ARM_GOTOFF << 16) | ElfNative.EM_ARM : return "R_ARM_GOTOFF"; - case ((ulong)ElfNative.R_ARM_GOTPC << 16) | ElfNative.EM_ARM : return "R_ARM_GOTPC"; - case ((ulong)ElfNative.R_ARM_GOT32 << 16) | ElfNative.EM_ARM : return "R_ARM_GOT32"; - case ((ulong)ElfNative.R_ARM_PLT32 << 16) | ElfNative.EM_ARM : return "R_ARM_PLT32"; - case ((ulong)ElfNative.R_ARM_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_CALL"; - case ((ulong)ElfNative.R_ARM_JUMP24 << 16) | ElfNative.EM_ARM : return "R_ARM_JUMP24"; - case ((ulong)ElfNative.R_ARM_THM_JUMP24 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP24"; - case ((ulong)ElfNative.R_ARM_BASE_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_BASE_ABS"; - case ((ulong)ElfNative.R_ARM_ALU_PCREL_7_0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_7_0"; - case ((ulong)ElfNative.R_ARM_ALU_PCREL_15_8 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_15_8"; - case ((ulong)ElfNative.R_ARM_ALU_PCREL_23_15 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PCREL_23_15"; - case ((ulong)ElfNative.R_ARM_LDR_SBREL_11_0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SBREL_11_0"; - case ((ulong)ElfNative.R_ARM_ALU_SBREL_19_12 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SBREL_19_12"; - case ((ulong)ElfNative.R_ARM_ALU_SBREL_27_20 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SBREL_27_20"; - case ((ulong)ElfNative.R_ARM_TARGET1 << 16) | ElfNative.EM_ARM : return "R_ARM_TARGET1"; - case ((ulong)ElfNative.R_ARM_SBREL31 << 16) | ElfNative.EM_ARM : return "R_ARM_SBREL31"; - case ((ulong)ElfNative.R_ARM_V4BX << 16) | ElfNative.EM_ARM : return "R_ARM_V4BX"; - case ((ulong)ElfNative.R_ARM_TARGET2 << 16) | ElfNative.EM_ARM : return "R_ARM_TARGET2"; - case ((ulong)ElfNative.R_ARM_PREL31 << 16) | ElfNative.EM_ARM : return "R_ARM_PREL31"; - case ((ulong)ElfNative.R_ARM_MOVW_ABS_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_ABS_NC"; - case ((ulong)ElfNative.R_ARM_MOVT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_ABS"; - case ((ulong)ElfNative.R_ARM_MOVW_PREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_PREL_NC"; - case ((ulong)ElfNative.R_ARM_MOVT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_PREL"; - case ((ulong)ElfNative.R_ARM_THM_MOVW_ABS_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_ABS_NC"; - case ((ulong)ElfNative.R_ARM_THM_MOVT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_ABS"; - case ((ulong)ElfNative.R_ARM_THM_MOVW_PREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_PREL_NC"; - case ((ulong)ElfNative.R_ARM_THM_MOVT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_PREL"; - case ((ulong)ElfNative.R_ARM_THM_JUMP19 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP19"; - case ((ulong)ElfNative.R_ARM_THM_JUMP6 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_JUMP6"; - case ((ulong)ElfNative.R_ARM_THM_ALU_PREL_11_0 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_ALU_PREL_11_0"; - case ((ulong)ElfNative.R_ARM_THM_PC12 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC12"; - case ((ulong)ElfNative.R_ARM_ABS32_NOI << 16) | ElfNative.EM_ARM : return "R_ARM_ABS32_NOI"; - case ((ulong)ElfNative.R_ARM_REL32_NOI << 16) | ElfNative.EM_ARM : return "R_ARM_REL32_NOI"; - case ((ulong)ElfNative.R_ARM_ALU_PC_G0_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G0_NC"; - case ((ulong)ElfNative.R_ARM_ALU_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G0"; - case ((ulong)ElfNative.R_ARM_ALU_PC_G1_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G1_NC"; - case ((ulong)ElfNative.R_ARM_ALU_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G1"; - case ((ulong)ElfNative.R_ARM_ALU_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_PC_G2"; - case ((ulong)ElfNative.R_ARM_LDR_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_PC_G1"; - case ((ulong)ElfNative.R_ARM_LDR_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_PC_G2"; - case ((ulong)ElfNative.R_ARM_LDRS_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G0"; - case ((ulong)ElfNative.R_ARM_LDRS_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G1"; - case ((ulong)ElfNative.R_ARM_LDRS_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_PC_G2"; - case ((ulong)ElfNative.R_ARM_LDC_PC_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G0"; - case ((ulong)ElfNative.R_ARM_LDC_PC_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G1"; - case ((ulong)ElfNative.R_ARM_LDC_PC_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_PC_G2"; - case ((ulong)ElfNative.R_ARM_ALU_SB_G0_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G0_NC"; - case ((ulong)ElfNative.R_ARM_ALU_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G0"; - case ((ulong)ElfNative.R_ARM_ALU_SB_G1_NC << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G1_NC"; - case ((ulong)ElfNative.R_ARM_ALU_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G1"; - case ((ulong)ElfNative.R_ARM_ALU_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_ALU_SB_G2"; - case ((ulong)ElfNative.R_ARM_LDR_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G0"; - case ((ulong)ElfNative.R_ARM_LDR_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G1"; - case ((ulong)ElfNative.R_ARM_LDR_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDR_SB_G2"; - case ((ulong)ElfNative.R_ARM_LDRS_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G0"; - case ((ulong)ElfNative.R_ARM_LDRS_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G1"; - case ((ulong)ElfNative.R_ARM_LDRS_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDRS_SB_G2"; - case ((ulong)ElfNative.R_ARM_LDC_SB_G0 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G0"; - case ((ulong)ElfNative.R_ARM_LDC_SB_G1 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G1"; - case ((ulong)ElfNative.R_ARM_LDC_SB_G2 << 16) | ElfNative.EM_ARM : return "R_ARM_LDC_SB_G2"; - case ((ulong)ElfNative.R_ARM_MOVW_BREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_BREL_NC"; - case ((ulong)ElfNative.R_ARM_MOVT_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVT_BREL"; - case ((ulong)ElfNative.R_ARM_MOVW_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_MOVW_BREL"; - case ((ulong)ElfNative.R_ARM_THM_MOVW_BREL_NC << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_BREL_NC"; - case ((ulong)ElfNative.R_ARM_THM_MOVT_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVT_BREL"; - case ((ulong)ElfNative.R_ARM_THM_MOVW_BREL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_MOVW_BREL"; - case ((ulong)ElfNative.R_ARM_TLS_GOTDESC << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_GOTDESC"; - case ((ulong)ElfNative.R_ARM_TLS_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_CALL"; - case ((ulong)ElfNative.R_ARM_TLS_DESCSEQ << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_DESCSEQ"; - case ((ulong)ElfNative.R_ARM_THM_TLS_CALL << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_CALL"; - case ((ulong)ElfNative.R_ARM_PLT32_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_PLT32_ABS"; - case ((ulong)ElfNative.R_ARM_GOT_ABS << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_ABS"; - case ((ulong)ElfNative.R_ARM_GOT_PREL << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_PREL"; - case ((ulong)ElfNative.R_ARM_GOT_BREL12 << 16) | ElfNative.EM_ARM : return "R_ARM_GOT_BREL12"; - case ((ulong)ElfNative.R_ARM_GOTOFF12 << 16) | ElfNative.EM_ARM : return "R_ARM_GOTOFF12"; - case ((ulong)ElfNative.R_ARM_GOTRELAX << 16) | ElfNative.EM_ARM : return "R_ARM_GOTRELAX"; - case ((ulong)ElfNative.R_ARM_GNU_VTENTRY << 16) | ElfNative.EM_ARM : return "R_ARM_GNU_VTENTRY"; - case ((ulong)ElfNative.R_ARM_GNU_VTINHERIT << 16) | ElfNative.EM_ARM : return "R_ARM_GNU_VTINHERIT"; - case ((ulong)ElfNative.R_ARM_THM_PC11 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC11"; - case ((ulong)ElfNative.R_ARM_THM_PC9 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_PC9"; - case ((ulong)ElfNative.R_ARM_TLS_GD32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_GD32"; - case ((ulong)ElfNative.R_ARM_TLS_LDM32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDM32"; - case ((ulong)ElfNative.R_ARM_TLS_LDO32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDO32"; - case ((ulong)ElfNative.R_ARM_TLS_IE32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_IE32"; - case ((ulong)ElfNative.R_ARM_TLS_LE32 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LE32"; - case ((ulong)ElfNative.R_ARM_TLS_LDO12 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LDO12"; - case ((ulong)ElfNative.R_ARM_TLS_LE12 << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_LE12"; - case ((ulong)ElfNative.R_ARM_TLS_IE12GP << 16) | ElfNative.EM_ARM : return "R_ARM_TLS_IE12GP"; - case ((ulong)ElfNative.R_ARM_ME_TOO << 16) | ElfNative.EM_ARM : return "R_ARM_ME_TOO"; - case ((ulong)ElfNative.R_ARM_THM_TLS_DESCSEQ << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_DESCSEQ"; - case ((ulong)ElfNative.R_ARM_THM_TLS_DESCSEQ32 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_TLS_DESCSEQ32"; - case ((ulong)ElfNative.R_ARM_THM_GOT_BREL12 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_GOT_BREL12"; - case ((ulong)ElfNative.R_ARM_IRELATIVE << 16) | ElfNative.EM_ARM : return "R_ARM_IRELATIVE"; - case ((ulong)ElfNative.R_ARM_RXPC25 << 16) | ElfNative.EM_ARM : return "R_ARM_RXPC25"; - case ((ulong)ElfNative.R_ARM_RSBREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_RSBREL32"; - case ((ulong)ElfNative.R_ARM_THM_RPC22 << 16) | ElfNative.EM_ARM : return "R_ARM_THM_RPC22"; - case ((ulong)ElfNative.R_ARM_RREL32 << 16) | ElfNative.EM_ARM : return "R_ARM_RREL32"; - case ((ulong)ElfNative.R_ARM_RABS22 << 16) | ElfNative.EM_ARM : return "R_ARM_RABS22"; - case ((ulong)ElfNative.R_ARM_RPC24 << 16) | ElfNative.EM_ARM : return "R_ARM_RPC24"; - case ((ulong)ElfNative.R_ARM_RBASE << 16) | ElfNative.EM_ARM : return "R_ARM_RBASE"; - case ((ulong)ElfNative.R_X86_64_NONE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_NONE"; - case ((ulong)ElfNative.R_X86_64_64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_64"; - case ((ulong)ElfNative.R_X86_64_PC32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC32"; - case ((ulong)ElfNative.R_X86_64_GOT32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOT32"; - case ((ulong)ElfNative.R_X86_64_PLT32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PLT32"; - case ((ulong)ElfNative.R_X86_64_COPY << 16) | ElfNative.EM_X86_64 : return "R_X86_64_COPY"; - case ((ulong)ElfNative.R_X86_64_GLOB_DAT << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GLOB_DAT"; - case ((ulong)ElfNative.R_X86_64_JUMP_SLOT << 16) | ElfNative.EM_X86_64 : return "R_X86_64_JUMP_SLOT"; - case ((ulong)ElfNative.R_X86_64_RELATIVE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_RELATIVE"; - case ((ulong)ElfNative.R_X86_64_GOTPCREL << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPCREL"; - case ((ulong)ElfNative.R_X86_64_32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_32"; - case ((ulong)ElfNative.R_X86_64_32S << 16) | ElfNative.EM_X86_64 : return "R_X86_64_32S"; - case ((ulong)ElfNative.R_X86_64_16 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_16"; - case ((ulong)ElfNative.R_X86_64_PC16 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC16"; - case ((ulong)ElfNative.R_X86_64_8 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_8"; - case ((ulong)ElfNative.R_X86_64_PC8 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC8"; - case ((ulong)ElfNative.R_X86_64_DTPMOD64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPMOD64"; - case ((ulong)ElfNative.R_X86_64_DTPOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPOFF64"; - case ((ulong)ElfNative.R_X86_64_TPOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TPOFF64"; - case ((ulong)ElfNative.R_X86_64_TLSGD << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSGD"; - case ((ulong)ElfNative.R_X86_64_TLSLD << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSLD"; - case ((ulong)ElfNative.R_X86_64_DTPOFF32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_DTPOFF32"; - case ((ulong)ElfNative.R_X86_64_GOTTPOFF << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTTPOFF"; - case ((ulong)ElfNative.R_X86_64_TPOFF32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TPOFF32"; - case ((ulong)ElfNative.R_X86_64_PC64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PC64"; - case ((ulong)ElfNative.R_X86_64_GOTOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTOFF64"; - case ((ulong)ElfNative.R_X86_64_GOTPC32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC32"; - case ((ulong)ElfNative.R_X86_64_GOT64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOT64"; - case ((ulong)ElfNative.R_X86_64_GOTPCREL64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPCREL64"; - case ((ulong)ElfNative.R_X86_64_GOTPC64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC64"; - case ((ulong)ElfNative.R_X86_64_GOTPLT64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPLT64"; - case ((ulong)ElfNative.R_X86_64_PLTOFF64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_PLTOFF64"; - case ((ulong)ElfNative.R_X86_64_SIZE32 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_SIZE32"; - case ((ulong)ElfNative.R_X86_64_SIZE64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_SIZE64"; - case ((ulong)ElfNative.R_X86_64_GOTPC32_TLSDESC << 16) | ElfNative.EM_X86_64 : return "R_X86_64_GOTPC32_TLSDESC"; - case ((ulong)ElfNative.R_X86_64_TLSDESC_CALL << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSDESC_CALL"; - case ((ulong)ElfNative.R_X86_64_TLSDESC << 16) | ElfNative.EM_X86_64 : return "R_X86_64_TLSDESC"; - case ((ulong)ElfNative.R_X86_64_IRELATIVE << 16) | ElfNative.EM_X86_64 : return "R_X86_64_IRELATIVE"; - case ((ulong)ElfNative.R_X86_64_RELATIVE64 << 16) | ElfNative.EM_X86_64 : return "R_X86_64_RELATIVE64"; - default: return null; - } - } - } - - public readonly partial struct ElfNoteTypeEx - { - /// - /// Contains copy of prstatus struct - /// - public static readonly ElfNoteTypeEx PRSTATUS = new ElfNoteTypeEx(ElfNative.NT_PRSTATUS); - - /// - /// Contains copy of fpregset struct - /// - public static readonly ElfNoteTypeEx FPREGSET = new ElfNoteTypeEx(ElfNative.NT_FPREGSET); - - /// - /// Contains copy of prpsinfo struct - /// - public static readonly ElfNoteTypeEx PRPSINFO = new ElfNoteTypeEx(ElfNative.NT_PRPSINFO); - - /// - /// Contains copy of prxregset struct - /// - public static readonly ElfNoteTypeEx PRXREG = new ElfNoteTypeEx(ElfNative.NT_PRXREG); - - /// - /// Contains copy of task structure - /// - public static readonly ElfNoteTypeEx TASKSTRUCT = new ElfNoteTypeEx(ElfNative.NT_TASKSTRUCT); - - /// - /// String from sysinfo(SI_PLATFORM) - /// - public static readonly ElfNoteTypeEx PLATFORM = new ElfNoteTypeEx(ElfNative.NT_PLATFORM); - - /// - /// Contains copy of auxv array - /// - public static readonly ElfNoteTypeEx AUXV = new ElfNoteTypeEx(ElfNative.NT_AUXV); - - /// - /// Contains copy of gwindows struct - /// - public static readonly ElfNoteTypeEx GWINDOWS = new ElfNoteTypeEx(ElfNative.NT_GWINDOWS); - - /// - /// Contains copy of asrset struct - /// - public static readonly ElfNoteTypeEx ASRS = new ElfNoteTypeEx(ElfNative.NT_ASRS); - - /// - /// Contains copy of pstatus struct - /// - public static readonly ElfNoteTypeEx PSTATUS = new ElfNoteTypeEx(ElfNative.NT_PSTATUS); - - /// - /// Contains copy of psinfo struct - /// - public static readonly ElfNoteTypeEx PSINFO = new ElfNoteTypeEx(ElfNative.NT_PSINFO); - - /// - /// Contains copy of prcred struct - /// - public static readonly ElfNoteTypeEx PRCRED = new ElfNoteTypeEx(ElfNative.NT_PRCRED); - - /// - /// Contains copy of utsname struct - /// - public static readonly ElfNoteTypeEx UTSNAME = new ElfNoteTypeEx(ElfNative.NT_UTSNAME); - - /// - /// Contains copy of lwpstatus struct - /// - public static readonly ElfNoteTypeEx LWPSTATUS = new ElfNoteTypeEx(ElfNative.NT_LWPSTATUS); - - /// - /// Contains copy of lwpinfo struct - /// - public static readonly ElfNoteTypeEx LWPSINFO = new ElfNoteTypeEx(ElfNative.NT_LWPSINFO); - - /// - /// Contains copy of fprxregset struct - /// - public static readonly ElfNoteTypeEx PRFPXREG = new ElfNoteTypeEx(ElfNative.NT_PRFPXREG); - - /// - /// Contains copy of siginfo_t, size might increase - /// - public static readonly ElfNoteTypeEx SIGINFO = new ElfNoteTypeEx(ElfNative.NT_SIGINFO); - - /// - /// Contains information about mapped files - /// - public static readonly ElfNoteTypeEx FILE = new ElfNoteTypeEx(ElfNative.NT_FILE); - - /// - /// Contains copy of user_fxsr_struct - /// - public static readonly ElfNoteTypeEx PRXFPREG = new ElfNoteTypeEx(ElfNative.NT_PRXFPREG); - - /// - /// PowerPC Altivec/VMX registers - /// - public static readonly ElfNoteTypeEx PPC_VMX = new ElfNoteTypeEx(ElfNative.NT_PPC_VMX); - - /// - /// PowerPC SPE/EVR registers - /// - public static readonly ElfNoteTypeEx PPC_SPE = new ElfNoteTypeEx(ElfNative.NT_PPC_SPE); - - /// - /// PowerPC VSX registers - /// - public static readonly ElfNoteTypeEx PPC_VSX = new ElfNoteTypeEx(ElfNative.NT_PPC_VSX); - - /// - /// i386 TLS slots (struct user_desc) - /// - public static readonly ElfNoteTypeEx I386_TLS = new ElfNoteTypeEx(ElfNative.NT_386_TLS); - - /// - /// x86 io permission bitmap (1=deny) - /// - public static readonly ElfNoteTypeEx I386_IOPERM = new ElfNoteTypeEx(ElfNative.NT_386_IOPERM); - - /// - /// x86 extended state using xsave - /// - public static readonly ElfNoteTypeEx X86_XSTATE = new ElfNoteTypeEx(ElfNative.NT_X86_XSTATE); - - /// - /// s390 upper register halves - /// - public static readonly ElfNoteTypeEx S390_HIGH_GPRS = new ElfNoteTypeEx(ElfNative.NT_S390_HIGH_GPRS); - - /// - /// s390 timer register - /// - public static readonly ElfNoteTypeEx S390_TIMER = new ElfNoteTypeEx(ElfNative.NT_S390_TIMER); - - /// - /// s390 TOD clock comparator register - /// - public static readonly ElfNoteTypeEx S390_TODCMP = new ElfNoteTypeEx(ElfNative.NT_S390_TODCMP); - - /// - /// s390 TOD programmable register - /// - public static readonly ElfNoteTypeEx S390_TODPREG = new ElfNoteTypeEx(ElfNative.NT_S390_TODPREG); - - /// - /// s390 control registers - /// - public static readonly ElfNoteTypeEx S390_CTRS = new ElfNoteTypeEx(ElfNative.NT_S390_CTRS); - - /// - /// s390 prefix register - /// - public static readonly ElfNoteTypeEx S390_PREFIX = new ElfNoteTypeEx(ElfNative.NT_S390_PREFIX); - - /// - /// s390 breaking event address - /// - public static readonly ElfNoteTypeEx S390_LAST_BREAK = new ElfNoteTypeEx(ElfNative.NT_S390_LAST_BREAK); - - /// - /// s390 system call restart data - /// - public static readonly ElfNoteTypeEx S390_SYSTEM_CALL = new ElfNoteTypeEx(ElfNative.NT_S390_SYSTEM_CALL); - - /// - /// s390 transaction diagnostic block - /// - public static readonly ElfNoteTypeEx S390_TDB = new ElfNoteTypeEx(ElfNative.NT_S390_TDB); - - /// - /// ARM VFP/NEON registers - /// - public static readonly ElfNoteTypeEx ARM_VFP = new ElfNoteTypeEx(ElfNative.NT_ARM_VFP); - - /// - /// ARM TLS register - /// - public static readonly ElfNoteTypeEx ARM_TLS = new ElfNoteTypeEx(ElfNative.NT_ARM_TLS); - - /// - /// ARM hardware breakpoint registers - /// - public static readonly ElfNoteTypeEx ARM_HW_BREAK = new ElfNoteTypeEx(ElfNative.NT_ARM_HW_BREAK); - - /// - /// ARM hardware watchpoint registers - /// - public static readonly ElfNoteTypeEx ARM_HW_WATCH = new ElfNoteTypeEx(ElfNative.NT_ARM_HW_WATCH); - - /// - /// Contains a version string. - /// - public static readonly ElfNoteTypeEx VERSION = new ElfNoteTypeEx(ElfNative.NT_VERSION); - - public static readonly ElfNoteTypeEx GNU_ABI_TAG = new ElfNoteTypeEx(ElfNative.NT_GNU_ABI_TAG); - - public static readonly ElfNoteTypeEx GNU_HWCAP = new ElfNoteTypeEx(ElfNative.NT_GNU_HWCAP); - - public static readonly ElfNoteTypeEx GNU_BUILD_ID = new ElfNoteTypeEx(ElfNative.NT_GNU_BUILD_ID); - - public static readonly ElfNoteTypeEx GNU_GOLD_VERSION = new ElfNoteTypeEx(ElfNative.NT_GNU_GOLD_VERSION); - - private string ToStringInternal() - { - switch ((uint)Value) - { - case ElfNative.NT_PRSTATUS: return "NT_PRSTATUS"; - case ElfNative.NT_FPREGSET: return "NT_FPREGSET"; - case ElfNative.NT_PRPSINFO: return "NT_PRPSINFO"; - case ElfNative.NT_PRXREG: return "NT_PRXREG"; - case ElfNative.NT_PLATFORM: return "NT_PLATFORM"; - case ElfNative.NT_AUXV: return "NT_AUXV"; - case ElfNative.NT_GWINDOWS: return "NT_GWINDOWS"; - case ElfNative.NT_ASRS: return "NT_ASRS"; - case ElfNative.NT_PSTATUS: return "NT_PSTATUS"; - case ElfNative.NT_PSINFO: return "NT_PSINFO"; - case ElfNative.NT_PRCRED: return "NT_PRCRED"; - case ElfNative.NT_UTSNAME: return "NT_UTSNAME"; - case ElfNative.NT_LWPSTATUS: return "NT_LWPSTATUS"; - case ElfNative.NT_LWPSINFO: return "NT_LWPSINFO"; - case ElfNative.NT_PRFPXREG: return "NT_PRFPXREG"; - case ElfNative.NT_SIGINFO: return "NT_SIGINFO"; - case ElfNative.NT_FILE: return "NT_FILE"; - case ElfNative.NT_PRXFPREG: return "NT_PRXFPREG"; - case ElfNative.NT_PPC_VMX: return "NT_PPC_VMX"; - case ElfNative.NT_PPC_SPE: return "NT_PPC_SPE"; - case ElfNative.NT_PPC_VSX: return "NT_PPC_VSX"; - case ElfNative.NT_386_TLS: return "NT_386_TLS"; - case ElfNative.NT_386_IOPERM: return "NT_386_IOPERM"; - case ElfNative.NT_X86_XSTATE: return "NT_X86_XSTATE"; - case ElfNative.NT_S390_HIGH_GPRS: return "NT_S390_HIGH_GPRS"; - case ElfNative.NT_S390_TIMER: return "NT_S390_TIMER"; - case ElfNative.NT_S390_TODCMP: return "NT_S390_TODCMP"; - case ElfNative.NT_S390_TODPREG: return "NT_S390_TODPREG"; - case ElfNative.NT_S390_CTRS: return "NT_S390_CTRS"; - case ElfNative.NT_S390_PREFIX: return "NT_S390_PREFIX"; - case ElfNative.NT_S390_LAST_BREAK: return "NT_S390_LAST_BREAK"; - case ElfNative.NT_S390_SYSTEM_CALL: return "NT_S390_SYSTEM_CALL"; - case ElfNative.NT_S390_TDB: return "NT_S390_TDB"; - case ElfNative.NT_ARM_VFP: return "NT_ARM_VFP"; - case ElfNative.NT_ARM_TLS: return "NT_ARM_TLS"; - case ElfNative.NT_ARM_HW_BREAK: return "NT_ARM_HW_BREAK"; - case ElfNative.NT_ARM_HW_WATCH: return "NT_ARM_HW_WATCH"; - default: return null; - } - } - } - - public enum ElfNoteType : uint - { - PRSTATUS = ElfNative.NT_PRSTATUS, - - FPREGSET = ElfNative.NT_FPREGSET, - - PRPSINFO = ElfNative.NT_PRPSINFO, - - PRXREG = ElfNative.NT_PRXREG, - - TASKSTRUCT = ElfNative.NT_TASKSTRUCT, - - PLATFORM = ElfNative.NT_PLATFORM, - - AUXV = ElfNative.NT_AUXV, - - GWINDOWS = ElfNative.NT_GWINDOWS, - - ASRS = ElfNative.NT_ASRS, - - PSTATUS = ElfNative.NT_PSTATUS, - - PSINFO = ElfNative.NT_PSINFO, - - PRCRED = ElfNative.NT_PRCRED, - - UTSNAME = ElfNative.NT_UTSNAME, - - LWPSTATUS = ElfNative.NT_LWPSTATUS, - - LWPSINFO = ElfNative.NT_LWPSINFO, - - PRFPXREG = ElfNative.NT_PRFPXREG, - - SIGINFO = ElfNative.NT_SIGINFO, - - FILE = ElfNative.NT_FILE, - - PRXFPREG = ElfNative.NT_PRXFPREG, - - PPC_VMX = ElfNative.NT_PPC_VMX, - - PPC_SPE = ElfNative.NT_PPC_SPE, - - PPC_VSX = ElfNative.NT_PPC_VSX, - - I386_TLS = ElfNative.NT_386_TLS, - - I386_IOPERM = ElfNative.NT_386_IOPERM, - - X86_XSTATE = ElfNative.NT_X86_XSTATE, - - S390_HIGH_GPRS = ElfNative.NT_S390_HIGH_GPRS, - - S390_TIMER = ElfNative.NT_S390_TIMER, - - S390_TODCMP = ElfNative.NT_S390_TODCMP, - - S390_TODPREG = ElfNative.NT_S390_TODPREG, - - S390_CTRS = ElfNative.NT_S390_CTRS, - - S390_PREFIX = ElfNative.NT_S390_PREFIX, - - S390_LAST_BREAK = ElfNative.NT_S390_LAST_BREAK, - - S390_SYSTEM_CALL = ElfNative.NT_S390_SYSTEM_CALL, - - S390_TDB = ElfNative.NT_S390_TDB, - - ARM_VFP = ElfNative.NT_ARM_VFP, - - ARM_TLS = ElfNative.NT_ARM_TLS, - - ARM_HW_BREAK = ElfNative.NT_ARM_HW_BREAK, - - ARM_HW_WATCH = ElfNative.NT_ARM_HW_WATCH, - - VERSION = ElfNative.NT_VERSION, - - GNU_ABI_TAG = ElfNative.NT_GNU_ABI_TAG, - - GNU_HWCAP = ElfNative.NT_GNU_HWCAP, - - GNU_BUILD_ID = ElfNative.NT_GNU_BUILD_ID, - - GNU_GOLD_VERSION = ElfNative.NT_GNU_GOLD_VERSION, - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml b/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml deleted file mode 100644 index b6e2c66ab4186f..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/dotnet-releaser.toml +++ /dev/null @@ -1,9 +0,0 @@ -# configuration file for dotnet-releaser -[msbuild] -project = "LibObjectFile.sln" -build_debug = true -[test] -run_tests_for_debug = true -[github] -user = "xoofx" -repo = "LibObjectFile" diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs deleted file mode 100644 index 2f5ea0cdb82088..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/ObjDisasmApp.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.Buffers; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using Iced.Intel; -using LibObjectFile.Ar; -using LibObjectFile.Elf; -using Decoder = Iced.Intel.Decoder; - -namespace LibObjectFile.Disasm -{ - public class ObjDisasmApp - { - public ObjDisasmApp() - { - FunctionRegexFilters = new List(); - Files = new List(); - Output = Console.Out; - } - - public List FunctionRegexFilters { get; } - - public List Files { get; } - - public bool Verbose { get; set; } - - public bool Listing { get; set; } - - public TextWriter Output { get; set; } - - public void Run() - { - foreach (var file in Files) - { - using var stream = new FileStream(file, FileMode.Open, FileAccess.Read); - - if (ArArchiveFile.IsAr(stream)) - { - var options = new ArArchiveFileReaderOptions(ArArchiveKind.GNU); - - var archive = ArArchiveFile.Read(stream, options); - - foreach (var objFile in archive.Files) - { - if (objFile is ArElfFile elfFile) - { - ProcessElf(objFile.Name, elfFile.ElfObjectFile); - } - } - } - else if (ElfObjectFile.IsElf(stream)) - { - var elfObjectFile = ElfObjectFile.Read(stream, new ElfReaderOptions() {ReadOnly = true}); - ProcessElf(Path.GetFileName(file), elfObjectFile); - } - } - } - - private void ProcessElf(string name, ElfObjectFile elfObjectFile) - { - foreach(var symbolTable in elfObjectFile.Sections.OfType()) - { - foreach(var symbol in symbolTable.Entries) - { - if (symbol.Type != ElfSymbolType.Function) continue; - if (symbol.Bind == ElfSymbolBind.Local) continue; - - if (FunctionRegexFilters.Count > 0) - { - foreach (var functionRegexFilter in FunctionRegexFilters) - { - if (functionRegexFilter.Match(symbol.Name).Success) - { - DumpFunction(symbol); - break; - } - } - } - else - { - DumpFunction(symbol); - } - } - } - } - - private void DumpFunction(ElfSymbol symbol) - { - var functionSize = symbol.Size; - var section = symbol.Section.Section; - Output.WriteLine($"Function: {symbol.Name}"); - - if (section is ElfBinarySection binarySection) - { - binarySection.Stream.Position = (long)symbol.Value; - - Disasm(binarySection.Stream, (uint)functionSize, Output); - Output.WriteLine(); - } - } - - private static void Disasm(Stream stream, uint size, TextWriter writer, Formatter formatter = null) - { - var buffer = ArrayPool.Shared.Rent((int)size); - var startPosition = stream.Position; - stream.Read(buffer, 0, (int) size); - stream.Position = startPosition; - - // You can also pass in a hex string, eg. "90 91 929394", or you can use your own CodeReader - // reading data from a file or memory etc - var codeReader = new StreamCodeReader(stream, size); - var decoder = Decoder.Create(IntPtr.Size * 8, codeReader); - decoder.IP = (ulong) 0; - ulong endRip = decoder.IP + (uint)size; - - // This list is faster than List since it uses refs to the Instructions - // instead of copying them (each Instruction is 32 bytes in size). It has a ref indexer, - // and a ref iterator. Add() uses 'in' (ref readonly). - var instructions = new InstructionList(); - while (decoder.IP < endRip) - { - // The method allocates an uninitialized element at the end of the list and - // returns a reference to it which is initialized by Decode(). - decoder.Decode(out instructions.AllocUninitializedElement()); - } - - // Formatters: Masm*, Nasm* and Gas* (AT&T) - if (formatter == null) - { - formatter = new NasmFormatter(); - formatter.Options.DigitSeparator = ""; - formatter.Options.FirstOperandCharIndex = 10; - } - - var output = new StringOutput(); - // Use InstructionList's ref iterator (C# 7.3) to prevent copying 32 bytes every iteration - foreach (ref var instr in instructions) - { - // Don't use instr.ToString(), it allocates more, uses masm syntax and default options - formatter.Format(instr, output); - writer.Write($"{instr.IP:X16} "); - for (int i = 0; i < instr.Length; i++) - { - writer.Write(buffer[(int)instr.IP + i].ToString("X2")); - } - writer.Write(new string(' ', 16 * 2 - instr.Length * 2)); - writer.WriteLine($"{output.ToStringAndReset()}"); - } - } - - private class StreamCodeReader : CodeReader - { - private readonly Stream _stream; - private long _size; - - public StreamCodeReader(Stream stream, uint size) - { - _stream = stream; - _size = size; - } - - public override int ReadByte() - { - if (_size < 0) - { - return -1; - } - - _size--; - return _stream.ReadByte(); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs deleted file mode 100644 index 56dcba718e3fc1..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/Program.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.IO; -using System.Text.RegularExpressions; -using Mono.Options; - -namespace LibObjectFile.Disasm -{ - /// - /// A minimalistic program to disassemble functions in .a and ELF files - /// TODO: handle correctly RIP, labels, relocation...etc. - /// - class Program - { - static int Main(string[] args) - { - - var exeName = Path.GetFileNameWithoutExtension(typeof(Program).Assembly.Location); - bool showHelp = false; - - - var objDisasmApp = new ObjDisasmApp(); - - var _ = string.Empty; - var options = new OptionSet - { - "Copyright (C) 2019 Alexandre Mutel. All Rights Reserved", - $"{exeName} - Version: " - + - $"{typeof(Program).Assembly.GetName().Version.Major}.{typeof(Program).Assembly.GetName().Version.Minor}.{typeof(Program).Assembly.GetName().Version.Build}" + string.Empty, - _, - $"Usage: {exeName} [options]+ [.o|.a files]", - _, - "Disassemble the global functions found in a list of ELF object .o files or archive `ar` files.", - _, - "## Options", - _, - {"f|func=", "Add a regex filtering for function symbols. Can add multiples.", v=> objDisasmApp.FunctionRegexFilters.Add(new Regex(v)) }, - {"l|list=", "List functions that can be decompiled.", v=> objDisasmApp.Listing = true}, - _, - {"h|help", "Show this message and exit", v => showHelp = true }, - {"v|verbose", "Show more verbose progress logs", v => objDisasmApp.Verbose = true }, - }; - - try - { - var files = options.Parse(args); - - if (showHelp) - { - options.WriteOptionDescriptions(Console.Out); - return 0; - } - - foreach (var file in files) - { - var filePath = Path.Combine(Environment.CurrentDirectory, file); - if (!File.Exists(filePath)) - { - throw new OptionException($"The file {file} does not exist", "[files]"); - } - - objDisasmApp.Files.Add(filePath); - } - - objDisasmApp.Run(); - } - catch (Exception exception) - { - if (exception is OptionException || exception is ObjectFileException) - { - var backColor = Console.ForegroundColor; - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(exception.Message); - Console.ForegroundColor = backColor; - Console.WriteLine("See --help for usage"); - return 1; - } - else - { - throw; - } - } - - return 0; - } - } -} diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj b/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj deleted file mode 100644 index fa42be0bd4986a..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/objdasm/objdasm.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Exe - net7.0 - LibObjectFile.Disasm - false - - - - - - - - - - - - diff --git a/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh b/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh deleted file mode 100755 index 0f368076b1dc04..00000000000000 --- a/src/coreclr/tools/aot/external/LibObjectFile/src/test-with-docker.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -export TEST_TAG_NAME=libobjectfile-tests - -# To rebuild the image, simply delete the tag: -# docker rmi $TEST_TAG_NAME - -if [[ "$(docker images -q ${TEST_TAG_NAME}:latest 2> /dev/null)" == "" ]]; then - docker build -t ${TEST_TAG_NAME} . -fi - -# Run unit tests in Docker - See Dockerfile -docker run -v `pwd`:/src --rm -it ${TEST_TAG_NAME} - From e7cda50522f2b3523c62eb545265069d4b7f9fd8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 6 Dec 2023 15:52:05 +0100 Subject: [PATCH 101/144] Port from main: Fix generating debug info for static fields --- .../Compiler/ObjectWriter/ObjectWriter.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 48d880d9c76383..a61b431408a307 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -397,7 +397,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 7 Dec 2023 11:25:43 +0100 Subject: [PATCH 102/144] Add (untested) x86 support to ElfObjectWriter --- .../Compiler/ObjectWriter/ElfNative.cs | 42 ++ .../Compiler/ObjectWriter/ElfObjectWriter.cs | 628 ++++++++++-------- 2 files changed, 390 insertions(+), 280 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs index ddf1f09b1a6e6d..0dbbf2ca221648 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -69,6 +69,48 @@ public static class ElfNative public const byte STB_GLOBAL = 1; public const byte STB_WEAK = 2; + public const uint R_386_NONE = 0; + public const uint R_386_32 = 1; + public const uint R_386_PC32 = 2; + public const uint R_386_GOT32 = 3; + public const uint R_386_PLT32 = 4; + public const uint R_386_COPY = 5; + public const uint R_386_GLOB_DAT = 6; + public const uint R_386_JMP_SLOT = 7; + public const uint R_386_RELATIVE = 8; + public const uint R_386_GOTOFF = 9; + public const uint R_386_GOTPC = 10; + public const uint R_386_32PLT = 11; + public const uint R_386_TLS_TPOFF = 14; + public const uint R_386_TLS_IE = 15; + public const uint R_386_TLS_GOTIE = 16; + public const uint R_386_TLS_LE = 17; + public const uint R_386_TLS_GD = 18; + public const uint R_386_TLS_LDM = 19; + public const uint R_386_16 = 20; + public const uint R_386_PC16 = 21; + public const uint R_386_8 = 22; + public const uint R_386_PC8 = 23; + public const uint R_386_TLS_GD_32 = 24; + public const uint R_386_TLS_GD_PUSH = 25; + public const uint R_386_TLS_GD_CALL = 26; + public const uint R_386_TLS_GD_POP = 27; + public const uint R_386_TLS_LDM_32 = 28; + public const uint R_386_TLS_LDM_PUSH = 29; + public const uint R_386_TLS_LDM_CALL = 30; + public const uint R_386_TLS_LDM_POP = 31; + public const uint R_386_TLS_LDO_32 = 32; + public const uint R_386_TLS_IE_32 = 33; + public const uint R_386_TLS_LE_32 = 34; + public const uint R_386_TLS_DTPMOD32 = 35; + public const uint R_386_TLS_DTPOFF32 = 36; + public const uint R_386_TLS_TPOFF32 = 37; + public const uint R_386_SIZE32 = 38; + public const uint R_386_TLS_GOTDESC = 39; + public const uint R_386_TLS_DESC_CALL = 40; + public const uint R_386_TLS_DESC = 41; + public const uint R_386_IRELATIVE = 42; + public const uint R_X86_64_NONE = 0; public const uint R_X86_64_64 = 1; public const uint R_X86_64_PC32 = 2; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index dfb32117b34d03..b128d8365333f2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -30,6 +30,7 @@ private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) { _machine = factory.Target.Architecture switch { + TargetArchitecture.X86 => ElfNative.EM_386, TargetArchitecture.X64 => ElfNative.EM_X86_64, TargetArchitecture.ARM64 => ElfNative.EM_AARCH64, _ => throw new NotSupportedException("Unsupported architecture") @@ -222,6 +223,9 @@ protected override void EmitRelocations(int sectionIndex, List relocationList) + private void EmitRelocationsX86(int sectionIndex, List relocationList) { if (relocationList.Count > 0) { - Span relocationEntry = stackalloc byte[24]; - var relocationStream = new MemoryStream(24 * relocationList.Count); + Span relocationEntry = stackalloc byte[12]; + var relocationStream = new MemoryStream(12 * relocationList.Count); _sections[sectionIndex].RelocationStream = relocationStream; foreach (SymbolicRelocation symbolicRelocation in relocationList) { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_AARCH64_ABS64, - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_AARCH64_ABS32, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_AARCH64_PREL32, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfNative.R_AARCH64_CALL26, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfNative.R_AARCH64_ADR_PREL_PG_HI21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfNative.R_AARCH64_ADD_ABS_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21, - RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfNative.R_AARCH64_TLSDESC_LD64_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfNative.R_AARCH64_TLSDESC_ADD_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfNative.R_AARCH64_TLSDESC_CALL, + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_386_32, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_386_PC32, + RelocType.IMAGE_REL_BASED_REL32 => ElfNative.R_386_PLT32, + RelocType.IMAGE_REL_TLSGD => ElfNative.R_386_TLS_GD, + RelocType.IMAGE_REL_TPOFF => ElfNative.R_386_TLS_TPOFF, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; - BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry, (ulong)symbolicRelocation.Offset); - BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry.Slice(8), ((ulong)symbolIndex << 32) | type); - BinaryPrimitives.WriteInt64LittleEndian(relocationEntry.Slice(16), symbolicRelocation.Addend); + long addend = symbolicRelocation.Addend; + if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + { + addend -= 4; + } + + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry, (uint)symbolicRelocation.Offset); + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry.Slice(4), ((uint)symbolIndex << 8) | type); + BinaryPrimitives.WriteInt32LittleEndian(relocationEntry.Slice(8), (int)addend); relocationStream.Write(relocationEntry); } } @@ -304,237 +307,284 @@ private void EmitRelocationsX64(int sectionIndex, List reloc } } + private void EmitRelocationsARM64(int sectionIndex, List relocationList) + { + if (relocationList.Count > 0) + { + Span relocationEntry = stackalloc byte[24]; + var relocationStream = new MemoryStream(24 * relocationList.Count); + _sections[sectionIndex].RelocationStream = relocationStream; + foreach (SymbolicRelocation symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + uint type = symbolicRelocation.Type switch + { + RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_AARCH64_ABS64, + RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_AARCH64_ABS32, + RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_AARCH64_PREL32, + RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfNative.R_AARCH64_CALL26, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfNative.R_AARCH64_ADR_PREL_PG_HI21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfNative.R_AARCH64_ADD_ABS_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12, + RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21, + RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfNative.R_AARCH64_TLSDESC_LD64_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfNative.R_AARCH64_TLSDESC_ADD_LO12, + RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfNative.R_AARCH64_TLSDESC_CALL, + _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) + }; + + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry, (ulong)symbolicRelocation.Offset); + BinaryPrimitives.WriteUInt64LittleEndian(relocationEntry.Slice(8), ((ulong)symbolIndex << 32) | type); + BinaryPrimitives.WriteInt64LittleEndian(relocationEntry.Slice(16), symbolicRelocation.Addend); + relocationStream.Write(relocationEntry); + } + } + } + protected override void EmitSectionsAndLayout() { } protected override void EmitObjectFile(string objectFilePath) { - using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) + using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); + switch (_machine) { - ulong sectionHeaderOffset = (ulong)ElfHeader.Size; - uint sectionCount = 1; // NULL section - bool hasSymTabExtendedIndices = false; - Span tempBuffer = stackalloc byte[sizeof(uint)]; - - _sections.AddRange(_comdatNameToElfSection.Values); - _sections.Add(new SectionDefinition - { - Name = ".note.GNU-stack", - Type = ElfNative.SHT_PROGBITS, - Stream = Stream.Null, - }); + case ElfNative.EM_386: + EmitObjectFile(outputFileStream); + break; + default: + EmitObjectFile(outputFileStream); + break; + } + } - foreach (var section in _sections) - { - _stringTable.ReserveString(section.Name); - section.SectionIndex = (uint)sectionCount; - if (section.Alignment > 0) - { - sectionHeaderOffset = (ulong)((sectionHeaderOffset + (ulong)section.Alignment - 1) & ~(ulong)(section.Alignment - 1)); - } - section.SectionOffset = sectionHeaderOffset; - if (section.Type != ElfNative.SHT_NOBITS) - { - sectionHeaderOffset += (ulong)section.Stream.Length; - } - sectionHeaderOffset += (ulong)section.RelocationStream.Length; - sectionCount++; - if (section.RelocationStream != Stream.Null) - { - _stringTable.ReserveString(".rela" + section.Name); - sectionCount++; - } + private void EmitObjectFile(FileStream outputFileStream) + where TSize : struct, IBinaryInteger + { + ulong sectionHeaderOffset = (ulong)ElfHeader.GetSize(); + uint sectionCount = 1; // NULL section + bool hasSymTabExtendedIndices = false; + Span tempBuffer = stackalloc byte[sizeof(uint)]; - // Write the section index into the section's group. We store all the groups - // at the end so we can modify their contents in this loop safely. - if (section.GroupSection is not null) - { - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, section.SectionIndex); - section.GroupSection.Stream.Write(tempBuffer); - } - } + _sections.AddRange(_comdatNameToElfSection.Values); + _sections.Add(new SectionDefinition + { + Name = ".note.GNU-stack", + Type = ElfNative.SHT_PROGBITS, + Stream = Stream.Null, + }); - // Reserve all symbol names - foreach (var symbol in _symbols) + foreach (var section in _sections) + { + _stringTable.ReserveString(section.Name); + section.SectionIndex = (uint)sectionCount; + if (section.Alignment > 0) { - if (symbol.Name is not null) - { - _stringTable.ReserveString(symbol.Name); - } + sectionHeaderOffset = (ulong)((sectionHeaderOffset + (ulong)section.Alignment - 1) & ~(ulong)(section.Alignment - 1)); } - _stringTable.ReserveString(".strtab"); - _stringTable.ReserveString(".symtab"); - if (sectionCount >= ElfNative.SHN_LORESERVE) + section.SectionOffset = sectionHeaderOffset; + if (section.Type != ElfNative.SHT_NOBITS) { - _stringTable.ReserveString(".symtab_shndx"); - hasSymTabExtendedIndices = true; + sectionHeaderOffset += (ulong)section.Stream.Length; } - - uint strTabSectionIndex = sectionCount; - sectionHeaderOffset += _stringTable.Size; - sectionCount++; - uint symTabSectionIndex = sectionCount; - sectionHeaderOffset += (ulong)(_symbols.Count * ElfSymbol.Size64); + sectionHeaderOffset += (ulong)section.RelocationStream.Length; sectionCount++; - if (hasSymTabExtendedIndices) + if (section.RelocationStream != Stream.Null) { - sectionHeaderOffset += (ulong)(_symbols.Count * sizeof(uint)); + _stringTable.ReserveString(".rela" + section.Name); sectionCount++; } - ElfHeader elfHeader = new ElfHeader + // Write the section index into the section's group. We store all the groups + // at the end so we can modify their contents in this loop safely. + if (section.GroupSection is not null) { - Type = ElfNative.ET_REL, - Machine = _machine, - Version = ElfNative.EV_CURRENT, - SegmentHeaderEntrySize = 0x38, - SectionHeaderOffset = sectionHeaderOffset, - SectionHeaderEntrySize = (ushort)ElfSectionHeader.Size, - SectionHeaderEntryCount = sectionCount < ElfNative.SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, - StringTableIndex = strTabSectionIndex < ElfNative.SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)ElfNative.SHN_XINDEX, - }; - elfHeader.Write(outputFileStream); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, section.SectionIndex); + section.GroupSection.Stream.Write(tempBuffer); + } + } + + // Reserve all symbol names + foreach (var symbol in _symbols) + { + if (symbol.Name is not null) + { + _stringTable.ReserveString(symbol.Name); + } + } + _stringTable.ReserveString(".strtab"); + _stringTable.ReserveString(".symtab"); + if (sectionCount >= ElfNative.SHN_LORESERVE) + { + _stringTable.ReserveString(".symtab_shndx"); + hasSymTabExtendedIndices = true; + } + + uint strTabSectionIndex = sectionCount; + sectionHeaderOffset += _stringTable.Size; + sectionCount++; + uint symTabSectionIndex = sectionCount; + sectionHeaderOffset += (ulong)(_symbols.Count * ElfSymbol.GetSize()); + sectionCount++; + if (hasSymTabExtendedIndices) + { + sectionHeaderOffset += (ulong)(_symbols.Count * sizeof(uint)); + sectionCount++; + } + + ElfHeader elfHeader = new ElfHeader + { + Type = ElfNative.ET_REL, + Machine = _machine, + Version = ElfNative.EV_CURRENT, + SegmentHeaderEntrySize = 0x38, + SectionHeaderOffset = sectionHeaderOffset, + SectionHeaderEntrySize = (ushort)ElfSectionHeader.GetSize(), + SectionHeaderEntryCount = sectionCount < ElfNative.SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, + StringTableIndex = strTabSectionIndex < ElfNative.SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)ElfNative.SHN_XINDEX, + }; + elfHeader.Write(outputFileStream); - foreach (var section in _sections) + foreach (var section in _sections) + { + if (section.Type != ElfNative.SHT_NOBITS) { - if (section.Type != ElfNative.SHT_NOBITS) + outputFileStream.Position = (long)section.SectionOffset; + section.Stream.Position = 0; + section.Stream.CopyTo(outputFileStream); + if (section.RelocationStream != Stream.Null) { - outputFileStream.Position = (long)section.SectionOffset; - section.Stream.Position = 0; - section.Stream.CopyTo(outputFileStream); - if (section.RelocationStream != Stream.Null) - { - section.RelocationStream.Position = 0; - section.RelocationStream.CopyTo(outputFileStream); - } + section.RelocationStream.Position = 0; + section.RelocationStream.CopyTo(outputFileStream); } } + } + + ulong stringTableOffset = (ulong)outputFileStream.Position; + _stringTable.Write(outputFileStream); - ulong stringTableOffset = (ulong)outputFileStream.Position; - _stringTable.Write(outputFileStream); + ulong symbolTableOffset = (ulong)outputFileStream.Position; + foreach (var symbol in _symbols) + { + symbol.Write(outputFileStream, _stringTable); + } - ulong symbolTableOffset = (ulong)outputFileStream.Position; + ulong symbolTableExtendedIndicesOffset = (ulong)outputFileStream.Position; + if (hasSymTabExtendedIndices) + { foreach (var symbol in _symbols) { - symbol.Write64(outputFileStream, _stringTable); + uint index = symbol.Section?.SectionIndex ?? 0; + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, index >= ElfNative.SHN_LORESERVE ? index : 0); + outputFileStream.Write(tempBuffer); } + } - ulong symbolTableExtendedIndicesOffset = (ulong)outputFileStream.Position; - if (hasSymTabExtendedIndices) - { - foreach (var symbol in _symbols) - { - uint index = symbol.Section?.SectionIndex ?? 0; - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, index >= ElfNative.SHN_LORESERVE ? index : 0); - outputFileStream.Write(tempBuffer); - } - } + // Null section + ElfSectionHeader nullSectionHeader = new ElfSectionHeader + { + NameIndex = 0, + Type = ElfNative.SHT_NULL, + Flags = 0u, + Address = 0u, + Offset = 0u, + SectionSize = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, + Link = strTabSectionIndex >= ElfNative.SHN_LORESERVE ? strTabSectionIndex : 0u, + Info = 0u, + Alignment = 0u, + EntrySize = 0u, + }; + nullSectionHeader.Write(outputFileStream); + + foreach (var section in _sections) + { + uint groupFlag = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u; - // Null section - ElfSectionHeader nullSectionHeader = new ElfSectionHeader + ElfSectionHeader sectionHeader = new ElfSectionHeader { - NameIndex = 0, - Type = ElfNative.SHT_NULL, - Flags = 0u, + NameIndex = _stringTable.GetStringOffset(section.Name), + Type = section.Type, + Flags = section.Flags | groupFlag, Address = 0u, - Offset = 0u, - SectionSize = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, - Link = strTabSectionIndex >= ElfNative.SHN_LORESERVE ? strTabSectionIndex : 0u, - Info = 0u, - Alignment = 0u, - EntrySize = 0u, + Offset = section.SectionOffset, + SectionSize = (ulong)section.Stream.Length, + Link = section.Type == ElfNative.SHT_GROUP ? symTabSectionIndex : 0u, + Info = section.Info, + Alignment = (ulong)section.Alignment, + EntrySize = section.Type == ElfNative.SHT_GROUP ? (uint)sizeof(uint) : 0u, }; - nullSectionHeader.Write(outputFileStream); + sectionHeader.Write(outputFileStream); - foreach (var section in _sections) + if (section.Type != ElfNative.SHT_NOBITS && + section.RelocationStream != Stream.Null) { - uint groupFlag = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u; - - ElfSectionHeader sectionHeader = new ElfSectionHeader + sectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset(section.Name), - Type = section.Type, - Flags = section.Flags | groupFlag, + NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), + Type = ElfNative.SHT_RELA, + Flags = groupFlag, Address = 0u, - Offset = section.SectionOffset, - SectionSize = (ulong)section.Stream.Length, - Link = section.Type == ElfNative.SHT_GROUP ? symTabSectionIndex : 0u, - Info = section.Info, - Alignment = (ulong)section.Alignment, - EntrySize = section.Type == ElfNative.SHT_GROUP ? (uint)sizeof(uint) : 0u, + Offset = section.SectionOffset + sectionHeader.SectionSize, + SectionSize = (ulong)section.RelocationStream.Length, + Link = symTabSectionIndex, + Info = section.SectionIndex, + Alignment = 8u, + EntrySize = 24u, }; - sectionHeader.Write(outputFileStream); - - if (section.Type != ElfNative.SHT_NOBITS && - section.RelocationStream != Stream.Null) - { - sectionHeader = new ElfSectionHeader - { - NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), - Type = ElfNative.SHT_RELA, - Flags = groupFlag, - Address = 0u, - Offset = section.SectionOffset + sectionHeader.SectionSize, - SectionSize = (ulong)section.RelocationStream.Length, - Link = symTabSectionIndex, - Info = section.SectionIndex, - Alignment = 8u, - EntrySize = 24u, - }; - sectionHeader.Write(outputFileStream); - } + sectionHeader.Write(outputFileStream); } + } - // String table section - ElfSectionHeader stringTableSectionHeader = new ElfSectionHeader - { - NameIndex = _stringTable.GetStringOffset(".strtab"), - Type = ElfNative.SHT_STRTAB, - Flags = 0u, - Address = 0u, - Offset = stringTableOffset, - SectionSize = _stringTable.Size, - Link = 0u, - Info = 0u, - Alignment = 0u, - EntrySize = 0u, - }; - stringTableSectionHeader.Write(outputFileStream); + // String table section + ElfSectionHeader stringTableSectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".strtab"), + Type = ElfNative.SHT_STRTAB, + Flags = 0u, + Address = 0u, + Offset = stringTableOffset, + SectionSize = _stringTable.Size, + Link = 0u, + Info = 0u, + Alignment = 0u, + EntrySize = 0u, + }; + stringTableSectionHeader.Write(outputFileStream); - // Symbol table section - ElfSectionHeader symbolTableSectionHeader = new ElfSectionHeader + // Symbol table section + ElfSectionHeader symbolTableSectionHeader = new ElfSectionHeader + { + NameIndex = _stringTable.GetStringOffset(".symtab"), + Type = ElfNative.SHT_SYMTAB, + Flags = 0u, + Address = 0u, + Offset = symbolTableOffset, + SectionSize = (ulong)(_symbols.Count * ElfSymbol.GetSize()), + Link = strTabSectionIndex, + Info = _localSymbolCount, + Alignment = 0u, + EntrySize = (uint)ElfSymbol.GetSize(), + }; + symbolTableSectionHeader.Write(outputFileStream); + + if (hasSymTabExtendedIndices) + { + ElfSectionHeader sectionHeader = new ElfSectionHeader { - NameIndex = _stringTable.GetStringOffset(".symtab"), - Type = ElfNative.SHT_SYMTAB, + NameIndex = _stringTable.GetStringOffset(".symtab_shndx"), + Type = ElfNative.SHT_SYMTAB_SHNDX, Flags = 0u, Address = 0u, - Offset = symbolTableOffset, - SectionSize = (ulong)(_symbols.Count * ElfSymbol.Size64), - Link = strTabSectionIndex, - Info = _localSymbolCount, + Offset = symbolTableExtendedIndicesOffset, + SectionSize = (ulong)(_symbols.Count * sizeof(uint)), + Link = symTabSectionIndex, + Info = 0u, Alignment = 0u, - EntrySize = (uint)ElfSymbol.Size64, + EntrySize = (uint)sizeof(uint), }; - symbolTableSectionHeader.Write(outputFileStream); - - if (hasSymTabExtendedIndices) - { - ElfSectionHeader sectionHeader = new ElfSectionHeader - { - NameIndex = _stringTable.GetStringOffset(".symtab_shndx"), - Type = ElfNative.SHT_SYMTAB_SHNDX, - Flags = 0u, - Address = 0u, - Offset = symbolTableExtendedIndicesOffset, - SectionSize = (ulong)(_symbols.Count * sizeof(uint)), - Link = symTabSectionIndex, - Info = 0u, - Alignment = 0u, - EntrySize = (uint)sizeof(uint), - }; - sectionHeader.Write(outputFileStream); - } + sectionHeader.Write(outputFileStream); } } @@ -560,17 +610,16 @@ private sealed class SectionDefinition public ulong SectionOffset { get; set; } } - private sealed class ElfHeader - where T : struct, IBinaryInteger + private sealed class ElfHeader { private static ReadOnlySpan Magic => new byte[] { 0x7f, 0x45, 0x4c, 0x46 }; public ushort Type { get; set; } public ushort Machine { get; set; } public uint Version { get; set; } - public T EntryPoint { get; set; } - public T SegmentHeaderOffset { get; set; } - public T SectionHeaderOffset { get; set; } + public ulong EntryPoint { get; set; } + public ulong SegmentHeaderOffset { get; set; } + public ulong SectionHeaderOffset { get; set; } public uint Flags { get; set; } public ushort SegmentHeaderEntrySize { get; set; } public ushort SegmentHeaderEntryCount { get; set; } @@ -578,48 +627,51 @@ private sealed class ElfHeader public ushort SectionHeaderEntryCount { get; set; } public ushort StringTableIndex { get; set; } - private static IBinaryInteger TDefault => default(T); - - public static int Size => - Magic.Length + - 1 + // Class - 1 + // Endianness - 1 + // Header version - 1 + // ABI - 1 + // ABI version - 7 + // Padding - sizeof(ushort) + // Type - sizeof(ushort) + // Machine - sizeof(uint) + // Version - TDefault.GetByteCount() + // Entry point - TDefault.GetByteCount() + // Segment header offset - TDefault.GetByteCount() + // Section header offset - sizeof(uint) + // Flags - sizeof(ushort) + // ELF Header size - sizeof(ushort) + // Segment header entry size - sizeof(ushort) + // Segment header entry count - sizeof(ushort) + // Section header entry size - sizeof(ushort) + // Section header entry count - sizeof(ushort); // String table index - - public void Write(FileStream stream) - { - Span buffer = stackalloc byte[Size]; + public static int GetSize() + where TSize : struct, IBinaryInteger + { + return + Magic.Length + + 1 + // Class + 1 + // Endianness + 1 + // Header version + 1 + // ABI + 1 + // ABI version + 7 + // Padding + sizeof(ushort) + // Type + sizeof(ushort) + // Machine + sizeof(uint) + // Version + default(TSize).GetByteCount() + // Entry point + default(TSize).GetByteCount() + // Segment header offset + default(TSize).GetByteCount() + // Section header offset + sizeof(uint) + // Flags + sizeof(ushort) + // ELF Header size + sizeof(ushort) + // Segment header entry size + sizeof(ushort) + // Segment header entry count + sizeof(ushort) + // Section header entry size + sizeof(ushort) + // Section header entry count + sizeof(ushort); // String table index + } + + public void Write(FileStream stream) + where TSize : struct, IBinaryInteger + { + Span buffer = stackalloc byte[GetSize()]; buffer.Clear(); Magic.CopyTo(buffer.Slice(0, Magic.Length)); - buffer[4] = typeof(T) == typeof(uint) ? ElfNative.ELFCLASS32 : ElfNative.ELFCLASS64; + buffer[4] = typeof(TSize) == typeof(uint) ? ElfNative.ELFCLASS32 : ElfNative.ELFCLASS64; buffer[5] = ElfNative.ELFDATA2LSB; buffer[6] = 1; var tempBuffer = buffer.Slice(16); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Type).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Machine).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Version).WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(EntryPoint.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(SegmentHeaderOffset.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(SectionHeaderOffset.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(EntryPoint).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(SegmentHeaderOffset).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(SectionHeaderOffset).WriteLittleEndian(tempBuffer)); BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, Flags); - BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(4), (ushort)Size); + BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(4), (ushort)buffer.Length); BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(6), SegmentHeaderEntrySize); BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(8), SegmentHeaderEntryCount); BinaryPrimitives.WriteUInt16LittleEndian(tempBuffer.Slice(10), SectionHeaderEntrySize); @@ -630,49 +682,51 @@ public void Write(FileStream stream) } } - private sealed class ElfSectionHeader - where TSize : struct, IBinaryInteger + private sealed class ElfSectionHeader { public uint NameIndex { get; set; } public uint Type { get; set; } - public TSize Flags { get; set; } - public TSize Address { get; set; } - public TSize Offset { get; set; } - public TSize SectionSize { get; set; } + public ulong Flags { get; set; } + public ulong Address { get; set; } + public ulong Offset { get; set; } + public ulong SectionSize { get; set; } public uint Link { get; set; } public uint Info { get; set; } - public TSize Alignment { get; set; } - public TSize EntrySize { get; set; } - - private static IBinaryInteger TSizeDefault => default(TSize); - - public static int Size => - sizeof(uint) + // Name index - sizeof(uint) + // Type - TSizeDefault.GetByteCount() + // Flags - TSizeDefault.GetByteCount() + // Address - TSizeDefault.GetByteCount() + // Offset - TSizeDefault.GetByteCount() + // Size - sizeof(uint) + // Link - sizeof(uint) + // Info - TSizeDefault.GetByteCount() + // Alignment - TSizeDefault.GetByteCount(); // Entry size - - public void Write(FileStream stream) - { - Span buffer = stackalloc byte[Size]; + public ulong Alignment { get; set; } + public ulong EntrySize { get; set; } + + public static int GetSize() + where TSize : struct, IBinaryInteger + { + return + sizeof(uint) + // Name index + sizeof(uint) + // Type + default(TSize).GetByteCount() + // Flags + default(TSize).GetByteCount() + // Address + default(TSize).GetByteCount() + // Offset + default(TSize).GetByteCount() + // Size + sizeof(uint) + // Link + sizeof(uint) + // Info + default(TSize).GetByteCount() + // Alignment + default(TSize).GetByteCount(); // Entry size + } + + public void Write(FileStream stream) + where TSize : struct, IBinaryInteger + { + Span buffer = stackalloc byte[GetSize()]; var tempBuffer = buffer; tempBuffer = tempBuffer.Slice(((IBinaryInteger)NameIndex).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Type).WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(Flags.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(Address.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(Offset.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(SectionSize.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Flags).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Address).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Offset).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(SectionSize).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Link).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Info).WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(Alignment.WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(EntrySize.WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Alignment).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(EntrySize).WriteLittleEndian(tempBuffer)); stream.Write(buffer); } @@ -687,25 +741,39 @@ private sealed class ElfSymbol public byte Info { get; init; } public byte Other { get; init; } - public static int Size64 => 24; + public static int GetSize() + where TSize : struct, IBinaryInteger + { + return typeof(TSize) == typeof(uint) ? 16 : 24; + } - public void Write64(FileStream stream, ElfStringTable stringTable) + public void Write(FileStream stream, ElfStringTable stringTable) + where TSize : struct, IBinaryInteger { - Span buffer = stackalloc byte[Size64]; + Span buffer = stackalloc byte[GetSize()]; + ushort sectionIndex; + + sectionIndex = Section is { SectionIndex: >= ElfNative.SHN_LORESERVE } ? + (ushort)ElfNative.SHN_XINDEX : + (Section is not null ? (ushort)Section.SectionIndex : (ushort)0u); BinaryPrimitives.WriteUInt32LittleEndian(buffer, Name is not null ? stringTable.GetStringOffset(Name) : 0); - buffer[4] = Info; - buffer[5] = Other; - if (Section is { SectionIndex: >= ElfNative.SHN_LORESERVE }) + if (typeof(TSize) == typeof(uint)) { - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), (ushort)ElfNative.SHN_XINDEX); + TSize.CreateChecked(Value).WriteLittleEndian(buffer.Slice(4)); + TSize.CreateChecked(Size).WriteLittleEndian(buffer.Slice(8)); + buffer[12] = Info; + buffer[13] = Other; + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(14), sectionIndex); } else { - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), Section is not null ? (ushort)Section.SectionIndex : (ushort)0u); + buffer[4] = Info; + buffer[5] = Other; + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6), sectionIndex); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(8), Value); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(16), Size); } - BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(8), Value); - BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(16), Size); stream.Write(buffer); } From 75d34e580651e4d84d7150301e249b3e2f95c00b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 7 Dec 2023 12:26:12 +0100 Subject: [PATCH 103/144] Cleanup --- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 198 ++++++++++-------- 1 file changed, 108 insertions(+), 90 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index b128d8365333f2..fa6347d395ff6c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -16,11 +16,10 @@ namespace ILCompiler.ObjectWriter public sealed class ElfObjectWriter : UnixObjectWriter { private readonly ushort _machine; - private readonly ElfStringTable _stringTable = new(); - private readonly List _sections = new(); + private readonly List _sections = new(); private readonly List _symbols = new(); private uint _localSymbolCount; - private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); + private readonly Dictionary _comdatNameToElfSection = new(StringComparer.Ordinal); // Symbol table private readonly Dictionary _symbolNameToIndex = new(); @@ -48,7 +47,7 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa int sectionIndex = _sections.Count; uint type = 0; uint flags = 0; - SectionDefinition groupSection = null; + ElfSectionDefinition groupSection = null; if (section.Type == SectionType.Uninitialized) { @@ -72,30 +71,40 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa }; } - if (comdatName is not null && - !_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) + if (comdatName is not null) { - Span tempBuffer = stackalloc byte[sizeof(uint)]; - groupSection = new SectionDefinition + flags |= ElfNative.SHF_GROUP; + if (!_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) { - Name = ".group", - Type = ElfNative.SHT_GROUP, - Alignment = 4, - Stream = new MemoryStream(5 * sizeof(uint)), - }; + Span tempBuffer = stackalloc byte[sizeof(uint)]; + groupSection = new ElfSectionDefinition + { + SectionHeader = new ElfSectionHeader + { + Type = ElfNative.SHT_GROUP, + Alignment = 4, + EntrySize = (uint)sizeof(uint), + }, + Name = ".group", + Stream = new MemoryStream(5 * sizeof(uint)), + }; - // Write group flags - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, /*ElfNative.GRP_COMDAT*/1u); - groupSection.Stream.Write(tempBuffer); + // Write group flags + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, /*ElfNative.GRP_COMDAT*/1u); + groupSection.Stream.Write(tempBuffer); - _comdatNameToElfSection.Add(comdatName, groupSection); + _comdatNameToElfSection.Add(comdatName, groupSection); + } } - _sections.Add(new SectionDefinition + _sections.Add(new ElfSectionDefinition { + SectionHeader = new ElfSectionHeader + { + Type = type, + Flags = flags, + }, Name = sectionName, - Type = type, - Flags = flags, Stream = sectionStream, GroupSection = groupSection, }); @@ -116,8 +125,8 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - SectionDefinition elfSection = _sections[sectionIndex]; - elfSection.Alignment = Math.Max(elfSection.Alignment, alignment); + ElfSectionDefinition elfSection = _sections[sectionIndex]; + elfSection.SectionHeader.Alignment = Math.Max(elfSection.SectionHeader.Alignment, (ulong)alignment); } protected internal override void EmitRelocation( @@ -177,7 +186,7 @@ protected override void EmitSymbolTable( { var section = _sections[definition.SectionIndex]; var type = - (section.Flags & ElfNative.SHF_TLS) == ElfNative.SHF_TLS ? ElfNative.STT_TLS : + (section.SectionHeader.Flags & ElfNative.SHF_TLS) == ElfNative.SHF_TLS ? ElfNative.STT_TLS : definition.Size > 0 ? ElfNative.STT_FUNC : ElfNative.STT_NOTYPE; sortedSymbols.Add(new ElfSymbol { @@ -213,9 +222,9 @@ protected override void EmitSymbolTable( } // Update group sections links - foreach ((string comdatName, SectionDefinition groupSection) in _comdatNameToElfSection) + foreach ((string comdatName, ElfSectionDefinition groupSection) in _comdatNameToElfSection) { - groupSection.Info = (uint)_symbolNameToIndex[comdatName]; + groupSection.SectionHeader.Info = (uint)_symbolNameToIndex[comdatName]; } } @@ -363,34 +372,54 @@ protected override void EmitObjectFile(string objectFilePath) private void EmitObjectFile(FileStream outputFileStream) where TSize : struct, IBinaryInteger { - ulong sectionHeaderOffset = (ulong)ElfHeader.GetSize(); + ElfStringTable _stringTable = new(); uint sectionCount = 1; // NULL section bool hasSymTabExtendedIndices = false; Span tempBuffer = stackalloc byte[sizeof(uint)]; + // Merge the group sections at the end of the section lists _sections.AddRange(_comdatNameToElfSection.Values); - _sections.Add(new SectionDefinition + + // Add marker for non-executable stack + _sections.Add(new ElfSectionDefinition { + SectionHeader = new ElfSectionHeader { Type = ElfNative.SHT_PROGBITS }, Name = ".note.GNU-stack", - Type = ElfNative.SHT_PROGBITS, Stream = Stream.Null, }); + // Reserve all symbol names + foreach (var symbol in _symbols) + { + if (symbol.Name is not null) + { + _stringTable.ReserveString(symbol.Name); + } + } + + // Layout the section content in the output file + ulong currentOffset = (ulong)ElfHeader.GetSize(); foreach (var section in _sections) { _stringTable.ReserveString(section.Name); - section.SectionIndex = (uint)sectionCount; - if (section.Alignment > 0) + + if (section.SectionHeader.Alignment > 0) { - sectionHeaderOffset = (ulong)((sectionHeaderOffset + (ulong)section.Alignment - 1) & ~(ulong)(section.Alignment - 1)); + currentOffset = (ulong)((currentOffset + (ulong)section.SectionHeader.Alignment - 1) & ~(ulong)(section.SectionHeader.Alignment - 1)); } - section.SectionOffset = sectionHeaderOffset; - if (section.Type != ElfNative.SHT_NOBITS) + + // Update section layout + section.SectionIndex = (uint)sectionCount; + section.SectionHeader.Offset = currentOffset; + section.SectionHeader.Size = (ulong)section.Stream.Length; + + if (section.SectionHeader.Type != ElfNative.SHT_NOBITS) { - sectionHeaderOffset += (ulong)section.Stream.Length; + currentOffset += (ulong)section.Stream.Length; } - sectionHeaderOffset += (ulong)section.RelocationStream.Length; + currentOffset += (ulong)section.RelocationStream.Length; sectionCount++; + if (section.RelocationStream != Stream.Null) { _stringTable.ReserveString(".rela" + section.Name); @@ -406,14 +435,7 @@ private void EmitObjectFile(FileStream outputFileStream) } } - // Reserve all symbol names - foreach (var symbol in _symbols) - { - if (symbol.Name is not null) - { - _stringTable.ReserveString(symbol.Name); - } - } + // Reserve names for the predefined sections _stringTable.ReserveString(".strtab"); _stringTable.ReserveString(".symtab"); if (sectionCount >= ElfNative.SHN_LORESERVE) @@ -422,36 +444,45 @@ private void EmitObjectFile(FileStream outputFileStream) hasSymTabExtendedIndices = true; } + // Layout the string and symbol table uint strTabSectionIndex = sectionCount; - sectionHeaderOffset += _stringTable.Size; + currentOffset += _stringTable.Size; sectionCount++; uint symTabSectionIndex = sectionCount; - sectionHeaderOffset += (ulong)(_symbols.Count * ElfSymbol.GetSize()); + currentOffset += (ulong)(_symbols.Count * ElfSymbol.GetSize()); sectionCount++; if (hasSymTabExtendedIndices) { - sectionHeaderOffset += (ulong)(_symbols.Count * sizeof(uint)); + currentOffset += (ulong)(_symbols.Count * sizeof(uint)); sectionCount++; } + // Update group section links + foreach (ElfSectionDefinition groupSection in _comdatNameToElfSection.Values) + { + groupSection.SectionHeader.Link = symTabSectionIndex; + } + + // Write the ELF file header ElfHeader elfHeader = new ElfHeader { Type = ElfNative.ET_REL, Machine = _machine, Version = ElfNative.EV_CURRENT, SegmentHeaderEntrySize = 0x38, - SectionHeaderOffset = sectionHeaderOffset, + SectionHeaderOffset = currentOffset, SectionHeaderEntrySize = (ushort)ElfSectionHeader.GetSize(), SectionHeaderEntryCount = sectionCount < ElfNative.SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, StringTableIndex = strTabSectionIndex < ElfNative.SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)ElfNative.SHN_XINDEX, }; elfHeader.Write(outputFileStream); + // Write the section contents and relocations foreach (var section in _sections) { - if (section.Type != ElfNative.SHT_NOBITS) + if (section.SectionHeader.Type != ElfNative.SHT_NOBITS) { - outputFileStream.Position = (long)section.SectionOffset; + outputFileStream.Position = (long)section.SectionHeader.Offset; section.Stream.Position = 0; section.Stream.CopyTo(outputFileStream); if (section.RelocationStream != Stream.Null) @@ -462,6 +493,7 @@ private void EmitObjectFile(FileStream outputFileStream) } } + // Write the string and symbol table contents ulong stringTableOffset = (ulong)outputFileStream.Position; _stringTable.Write(outputFileStream); @@ -482,6 +514,8 @@ private void EmitObjectFile(FileStream outputFileStream) } } + // Finally, write the section headers + // Null section ElfSectionHeader nullSectionHeader = new ElfSectionHeader { @@ -490,7 +524,7 @@ private void EmitObjectFile(FileStream outputFileStream) Flags = 0u, Address = 0u, Offset = 0u, - SectionSize = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, + Size = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, Link = strTabSectionIndex >= ElfNative.SHN_LORESERVE ? strTabSectionIndex : 0u, Info = 0u, Alignment = 0u, @@ -498,42 +532,29 @@ private void EmitObjectFile(FileStream outputFileStream) }; nullSectionHeader.Write(outputFileStream); + // User sections and their relocations foreach (var section in _sections) { - uint groupFlag = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u; + section.SectionHeader.NameIndex = _stringTable.GetStringOffset(section.Name); + section.SectionHeader.Write(outputFileStream); - ElfSectionHeader sectionHeader = new ElfSectionHeader - { - NameIndex = _stringTable.GetStringOffset(section.Name), - Type = section.Type, - Flags = section.Flags | groupFlag, - Address = 0u, - Offset = section.SectionOffset, - SectionSize = (ulong)section.Stream.Length, - Link = section.Type == ElfNative.SHT_GROUP ? symTabSectionIndex : 0u, - Info = section.Info, - Alignment = (ulong)section.Alignment, - EntrySize = section.Type == ElfNative.SHT_GROUP ? (uint)sizeof(uint) : 0u, - }; - sectionHeader.Write(outputFileStream); - - if (section.Type != ElfNative.SHT_NOBITS && + if (section.SectionHeader.Type != ElfNative.SHT_NOBITS && section.RelocationStream != Stream.Null) { - sectionHeader = new ElfSectionHeader + ElfSectionHeader relaSectionHeader = new ElfSectionHeader { NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), Type = ElfNative.SHT_RELA, - Flags = groupFlag, + Flags = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u, Address = 0u, - Offset = section.SectionOffset + sectionHeader.SectionSize, - SectionSize = (ulong)section.RelocationStream.Length, + Offset = section.SectionHeader.Offset + section.SectionHeader.Size, + Size = (ulong)section.RelocationStream.Length, Link = symTabSectionIndex, Info = section.SectionIndex, Alignment = 8u, EntrySize = 24u, }; - sectionHeader.Write(outputFileStream); + relaSectionHeader.Write(outputFileStream); } } @@ -545,7 +566,7 @@ private void EmitObjectFile(FileStream outputFileStream) Flags = 0u, Address = 0u, Offset = stringTableOffset, - SectionSize = _stringTable.Size, + Size = _stringTable.Size, Link = 0u, Info = 0u, Alignment = 0u, @@ -561,7 +582,7 @@ private void EmitObjectFile(FileStream outputFileStream) Flags = 0u, Address = 0u, Offset = symbolTableOffset, - SectionSize = (ulong)(_symbols.Count * ElfSymbol.GetSize()), + Size = (ulong)(_symbols.Count * ElfSymbol.GetSize()), Link = strTabSectionIndex, Info = _localSymbolCount, Alignment = 0u, @@ -569,6 +590,9 @@ private void EmitObjectFile(FileStream outputFileStream) }; symbolTableSectionHeader.Write(outputFileStream); + // If the symbol table has references to sections with indexes higher than + // SHN_LORESERVE (0xff00) we need to write them down in a separate table + // in the .symtab_shndx section. if (hasSymTabExtendedIndices) { ElfSectionHeader sectionHeader = new ElfSectionHeader @@ -578,7 +602,7 @@ private void EmitObjectFile(FileStream outputFileStream) Flags = 0u, Address = 0u, Offset = symbolTableExtendedIndicesOffset, - SectionSize = (ulong)(_symbols.Count * sizeof(uint)), + Size = (ulong)(_symbols.Count * sizeof(uint)), Link = symTabSectionIndex, Info = 0u, Alignment = 0u, @@ -594,20 +618,14 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection(FileStream stream) tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Flags).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Address).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Offset).WriteLittleEndian(tempBuffer)); - tempBuffer = tempBuffer.Slice(TSize.CreateChecked(SectionSize).WriteLittleEndian(tempBuffer)); + tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Size).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Link).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Info).WriteLittleEndian(tempBuffer)); tempBuffer = tempBuffer.Slice(TSize.CreateChecked(Alignment).WriteLittleEndian(tempBuffer)); @@ -737,7 +755,7 @@ private sealed class ElfSymbol public string Name { get; init; } public ulong Value { get; init; } public ulong Size { get; init; } - public SectionDefinition Section { get; init; } + public ElfSectionDefinition Section { get; init; } public byte Info { get; init; } public byte Other { get; init; } From aa6e94e96dc083ba687d3205e33c60c556169c7d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 8 Dec 2023 10:11:46 +0100 Subject: [PATCH 104/144] Move Dwarf/CodeView files into their respective directories --- .../{ => CodeView}/CodeViewFileTableBuilder.cs | 0 .../{ => CodeView}/CodeViewNative.cs | 0 .../{ => CodeView}/CodeViewSymbolsBuilder.cs | 0 .../{ => CodeView}/CodeViewTypesBuilder.cs | 0 .../ObjectWriter/{ => Dwarf}/DwarfBuilder.cs | 0 .../ObjectWriter/{ => Dwarf}/DwarfCie.cs | 0 .../ObjectWriter/{ => Dwarf}/DwarfEhFrame.cs | 0 .../ObjectWriter/{ => Dwarf}/DwarfFde.cs | 0 .../ObjectWriter/{ => Dwarf}/DwarfNative.cs | 0 .../ILCompiler.Compiler.csproj | 18 +++++++++--------- 10 files changed, 9 insertions(+), 9 deletions(-) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => CodeView}/CodeViewFileTableBuilder.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => CodeView}/CodeViewNative.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => CodeView}/CodeViewSymbolsBuilder.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => CodeView}/CodeViewTypesBuilder.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => Dwarf}/DwarfBuilder.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => Dwarf}/DwarfCie.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => Dwarf}/DwarfEhFrame.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => Dwarf}/DwarfFde.cs (100%) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{ => Dwarf}/DwarfNative.cs (100%) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewFileTableBuilder.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewNative.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewSymbolsBuilder.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeViewTypesBuilder.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfBuilder.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfCie.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfEhFrame.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfFde.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/DwarfNative.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 9dcf0d46288c5d..667b5e698954b3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -588,22 +588,22 @@ + + + + - - - - - - - - - + + + + + From 0048be7581a8037d9ccfa1a34badb9274741a896 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 8 Dec 2023 10:36:17 +0100 Subject: [PATCH 105/144] Make bulk of the ObjectWriter classes internal, improve logging --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 10 +-- .../Compiler/ObjectWriter/Dwarf/DwarfCie.cs | 2 +- .../ObjectWriter/Dwarf/DwarfEhFrame.cs | 2 +- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 3 +- .../ObjectWriter/Dwarf/DwarfNative.cs | 2 +- .../Compiler/ObjectWriter/ElfNative.cs | 2 +- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 10 +-- .../Compiler/ObjectWriter/LlvmObjectWriter.cs | 12 ++- .../Compiler/ObjectWriter/MachObjectWriter.cs | 10 +-- .../Compiler/ObjectWriter/ObjectWriter.cs | 85 ++++++++++++++++++- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 2 +- .../Compiler/RyuJitCompilation.cs | 13 +-- 12 files changed, 101 insertions(+), 52 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 72499a4f2e4101..b1f8052bf4f8fc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -24,7 +24,7 @@ namespace ILCompiler.ObjectWriter { - public sealed class CoffObjectWriter : ObjectWriter + internal sealed class CoffObjectWriter : ObjectWriter { private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName, string SymbolName); @@ -53,7 +53,7 @@ private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, private ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); - private CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) + public CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { _machine = factory.Target.Architecture switch @@ -668,12 +668,6 @@ protected override void EmitDebugSections(IDictionary _debugFileTableBuilder.Write(_debugSymbolSectionWriter.Stream); } - public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) - { - using CoffObjectWriter objectWriter = new CoffObjectWriter(factory, options); - objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); - } - private sealed class CoffHeader { public Machine Machine { get; set; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs index fa8c74d6a0ae71..57054a1186e618 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs @@ -7,7 +7,7 @@ namespace ILCompiler.ObjectWriter { - public class DwarfCie + internal sealed class DwarfCie { public byte PointerEncoding; public byte LsdaEncoding; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index e5db70f35c8068..24309da3afe211 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -12,7 +12,7 @@ namespace ILCompiler.ObjectWriter { - public class DwarfEhFrame + internal sealed class DwarfEhFrame { private SectionWriter _sectionWriter; private bool _is64Bit; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index 02da816018601d..66551cc20219aa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -8,7 +8,7 @@ namespace ILCompiler.ObjectWriter { - public class DwarfFde + internal sealed class DwarfFde { public DwarfCie Cie; public string PcStartSymbolName; @@ -21,6 +21,7 @@ public DwarfFde(DwarfCie cie, byte[] instructions) { Cie = cie; Instructions = instructions; + PersonalitySymbolName = null; } private enum CFI_OPCODE diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs index e2fed04506994f..964beb16d0d0b5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs @@ -3,7 +3,7 @@ namespace ILCompiler.ObjectWriter { - public static class DwarfNative + internal static class DwarfNative { public const byte DW_EH_PE_absptr = 0x00; public const byte DW_EH_PE_omit = 0xff; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs index 0dbbf2ca221648..4a11a726fc3efb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. namespace ILCompiler.ObjectWriter { - public static class ElfNative + internal static class ElfNative { public const byte EV_CURRENT = 1; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index fa6347d395ff6c..2ab1ff361503b9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -13,7 +13,7 @@ namespace ILCompiler.ObjectWriter { - public sealed class ElfObjectWriter : UnixObjectWriter + internal sealed class ElfObjectWriter : UnixObjectWriter { private readonly ushort _machine; private readonly List _sections = new(); @@ -24,7 +24,7 @@ public sealed class ElfObjectWriter : UnixObjectWriter // Symbol table private readonly Dictionary _symbolNameToIndex = new(); - private ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) + public ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { _machine = factory.Target.Architecture switch @@ -612,12 +612,6 @@ private void EmitObjectFile(FileStream outputFileStream) } } - public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) - { - using ElfObjectWriter writer = new ElfObjectWriter(factory, options); - writer.EmitObject(objectFilePath, nodes, dumper, logger); - } - private sealed class ElfSectionDefinition { public required ElfSectionHeader SectionHeader { get; init; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs index 8d148d4db930f9..31f7f31a693a29 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs @@ -21,7 +21,7 @@ namespace ILCompiler.ObjectWriter /// /// Object writer using src/Native/ObjWriter /// - public class LlvmObjectWriter : IDisposable, ITypesDebugInfoWriter + internal sealed class LlvmObjectWriter : IDisposable, ITypesDebugInfoWriter { private readonly ObjectWritingOptions _options; @@ -214,6 +214,7 @@ private static extern void EmitWinFrameInfo(IntPtr objWriter, byte[] methodName, byte[] blobSymbolName); public void EmitWinFrameInfo(int startOffset, int endOffset, int blobSize, byte[] blobSymbolName) { + _ = blobSize; EmitWinFrameInfo(_nativeObjectWriter, _currentNodeZeroTerminatedName.UnderlyingArray, startOffset, endOffset, blobSymbolName); } @@ -617,7 +618,7 @@ private bool TryGetCompactUnwindEncoding(byte[] blob, out uint encoding) return false; } - public void BuildCFIMap(NodeFactory factory, ObjectNode node) + public void BuildCFIMap(ObjectNode node) { _offsetToCfis.Clear(); _offsetToCfiStart.Clear(); @@ -933,7 +934,7 @@ public void Dispose() Dispose(true); } - public virtual void Dispose(bool bDisposing) + public void Dispose(bool bDisposing) { if (_nativeObjectWriter != IntPtr.Zero) { @@ -1089,7 +1090,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection symbolName.StartsWith('l'); - - public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) - { - using MachObjectWriter objectWriter = new MachObjectWriter(factory, options); - objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); - } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index a61b431408a307..e3f15340539f54 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using ILCompiler.DependencyAnalysis; @@ -308,13 +309,30 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) + { + var stopwatch = new Stopwatch(); + stopwatch.Start(); + + if (Environment.GetEnvironmentVariable("DOTNET_USE_LLVM_OBJWRITER") == "1") + { + LlvmObjectWriter.EmitObject(objectFilePath, nodes, factory, options, dumper, logger); + } + else if (factory.Target.IsOSXLike) + { + using MachObjectWriter objectWriter = new MachObjectWriter(factory, options); + objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); + } + else if (factory.Target.OperatingSystem == TargetOS.Windows) + { + using CoffObjectWriter objectWriter = new CoffObjectWriter(factory, options); + objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); + } + else + { + using ElfObjectWriter objectWriter = new ElfObjectWriter(factory, options); + objectWriter.EmitObject(objectFilePath, nodes, dumper, logger); + } + + stopwatch.Stop(); + if (logger.IsVerbose) + logger.LogMessage($"Done writing object file in {stopwatch.Elapsed}"); + } + + private struct ProgressReporter + { + private readonly Logger _logger; + private readonly int _increment; + private int _current; + + // Will report progress every (100 / 10) = 10% + private const int Steps = 10; + + public ProgressReporter(Logger logger, int total) + { + _logger = logger; + _increment = total / Steps; + _current = 0; + } + + public void LogProgress() + { + _current++; + + int adjusted = _current + Steps - 1; + if ((adjusted % _increment) == 0) + { + _logger.LogMessage($"{(adjusted / _increment) * (100 / Steps)}%..."); + } + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 38899685ea1f3f..84cf60b87f8927 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -12,7 +12,7 @@ namespace ILCompiler.ObjectWriter { - public abstract class UnixObjectWriter : ObjectWriter + internal abstract class UnixObjectWriter : ObjectWriter { private sealed record SectionDefinition(string SymbolName, Stream SectionStream); diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs index 495a0bfbc37be1..b20a3a470d0378 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs @@ -108,18 +108,7 @@ protected override void CompileInternal(string outputFile, ObjectDumper dumper) if ((_compilationOptions & RyuJitCompilationOptions.ControlFlowGuardAnnotations) != 0) options |= ObjectWritingOptions.ControlFlowGuard; - var stopwatch = new Stopwatch(); - stopwatch.Start(); - if (Environment.GetEnvironmentVariable("DOTNET_USE_LLVM_OBJWRITER") == "1") - LlvmObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - else if (NodeFactory.Target.IsOSXLike) - MachObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - else if (NodeFactory.Target.OperatingSystem == TargetOS.Windows) - CoffObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - else - ElfObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); - stopwatch.Stop(); - Console.WriteLine("Emitting object file took " + stopwatch.Elapsed); + ObjectWriter.ObjectWriter.EmitObject(outputFile, nodes, NodeFactory, options, dumper, _logger); } protected override void ComputeDependencyNodeDependencies(List> obj) From 5c5d6a170ae6ffa3603237c8b2e16394a3bd0066 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 8 Dec 2023 10:50:51 +0100 Subject: [PATCH 106/144] Use IBinaryInteger for WriteLittleEndian helper method --- .../ObjectWriter/Dwarf/DwarfBuilder.cs | 8 +++--- .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 10 +++---- .../Dwarf/DwarfLineProgramTableWriter.cs | 18 ++++++------- .../Dwarf/DwarfLineSequenceWriter.cs | 16 +++++------ .../ObjectWriter/ObjectWriterStream.cs | 27 +++++-------------- 5 files changed, 32 insertions(+), 47 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs index 879b2ffa02c466..f2048a309ee48e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs @@ -124,7 +124,7 @@ public void WriteInfoTable( byte[] sizeBuffer = new byte[sizeof(uint)]; infoSectionWriter.Stream.AppendData(sizeBuffer); // Version - infoSectionWriter.Stream.WriteUInt16((ushort)(_useDwarf5 ? 5u : 4u)); + infoSectionWriter.Stream.WriteLittleEndian((ushort)(_useDwarf5 ? 5u : 4u)); if (_useDwarf5) { // Unit type, Address Size @@ -227,7 +227,7 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) var sizeBuffer = new byte[sizeof(uint)]; arangeSectionWriter.Stream.AppendData(sizeBuffer); // Version - arangeSectionWriter.Stream.WriteUInt16(2); + arangeSectionWriter.Stream.WriteLittleEndian(2); // Debug Info Offset arangeSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", 0); // Address size, Segment selector size @@ -239,8 +239,8 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); switch (_targetPointerSize) { - case 8: arangeSectionWriter.Stream.WriteUInt64(sectionInfo.Size); break; - case 4: arangeSectionWriter.Stream.WriteUInt32((uint)sectionInfo.Size); break; + case 8: arangeSectionWriter.Stream.WriteLittleEndian(sectionInfo.Size); break; + case 4: arangeSectionWriter.Stream.WriteLittleEndian((uint)sectionInfo.Size); break; default: throw new NotSupportedException(); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index a1b25da6b9c10d..e03389e5a85fb9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -78,10 +78,10 @@ public void WriteEndDIE() public void Write(ReadOnlySpan buffer) => _infoSectionWriter.Stream.Write(buffer); public void WriteULEB128(ulong value) => _infoSectionWriter.Stream.WriteULEB128(value); - public void WriteUInt8(byte value) => _infoSectionWriter.Stream.WriteUInt8(value); - public void WriteUInt16(ushort value) => _infoSectionWriter.Stream.WriteUInt16(value); - public void WriteUInt32(uint value) => _infoSectionWriter.Stream.WriteUInt32(value); - public void WriteUInt64(ulong value) => _infoSectionWriter.Stream.WriteUInt64(value); + public void WriteUInt8(byte value) => _infoSectionWriter.Stream.WriteLittleEndian(value); + public void WriteUInt16(ushort value) => _infoSectionWriter.Stream.WriteLittleEndian(value); + public void WriteUInt32(uint value) => _infoSectionWriter.Stream.WriteLittleEndian(value); + public void WriteUInt64(ulong value) => _infoSectionWriter.Stream.WriteLittleEndian(value); public void WriteAddressSize(ulong value) { @@ -162,7 +162,7 @@ public void WriteLocationListExpression(string methodName, long startOffset, lon _ = expressionBuilder; _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, startOffset); _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, endOffset); - _locSectionWriter.Stream.WriteUInt16((ushort)_expressionBufferWriter.WrittenCount); + _locSectionWriter.Stream.WriteLittleEndian((ushort)_expressionBufferWriter.WrittenCount); _locSectionWriter.Stream.Write(_expressionBufferWriter.WrittenSpan); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs index 54a3ffca424dab..4acbb6a10cde40 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs @@ -53,21 +53,21 @@ public DwarfLineProgramTableWriter( _sizeBuffer = new byte[sizeof(uint)]; lineSectionWriter.Stream.AppendData(_sizeBuffer); // Version - lineSectionWriter.Stream.WriteUInt16(4); + lineSectionWriter.Stream.WriteLittleEndian(4); // Header Length var headerSizeBuffer = new byte[sizeof(uint)]; lineSectionWriter.Stream.AppendData(headerSizeBuffer); var headerStart = lineSectionWriter.Stream.Position; - lineSectionWriter.Stream.WriteUInt8(minimumInstructionLength); - lineSectionWriter.Stream.WriteUInt8(MaximumOperationsPerInstruction); + lineSectionWriter.Stream.WriteByte(minimumInstructionLength); + lineSectionWriter.Stream.WriteByte(MaximumOperationsPerInstruction); // default_is_stmt - lineSectionWriter.Stream.WriteUInt8(1); + lineSectionWriter.Stream.WriteByte(1); // line_base - lineSectionWriter.Stream.WriteUInt8(unchecked((byte)LineBase)); + lineSectionWriter.Stream.WriteByte(unchecked((byte)LineBase)); // line_range - lineSectionWriter.Stream.WriteUInt8(LineRange); + lineSectionWriter.Stream.WriteByte(LineRange); // opcode_base - lineSectionWriter.Stream.WriteUInt8(OpCodeBase); + lineSectionWriter.Stream.WriteByte(OpCodeBase); // standard_opcode_lengths foreach (var opcodeLength in StandardOpCodeLengths) { @@ -88,7 +88,7 @@ public DwarfLineProgramTableWriter( } } // Terminate directory list (empty string) - lineSectionWriter.Stream.WriteUInt8(0); + lineSectionWriter.Stream.WriteByte(0); // File names uint fileNameIndex = 1; @@ -105,7 +105,7 @@ public DwarfLineProgramTableWriter( fileNameIndex++; } // Terminate file name list (empty string) - lineSectionWriter.Stream.WriteUInt8(0); + lineSectionWriter.Stream.WriteByte(0); // Update header size BinaryPrimitives.WriteInt32LittleEndian(headerSizeBuffer, (int)(lineSectionWriter.Stream.Position - headerStart)); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs index 4a9b891987257a..1b8d85c0b9da30 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs @@ -38,14 +38,14 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo if (_column != sequencePoint.ColNumber) { _column = sequencePoint.ColNumber; - _writer.WriteUInt8(DW_LNS_set_column); + _writer.WriteByte(DW_LNS_set_column); _writer.WriteULEB128((uint)_column); } if (_fileNameIndex != fileNameIndex) { _fileNameIndex = fileNameIndex; - _writer.WriteUInt8(DW_LNS_set_file); + _writer.WriteByte(DW_LNS_set_file); _writer.WriteULEB128((uint)_fileNameIndex); } @@ -58,7 +58,7 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo if (!canEncodeLineInSpecialCode) { - _writer.WriteUInt8(DW_LNS_advance_line); + _writer.WriteByte(DW_LNS_advance_line); _writer.WriteSLEB128(deltaLine); deltaLine = 0; } @@ -68,7 +68,7 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo if (deltaAddress > _maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * _maxDeltaAddressPerSpecialCode)) { deltaAddress -= _maxDeltaAddressPerSpecialCode; - _writer.WriteUInt8(DW_LNS_const_add_pc); + _writer.WriteByte(DW_LNS_const_add_pc); } if (deltaAddress > 0 || deltaLine != 0) @@ -79,20 +79,20 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo DwarfLineProgramTableWriter.OpCodeBase + (ulong)(deltaLine - DwarfLineProgramTableWriter.LineBase); if (opcode > 255) { - _writer.WriteUInt8(DW_LNS_advance_pc); + _writer.WriteByte(DW_LNS_advance_pc); _writer.WriteULEB128((uint)operationAdvance); if (deltaLine != 0) { - _writer.WriteUInt8((byte)(DwarfLineProgramTableWriter.OpCodeBase + deltaLine - DwarfLineProgramTableWriter.LineBase)); + _writer.WriteByte((byte)(DwarfLineProgramTableWriter.OpCodeBase + deltaLine - DwarfLineProgramTableWriter.LineBase)); } else { - _writer.WriteUInt8(DW_LNS_copy); + _writer.WriteByte(DW_LNS_copy); } } else { - _writer.WriteUInt8((byte)opcode); + _writer.WriteByte((byte)opcode); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs index bac3c58e6e0029..c52dca6d656cd6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Numerics; using System.Text; namespace ILCompiler.ObjectWriter @@ -176,7 +177,7 @@ public void WriteSLEB128(long value) DwarfHelper.WriteSLEB128(_appendBuffer, value); } - public void WriteUInt8(byte value) + public override void WriteByte(byte value) { Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); Span buffer = _appendBuffer.GetSpan(1); @@ -184,28 +185,12 @@ public void WriteUInt8(byte value) _appendBuffer.Advance(1); } - public void WriteUInt16(ushort value) + public void WriteLittleEndian(T value) + where T : IBinaryInteger { Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - Span buffer = _appendBuffer.GetSpan(sizeof(ushort)); - BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); - _appendBuffer.Advance(sizeof(ushort)); - } - - public void WriteUInt32(uint value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - Span buffer = _appendBuffer.GetSpan(sizeof(uint)); - BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); - _appendBuffer.Advance(sizeof(uint)); - } - - public void WriteUInt64(ulong value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - Span buffer = _appendBuffer.GetSpan(sizeof(ulong)); - BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); - _appendBuffer.Advance(sizeof(ulong)); + Span buffer = _appendBuffer.GetSpan(value.GetByteCount()); + _appendBuffer.Advance(value.WriteLittleEndian(buffer)); } public void WriteUtf8String(string value) From 288eedd0ed0d7701ebdda8f0e25c4f81d15c70ef Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 9 Dec 2023 15:15:09 +0100 Subject: [PATCH 107/144] Add simple Mach-O object file writer that doesn't use Melanzana.MachO --- .../Compiler/ObjectWriter/MachNative.cs | 114 +++ .../Compiler/ObjectWriter/MachObjectWriter.cs | 684 ++++++++++++++---- .../ILCompiler.Compiler.csproj | 3 +- .../tools/aot/external/Directory.Build.props | 5 - .../aot/external/Directory.Build.targets | 1 - .../tools/aot/external/Melanzana/CodeSign.sln | 49 -- .../external/Melanzana/Directory.Build.props | 13 - .../tools/aot/external/Melanzana/LICENSE | 21 - .../DataMemberSymbol.cs | 35 - .../Generator.Attribute.cs | 37 - .../Generator.ReadWrite.cs | 367 ---------- .../Generator.cs | 54 -- .../Melanzana.BinaryFormat.Generator.csproj | 12 - .../Melanzana.CodeSign.Tests/Data/a.out | Bin 34976 -> 0 bytes .../Melanzana.CodeSign.Tests.csproj | 31 - .../RequirementTest.cs | 27 - .../Melanzana.CodeSign.Tests/ResignTest.cs | 44 -- .../AppleCertificateExtensions.cs | 74 -- .../Melanzana.CodeSign/Blobs/BlobMagic.cs | 14 - .../Blobs/CmsWrapperBlob.cs | 121 ---- .../Blobs/CodeDirectoryBaselineHeader.cs | 22 - .../Blobs/CodeDirectoryBuilder.cs | 205 ------ .../Blobs/CodeDirectoryCodeLimit64Header.cs | 10 - .../Blobs/CodeDirectoryExecSegmentHeader.cs | 11 - .../Blobs/CodeDirectoryFlags.cs | 7 - .../Blobs/CodeDirectoryPreencryptHeader.cs | 10 - .../Blobs/CodeDirectoryScatterHeader.cs | 9 - .../Blobs/CodeDirectorySpecialSlot.cs | 18 - .../Blobs/CodeDirectoryTeamIdHeader.cs | 9 - .../Blobs/CodeDirectoryVersion.cs | 13 - .../Blobs/EntitlementsBlob.cs | 21 - .../Blobs/EntitlementsDerBlob.cs | 21 - .../Blobs/ExecutableSegmentFlags.cs | 13 - .../Melanzana.CodeSign/Blobs/HashType.cs | 12 - .../Blobs/HashTypeExtensions.cs | 47 -- .../Melanzana/Melanzana.CodeSign/Bundle.cs | 130 ---- .../IntermediateG1Certificate.cer | Bin 1062 -> 0 bytes .../IntermediateG3Certificate.cer | Bin 1109 -> 0 bytes .../Certificates/RootCertificate.cer | Bin 1215 -> 0 bytes .../Melanzana.CodeSign/CodeSignAllocate.cs | 50 -- .../Melanzana.CodeSign/CodeSignOptions.cs | 37 - .../Melanzana.CodeSign/Entitlements.cs | 31 - .../Melanzana.CodeSign.csproj | 26 - .../PropertyList/DerPropertyListWriter.cs | 86 --- .../Melanzana.CodeSign/ProvisioningProfile.cs | 29 - .../Expression.ConversionHelpers.cs | 89 --- .../Requirements/Expression.Derived.cs | 470 ------------ .../Requirements/Expression.FromBlob.cs | 157 ---- .../Requirements/Expression.Static.cs | 42 -- .../Requirements/Expression.cs | 9 - .../Requirements/ExpressionMatchType.cs | 21 - .../Requirements/ExpressionOperation.cs | 30 - .../Requirements/Requirement.cs | 41 -- .../Requirements/RequirementSet.cs | 73 -- .../Requirements/RequirementType.cs | 12 - .../Melanzana.CodeSign/ResourceBuilder.cs | 98 --- .../Melanzana.CodeSign/ResourceRule.cs | 32 - .../Melanzana/Melanzana.CodeSign/Signer.cs | 459 ------------ .../Melanzana.MachO.Tests/CreateTests.cs | 176 ----- .../Melanzana.MachO.Tests/Data/a.fat.out | Bin 84128 -> 0 bytes .../Melanzana.MachO.Tests/Data/a.out | Bin 34976 -> 0 bytes .../Melanzana.MachO.Tests.csproj | 31 - .../Melanzana.MachO.Tests/ReadTests.cs | 82 --- .../Melanzana.MachO.Tests/RoundtripTests.cs | 48 -- .../BinaryFormat/BuildToolVersionHeader.cs | 9 - .../BinaryFormat/BuildVersionCommandHeader.cs | 11 - .../BinaryFormat/DyldInfoHeader.cs | 17 - .../BinaryFormat/DylibCommandHeader.cs | 11 - .../DynamicSymbolTableCommandHeader.cs | 25 - .../BinaryFormat/FatArchHeader.cs | 12 - .../Melanzana.MachO/BinaryFormat/FatHeader.cs | 8 - .../BinaryFormat/IMachHeader.cs | 12 - .../BinaryFormat/LinkEditHeader.cs | 9 - .../BinaryFormat/LoadCommandHeader.cs | 9 - .../BinaryFormat/MachFixedName.cs | 52 -- .../BinaryFormat/MachHeader.cs | 13 - .../BinaryFormat/MachHeader64.cs | 14 - .../BinaryFormat/MainCommandHeader.cs | 9 - .../BinaryFormat/Section64Header.cs | 19 - .../BinaryFormat/SectionHeader.cs | 18 - .../BinaryFormat/Segment64Header.cs | 16 - .../BinaryFormat/SegmentHeader.cs | 16 - .../BinaryFormat/SymbolHeader.cs | 11 - .../BinaryFormat/SymbolTableCommandHeader.cs | 11 - .../BinaryFormat/TwoLevelHintsHeader.cs | 9 - .../BinaryFormat/VersionMinCommandHeader.cs | 9 - .../LoadCommands/MachBuildTool.cs | 9 - .../LoadCommands/MachBuildToolVersion.cs | 9 - .../LoadCommands/MachBuildVersion.cs | 11 - .../LoadCommands/MachBuildVersionBase.cs | 13 - .../LoadCommands/MachCodeSignature.cs | 15 - .../LoadCommands/MachCustomLoadCommand.cs | 17 - .../LoadCommands/MachDataInCode.cs | 15 - .../LoadCommands/MachDyldChainedFixups.cs | 15 - .../LoadCommands/MachDyldExportsTrie.cs | 15 - .../LoadCommands/MachDyldInfo.cs | 56 -- .../LoadCommands/MachDyldInfoOnly.cs | 21 - .../LoadCommands/MachDylibCodeSigningDirs.cs | 15 - .../LoadCommands/MachDylibCommand.cs | 16 - .../MachDynamicLinkEditSymbolTable.cs | 180 ----- .../LoadCommands/MachEntrypointCommand.cs | 12 - .../LoadCommands/MachFunctionStarts.cs | 15 - .../LoadCommands/MachLinkEdit.cs | 38 - .../MachLinkerOptimizationHint.cs | 15 - .../LoadCommands/MachLoadDylibCommand.cs | 6 - .../LoadCommands/MachLoadWeakDylibCommand.cs | 6 - .../LoadCommands/MachReexportDylibCommand.cs | 6 - .../LoadCommands/MachSection.cs | 163 ----- .../LoadCommands/MachSectionAttributes.cs | 17 - .../LoadCommands/MachSectionType.cs | 28 - .../LoadCommands/MachSegment.cs | 189 ----- .../LoadCommands/MachSegmentFlags.cs | 9 - .../LoadCommands/MachSegmentSplitInfo.cs | 15 - .../LoadCommands/MachSymbolTable.cs | 82 --- .../LoadCommands/MachTwoLevelHints.cs | 26 - .../LoadCommands/MachVersionMinIOS.cs | 7 - .../LoadCommands/MachVersionMinMacOS.cs | 7 - .../LoadCommands/MachVersionMinTvOS.cs | 7 - .../LoadCommands/MachVersionMinWatchOS.cs | 7 - .../Melanzana.MachO/MachArm64CpuSubType.cs | 34 - .../Melanzana.MachO/MachArmCpuSubType.cs | 83 --- .../Melanzana.MachO/MachCpuSubType.cs | 19 - .../Melanzana/Melanzana.MachO/MachCpuType.cs | 20 - .../Melanzana/Melanzana.MachO/MachFileType.cs | 17 - .../Melanzana.MachO/MachHeaderFlags.cs | 32 - .../Melanzana.MachO/MachI386CpuSubType.cs | 118 --- .../Melanzana.MachO/MachLayoutOptions.cs | 32 - .../Melanzana.MachO/MachLinkEditData.cs | 67 -- .../Melanzana.MachO/MachLoadCommand.cs | 11 - .../Melanzana.MachO/MachLoadCommandType.cs | 63 -- .../Melanzana/Melanzana.MachO/MachMagic.cs | 12 - .../Melanzana.MachO/MachObjectFile.cs | 321 -------- .../Melanzana/Melanzana.MachO/MachPlatform.cs | 16 - .../Melanzana/Melanzana.MachO/MachReader.cs | 371 ---------- .../Melanzana.MachO/MachRelocation.cs | 41 -- .../MachRelocationCollection.cs | 146 ---- .../Melanzana.MachO/MachRelocationType.cs | 35 - .../Melanzana/Melanzana.MachO/MachSymbol.cs | 16 - .../Melanzana.MachO/MachSymbolDescriptor.cs | 19 - .../MachSymbolTableCollection.cs | 222 ------ .../Melanzana.MachO/MachSymbolType.cs | 17 - .../Melanzana.MachO/MachVmProtection.cs | 11 - .../Melanzana/Melanzana.MachO/MachWriter.cs | 562 -------------- .../Melanzana.MachO/MachX8664CpuSubType.cs | 23 - .../Melanzana.MachO/Melanzana.MachO.csproj | 17 - .../Melanzana/Melanzana.MachO/README.md | 18 - .../Melanzana.Streams.csproj | 9 - .../Melanzana.Streams/SliceStream.cs | 178 ----- .../Melanzana.Streams/StreamExtensions.cs | 34 - .../UnclosableMemoryStream.cs | 9 - .../tools/aot/external/Melanzana/README.md | 9 - .../external/Melanzana/codesign/Program.cs | 103 --- .../Melanzana/codesign/codesign.csproj | 23 - .../tools/aot/external/Melanzana/version.json | 8 - 154 files changed, 651 insertions(+), 7840 deletions(-) create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs delete mode 100644 src/coreclr/tools/aot/external/Directory.Build.props delete mode 100644 src/coreclr/tools/aot/external/Directory.Build.targets delete mode 100644 src/coreclr/tools/aot/external/Melanzana/CodeSign.sln delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Directory.Build.props delete mode 100644 src/coreclr/tools/aot/external/Melanzana/LICENSE delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj delete mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/RootCertificate.cer delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs delete mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out delete mode 100755 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/README.md delete mode 100644 src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs delete mode 100644 src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj delete mode 100644 src/coreclr/tools/aot/external/Melanzana/version.json diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs new file mode 100644 index 00000000000000..b8f65a9c91bc51 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +namespace ILCompiler.ObjectWriter +{ + internal static class MachNative + { + public const uint MH_MAGIC_64 = 0xfeedfacf; + + // File type + public const uint MH_OBJECT = 0x1; + + // File header flags + public const uint MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000; + + // Load command types + public const uint LC_SYMTAB = 0x2; + public const uint LC_DYSYMTAB = 0xb; + public const uint LC_SEGMENT_64 = 0x19; + public const uint LC_BUILD_VERSION = 0x32; + + // Memory protection + public const uint VM_PROT_NONE = 0; + public const uint VM_PROT_READ = 1; + public const uint VM_PROT_WRITE = 2; + public const uint VM_PROT_EXECUTE = 4; + + // Section types + public const uint S_REGULAR = 0; + public const uint S_ZEROFILL = 1; + public const uint S_CSTRING_LITERALS = 2; + public const uint S_4BYTE_LITERALS = 3; + public const uint S_LITERAL_POINTERS = 5; + public const uint S_NON_LAZY_SYMBOL_POINTERS = 6; + public const uint S_LAZY_SYMBOL_POINTERS = 7; + public const uint S_SYMBOL_STUBS = 8; + public const uint S_MOD_INIT_FUNC_POINTERS = 9; + public const uint S_MOD_TERM_FUNC_POINTERS = 10; + public const uint S_COALESCED = 11; + public const uint S_GB_ZEROFILL = 12; + public const uint S_INTERPOSING = 13; + public const uint S_16BYTE_LITERALS = 14; + public const uint S_DTRACE_DOF = 15; + public const uint S_LAZY_DYLIB_SYMBOL_POINTERS = 16; + public const uint S_THREAD_LOCAL_REGULAR = 17; + public const uint S_THREAD_LOCAL_ZEROFILL = 18; + public const uint S_THREAD_LOCAL_VARIABLES = 19; + public const uint S_THREAD_LOCAL_VARIABLE_POINTERS = 20; + public const uint S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 21; + public const uint S_INIT_FUNC_OFFSETS = 22; + + // Section flags + public const uint S_ATTR_SOME_INSTRUCTIONS = 0x400; + public const uint S_ATTR_DEBUG = 0x2000000; + public const uint S_ATTR_LIVE_SUPPORT = 0x8000000; + public const uint S_ATTR_NO_DEAD_STRIP = 0x10000000; + public const uint S_ATTR_STRIP_STATIC_SYMS = 0x20000000; + public const uint S_ATTR_NO_TOC = 0x40000000; + public const uint S_ATTR_PURE_INSTRUCTIONS = 0x80000000; + + // Relocation types + public const byte X86_64_RELOC_UNSIGNED = 0; + public const byte X86_64_RELOC_SIGNED = 1; + public const byte X86_64_RELOC_BRANCH = 2; + public const byte X86_64_RELOC_GOT_LOAD = 3; + public const byte X86_64_RELOC_GOT = 4; + public const byte X86_64_RELOC_SUBTRACTOR = 5; + public const byte X86_64_RELOC_SIGNED_1 = 6; + public const byte X86_64_RELOC_SIGNED_2 = 7; + public const byte X86_64_RELOC_SIGNED_4 = 8; + public const byte X86_64_RELOC_TLV = 9; + public const byte ARM64_RELOC_UNSIGNED = 0; + public const byte ARM64_RELOC_SUBTRACTOR = 1; + public const byte ARM64_RELOC_BRANCH26 = 2; + public const byte ARM64_RELOC_PAGE21 = 3; + public const byte ARM64_RELOC_PAGEOFF12 = 4; + public const byte ARM64_RELOC_GOT_LOAD_PAGE21 = 5; + public const byte ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6; + public const byte ARM64_RELOC_POINTER_TO_GOT = 7; + public const byte ARM64_RELOC_TLVP_LOAD_PAGE21 = 8; + public const byte ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9; + public const byte ARM64_RELOC_ADDEND = 10; + + // Symbol type + public const byte N_UNDF = 0; + public const byte N_EXT = 1; + public const byte N_ABS = 2; + public const byte N_INDR = 0xa; + public const byte N_SECT = 0xe; + public const byte N_PBUD = 0xc; + + // Symbol descriptor flags + public const ushort REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0; + public const ushort REFERENCE_FLAG_UNDEFINED_LAZY = 1; + public const ushort REFERENCE_FLAG_DEFINED = 2; + public const ushort REFERENCE_FLAG_PRIVATE_DEFINED = 3; + public const ushort REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY = 4; + public const ushort REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY = 5; + public const ushort REFERENCED_DYNAMICALLY = 0x10; + public const ushort N_NO_DEAD_STRIP = 0x20; + public const ushort N_WEAK_REF = 0x40; + public const ushort N_WEAK_DEF = 0x80; + + public const uint PLATFORM_MACOS = 1; + public const uint PLATFORM_IOS = 2; + public const uint PLATFORM_TVOS = 3; + public const uint PLATFORM_WATCHOS = 4; + public const uint PLATFORM_BRIDGEOS = 5; + public const uint PLATFORM_MACCATALYST = 6; + public const uint PLATFORM_IOSSIMULATOR = 7; + public const uint PLATFORM_TVOSSIMULATOR = 8; + public const uint PLATFORM_WATCHOSSIMULATOR = 9; + public const uint PLATFORM_DRIVERKIT = 10; + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index a12c16ecc9163d..92c29f9076e4b7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -9,10 +9,10 @@ using System.IO; using System.Linq; using System.Numerics; +using System.Text; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; -using Melanzana.MachO; namespace ILCompiler.ObjectWriter { @@ -21,148 +21,246 @@ internal sealed class MachObjectWriter : UnixObjectWriter private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); private readonly TargetOS _targetOS; - private readonly MachObjectFile _objectFile; - private readonly MachSegment _segment; + private readonly MachCpuType _cpuType; + private readonly List _sections = new(); // Exception handling sections private MachSection _compactUnwindSection; + private MemoryStream _compactUnwindStream; private readonly List _compactUnwindCodes = new(); private readonly uint _compactUnwindDwarfCode; // Symbol table private readonly Dictionary _symbolNameToIndex = new(); - private MachSymbolTable _symbolTable; - private MachDynamicLinkEditSymbolTable _dySymbolTable; + private readonly List _symbolTable = new(); + private readonly MachDynamicLinkEditSymbolTable _dySymbolTable = new(); public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) { - _objectFile = new MachObjectFile - { - FileType = MachFileType.Object, - IsLittleEndian = true, - Flags = MachHeaderFlags.SubsectionsViaSymbols - }; - switch (factory.Target.Architecture) { case TargetArchitecture.ARM64: - _objectFile.CpuType = MachCpuType.Arm64; - _objectFile.CpuSubType = (uint)MachArm64CpuSubType.All; + _cpuType = MachCpuType.Arm64; _compactUnwindDwarfCode = 0x3_00_00_00u; break; case TargetArchitecture.X64: - _objectFile.CpuType = MachCpuType.X86_64; - _objectFile.CpuSubType = (uint)X8664CpuSubType.All; + _cpuType = MachCpuType.X86_64; _compactUnwindDwarfCode = 0x4_00_00_00u; break; default: throw new NotSupportedException("Unsupported architecture"); } - // Mach-O object files have single segment with no name - _segment = new MachSegment(_objectFile, "") - { - InitialProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, - MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, - }; - _objectFile.LoadCommands.Add(_segment); - _targetOS = factory.Target.OperatingSystem; } protected override void EmitSectionsAndLayout() { - _compactUnwindSection = new MachSection(_objectFile, "__LD", "__compact_unwind") + // Layout sections. At this point we don't really care if the file offsets are correct + // but we need to compute the virtual addresses to populate the symbol table. + uint fileOffset = 0; + LayoutSections(ref fileOffset, out _, out _); + + // Generate section base symbols. The section symbols are used for PC relative relocations + // to subtract the base of the section, and in DWARF to emit section relative relocations. + byte sectionIndex = 0; + foreach (MachSection section in _sections) { - Log2Alignment = 3, - Type = MachSectionType.Regular, - Attributes = MachSectionAttributes.Debug, - // Preset the size of the compact unwind section which is not generated yet - Size = 32u * (ulong)_compactUnwindCodes.Count, + var machSymbol = new MachSymbol + { + Name = $"lsection{sectionIndex}", + Section = section, + Value = section.VirtualAddress, + Descriptor = 0, + Type = MachNative.N_SECT, + }; + _symbolTable.Add(machSymbol); + _symbolNameToIndex[machSymbol.Name] = sectionIndex; + sectionIndex++; + } + } + + private void LayoutSections(ref uint fileOffset, out uint segmentFileSize, out ulong segmentSize) + { + ulong virtualAddress = 0; + byte sectionIndex = 1; + + segmentFileSize = 0; + segmentSize = 0; + foreach (MachSection section in _sections) + { + uint alignment = 1u << (int)section.Log2Alignment; + + fileOffset = (fileOffset + alignment - 1) & ~(alignment - 1); + virtualAddress = (virtualAddress + alignment - 1) & ~(alignment - 1); + + if (section.IsInFile) + { + section.FileOffset = fileOffset; + fileOffset += (uint)section.Size; + segmentFileSize = Math.Max(segmentFileSize, fileOffset); + } + else + { + // The offset is unused for virtual sections. + section.FileOffset = 0; + } + + section.VirtualAddress = virtualAddress; + virtualAddress += section.Size; + + section.SectionIndex = sectionIndex; + sectionIndex++; + + segmentSize = Math.Max(segmentSize, virtualAddress); + } + + // ...and the relocation tables + foreach (MachSection section in _sections) + { + section.RelocationOffset = fileOffset; + fileOffset += section.NumberOfRelocationEntries * 8; + } + } + + protected override void EmitObjectFile(string objectFilePath) + { + _sections.Add(_compactUnwindSection); + + // Segment + sections + uint loadCommandsCount = 1; + uint loadCommandsSize = (uint)(MachSegment64Header.HeaderSize + _sections.Count * MachSection.HeaderSize); + // Symbol table + loadCommandsCount += 2; + loadCommandsSize += (uint)(MachSymbolTableCommandHeader.HeaderSize + MachDynamicLinkEditSymbolTable.HeaderSize); + // Build version + loadCommandsCount++; + loadCommandsSize += (uint)MachBuildVersionCommandHeader.HeaderSize; + + // We added the compact unwinding section, debug sections, and relocations, + // so re-run the layout and this time calculate with the correct file offsets. + uint fileOffset = (uint)MachHeader64.HeaderSize + loadCommandsSize; + uint segmentFileOffset = fileOffset; + LayoutSections(ref fileOffset, out uint segmentFileSize, out ulong segmentSize); + + using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); + + MachHeader64 machHeader = new MachHeader64 + { + CpuType = _cpuType, + CpuSubType = 0, + FileType = MachNative.MH_OBJECT, + NumberOfCommands = loadCommandsCount, + SizeOfCommands = loadCommandsSize, + Flags = MachNative.MH_SUBSECTIONS_VIA_SYMBOLS, + Reserved = 0, + }; + machHeader.Write(outputFileStream); + + MachSegment64Header machSegment64Header = new MachSegment64Header + { + Name = "", + InitialProtection = MachNative.VM_PROT_READ | MachNative.VM_PROT_WRITE | MachNative.VM_PROT_EXECUTE, + MaximumProtection = MachNative.VM_PROT_READ | MachNative.VM_PROT_WRITE | MachNative.VM_PROT_EXECUTE, + Address = 0, + Size = segmentSize, + FileOffset = segmentFileOffset, + FileSize = segmentFileSize, + NumberOfSections = (uint)_sections.Count, }; + machSegment64Header.Write(outputFileStream); + + foreach (MachSection section in _sections) + { + section.WriteHeader(outputFileStream); + } + + MachStringTable stringTable = new(); + foreach (MachSymbol symbol in _symbolTable) + { + stringTable.ReserveString(symbol.Name); + } - // Insert all the load commands to ensure we have correct layout - _symbolTable = new MachSymbolTable(_objectFile); - _dySymbolTable = new MachDynamicLinkEditSymbolTable(); - _objectFile.LoadCommands.Add(_symbolTable); - _objectFile.LoadCommands.Add(_dySymbolTable); + uint stringTableOffset = fileOffset; + uint symbolTableOffset = stringTableOffset + ((stringTable.Size + 7u) & ~7u); + MachSymbolTableCommandHeader symbolTableHeader = new MachSymbolTableCommandHeader + { + SymbolTableOffset = symbolTableOffset, + NumberOfSymbols = (uint)_symbolTable.Count, + StringTableOffset = stringTableOffset, + StringTableSize = stringTable.Size, + }; + symbolTableHeader.Write(outputFileStream); + _dySymbolTable.Write(outputFileStream); - var sdkVersion = new Version(16, 0, 0); + // Build version + MachBuildVersionCommandHeader buildVersion = new MachBuildVersionCommandHeader + { + SdkVersion = 0x10_00_00u, // 16.0.0 + }; switch (_targetOS) { case TargetOS.OSX: - _objectFile.LoadCommands.Add(new MachVersionMinMacOS - { - MinimumPlatformVersion = new Version(10, 12, 0), - SdkVersion = sdkVersion, - }); + buildVersion.Platform = MachNative.PLATFORM_MACOS; + buildVersion.MinimumPlatformVersion = 0x0a_0c_00; // 10.12.0 break; case TargetOS.MacCatalyst: - _objectFile.LoadCommands.Add(new MachBuildVersion + buildVersion.Platform = MachNative.PLATFORM_MACCATALYST; + buildVersion.MinimumPlatformVersion = _cpuType switch { - TargetPlatform = MachPlatform.MacCatalyst, - MinimumPlatformVersion = _objectFile.CpuType switch { - MachCpuType.X86_64 => new Version(13, 5, 0), - _ => new Version(14, 2, 0), - }, - SdkVersion = sdkVersion, - }); + MachCpuType.X86_64 => 0x0d_05_00u, // 13.5.0 + _ => 0x0e_02_00u, // 14.2.0 + }; break; case TargetOS.iOS: case TargetOS.iOSSimulator: case TargetOS.tvOS: case TargetOS.tvOSSimulator: - _objectFile.LoadCommands.Add(new MachBuildVersion + buildVersion.Platform = _targetOS switch { - TargetPlatform = _targetOS switch - { - TargetOS.iOS => MachPlatform.IOS, - TargetOS.iOSSimulator => MachPlatform.IOSSimulator, - TargetOS.tvOS => MachPlatform.TvOS, - TargetOS.tvOSSimulator => MachPlatform.TvOSSimulator, - _ => 0, - }, - MinimumPlatformVersion = new Version(11, 0, 0), - SdkVersion = sdkVersion, - }); + TargetOS.iOS => MachNative.PLATFORM_IOS, + TargetOS.iOSSimulator => MachNative.PLATFORM_IOSSIMULATOR, + TargetOS.tvOS => MachNative.PLATFORM_TVOS, + TargetOS.tvOSSimulator => MachNative.PLATFORM_TVOSSIMULATOR, + _ => 0, + }; + buildVersion.MinimumPlatformVersion = 0x0b_00_00; // 11.0.0 break; } + buildVersion.Write(outputFileStream); - // Layout the sections - _objectFile.UpdateLayout(); - - // Generate section base symbols. The section symbols are used for PC relative relocations - // to subtract the base of the section, and in DWARF to emit section relative relocations. - uint sectionIndex = 0; - foreach (MachSection machSection in _segment.Sections) + // Write section contents + foreach (MachSection section in _sections) { - var machSymbol = new MachSymbol + if (section.IsInFile) { - Name = $"lsection{sectionIndex}", - Section = machSection, - Value = machSection.VirtualAddress, - Descriptor = 0, - Type = MachSymbolType.Section, - }; - _symbolTable.Symbols.Add(machSymbol); - _symbolNameToIndex[machSymbol.Name] = sectionIndex; - sectionIndex++; + outputFileStream.Position = (long)section.FileOffset; + section.Stream.Position = 0; + section.Stream.CopyTo(outputFileStream); + } } - } - protected override void EmitObjectFile(string objectFilePath) - { - _segment.Sections.Add(_compactUnwindSection); - - // Update layout again to account for symbol table and relocation tables - _objectFile.UpdateLayout(); + // Write relocations + foreach (MachSection section in _sections) + { + if (section.NumberOfRelocationEntries > 0) + { + foreach (MachRelocation relocation in section.Relocations) + { + relocation.Write(outputFileStream); + } + } + } - using (var outputFileStream = new FileStream(objectFilePath, FileMode.Create)) + // Write string and symbol table + stringTable.Write(outputFileStream); + outputFileStream.Position = symbolTableOffset; + foreach (MachSymbol symbol in _symbolTable) { - MachWriter.Write(outputFileStream, _objectFile); + symbol.Write(outputFileStream, stringTable); } } @@ -197,41 +295,40 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa _ => section.Name }; - MachSectionAttributes attributes = section.Name switch + uint flags = section.Name switch + { + "bss" => MachNative.S_ZEROFILL, + ".eh_frame" => MachNative.S_COALESCED, + _ => section.Type == SectionType.Uninitialized ? MachNative.S_ZEROFILL : MachNative.S_REGULAR + }; + + flags |= section.Name switch { - ".dotnet_eh_table" => MachSectionAttributes.Debug, - ".eh_frame" => MachSectionAttributes.LiveSupport | MachSectionAttributes.StripStaticSymbols | MachSectionAttributes.NoTableOfContents, + ".dotnet_eh_table" => MachNative.S_ATTR_DEBUG, + ".eh_frame" => MachNative.S_ATTR_LIVE_SUPPORT | MachNative.S_ATTR_STRIP_STATIC_SYMS | MachNative.S_ATTR_NO_TOC, _ => section.Type switch { - SectionType.Executable => MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, - SectionType.Debug => MachSectionAttributes.Debug, + SectionType.Executable => MachNative.S_ATTR_SOME_INSTRUCTIONS | MachNative.S_ATTR_PURE_INSTRUCTIONS, + SectionType.Debug => MachNative.S_ATTR_DEBUG, _ => 0 } }; - MachSectionType type = section.Name switch - { - "bss" => MachSectionType.ZeroFill, - ".eh_frame" => MachSectionType.Coalesced, - _ => section.Type == SectionType.Uninitialized ? MachSectionType.ZeroFill : MachSectionType.Regular - }; - - MachSection machSection = new MachSection(_objectFile, segmentName, sectionName, sectionStream) + MachSection machSection = new MachSection(segmentName, sectionName, sectionStream) { Log2Alignment = 1, - Type = type, - Attributes = attributes, + Flags = flags, }; - int sectionIndex = _segment.Sections.Count; - _segment.Sections.Add(machSection); + int sectionIndex = _sections.Count; + _sections.Add(machSection); base.CreateSection(section, comdatName, symbolName ?? $"lsection{sectionIndex}", sectionStream); } protected internal override void UpdateSectionAlignment(int sectionIndex, int alignment) { - MachSection machSection = _segment.Sections[sectionIndex]; + MachSection machSection = _sections[sectionIndex]; Debug.Assert(BitOperations.IsPow2(alignment)); machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); } @@ -247,8 +344,8 @@ protected internal override void EmitRelocation( if (relocType is RelocType.IMAGE_REL_BASED_DIR64 or RelocType.IMAGE_REL_BASED_HIGHLOW) { // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly - MachSection machSection = _segment.Sections[sectionIndex]; - if (machSection.Attributes.HasFlag(MachSectionAttributes.Debug) && + MachSection machSection = _sections[sectionIndex]; + if ((machSection.Flags & MachNative.S_ATTR_DEBUG) != 0 && machSection.SegmentName == "__DWARF") { // DWARF section to DWARF section relocation @@ -273,7 +370,7 @@ protected internal override void EmitRelocation( Debug.Assert(IsSectionSymbolName(symbolName)); Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; - BinaryPrimitives.WriteUInt64LittleEndian(data, _segment.Sections[targetSectionIndex].VirtualAddress + (ulong)addend); + BinaryPrimitives.WriteUInt64LittleEndian(data, _sections[targetSectionIndex].VirtualAddress + (ulong)addend); base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } @@ -287,7 +384,7 @@ protected internal override void EmitRelocation( if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) { - Debug.Assert(_objectFile.CpuType == MachCpuType.Arm64); + Debug.Assert(_cpuType == MachCpuType.Arm64); Debug.Assert(addend == 0); } else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) @@ -303,7 +400,7 @@ protected internal override void EmitRelocation( } else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) { - if (_objectFile.CpuType == MachCpuType.Arm64) + if (_cpuType == MachCpuType.Arm64) { // On ARM64 we need to represent PC relative relocations as // subtraction and the PC offset is baked into the addend. @@ -336,7 +433,7 @@ protected internal override void EmitRelocation( } else if (relocType == RelocType.IMAGE_REL_BASED_REL32) { - Debug.Assert(_objectFile.CpuType != MachCpuType.Arm64); + Debug.Assert(_cpuType != MachCpuType.Arm64); if (addend != 0) { BinaryPrimitives.WriteInt32LittleEndian( @@ -356,7 +453,7 @@ protected override void EmitSymbolTable( { // We already emitted symbols for all non-debug sections in EmitSectionsAndLayout, // these symbols are local and we need to account for them. - uint symbolIndex = (uint)_symbolTable.Symbols.Count; + uint symbolIndex = (uint)_symbolTable.Count; _dySymbolTable.LocalSymbolsIndex = 0; _dySymbolTable.LocalSymbolsCount = symbolIndex; @@ -364,20 +461,20 @@ protected override void EmitSymbolTable( var sortedDefinedSymbols = new List(definedSymbols.Count); foreach ((string name, SymbolDefinition definition) in definedSymbols) { - MachSection section = _segment.Sections[definition.SectionIndex]; + MachSection section = _sections[definition.SectionIndex]; sortedDefinedSymbols.Add(new MachSymbol { Name = name, Section = section, Value = section.VirtualAddress + (ulong)definition.Value, Descriptor = 0, - Type = MachSymbolType.Section | MachSymbolType.External, + Type = MachNative.N_SECT | MachNative.N_EXT, }); } sortedDefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); foreach (MachSymbol definedSymbol in sortedDefinedSymbols) { - _symbolTable.Symbols.Add(definedSymbol); + _symbolTable.Add(definedSymbol); _symbolNameToIndex[definedSymbol.Name] = symbolIndex; symbolIndex++; } @@ -388,17 +485,20 @@ protected override void EmitSymbolTable( uint savedSymbolIndex = symbolIndex; foreach (string externSymbol in undefinedSymbols) { - var machSymbol = new MachSymbol + if (!_symbolNameToIndex.ContainsKey(externSymbol)) { - Name = externSymbol, - Section = null, - Value = 0, - Descriptor = 0, - Type = MachSymbolType.Undefined | MachSymbolType.External, - }; - _symbolTable.Symbols.Add(machSymbol); - _symbolNameToIndex[externSymbol] = symbolIndex; - symbolIndex++; + var machSymbol = new MachSymbol + { + Name = externSymbol, + Section = null, + Value = 0, + Descriptor = 0, + Type = MachNative.N_UNDF | MachNative.N_EXT, + }; + _symbolTable.Add(machSymbol); + _symbolNameToIndex[externSymbol] = symbolIndex; + symbolIndex++; + } } _dySymbolTable.UndefinedSymbolsIndex = _dySymbolTable.LocalSymbolsCount + _dySymbolTable.ExternalSymbolsCount; @@ -409,7 +509,7 @@ protected override void EmitSymbolTable( protected override void EmitRelocations(int sectionIndex, List relocationList) { - if (_objectFile.CpuType == MachCpuType.Arm64) + if (_cpuType == MachCpuType.Arm64) { EmitRelocationsArm64(sectionIndex, relocationList); } @@ -421,7 +521,7 @@ protected override void EmitRelocations(int sectionIndex, List relocationList) { - ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; + ICollection sectionRelocations = _sections[sectionIndex].Relocations; relocationList.Reverse(); foreach (SymbolicRelocation symbolicRelocation in relocationList) @@ -437,7 +537,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, - RelocationType = MachRelocationType.X86_64Unsigned, + RelocationType = MachNative.X86_64_RELOC_UNSIGNED, IsExternal = isExternal, IsPCRelative = false, }); @@ -450,7 +550,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, - RelocationType = MachRelocationType.X86_64Subtractor, + RelocationType = MachNative.X86_64_RELOC_SUBTRACTOR, IsExternal = true, IsPCRelative = false, }); @@ -460,7 +560,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachRelocationType.X86_64Unsigned, + RelocationType = MachNative.X86_64_RELOC_UNSIGNED, IsExternal = true, IsPCRelative = false, }); @@ -473,7 +573,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachRelocationType.X86_64Branch, + RelocationType = MachNative.X86_64_RELOC_BRANCH, IsExternal = true, IsPCRelative = true, }); @@ -487,7 +587,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc private void EmitRelocationsArm64(int sectionIndex, List relocationList) { - ICollection sectionRelocations = _segment.Sections[sectionIndex].Relocations; + ICollection sectionRelocations = _sections[sectionIndex].Relocations; relocationList.Reverse(); foreach (SymbolicRelocation symbolicRelocation in relocationList) @@ -502,7 +602,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachRelocationType.Arm64Branch26, + RelocationType = MachNative.ARM64_RELOC_BRANCH26, IsExternal = true, IsPCRelative = true, }); @@ -517,16 +617,16 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)symbolicRelocation.Addend, Length = 4, - RelocationType = MachRelocationType.Arm64Addend, + RelocationType = MachNative.ARM64_RELOC_ADDEND, IsExternal = false, IsPCRelative = false, }); } - MachRelocationType type = symbolicRelocation.Type switch + byte type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => MachRelocationType.Arm64Page21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => MachRelocationType.Arm64PageOffset21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => MachNative.ARM64_RELOC_PAGE21, + RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => MachNative.ARM64_RELOC_PAGEOFF12, _ => 0 }; @@ -550,7 +650,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, - RelocationType = MachRelocationType.Arm64Unsigned, + RelocationType = MachNative.ARM64_RELOC_UNSIGNED, IsExternal = isExternal, IsPCRelative = false, }); @@ -564,7 +664,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, - RelocationType = MachRelocationType.Arm64Subtractor, + RelocationType = MachNative.ARM64_RELOC_SUBTRACTOR, IsExternal = true, IsPCRelative = false, }); @@ -574,7 +674,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachRelocationType.Arm64Unsigned, + RelocationType = MachNative.ARM64_RELOC_UNSIGNED, IsExternal = true, IsPCRelative = false, }); @@ -588,16 +688,24 @@ private void EmitRelocationsArm64(int sectionIndex, List rel private void EmitCompactUnwindTable(IDictionary definedSymbols) { - using Stream compactUnwindStream = _compactUnwindSection.GetWriteStream(); + _compactUnwindStream = new MemoryStream(32 * _compactUnwindCodes.Count); + // Preset the size of the compact unwind section which is not generated yet + _compactUnwindStream.SetLength(32 * _compactUnwindCodes.Count); + + _compactUnwindSection = new MachSection("__LD", "__compact_unwind", _compactUnwindStream) + { + Log2Alignment = 3, + Flags = MachNative.S_REGULAR | MachNative.S_ATTR_DEBUG, + }; - IList symbols = _symbolTable.Symbols; + IList symbols = _symbolTable; Span tempBuffer = stackalloc byte[8]; foreach (var cu in _compactUnwindCodes) { EmitCompactUnwindSymbol(cu.PcStartSymbolName); BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, cu.PcLength); BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer.Slice(4), cu.Code); - compactUnwindStream.Write(tempBuffer); + _compactUnwindStream.Write(tempBuffer); EmitCompactUnwindSymbol(cu.PersonalitySymbolName); EmitCompactUnwindSymbol(cu.LsdaSymbolName); } @@ -608,21 +716,21 @@ void EmitCompactUnwindSymbol(string symbolName) if (symbolName != null) { SymbolDefinition symbol = definedSymbols[symbolName]; - MachSection section = _segment.Sections[symbol.SectionIndex]; + MachSection section = _sections[symbol.SectionIndex]; BinaryPrimitives.WriteUInt64LittleEndian(tempBuffer, section.VirtualAddress + (ulong)symbol.Value); _compactUnwindSection.Relocations.Add( new MachRelocation { - Address = (int)compactUnwindStream.Position, + Address = (int)_compactUnwindStream.Position, SymbolOrSectionIndex = (byte)(1 + symbol.SectionIndex), // 1-based Length = 8, - RelocationType = MachRelocationType.Arm64Unsigned, + RelocationType = MachNative.ARM64_RELOC_UNSIGNED, IsExternal = false, IsPCRelative = false, } ); } - compactUnwindStream.Write(tempBuffer); + _compactUnwindStream.Write(tempBuffer); } } @@ -653,7 +761,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt { uint encoding = _compactUnwindDwarfCode; - if (_objectFile.CpuType == MachCpuType.Arm64) + if (_cpuType == MachCpuType.Arm64) { if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) { @@ -673,5 +781,285 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt } private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); + + public enum MachCpuType : uint + { + X86 = 7, + X86_64 = X86 | Architecture64, + Arm = 12, + Arm64 = Arm | Architecture64, + Architecture64 = 0x1000000, + } + + private struct MachHeader64 + { + public MachCpuType CpuType { get; set; } + public uint CpuSubType { get; set; } + public uint FileType { get; set; } + public uint NumberOfCommands { get; set; } + public uint SizeOfCommands { get; set; } + public uint Flags { get; set; } + public uint Reserved { get; set; } + + public static int HeaderSize => 32; + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.MH_MAGIC_64); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)CpuType); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), CpuSubType); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), FileType); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(16, 4), NumberOfCommands); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(20, 4), SizeOfCommands); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(24, 4), Flags); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(28, 4), Reserved); + + stream.Write(buffer); + } + } + + public struct MachSegment64Header + { + public string Name { get; set; } + public ulong Address { get; set; } + public ulong Size { get; set; } + public ulong FileOffset { get; set; } + public ulong FileSize { get; set; } + public uint MaximumProtection { get; set; } + public uint InitialProtection { get; set; } + public uint NumberOfSections { get; set; } + public uint Flags { get; set; } + + public static int HeaderSize => 72; + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.LC_SEGMENT_64); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)(HeaderSize + NumberOfSections * MachSection.HeaderSize)); + Debug.Assert(Encoding.UTF8.TryGetBytes(Name, buffer.Slice(8, 16), out _)); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(24, 8), Address); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(32, 8), Size); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(40, 8), FileOffset); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(48, 8), FileSize); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(56, 4), MaximumProtection); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(60, 4), InitialProtection); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(64, 4), NumberOfSections); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(68, 4), Flags); + + stream.Write(buffer); + } + } + + private sealed class MachSection + { + private Stream dataStream; + private List relocationCollection; + + public string SectionName { get; private init; } + public string SegmentName { get; private init; } + public ulong VirtualAddress { get; set; } + public ulong Size => (ulong)dataStream.Length; + public uint FileOffset { get; set; } + public uint Log2Alignment { get; set; } + public uint RelocationOffset { get; set; } + public uint NumberOfRelocationEntries => relocationCollection is null ? 0u : (uint)relocationCollection.Count; + public uint Flags { get; set; } + + public uint Type => Flags & 0xff; + public bool IsInFile => Size > 0 && Type != MachNative.S_ZEROFILL && Type != MachNative.S_GB_ZEROFILL && Type != MachNative.S_THREAD_LOCAL_ZEROFILL; + + public IList Relocations => relocationCollection ??= new List(); + public Stream Stream => dataStream; + public byte SectionIndex { get; set; } + + public static int HeaderSize => 80; // 64-bit section + + public MachSection(string segmentName, string sectionName, Stream stream) + { + ArgumentNullException.ThrowIfNull(segmentName); + ArgumentNullException.ThrowIfNull(sectionName); + + this.SegmentName = segmentName; + this.SectionName = sectionName; + this.dataStream = stream; + this.relocationCollection = null; + } + + public void WriteHeader(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + buffer.Clear(); + Debug.Assert(Encoding.UTF8.TryGetBytes(SectionName, buffer.Slice(0, 16), out _)); + Debug.Assert(Encoding.UTF8.TryGetBytes(SegmentName, buffer.Slice(16, 16), out _)); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(32, 8), VirtualAddress); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(40, 8), Size); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(48, 4), FileOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(52, 4), Log2Alignment); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(56, 4), RelocationOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(60, 4), NumberOfRelocationEntries); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(64, 4), Flags); + + stream.Write(buffer); + } + } + + private sealed class MachRelocation + { + public int Address { get; init; } + public uint SymbolOrSectionIndex { get; init; } + public bool IsPCRelative { get; init; } + public bool IsExternal { get; init; } + public byte Length { get; init; } + public byte RelocationType { get; init; } + + public void Write(FileStream stream) + { + Span relocationBuffer = stackalloc byte[8]; + uint info = SymbolOrSectionIndex; + info |= IsPCRelative ? 0x1_00_00_00u : 0u; + info |= Length switch { 1 => 0u << 25, 2 => 1u << 25, 4 => 2u << 25, _ => 3u << 25 }; + info |= IsExternal ? 0x8_00_00_00u : 0u; + info |= (uint)RelocationType << 28; + BinaryPrimitives.WriteInt32LittleEndian(relocationBuffer, Address); + BinaryPrimitives.WriteUInt32LittleEndian(relocationBuffer.Slice(4), info); + stream.Write(relocationBuffer); + } + } + + private sealed class MachSymbol + { + public string Name { get; init; } = string.Empty; + public byte Type { get; init; } + public MachSection Section { get; init; } + public ushort Descriptor { get; init; } + public ulong Value { get; init; } + + public void Write(FileStream stream, MachStringTable stringTable) + { + Span buffer = stackalloc byte[16]; + uint nameIndex = stringTable.GetStringOffset(Name); + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), nameIndex); + buffer[4] = Type; + buffer[5] = (byte)(Section?.SectionIndex ?? 0); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(6, 2), Descriptor); + BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(8), Value); + + stream.Write(buffer); + } + } + + private sealed class MachSymbolTableCommandHeader + { + public uint SymbolTableOffset { get; set; } + public uint NumberOfSymbols { get; set; } + public uint StringTableOffset { get; set; } + public uint StringTableSize { get; set; } + + public static int HeaderSize => 24; + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), (uint)MachNative.LC_SYMTAB); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), SymbolTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), NumberOfSymbols); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(16, 4), StringTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(20, 4), StringTableSize); + + stream.Write(buffer); + } + } + + private sealed class MachDynamicLinkEditSymbolTable + { + public uint LocalSymbolsIndex { get; set; } + public uint LocalSymbolsCount { get; set; } + public uint ExternalSymbolsIndex { get; set; } + public uint ExternalSymbolsCount { get; set; } + public uint UndefinedSymbolsIndex { get; set; } + public uint UndefinedSymbolsCount { get; set; } + public uint TableOfContentsOffset { get; set; } + public uint TableOfContentsCount { get; set; } + public uint ModuleTableOffset { get; set; } + public uint ModuleTableCount { get; set; } + public uint ExternalReferenceTableOffset { get; set; } + public uint ExternalReferenceTableCount { get; set; } + public uint IndirectSymbolTableOffset { get; set; } + public uint IndirectSymbolTableCount { get; set; } + public uint ExternalRelocationTableOffset { get; set; } + public uint ExternalRelocationTableCount { get; set; } + public uint LocalRelocationTableOffset { get; set; } + public uint LocalRelocationTableCount { get; set; } + + public static int HeaderSize => 80; + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), (uint)MachNative.LC_DYSYMTAB); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), LocalSymbolsIndex); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), LocalSymbolsCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(16, 4), ExternalSymbolsIndex); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(20, 4), ExternalSymbolsCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(24, 4), UndefinedSymbolsIndex); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(28, 4), UndefinedSymbolsCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(32, 4), TableOfContentsOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(36, 4), TableOfContentsCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(40, 4), ModuleTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(44, 4), ModuleTableCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(48, 4), ExternalReferenceTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(52, 4), ExternalReferenceTableCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(56, 4), IndirectSymbolTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(60, 4), IndirectSymbolTableCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(64, 4), ExternalRelocationTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(68, 4), ExternalRelocationTableCount); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(72, 4), LocalRelocationTableOffset); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(76, 4), LocalRelocationTableCount); + + stream.Write(buffer); + } + } + + private struct MachBuildVersionCommandHeader + { + public uint Platform; + public uint MinimumPlatformVersion { get; set; } + public uint SdkVersion { get; set; } + + public static int HeaderSize => 24; + + public void Write(FileStream stream) + { + Span buffer = stackalloc byte[HeaderSize]; + + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.LC_BUILD_VERSION); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), Platform); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), MinimumPlatformVersion); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(16, 4), SdkVersion); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(20, 4), 0); // No tools + + stream.Write(buffer); + } + } + + private sealed class MachStringTable : StringTableBuilder + { + public MachStringTable() + { + // Always start the table with empty string + GetStringOffset(""); + } + } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 667b5e698954b3..14eeb7baf2ca43 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -23,8 +23,6 @@ - - all contentfiles @@ -608,6 +606,7 @@ + diff --git a/src/coreclr/tools/aot/external/Directory.Build.props b/src/coreclr/tools/aot/external/Directory.Build.props deleted file mode 100644 index fe6c0d71e74a72..00000000000000 --- a/src/coreclr/tools/aot/external/Directory.Build.props +++ /dev/null @@ -1,5 +0,0 @@ - - - true - - diff --git a/src/coreclr/tools/aot/external/Directory.Build.targets b/src/coreclr/tools/aot/external/Directory.Build.targets deleted file mode 100644 index 058246e4086204..00000000000000 --- a/src/coreclr/tools/aot/external/Directory.Build.targets +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln b/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln deleted file mode 100644 index c2355ef7d1de9a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/CodeSign.sln +++ /dev/null @@ -1,49 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.4.32804.182 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.MachO", "Melanzana.MachO\Melanzana.MachO.csproj", "{22C66789-5A44-4C01-BFB8-8B10B45A2210}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.MachO.Tests", "Melanzana.MachO.Tests\Melanzana.MachO.Tests.csproj", "{B737E062-8A7C-48D2-8A51-645FA72FF378}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.BinaryFormat.Generator", "Melanzana.BinaryFormat.Generator\Melanzana.BinaryFormat.Generator.csproj", "{FD313869-B418-414C-BF94-357B82C5D6EB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.CodeSign", "Melanzana.CodeSign\Melanzana.CodeSign.csproj", "{727881F8-EBCD-42BD-97FE-BEE9917D4A5E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Melanzana.CodeSign.Tests", "Melanzana.CodeSign.Tests\Melanzana.CodeSign.Tests.csproj", "{30D19045-7A46-4993-B018-1F60397A741D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Debug|Any CPU.Build.0 = Debug|Any CPU - {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Release|Any CPU.ActiveCfg = Release|Any CPU - {22C66789-5A44-4C01-BFB8-8B10B45A2210}.Release|Any CPU.Build.0 = Release|Any CPU - {B737E062-8A7C-48D2-8A51-645FA72FF378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B737E062-8A7C-48D2-8A51-645FA72FF378}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B737E062-8A7C-48D2-8A51-645FA72FF378}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B737E062-8A7C-48D2-8A51-645FA72FF378}.Release|Any CPU.Build.0 = Release|Any CPU - {FD313869-B418-414C-BF94-357B82C5D6EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FD313869-B418-414C-BF94-357B82C5D6EB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FD313869-B418-414C-BF94-357B82C5D6EB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FD313869-B418-414C-BF94-357B82C5D6EB}.Release|Any CPU.Build.0 = Release|Any CPU - {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {727881F8-EBCD-42BD-97FE-BEE9917D4A5E}.Release|Any CPU.Build.0 = Release|Any CPU - {30D19045-7A46-4993-B018-1F60397A741D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30D19045-7A46-4993-B018-1F60397A741D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30D19045-7A46-4993-B018-1F60397A741D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30D19045-7A46-4993-B018-1F60397A741D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {833B1134-2178-41C7-B073-9287649F065E} - EndGlobalSection -EndGlobal diff --git a/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props b/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props deleted file mode 100644 index 03043b5e30be77..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Directory.Build.props +++ /dev/null @@ -1,13 +0,0 @@ - - - true - true - true - snupkg - - - - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/LICENSE b/src/coreclr/tools/aot/external/Melanzana/LICENSE deleted file mode 100644 index bfbd7349b9ddde..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Filip Navara - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs deleted file mode 100644 index 28504bf71a34fe..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/DataMemberSymbol.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Immutable; -using System.Diagnostics; -using Microsoft.CodeAnalysis; - -namespace BinaryFormat -{ - /// - /// Represents a member with no arguments, namely a field or property - /// - internal readonly struct DataMemberSymbol - { - private readonly ISymbol _symbol; - public DataMemberSymbol(ISymbol symbol) - { - Debug.Assert(symbol is - IFieldSymbol or - IPropertySymbol { Parameters: { Length: 0 }}); - _symbol = symbol; - } - - public ISymbol Symbol => _symbol; - - public ITypeSymbol Type => _symbol switch - { - IFieldSymbol f => f.Type, - IPropertySymbol p => p.Type, - _ => throw new InvalidOperationException() - }; - - public ImmutableArray Locations => _symbol.Locations; - - public string Name => _symbol.Name; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs deleted file mode 100644 index 00f30d345c9364..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.Attribute.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Diagnostics; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; - -namespace BinaryFormat -{ - public partial class Generator : ISourceGenerator - { - private const string AttributeSource = @" -#nullable disable - -[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] -internal sealed class GenerateReaderWriterAttribute : System.Attribute -{ - public GenerateReaderWriterAttribute() {} -} - -[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] -internal sealed class BigEndianAttribute : System.Attribute -{ - public BigEndianAttribute() {} -} - -[System.AttributeUsage(System.AttributeTargets.Struct | System.AttributeTargets.Class)] -internal sealed class LittleEndianAttribute : System.Attribute -{ - public LittleEndianAttribute() {} -} -"; - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs deleted file mode 100644 index 8e8e780cf4ac0b..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.ReadWrite.cs +++ /dev/null @@ -1,367 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace BinaryFormat -{ - public partial class Generator : ISourceGenerator - { - private void GenerateReaderWriter( - GeneratorExecutionContext context, - TypeDeclarationSyntax typeDecl, - SemanticModel semanticModel) - { - if (!typeDecl.Modifiers.Any(tok => tok.IsKind(SyntaxKind.PartialKeyword))) - { - // Type must be partial - context.ReportDiagnostic( - Diagnostic.Create( - "TypeMustBePartial", - category: "BinaryFormat", - $"Type {typeDecl.Identifier.ValueText} must be partial", - severity: DiagnosticSeverity.Error, - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - warningLevel: 0, - location: typeDecl.Identifier.GetLocation())); - return; - } - - var containerSymbol = semanticModel.GetDeclaredSymbol(typeDecl)!; - ITypeSymbol receiverType = containerSymbol; - - bool hasBigEndianAttribute = containerSymbol.GetAttributes().Any(a => a.AttributeClass.Name == "BigEndianAttribute"); - bool hasLittleEndianAttribute = containerSymbol.GetAttributes().Any(a => a.AttributeClass.Name == "LittleEndianAttribute"); - - var fieldsAndProps = receiverType.GetMembers() - .Where(m => m is { - DeclaredAccessibility: Accessibility.Public, - Kind: SymbolKind.Field or SymbolKind.Property, - }) - .Select(m => new DataMemberSymbol(m)).ToList(); - - var stringBuilder = new StringBuilder(); - string classOrStruct = typeDecl is ClassDeclarationSyntax ? "class" : "struct"; - - // FIXME: modifiers, class/struct/record - stringBuilder.AppendLine($"using System.Buffers.Binary;"); - stringBuilder.AppendLine($""); - stringBuilder.AppendLine($"namespace {containerSymbol.ContainingNamespace}"); - stringBuilder.AppendLine($"{{"); - stringBuilder.AppendLine($" public partial {classOrStruct} {typeDecl.Identifier}"); - stringBuilder.AppendLine($" {{"); - - // Try to generate the static size constant - GenerateBinarySize(context, typeDecl, semanticModel, stringBuilder, fieldsAndProps); - - if (hasLittleEndianAttribute && !hasBigEndianAttribute) - { - GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "", "LittleEndian", fieldsAndProps); - stringBuilder.AppendLine(); - GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "", "LittleEndian", fieldsAndProps); - } - else if (hasBigEndianAttribute && !hasLittleEndianAttribute) - { - GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "", "BigEndian", fieldsAndProps); - stringBuilder.AppendLine(); - GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "", "BigEndian", fieldsAndProps); - } - else - { - GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "LittleEndian", "LittleEndian", fieldsAndProps); - stringBuilder.AppendLine(); - GenerateReadMethod(context, typeDecl, semanticModel, stringBuilder, "BigEndian", "BigEndian", fieldsAndProps); - stringBuilder.AppendLine(); - stringBuilder.AppendLine($" public static {typeDecl.Identifier} Read(ReadOnlySpan buffer, bool isLittleEndian, out int bytesRead)"); - stringBuilder.AppendLine($" {{"); - stringBuilder.AppendLine($" return isLittleEndian ? ReadLittleEndian(buffer, out bytesRead) : ReadBigEndian(buffer, out bytesRead);"); - stringBuilder.AppendLine($" }}"); - stringBuilder.AppendLine(); - GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "LittleEndian", "LittleEndian", fieldsAndProps); - stringBuilder.AppendLine(); - GenerateWriteMethod(context, typeDecl, semanticModel, stringBuilder, "BigEndian", "BigEndian", fieldsAndProps); - stringBuilder.AppendLine(); - stringBuilder.AppendLine($" public void Write(Span buffer, bool isLittleEndian, out int bytesWritten)"); - stringBuilder.AppendLine($" {{"); - stringBuilder.AppendLine($" if (isLittleEndian)"); - stringBuilder.AppendLine($" {{"); - stringBuilder.AppendLine($" WriteLittleEndian(buffer, out bytesWritten);"); - stringBuilder.AppendLine($" }}"); - stringBuilder.AppendLine($" else"); - stringBuilder.AppendLine($" {{"); - stringBuilder.AppendLine($" WriteBigEndian(buffer, out bytesWritten);"); - stringBuilder.AppendLine($" }}"); - stringBuilder.AppendLine($" }}"); - } - - stringBuilder.AppendLine($" }}"); - stringBuilder.AppendLine($"}}"); - - context.AddSource($"{containerSymbol.Name}.Generated.cs", stringBuilder.ToString()); - } - - private void GenerateBinarySize( - GeneratorExecutionContext context, - TypeDeclarationSyntax typeDecl, - SemanticModel semanticModel, - StringBuilder stringBuilder, - List fieldsAndProps) - { - int size = 0; - //StringBuilder variableOffset = new StringBuilder(); - //int variableOffsetIndex = 1; - - foreach (var m in fieldsAndProps) - { - var memberType = m.Type; - - if (memberType.TypeKind == TypeKind.Enum && - memberType is INamedTypeSymbol nts) - { - memberType = nts.EnumUnderlyingType; - } - - switch (memberType.SpecialType) - { - case SpecialType.System_UInt16: - case SpecialType.System_UInt32: - case SpecialType.System_UInt64: - case SpecialType.System_Int16: - case SpecialType.System_Int32: - case SpecialType.System_Int64: - int basicTypeSize = memberType.SpecialType switch - { - SpecialType.System_UInt16 => 2, - SpecialType.System_UInt32 => 4, - SpecialType.System_UInt64 => 8, - SpecialType.System_Int16 => 2, - SpecialType.System_Int32 => 4, - SpecialType.System_Int64 => 8, - _ => 0 - }; - size += basicTypeSize; - break; - - case SpecialType.System_Byte: - size++; - break; - - default: - var binarySizeField = memberType.GetMembers().OfType().FirstOrDefault(f => f.Name == "BinarySize"); - if (binarySizeField != null && binarySizeField.ConstantValue is int binarySize) - { - // Handle nested types that have `const int BinarySize` - size += binarySize; - break; - } - return; - } - } - - stringBuilder.AppendLine($" public const int BinarySize = {size};"); - stringBuilder.AppendLine(); - } - - private void GenerateReadMethod( - GeneratorExecutionContext context, - TypeDeclarationSyntax typeDecl, - SemanticModel semanticModel, - StringBuilder stringBuilder, - string nameSuffix, - string endianSuffix, - List fieldsAndProps) - { - int offset = 0; - StringBuilder variableOffset = new StringBuilder(); - int variableOffsetIndex = 1; - - stringBuilder.AppendLine($" public static {typeDecl.Identifier} Read{nameSuffix}(ReadOnlySpan buffer, out int bytesRead)"); - stringBuilder.AppendLine($" {{"); - stringBuilder.AppendLine($" var result = new {typeDecl.Identifier}"); - stringBuilder.AppendLine($" {{"); - - foreach (var m in fieldsAndProps) - { - var memberType = m.Type; - string? readExpression; - string castExpression = ""; - - if (memberType.TypeKind == TypeKind.Enum && - memberType is INamedTypeSymbol nts) - { - // FIXME: Namespace - castExpression = $"({memberType.Name})"; - memberType = nts.EnumUnderlyingType; - } - - switch (memberType.SpecialType) - { - // Endianness aware basic types - case SpecialType.System_UInt16: - case SpecialType.System_UInt32: - case SpecialType.System_UInt64: - case SpecialType.System_Int16: - case SpecialType.System_Int32: - case SpecialType.System_Int64: - string? basicTypeName = memberType.SpecialType switch - { - SpecialType.System_UInt16 => "UInt16", - SpecialType.System_UInt32 => "UInt32", - SpecialType.System_UInt64 => "UInt64", - SpecialType.System_Int16 => "Int16", - SpecialType.System_Int32 => "Int32", - SpecialType.System_Int64 => "Int64", - _ => throw new InvalidOperationException() - }; - int basicTypeSize = memberType.SpecialType switch - { - SpecialType.System_UInt16 => 2, - SpecialType.System_UInt32 => 4, - SpecialType.System_UInt64 => 8, - SpecialType.System_Int16 => 2, - SpecialType.System_Int32 => 4, - SpecialType.System_Int64 => 8, - _ => 0 - }; - readExpression = $"{castExpression}BinaryPrimitives.Read{basicTypeName}{endianSuffix}(buffer.Slice({offset}{variableOffset}, {basicTypeSize}))"; - offset += basicTypeSize; - break; - - case SpecialType.System_Byte: - readExpression = $"{castExpression}buffer[{offset}{variableOffset}]"; - offset ++; - break; - - default: - var methods = memberType.GetMembers().OfType(); - if (methods.Any(m => m.Name == $"Read{nameSuffix}")) - { - // FIXME: Missing namespace - readExpression = $"{m.Type.Name}.Read{nameSuffix}(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; - } - else - { - // FIXME: Missing namespace - readExpression = $"{m.Type.Name}.Read(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; - } - - variableOffset.Append($" + _{variableOffsetIndex}"); - variableOffsetIndex++; - - // FIXME: Handle other basic type - // FIXME: Handle nested struct/classes by calling their Read - //throw new NotSupportedException(); - break; - } - - stringBuilder.AppendLine($" {m.Name} = {readExpression},"); - } - - stringBuilder.AppendLine($" }};"); - stringBuilder.AppendLine($" bytesRead = {offset}{variableOffset};"); - stringBuilder.AppendLine($" return result;"); - stringBuilder.AppendLine($" }}"); - } - - private void GenerateWriteMethod( - GeneratorExecutionContext context, - TypeDeclarationSyntax typeDecl, - SemanticModel semanticModel, - StringBuilder stringBuilder, - string nameSuffix, - string endianSuffix, - List fieldsAndProps) - { - int offset = 0; - StringBuilder variableOffset = new StringBuilder(); - int variableOffsetIndex = 1; - - stringBuilder.AppendLine($" public void Write{nameSuffix}(Span buffer, out int bytesWritten)"); - stringBuilder.AppendLine($" {{"); - - foreach (var m in fieldsAndProps) - { - var memberType = m.Type; - string? writeExpression; - string castExpression = ""; - - if (memberType.TypeKind == TypeKind.Enum && - memberType is INamedTypeSymbol nts) - { - // FIXME: Namespace - memberType = nts.EnumUnderlyingType; - castExpression = $"({memberType.Name})"; - } - - switch (memberType.SpecialType) - { - // Endianness aware basic types - case SpecialType.System_UInt16: - case SpecialType.System_UInt32: - case SpecialType.System_UInt64: - case SpecialType.System_Int16: - case SpecialType.System_Int32: - case SpecialType.System_Int64: - string? basicTypeName = memberType.SpecialType switch - { - SpecialType.System_UInt16 => "UInt16", - SpecialType.System_UInt32 => "UInt32", - SpecialType.System_UInt64 => "UInt64", - SpecialType.System_Int16 => "Int16", - SpecialType.System_Int32 => "Int32", - SpecialType.System_Int64 => "Int64", - _ => throw new InvalidOperationException() - }; - int basicTypeSize = memberType.SpecialType switch - { - SpecialType.System_UInt16 => 2, - SpecialType.System_UInt32 => 4, - SpecialType.System_UInt64 => 8, - SpecialType.System_Int16 => 2, - SpecialType.System_Int32 => 4, - SpecialType.System_Int64 => 8, - _ => 0 - }; - writeExpression = $"BinaryPrimitives.Write{basicTypeName}{endianSuffix}(buffer.Slice({offset}{variableOffset}, {basicTypeSize}), {castExpression}{m.Name})"; - offset += basicTypeSize; - break; - - case SpecialType.System_Byte: - writeExpression = $"buffer[{offset}{variableOffset}] = {castExpression}{m.Name}"; - offset ++; - break; - - default: - var methods = memberType.GetMembers().OfType(); - if (methods.Any(m => m.Name == $"Write{nameSuffix}")) - { - // FIXME: Missing namespace - writeExpression = $"{m.Name}.Write{nameSuffix}(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; - } - else - { - // FIXME: Missing namespace - writeExpression = $"{m.Name}.Write(buffer.Slice({offset}{variableOffset}), out var _{variableOffsetIndex})"; - } - - variableOffset.Append($" + _{variableOffsetIndex}"); - variableOffsetIndex++; - - // FIXME: Handle other basic type - // FIXME: Handle nested struct/classes by calling their Read - //throw new NotSupportedException(); - break; - } - - stringBuilder.AppendLine($" {writeExpression};"); - } - - stringBuilder.AppendLine($" bytesWritten = {offset}{variableOffset};"); - stringBuilder.AppendLine($" }}"); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs deleted file mode 100644 index 5ed215375b5173..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Generator.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Diagnostics; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; - -namespace BinaryFormat -{ - [Generator] - public partial class Generator : ISourceGenerator - { - public void Initialize(GeneratorInitializationContext context) - { -#if DEBUG - //if (!Debugger.IsAttached) - //{ - // Debugger.Launch(); - //} -#endif - - context.RegisterForPostInitialization((pi) => pi.AddSource("BinaryFormat.Attribute.cs", AttributeSource)); - context.RegisterForSyntaxNotifications(() => new MySyntaxReceiver()); - } - - public void Execute(GeneratorExecutionContext context) - { - MySyntaxReceiver syntaxReceiver = (MySyntaxReceiver)context.SyntaxContextReceiver; - - foreach (var userType in syntaxReceiver.TypesToAugment) - { - GenerateReaderWriter(context, userType, context.Compilation.GetSemanticModel(userType.SyntaxTree)); - } - } - - class MySyntaxReceiver : ISyntaxContextReceiver - { - public List TypesToAugment { get; private set; } = new(); - - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) - { - if (context.Node is TypeDeclarationSyntax tds && - context.SemanticModel.GetDeclaredSymbol(tds) is INamedTypeSymbol symbol && - symbol.GetAttributes().Any(a => a.AttributeClass.Name == "GenerateReaderWriterAttribute")) - { - TypesToAugment.Add(tds); - } - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj deleted file mode 100644 index 5bce006fbb24a3..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.BinaryFormat.Generator/Melanzana.BinaryFormat.Generator.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - netstandard2.0 - latest - annotations - - - - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Data/a.out deleted file mode 100755 index ce1e62c9c1815e7e57ab6ca0fa0cb6eac842a59d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34976 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 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj deleted file mode 100644 index 50161ce7e9df48..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/Melanzana.CodeSign.Tests.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs deleted file mode 100644 index efd7984b572d18..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/RequirementTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Xunit; -using System.IO; -using System.Linq; -using Melanzana.CodeSign.Requirements; - -namespace Melanzana.CodeSign.Tests -{ - public class RequirementTest - { - [Fact] - public void DefaultRequirement() - { - var defaultReq = RequirementSet.CreateDefault("BUNDLE ID", "FRIENDLY NAME")[RequirementType.Designated]; - var stringExpr = "identifier \"BUNDLE ID\" and anchor apple generic and certificate leaf[subject.CN] = \"FRIENDLY NAME\" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */"; - - // Check string representation - Assert.Equal(stringExpr, defaultReq.ToString()); - - // Check binary round-trip - var expr = new byte[defaultReq.Expression.Size]; - defaultReq.Expression.Write(expr, out var exprBytesWritten); - Assert.Equal(expr.Length, exprBytesWritten); - var readExpression = Expression.FromBlob(expr); - Assert.Equal(stringExpr, readExpression.ToString()); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs deleted file mode 100644 index 23bf073738028f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign.Tests/ResignTest.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Xunit; -using System.IO; -using System.Linq; -using Melanzana.CodeSign.Requirements; -using Melanzana.MachO; -using Melanzana.Streams; - -namespace Melanzana.CodeSign.Tests -{ - public class ResignTest - { - [Fact] - public void Resign() - { - // Read the test executable - var aOutStream = typeof(ResignTest).Assembly.GetManifestResourceStream("Melanzana.CodeSign.Tests.Data.a.out")!; - var objectFile = MachReader.Read(aOutStream).FirstOrDefault(); - Assert.NotNull(objectFile); - - // Strip the signature - var codeSignature = objectFile!.LoadCommands.OfType().FirstOrDefault(); - Assert.NotNull(codeSignature); - var originalSignatureSize = codeSignature!.FileSize; - objectFile!.LoadCommands.Remove(codeSignature); - - // Write the stripped file to disk - var tempFileName = Path.GetTempFileName(); - using (var tempFile = new FileStream(tempFileName, FileMode.Create)) - { - MachWriter.Write(tempFile, objectFile); - Assert.Equal(aOutStream.Length - originalSignatureSize, tempFile.Length); - } - - // Ad-hoc sign the file - var codeSignOptions = new CodeSignOptions { }; - var signer = new Signer(codeSignOptions); - signer.Sign(tempFileName); - - // TODO: Check signature - - File.Delete(tempFileName); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs deleted file mode 100644 index 8e85bc91ad1682..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/AppleCertificateExtensions.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Formats.Asn1; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; - -namespace Melanzana.CodeSign -{ - public static class AppleCertificateExtensions - { - private const string OrganizationalUnit = "2.5.4.11"; - - private static string ReadAnyAsnString(this AsnReader tavReader) - { - Asn1Tag tag = tavReader.PeekTag(); - - if (tag.TagClass != TagClass.Universal) - { - throw new CryptographicException("Invalid DER encoding"); - } - - switch ((UniversalTagNumber)tag.TagValue) - { - case UniversalTagNumber.BMPString: - case UniversalTagNumber.IA5String: - case UniversalTagNumber.NumericString: - case UniversalTagNumber.PrintableString: - case UniversalTagNumber.UTF8String: - case UniversalTagNumber.T61String: - // .NET's string comparisons start by checking the length, so a trailing - // NULL character which was literally embedded in the DER would cause a - // failure in .NET whereas it wouldn't have with strcmp. - return tavReader.ReadCharacterString((UniversalTagNumber)tag.TagValue).TrimEnd('\0'); - - default: - throw new CryptographicException("Invalid DER encoding"); - } - } - - public static bool IsAppleDeveloperCertificate(this X509Certificate2 certificate) - { - // FIXME: We should check the certificate anchor and only allow the following OIDs in extensions: - // 1.2.840.113635.100.6.1.2 (WWDR) - // 1.2.840.113635.100.6.1.12 (MACWWDR) - // 1.2.840.113635.100.6.1.13 (Developer ID) - // 1.2.840.113635.100.6.1.7 (Distribution) - // 1.2.840.113635.100.6.1.4 (iPhone Distribution) - return certificate.Extensions.Any(e => e.Oid?.Value?.StartsWith("1.2.840.113635.100.6.1.") ?? false); - } - - public static string GetTeamId(this X509Certificate2 certificate) - { - if (certificate.IsAppleDeveloperCertificate()) - { - AsnReader x500NameReader = new AsnReader(certificate.SubjectName.RawData, AsnEncodingRules.DER); - AsnReader x500NameSequenceReader = x500NameReader.ReadSequence(); - while (x500NameSequenceReader.HasData) - { - var rdnReader = x500NameSequenceReader.ReadSetOf(skipSortOrderValidation: true); - while (rdnReader.HasData) - { - AsnReader tavReader = rdnReader.ReadSequence(); - string oid = tavReader.ReadObjectIdentifier(); - string attributeValue = tavReader.ReadAnyAsnString(); - if (oid == OrganizationalUnit) - { - return attributeValue; - } - } - } - } - - return string.Empty; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs deleted file mode 100644 index 0d0f2ecbf71fba..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/BlobMagic.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum BlobMagic : uint - { - Requirement = 0xfade0c00, - Requirements = 0xfade0c01, - CodeDirectory = 0xfade0c02, - EmbeddedSignature = 0xfade0cc0, - DetachedSignature = 0xfade0cc1, - CmsWrapper = 0xfade0b01, - Entitlements = 0xfade7171, - EntitlementsDer = 0xfade7172, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs deleted file mode 100644 index c30793b8a2283c..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CmsWrapperBlob.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System.Buffers.Binary; -using System.Diagnostics; -using System.Formats.Asn1; -using System.Security.Cryptography; -using System.Security.Cryptography.Pkcs; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using Claunia.PropertyList; - -namespace Melanzana.CodeSign.Blobs -{ - public class CmsWrapperBlob - { - private readonly static string rootCertificatePath = "Melanzana.CodeSign.Certificates.RootCertificate.cer"; - private readonly static string g1IntermediateCertificatePath = "Melanzana.CodeSign.Certificates.IntermediateG1Certificate.cer"; - private readonly static string g3IntermediateCertificatePath = "Melanzana.CodeSign.Certificates.IntermediateG3Certificate.cer"; - - private static X509Certificate2 GetManifestCertificate(string name) - { - var memoryStream = new MemoryStream(); - using (var manifestStream = typeof(CmsWrapperBlob).Assembly.GetManifestResourceStream(name)) - { - Debug.Assert(manifestStream != null); - manifestStream.CopyTo(memoryStream); - } - return new X509Certificate2(memoryStream.ToArray()); - } - - public static byte[] Create( - X509Certificate2? developerCertificate, - AsymmetricAlgorithm? privateKey, - byte[] dataToSign, - HashType[] hashTypes, - byte[][] cdHashes) - { - if (dataToSign == null) - throw new ArgumentNullException(nameof(dataToSign)); - if (hashTypes == null) - throw new ArgumentNullException(nameof(hashTypes)); - if (cdHashes == null) - throw new ArgumentNullException(nameof(cdHashes)); - if (hashTypes.Length != cdHashes.Length) - throw new ArgumentException($"Length of hashType ({hashTypes.Length} is different from length of cdHashes ({cdHashes.Length})"); - - // Ad-hoc signature - if (developerCertificate == null) - { - var adhocBlobBuffer = new byte[8]; - BinaryPrimitives.WriteUInt32BigEndian(adhocBlobBuffer.AsSpan(0, 4), (uint)BlobMagic.CmsWrapper); - BinaryPrimitives.WriteUInt32BigEndian(adhocBlobBuffer.AsSpan(4, 4), (uint)adhocBlobBuffer.Length); - return adhocBlobBuffer; - } - - var certificatesList = new X509Certificate2Collection(); - - // Try to build full chain - var chain = new X509Chain(); - var chainPolicy = new X509ChainPolicy { TrustMode = X509ChainTrustMode.CustomRootTrust }; - chainPolicy.CustomTrustStore.Add(GetManifestCertificate(rootCertificatePath)); - chainPolicy.CustomTrustStore.Add(GetManifestCertificate(g1IntermediateCertificatePath)); - chainPolicy.CustomTrustStore.Add(GetManifestCertificate(g3IntermediateCertificatePath)); - chain.ChainPolicy = chainPolicy; - if (chain.Build(developerCertificate)) - { - certificatesList.AddRange(chain.ChainElements.Select(e => e.Certificate).ToArray()); - } - else - { - // Retry with default policy and system certificate store - chain.ChainPolicy = new X509ChainPolicy(); - if (chain.Build(developerCertificate)) - { - certificatesList.AddRange(chain.ChainElements.Select(e => e.Certificate).ToArray()); - } - } - - var cmsSigner = privateKey == null ? - new CmsSigner(developerCertificate) : - new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, developerCertificate, privateKey); - cmsSigner.Certificates.AddRange(certificatesList); - cmsSigner.IncludeOption = X509IncludeOption.None; - - cmsSigner.SignedAttributes.Add(new Pkcs9SigningTime()); - - // DER version of the hash attribute - var values = new AsnEncodedDataCollection(); - var oid = new Oid("1.2.840.113635.100.9.2", null); - var plistCdHashes = new NSArray(); - for (int i = 0; i < hashTypes.Length; i++) - { - var codeDirectoryAttrWriter = new AsnWriter(AsnEncodingRules.DER); - using (codeDirectoryAttrWriter.PushSequence()) - { - codeDirectoryAttrWriter.WriteObjectIdentifier(hashTypes[i].GetOid()); - codeDirectoryAttrWriter.WriteOctetString(cdHashes[i]); - } - values.Add(new AsnEncodedData(oid, codeDirectoryAttrWriter.Encode())); - plistCdHashes.Add(new NSData(cdHashes[i].AsSpan(0, 20).ToArray())); - } - cmsSigner.SignedAttributes.Add(new CryptographicAttributeObject(oid, values)); - - // PList version of the hash attribute - var plistBytes = Encoding.UTF8.GetBytes(new NSDictionary() { ["cdhashes"] = plistCdHashes }.ToXmlPropertyList()); - var codeDirectoryPListAttrWriter = new AsnWriter(AsnEncodingRules.DER); - codeDirectoryPListAttrWriter.WriteOctetString(plistBytes); - cmsSigner.SignedAttributes.Add(new AsnEncodedData("1.2.840.113635.100.9.1", codeDirectoryPListAttrWriter.Encode())); - - var signedCms = new SignedCms(new ContentInfo(dataToSign), true); - signedCms.ComputeSignature(cmsSigner); - - var encodedCms = signedCms.Encode(); - - var blobBuffer = new byte[8 + encodedCms.Length]; - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.CmsWrapper); - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); - encodedCms.CopyTo(blobBuffer.AsSpan(8)); - - return blobBuffer; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs deleted file mode 100644 index 1c563f5139d3d0..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBaselineHeader.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryBaselineHeader - { - public BlobMagic Magic; - public uint Size; - public CodeDirectoryVersion Version; - public CodeDirectoryFlags Flags; - public uint HashesOffset; - public uint IdentifierOffset; - public uint SpecialSlotCount; - public uint CodeSlotCount; - public uint ExecutableLength; - public byte HashSize; - public HashType HashType; - public byte Platform; - public byte Log2PageSize; - public uint Reserved; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs deleted file mode 100644 index befdaabdfcea5e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryBuilder.cs +++ /dev/null @@ -1,205 +0,0 @@ -using System.Buffers.Binary; -using System.Diagnostics; -using System.Security.Cryptography; -using System.Text; -using Melanzana.MachO; -using Melanzana.Streams; - -namespace Melanzana.CodeSign.Blobs -{ - class CodeDirectoryBuilder - { - private readonly MachObjectFile executable; - private readonly string identifier; - private readonly string teamId; - private readonly uint pageSize = 4096; - private readonly byte[][] specialSlots = new byte[7][]; - private int specialSlotCount; - - public CodeDirectoryBuilder(MachObjectFile executable, string identifier, string teamId) - { - this.executable = executable; - this.identifier = identifier; - this.teamId = teamId; - - if (executable.FileType == MachFileType.Execute) - ExecutableSegmentFlags |= ExecutableSegmentFlags.MainBinary; - } - - public void SetSpecialSlotData(CodeDirectorySpecialSlot slot, byte[] data) - { - Debug.Assert((int)slot >= 1 && (int)slot <= specialSlots.Length); - specialSlots[(int)(slot - 1)] = data; - specialSlotCount = Math.Max(specialSlotCount, (int)slot); - } - - public HashType HashType { get; set; } = HashType.SHA256; - - public ExecutableSegmentFlags ExecutableSegmentFlags { get; set; } - - public CodeDirectoryFlags Flags { get; set; } - - private static int GetFixedHeaderSize(CodeDirectoryVersion version) - { - int size = CodeDirectoryBaselineHeader.BinarySize; - if (version >= CodeDirectoryVersion.SupportsScatter) - size += CodeDirectoryScatterHeader.BinarySize; - if (version >= CodeDirectoryVersion.SupportsTeamId) - size += CodeDirectoryTeamIdHeader.BinarySize; - if (version >= CodeDirectoryVersion.SupportsCodeLimit64) - size += CodeDirectoryCodeLimit64Header.BinarySize; - if (version >= CodeDirectoryVersion.SupportsExecSegment) - size += CodeDirectoryExecSegmentHeader.BinarySize; - if (version >= CodeDirectoryVersion.SupportsPreEncrypt) - size += CodeDirectoryPreencryptHeader.BinarySize; - return size; - } - - public long Size(CodeDirectoryVersion version) - { - ulong execLength = executable.GetSigningLimit(); - uint codeSlotCount = (uint)((execLength + pageSize - 1) / pageSize); - byte hashSize = HashType.GetSize(); - - byte[] utf8Identifier = Encoding.UTF8.GetBytes(identifier); - byte[] utf8TeamId = Encoding.UTF8.GetBytes(teamId); - - long codeDirectorySize = GetFixedHeaderSize(version); - codeDirectorySize += utf8Identifier.Length + 1; - if (!String.IsNullOrEmpty(teamId)) - codeDirectorySize += utf8TeamId.Length + 1; - codeDirectorySize += (specialSlotCount + codeSlotCount) * hashSize; - if (version >= CodeDirectoryVersion.SupportsPreEncrypt) - codeDirectorySize += codeSlotCount * hashSize; - - return codeDirectorySize; - } - - public byte[] Build(Stream machOStream) - { - CodeDirectoryVersion version = CodeDirectoryVersion.HighestVersion; - - ulong execLength = executable.GetSigningLimit(); - uint codeSlotCount = (uint)((execLength + pageSize - 1) / pageSize); - byte[] utf8Identifier = Encoding.UTF8.GetBytes(identifier); - byte[] utf8TeamId = Encoding.UTF8.GetBytes(teamId); - byte hashSize = HashType.GetSize(); - var size = Size(version); - byte[] blobBuffer = new byte[size]; - - var textSegment = executable.LoadCommands.OfType().First(s => s.Name == "__TEXT"); - Debug.Assert(textSegment != null); - - var baselineHeader = new CodeDirectoryBaselineHeader(); - baselineHeader.Magic = BlobMagic.CodeDirectory; - baselineHeader.Size = (uint)size; - baselineHeader.Version = version; - baselineHeader.Flags = Flags; - // baselineHeader.HashesOffset = 0; -- Filled in later - // baselineHeader.IdentifierOffset = 0; -- Filled in later - baselineHeader.SpecialSlotCount = (uint)specialSlotCount; - baselineHeader.CodeSlotCount = codeSlotCount; - baselineHeader.ExecutableLength = (execLength > uint.MaxValue) ? uint.MaxValue : (uint)execLength; - baselineHeader.HashSize = hashSize; - baselineHeader.HashType = HashType; - baselineHeader.Platform = 0; // TODO - baselineHeader.Log2PageSize = (byte)Math.Log2(pageSize); - baselineHeader.Reserved = 0; - var scatterHeader = new CodeDirectoryScatterHeader(); - scatterHeader.ScatterOffset = 0; - var teamIdHeader = new CodeDirectoryTeamIdHeader(); - // teamIdHeader.TeamIdOffset = 0; -- Filled in later - var codeLimit64Header = new CodeDirectoryCodeLimit64Header(); - codeLimit64Header.Reserved = 0; - codeLimit64Header.CodeLimit64 = execLength >= uint.MaxValue ? execLength : 0; - var execSegementHeader = new CodeDirectoryExecSegmentHeader(); - execSegementHeader.Base = textSegment.FileOffset; - execSegementHeader.Limit = textSegment.FileSize; - execSegementHeader.Flags = ExecutableSegmentFlags; - - // Fill in flexible fields - int flexibleOffset = GetFixedHeaderSize(version); - - if (version >= CodeDirectoryVersion.SupportsScatter) - { - // TODO - } - - // Identifier - baselineHeader.IdentifierOffset = (uint)flexibleOffset; - utf8Identifier.AsSpan().CopyTo(blobBuffer.AsSpan(flexibleOffset, utf8Identifier.Length)); - flexibleOffset += utf8Identifier.Length + 1; - - // Team ID - if (version >= CodeDirectoryVersion.SupportsTeamId && !string.IsNullOrEmpty(teamId)) - { - teamIdHeader.TeamIdOffset = (uint)flexibleOffset; - utf8TeamId.AsSpan().CopyTo(blobBuffer.AsSpan(flexibleOffset, utf8TeamId.Length)); - flexibleOffset += utf8TeamId.Length + 1; - } - - // Pre-encrypt hashes - if (version >= CodeDirectoryVersion.SupportsPreEncrypt) - { - // TODO - } - - var hasher = HashType.GetIncrementalHash(); - - // Special slot hashes - for (int i = specialSlotCount - 1; i >= 0; i--) - { - if (specialSlots[i] != null) - { - hasher.AppendData(specialSlots[i]); - hasher.GetHashAndReset().CopyTo(blobBuffer.AsSpan(flexibleOffset, hashSize)); - } - flexibleOffset += hashSize; - } - - baselineHeader.HashesOffset = (uint)flexibleOffset; - - // Code hashes - Span buffer = stackalloc byte[(int)pageSize]; - long remaining = (long)execLength; - while (remaining > 0) - { - int codePageSize = (int)Math.Min(remaining, 4096); - machOStream.ReadFully(buffer.Slice(0, codePageSize)); - hasher.AppendData(buffer.Slice(0, codePageSize)); - hasher.GetHashAndReset().CopyTo(blobBuffer.AsSpan(flexibleOffset, hashSize)); - remaining -= codePageSize; - flexibleOffset += hashSize; - } - - Debug.Assert(flexibleOffset == blobBuffer.Length); - - // Write headers - int writeOffset = 0; - baselineHeader.Write(blobBuffer, out var bytesWritten); - writeOffset += bytesWritten; - if (version >= CodeDirectoryVersion.SupportsScatter) - { - scatterHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); - writeOffset += bytesWritten; - } - if (version >= CodeDirectoryVersion.SupportsTeamId) - { - teamIdHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); - writeOffset += bytesWritten; - } - if (version >= CodeDirectoryVersion.SupportsCodeLimit64) - { - codeLimit64Header.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); - writeOffset += bytesWritten; - } - if (version >= CodeDirectoryVersion.SupportsExecSegment) - { - execSegementHeader.Write(blobBuffer.AsSpan(writeOffset), out bytesWritten); - writeOffset += bytesWritten; - } - - return blobBuffer; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs deleted file mode 100644 index 451df807981fd7..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryCodeLimit64Header.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryCodeLimit64Header - { - public uint Reserved; - public ulong CodeLimit64; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs deleted file mode 100644 index 685eb5b038064a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryExecSegmentHeader.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryExecSegmentHeader - { - public ulong Base; - public ulong Limit; - public ExecutableSegmentFlags Flags; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs deleted file mode 100644 index ea7e238059f8ba..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryFlags.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum CodeDirectoryFlags : uint - { - Adhoc = 2, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs deleted file mode 100644 index 10bd00a25b0130..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryPreencryptHeader.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryPreencryptHeader - { - public uint HardendRuntimeVersion; - public uint PrencryptOffset; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs deleted file mode 100644 index ec1ffd9e8155af..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryScatterHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryScatterHeader - { - public uint ScatterOffset; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs deleted file mode 100644 index 8d56a9236e262d..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectorySpecialSlot.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum CodeDirectorySpecialSlot - { - InfoPlist = 1, - Requirements = 2, - ResourceDirectory = 3, - TopDirectory = 4, - Entitlements = 5, - RepresentationSpecific = 6, - EntitlementsDer = 7, - HighestSlot = EntitlementsDer, - - CodeDirectory = 0, - AlternativeCodeDirectory = 0x1000, - CmsWrapper = 0x10000, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs deleted file mode 100644 index 1b6ef46c50be12..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryTeamIdHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - [GenerateReaderWriter] - [BigEndian] - public partial class CodeDirectoryTeamIdHeader - { - public uint TeamIdOffset; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs deleted file mode 100644 index 3439c78c1c0d3f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/CodeDirectoryVersion.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum CodeDirectoryVersion : int - { - Baseline = 0x20001, - SupportsScatter = 0x20100, - SupportsTeamId = 0x20200, - SupportsCodeLimit64 = 0x20300, - SupportsExecSegment = 0x20400, - SupportsPreEncrypt = 0x20500, - HighestVersion = SupportsExecSegment, // TODO: We don't support pre-encryption yet - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs deleted file mode 100644 index a62f9fdb6da4b6..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsBlob.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using Claunia.PropertyList; - -namespace Melanzana.CodeSign.Blobs -{ - public class EntitlementsBlob - { - public static byte[] Create(Entitlements entitlements) - { - var plistBytes = Encoding.UTF8.GetBytes(entitlements.PList.ToXmlPropertyList()); - var blobBuffer = new byte[8 + plistBytes.Length]; - - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Entitlements); - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); - plistBytes.CopyTo(blobBuffer.AsSpan(8, plistBytes.Length)); - - return blobBuffer; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs deleted file mode 100644 index a943e479c4f702..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/EntitlementsDerBlob.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using Claunia.PropertyList; - -namespace Melanzana.CodeSign.Blobs -{ - public class EntitlementsDerBlob - { - public static byte[] Create(Entitlements entitlements) - { - var plistBytes = DerPropertyListWriter.Write(entitlements.PList); - var blobBuffer = new byte[8 + plistBytes.Length]; - - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.EntitlementsDer); - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(4, 4), (uint)blobBuffer.Length); - plistBytes.CopyTo(blobBuffer.AsSpan(8, plistBytes.Length)); - - return blobBuffer; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs deleted file mode 100644 index f32ee3c9914fb7..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/ExecutableSegmentFlags.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum ExecutableSegmentFlags : ulong - { - MainBinary = 1, - AllowUnsigned = 0x10, - Debugger = 0x20, - Jit = 0x40, - SkipLibraryValidation = 0x80, - CanLoadCdHash = 0x100, - CanExecuteCdHash = 0x200, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs deleted file mode 100644 index 4ba122c7c6cd8a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashType.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Melanzana.CodeSign.Blobs -{ - public enum HashType : byte - { - None, - SHA1, - SHA256, - SHA256Truncated, - SHA384, - SHA512, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs deleted file mode 100644 index cefbcd2782d58f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Blobs/HashTypeExtensions.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Security.Cryptography; - -namespace Melanzana.CodeSign.Blobs -{ - public static class HashTypeExtensions - { - - public static IncrementalHash GetIncrementalHash(this HashType hashType) - { - return hashType switch - { - HashType.SHA1 => IncrementalHash.CreateHash(HashAlgorithmName.SHA1), - HashType.SHA256 => IncrementalHash.CreateHash(HashAlgorithmName.SHA256), - HashType.SHA256Truncated => IncrementalHash.CreateHash(HashAlgorithmName.SHA256), - HashType.SHA384 => IncrementalHash.CreateHash(HashAlgorithmName.SHA384), - HashType.SHA512 => IncrementalHash.CreateHash(HashAlgorithmName.SHA512), - _ => throw new NotSupportedException() - }; - } - - public static byte GetSize(this HashType hashType) - { - return hashType switch - { - HashType.SHA1 => 20, - HashType.SHA256 => 32, - HashType.SHA256Truncated => 20, - HashType.SHA384 => 48, - HashType.SHA512 => 64, - _ => throw new NotSupportedException() - }; - } - - public static string GetOid(this HashType hashType) - { - return hashType switch - { - HashType.SHA1 => "1.3.14.3.2.26", - HashType.SHA256 => "2.16.840.1.101.3.4.2.1", - HashType.SHA256Truncated => "2.16.840.1.101.3.4.2.1", - HashType.SHA384 => "2.16.840.1.101.3.4.2.2", - HashType.SHA512 => "2.16.840.1.101.3.4.2.3", - _ => throw new NotSupportedException() - }; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs deleted file mode 100644 index aa4418e19ea440..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Bundle.cs +++ /dev/null @@ -1,130 +0,0 @@ -using Claunia.PropertyList; - -namespace Melanzana.CodeSign -{ - public class Bundle - { - public string BundlePath { get; private set; } - - public string ContentsPath { get; private set; } - - private readonly bool hasContents; - private readonly bool hasResources; - private readonly string? mainExecutable; - private readonly NSDictionary? infoPList; - private readonly string? bundleIdentifier; - - public Bundle(string path) - { - BundlePath = path; - - // Detect bundle type: - // - Shallow (eg. iOS) - // - `Contents/` (eg. macOS) - // - `Support Files/` - // - `Versions/...` - // - installer package - // - widget - // - etc. - - hasContents = Directory.Exists(Path.Combine(path, "Contents")); - ContentsPath = hasContents ? Path.Combine(path, "Contents") : path; - - // Look for Info.plist, then check CFBundleExecutable - var infoPlistPath = Path.Combine(ContentsPath, "Info.plist"); - if (File.Exists(infoPlistPath)) - { - infoPList = (NSDictionary)PropertyListParser.Parse(infoPlistPath); - - if (infoPList.TryGetValue("CFBundleExecutable", out var temp) && temp is NSString bundleExecutable) - { - if (hasContents) // macOS - { - mainExecutable = Path.Combine("MacOS", (string)bundleExecutable); - } - else - { - mainExecutable = (string)bundleExecutable; - } - - if (!File.Exists(Path.Combine(ContentsPath, mainExecutable))) - { - mainExecutable = null; - } - } - - if (infoPList.TryGetValue("CFBundleIdentifier", out temp) && temp is NSString bundleIdentifier) - { - this.bundleIdentifier = (string)bundleIdentifier; - } - } - else if (!hasContents && Directory.Exists(Path.Combine(BundlePath, "Versions"))) - { - ContentsPath = Path.Combine(BundlePath, "Versions", "Current"); - - // FIXME: Quick hack to get framework executables - var guessedName = Path.GetFileNameWithoutExtension(path); - if (File.Exists(Path.Combine(BundlePath, guessedName))) - { - mainExecutable = guessedName; - } - } - - hasResources = Directory.Exists(Path.Combine(ContentsPath, "Resources")); - } - - public string? MainExecutable => mainExecutable != null ? Path.Combine(ContentsPath, mainExecutable) : null; - - public string? BundleIdentifier => bundleIdentifier; - - public NSDictionary InfoPList => infoPList ?? new NSDictionary(); - - public void AddResourceRules(ResourceBuilder builder, bool useV2Rules = true) - { - string resourcePrefix = hasResources ? "Resources/" : ""; - - if (useV2Rules) - { - builder.AddRule(new ResourceRule("^.*")); - - // On macOS include nested signatures - if (hasResources) - { - builder.AddRule(new ResourceRule("^[^/]+") { IsNested = true, Weight = 10 }); - builder.AddRule(new ResourceRule("^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/") { IsNested = true, Weight = 10 }); - builder.AddRule(new ResourceRule($"^{resourcePrefix}") { Weight = 20 }); - } - - builder.AddRule(new ResourceRule(".*\\.dSYM($|/)") { Weight = 11 }); - - // Exclude specific files: - builder.AddRule(new ResourceRule("^Info\\.plist$") { IsOmitted = true, Weight = 20 }); - builder.AddRule(new ResourceRule("^PkgInfo$") { IsOmitted = true, Weight = 20 }); - - // Include specific files: - builder.AddRule(new ResourceRule("^embedded\\.provisionprofile$") { Weight = 20 }); - builder.AddRule(new ResourceRule("^version.plist$") { Weight = 20 }); - - builder.AddRule(new ResourceRule("^(.*/)?\\.DS_Store$") { IsOmitted = true, Weight = 2000 }); - } - else - { - builder.AddRule(new ResourceRule("^version.plist$")); - builder.AddRule(new ResourceRule(hasResources ? $"^{resourcePrefix}" : "^.*")); - } - - builder.AddRule(new ResourceRule($"^{resourcePrefix}.*\\.lproj/") { IsOptional = true, Weight = 1000 }); - builder.AddRule(new ResourceRule($"^{resourcePrefix}Base\\.lproj/") { Weight = 1010 }); - builder.AddRule(new ResourceRule($"^{resourcePrefix}.*\\.lproj/locversion.plist$") { IsOmitted = true, Weight = 1100 }); - - // Add implicit exclusions - builder.AddExclusion("_CodeSignature"); - builder.AddExclusion("CodeResources"); - builder.AddExclusion("_MASReceipt"); - if (mainExecutable != null) - { - builder.AddExclusion(mainExecutable); - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG1Certificate.cer deleted file mode 100644 index d2bb1da64122c864c872d9b711b176d042462748..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1062 zcmXqLVo@?^V&+=F%*4pV#KCxP&k@Vq1p)@VY@Awc9&O)w85vnw84QvPxeYkkm_u3E zgqcEv4TTK^K^!h&F2{m`oKywRyktE?H3JopAh)nAM9?|4s3bEjGdZy&Ge1wkv9u&3 zzbLb$(ooDm1f-5xm=~fhC_leM!P(J3PMp`!*ucoZ+{nZl`k>Qj@$g1r8WvHYTX!VypjWG%{)c-lQVYXRuCJE(pY=;r$WxRF4-br${9`c}_k`!An>Li0EopDe zv*^E}E$UaTdLwGTU-QAd$KGuPNJ^ruh+PumVL-h)reU3&vOc4_NAnbP|3 z#gVzkGL~*w{3pGxU>8%Qce&F<%bj1(KJXzgbzkmy4MuTzafLDk420{ zq(fbtbLBRPgzh)5cYSk@JQ@_Tc)I~VNLrYY@jnZz0W**?kOv7Uvq%_-HHc_m$aJ4l z#`*6{cCVhpvhVJ`^&D{qdLRYzEb0cT2FeQ*7s$8CW|Wi^Sn2C07v<Nhma(=FU z5ipVI0fh|sKiL>2Sz0$ga7&Wk^6MMZpzW` ze<$2-^n%rNMP7I9$xNP|H^ujq>s(2H^mkUSRbjJu1>%3p6qBF+hu?6 zedkq{<@Qo*x8F5!lFt%JA<5kEuT>H4)frt++IqZRKk^h=we)T%!^(BLy$#kqT(EJE zX2Ubi@~8Vu7BQZxzw?Oene~p{Z+0b3{mh!|*mRcPTGnUklH03)o}Bv9|B3H&wV91C z_x#+Vd5N(q?V(=JH^r`_KPnzJuG@ck!rYZ>Kd=95AvG=CKqhc$%$vflrY$-AJfiXd D2`7-6 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Certificates/IntermediateG3Certificate.cer deleted file mode 100644 index 32f96f81dd6ea4c1c0f8e84698a50df773444b83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1109 zcmXqLVhJ>8Vzyks%*4pVBv7+HlS_5G<-h9LE>#CBj=nSCW#iOp^Jx3d%gD&h%3zRW z$Zf#M#vIDRCd?EXY$$9X2;y)Fb2%0iH*zq6|t6T@0MSI(e)iI>Ymea#G4OQ&JUNQp-|v@(WUn6oOK7z!nxO;Ibd;6K){o*(MkVCXU}R-rZerwT0E%-lH8CYLni>cB0Y1I-s6|D1SjdC!T1#gEpxT}+xg zX~l#D^V*DQXL}#~nf!ynzs^Bts5HBBM?YUi*LCU=8QrPsRL7p`U7PH?oF*7nSE^d5p z(D=qc2pB!G!ijc@}j8RRiS(iVNi1WT9Gi4Pg$!gt>iJm2SVTDg9T1)HbA1Ze zB%z&Z8p%A<-z?u`zz34%2l<2rm_yhM1lYL1`5`%ljfs(k3792Na|kd^Ffy!76@KyU zL1VcKle^Qt_@$N#uaZ{&Jv!lJvGCP-voEaT@9jPPmhpU!hC}r6P!-1?f6gD=s{HcK zn~(XY8f4249ZB?5O<&J{%2IXh<;PWLj5T=q^cIFY6#se_vyLrL^X=nS9{G!0~pME4H^8F=`FYGft6Cx##-<@*tz`>mQ3dQ$4 zudQ=tHhBjnSZuXy%6$`L7`%^vqK~I%N&m9I(=G0PvZd;Idw*Vv`CNY}hnv&vQOc7; z=FB3JS6^jKS+(-^zi+cR(!1Yl?^q@7*}VSz={+ycznWUOVTlFYQsBg2!4D>>yS-j;I@c+L7YuChh5U7`KHvAiEsOqE5wMI&W5Px=0B&b;#hyADPKr1x`dQTTp(jgCTo z!8UtFgP!fq=lSQ_e%AKXkUH`2+}53ZH{)ckownU-we|}?AHyW>jf!G=C0A{DZzqYZ zUR*fIJvj8>dVR;uKYl+hIQwj|k87R0Pjj_t->jT;Rj-bAq&^<-@B zm%W!-{69S|b&uzbviZg$sSC@eoYZAvW@KPo+{9P~43RPeK43h`@-s62XJG-R8#V)e z5MLO?XEk63QUIB4HrbfL%co zBPgB8DzG#$asX{)0b&Md!c0zKWi)8~WT3^yq0I(NqwGwKVsaTJB?ZM+`ugSN<$8&r zl&P1TpQ{gMB`4||G#-X4W-@5pCe^q(C^aWDF)uk)0hmHdGBS%5lHrLqRUxTTAu+E~ zp&+rS1js5bF3n9XR!B@vPAw>b=t%?WNd@6N1&|%Uq@D!K48=g%l*FPGg_6{wT%d-$ z6ouscyp&8(HYirePg5u@PSruNs30Gx7i1YwCER{crYR^&OfJa;IuB@ONosCtUP-YY za{2^jO7!e*{cX?eJDxY@8r; zW8atJ+3zl;@Sm>qH@UIM?q|jS>=W#7YAu_)gB31Y9ND;kmOoeaf9*e!%UL;V#2vx} zUUwk!R<>!CBEM2a=7;zgw~E zguTASugG_6SFxo3)|+Pa2irq$E}yy6$m#cutA+FG76xsX-aFYzMMzw9>OIdRD+ Xyc@&=R&`yy_2kb5PImJRrKO4hMS!&; diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs deleted file mode 100644 index d2319aa496dd82..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignAllocate.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Melanzana.MachO; -using Melanzana.Streams; - -namespace Melanzana.CodeSign -{ - /// - /// Rewriter for the Mach-O or universal binaries that resizes the code signature section - /// and all related linker commands to make space for new signature. - /// - public class CodeSignAllocate - { - public IList objectFiles; - - public CodeSignAllocate(IList objectFiles) - { - this.objectFiles = objectFiles; - } - - public void SetArchSize(MachObjectFile machO, uint codeSignatureSize) - { - // Page alignment - codeSignatureSize = (codeSignatureSize + 0x3fffu) & ~0x3fffu; - - UpdateCodeSignatureLayout(machO, codeSignatureSize); - } - - public string Allocate() - { - var tempFileName = Path.GetTempFileName(); - using var output = File.OpenWrite(tempFileName); - MachWriter.Write(output, objectFiles); - return tempFileName; - } - - private static void UpdateCodeSignatureLayout(MachObjectFile machO, uint codeSignatureSize) - { - var linkEditSegment = machO.LoadCommands.OfType().First(s => s.Name == "__LINKEDIT"); - var codeSignatureCommand = machO.LoadCommands.OfType().FirstOrDefault(); - - if (codeSignatureCommand == null) - { - codeSignatureCommand = new MachCodeSignature(machO); - codeSignatureCommand.Data.FileOffset = (uint)machO.GetSigningLimit(); - machO.LoadCommands.Add(codeSignatureCommand); - } - - codeSignatureCommand.Data.Size = codeSignatureSize; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs deleted file mode 100644 index 902a0b370b41ea..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/CodeSignOptions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; - -namespace Melanzana.CodeSign -{ - public class CodeSignOptions - { - /// - /// Gets or sets the developer certificate used for signing. - /// - /// - /// Set to `null` to use adhoc signing. - /// - public X509Certificate2? DeveloperCertificate { get; set; } - - /// - /// Gets or sets a private key used for signing. - /// - /// - /// This property can be used to augment the developer certificate set through - /// . It can either be used when the developer - /// certificate itself doesn't contain the private key or the private key signing - /// is provided through external service or device. - /// - public AsymmetricAlgorithm? PrivateKey { get; set; } - - /// - /// Gets or sets the entitlements to be embedded in the signature. - /// - public Entitlements? Entitlements { get; set; } - - /// - /// Gets or sets whether the nested exectuables should be signed. - /// - public bool Deep { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs deleted file mode 100644 index 4fe066fc7498a4..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Entitlements.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using Claunia.PropertyList; - -namespace Melanzana.CodeSign -{ - public class Entitlements - { - public Entitlements(NSDictionary plist) - { - PList = plist; - } - - public NSDictionary PList { get; set; } - - public bool GetTaskAllow => GetBoolEntitlement("get-task-allow"); - public bool RunUnsignedCode => GetBoolEntitlement("run-unsigned-code"); - public bool Debugger => GetBoolEntitlement("com.apple.private.cs.debugger"); - public bool DynamicCodeSigning => GetBoolEntitlement("dynamic-codesigning"); - public bool SkipLibraryValidation => GetBoolEntitlement("com.apple.private.skip-library-validation"); - public bool CanLoadCdHash => GetBoolEntitlement("com.apple.private.amfi.can-load-cdhash"); - public bool CanExecuteCdHash => GetBoolEntitlement("com.apple.private.amfi.can-execute-cdhash"); - - private bool GetBoolEntitlement(string name) - { - if (PList.TryGetValue(name, out var temp) && temp is NSNumber number && number.isBoolean()) - return number.ToBool(); - return false; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj deleted file mode 100644 index 28dcb8622ba5fb..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Melanzana.CodeSign.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - net6.0 - enable - enable - - true - $(BaseIntermediateOutputPath)/GeneratedFiles - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs deleted file mode 100644 index d7b03624ed6560..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/PropertyList/DerPropertyListWriter.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Formats.Asn1; - -namespace Claunia.PropertyList -{ - public static class DerPropertyListWriter - { - public static byte[] Write(NSObject value) - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - var asnWriter = new AsnWriter(AsnEncodingRules.DER); - Write(asnWriter, value); - return asnWriter.Encode(); - } - - private static void Write(AsnWriter writer, NSObject value) - { - switch (value) - { - case NSDictionary dictionary: - Write(writer, dictionary); - break; - case NSNumber number: - Write(writer, number); - break; - case NSString @string: - Write(writer, @string); - break; - case NSArray array: - Write(writer, array); - break; - } - } - - private static void Write(AsnWriter writer, NSDictionary dictionary) - { - using (writer.PushSetOf()) - { - foreach (KeyValuePair entry in dictionary) - { - using (writer.PushSequence()) - { - writer.WriteCharacterString(UniversalTagNumber.UTF8String, entry.Key); - Write(writer, entry.Value); - } - } - } - } - - private static void Write(AsnWriter writer, NSArray array) - { - using (writer.PushSequence()) - { - foreach (NSObject item in array) - { - Write(writer, item); - } - } - } - - private static void Write(AsnWriter writer, NSString @string) - { - writer.WriteCharacterString(UniversalTagNumber.UTF8String, @string.ToString()); - } - - private static void Write(AsnWriter writer, NSNumber number) - { - if (number.isBoolean()) - { - writer.WriteBoolean(number.ToBool()); - return; - } - else if (number.isInteger()) - { - writer.WriteInteger(number.ToInt()); - } - else - { - throw new NotSupportedException(); - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs deleted file mode 100644 index bb56bb099650e5..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ProvisioningProfile.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Security.Cryptography.Pkcs; -using System.Security.Cryptography.X509Certificates; -using Claunia.PropertyList; - -namespace Melanzana.CodeSign -{ - public class ProvisioningProfile - { - private readonly NSDictionary plist; - - public ProvisioningProfile(string fileName) - { - var signedCms = new SignedCms(); - signedCms.Decode(File.ReadAllBytes(fileName)); - var contentInfo = signedCms.ContentInfo; - var content = contentInfo.Content; - - plist = (NSDictionary)XmlPropertyListParser.Parse(content); - - } - - public IEnumerable TeamIdentifiers => ((NSArray)plist["TeamIdentifier"]).Select(i => i.ToString()!).ToArray(); - - public IEnumerable DeveloperCertificates => - ((NSArray)plist["DeveloperCertificates"]).OfType().Select(d => new X509Certificate2((byte[])d)); - - public NSDictionary Entitlements => (NSDictionary)plist["Entitlements"]; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs deleted file mode 100644 index a749a6a047d44f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.ConversionHelpers.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using System.Formats.Asn1; -using Melanzana.MachO; - -namespace Melanzana.CodeSign.Requirements -{ - public abstract partial class Expression - { - private static int Align(int size) => (size + 3) & ~3; - - private static byte[] GetOidBytes(string oid) - { - var asnWriter = new AsnWriter(AsnEncodingRules.DER); - asnWriter.WriteObjectIdentifier(oid); - return asnWriter.Encode().AsSpan(2).ToArray(); - } - - private static string GetOidString(byte[] oid) - { - var oidBytes = new byte[oid.Length + 2]; - oidBytes[0] = 6; - oidBytes[1] = (byte)oid.Length; - oid.CopyTo(oidBytes.AsSpan(2)); - return AsnDecoder.ReadObjectIdentifier(oidBytes, AsnEncodingRules.DER, out _); - } - - private static byte[] GetTimestampBytes(DateTime dateTime) - { - long tsSeconds = (long)(dateTime - new DateTime(2001, 1, 1)).TotalSeconds; - var buffer = new byte[8]; - BinaryPrimitives.WriteInt64BigEndian(buffer, tsSeconds); - return buffer; - } - - private static string GetTimestampString(byte[] dateTime) - { - var tsSeconds = BinaryPrimitives.ReadInt64BigEndian(dateTime); - return new DateTime(2001, 1, 1).AddSeconds(tsSeconds).ToString("yyyyMMddHHmmssZ"); - } - - private static string BinaryValueToString(byte[] bytes) - { - return $"0x{Convert.ToHexString(bytes)}"; - } - - private static string ValueToString(byte[] bytes) - { - bool isPrintable = bytes.All(c => !char.IsControl((char)c) && char.IsAscii((char)c)); - if (!isPrintable) - { - return BinaryValueToString(bytes); - } - - bool needQuoting = - bytes.Length == 0 || - char.IsDigit((char)bytes[0]) || - bytes.Any(c => !char.IsLetterOrDigit((char)c)); - if (needQuoting) - { - var sb = new StringBuilder(); - sb.Append('"'); - foreach (var c in bytes) - { - if (c == (byte)'\\' || c == (byte)'"') - { - sb.Append('\\'); - } - sb.Append((char)c); - } - sb.Append('"'); - return sb.ToString(); - } - else - { - return Encoding.ASCII.GetString(bytes); - } - } - - private static string CertificateSlotToString(int slot) - { - return slot switch { - 0 => "leaf", - -1 => "root", - _ => slot.ToString(), - }; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs deleted file mode 100644 index ba1067dddd96e0..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Derived.cs +++ /dev/null @@ -1,470 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using System.Formats.Asn1; -using Melanzana.MachO; - -namespace Melanzana.CodeSign.Requirements -{ - public abstract partial class Expression - { - class SimpleExpression : Expression - { - ExpressionOperation op; - - public SimpleExpression(ExpressionOperation op) - { - this.op = op; - } - - public override int Size => 4; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); - bytesWritten = 4; - } - - public override string ToString() - { - return op switch { - ExpressionOperation.False => "never", - ExpressionOperation.True => "always", - ExpressionOperation.AppleAnchor => "anchor apple", - ExpressionOperation.AppleGenericAnchor => "anchor apple generic", - ExpressionOperation.TrustedCerts => "anchor trusted", - ExpressionOperation.Notarized => "notarized", - ExpressionOperation.LegacyDevID => "legacy", - _ => "unknown", - }; - } - } - - class BinaryOperatorExpression : Expression - { - ExpressionOperation op; - Expression left; - Expression right; - - public BinaryOperatorExpression(ExpressionOperation op, Expression left, Expression right) - { - this.op = op; - this.left = left; - this.right = right; - } - - public override int Size => 4 + left.Size + right.Size; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); - left.Write(buffer.Slice(4), out var bytesWrittenLeft); - right.Write(buffer.Slice(4 + bytesWrittenLeft), out var bytesWrittenRight); - bytesWritten = 4 + bytesWrittenLeft + bytesWrittenRight; - } - - private string? WrapInnerExpression(Expression innerExpression) - { - if (innerExpression is BinaryOperatorExpression boe && - boe.op != op) - { - return $"({boe})"; - } - - return innerExpression.ToString(); - } - - public override string ToString() - { - return op switch { - ExpressionOperation.And => $"{WrapInnerExpression(left)} and {WrapInnerExpression(right)}", - ExpressionOperation.Or => $"{WrapInnerExpression(left)} or {WrapInnerExpression(right)}", - _ => "unknown", - }; - } - } - - class UnaryOperatorExpression : Expression - { - ExpressionOperation op; - Expression inner; - - public UnaryOperatorExpression(ExpressionOperation op, Expression inner) - { - this.op = op; - this.inner = inner; - } - - public override int Size => 4 + inner.Size; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); - inner.Write(buffer.Slice(4), out var bytesWrittenInner); - bytesWritten = 4 + bytesWrittenInner; - } - - public override string ToString() - { - return op switch { - ExpressionOperation.Not => $"! {inner}", - _ => "unknown", - }; - } - } - - class StringExpression : Expression - { - ExpressionOperation op; - string opString; - - public StringExpression(ExpressionOperation op, string opString) - { - this.op = op; - this.opString = opString; - } - - public override int Size => 8 + Align(Encoding.UTF8.GetByteCount(opString)); - - public override void Write(Span buffer, out int bytesWritten) - { - byte[] opStringBytes = Encoding.UTF8.GetBytes(opString); - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), opStringBytes.Length); - opStringBytes.CopyTo(buffer.Slice(8, opStringBytes.Length)); - buffer.Slice(8 + opStringBytes.Length, Align(opStringBytes.Length) - opStringBytes.Length).Fill((byte)0); - bytesWritten = 8 + Align(opStringBytes.Length); - } - - public override string ToString() - { - return op switch { - ExpressionOperation.Ident => $"identifier \"{opString}\"", // FIXME: Escaping - _ => "unknown", - }; - } - } - - class CDHashExpression : Expression - { - private readonly byte[] codeDirectoryHash; - - public CDHashExpression(byte[] codeDirectoryHash) - { - this.codeDirectoryHash = codeDirectoryHash; - } - - public override int Size => 4 + codeDirectoryHash.Length; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)ExpressionOperation.CDHash); - codeDirectoryHash.CopyTo(buffer.Slice(4, codeDirectoryHash.Length)); - bytesWritten = 4 + codeDirectoryHash.Length; - } - - public override string ToString() - { - return $"cdhash H\"{Convert.ToHexString(codeDirectoryHash)}\""; - } - } - - class AnchorHashExpression : Expression - { - private readonly int certificateIndex; - private readonly byte[] anchorHash; - - public AnchorHashExpression(int certificateIndex, byte[] anchorHash) - { - this.certificateIndex = certificateIndex; - this.anchorHash = anchorHash; - } - - public override int Size => 8 + anchorHash.Length; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.AnchorHash); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), anchorHash.Length); - anchorHash.CopyTo(buffer.Slice(8, anchorHash.Length)); - bytesWritten = 8 + anchorHash.Length; - } - - public override string ToString() - { - return $"certificate {CertificateSlotToString(certificateIndex)} = H\"{Convert.ToHexString(anchorHash)}\""; - } - } - - abstract class MatchExpression : Expression - { - ExpressionMatchType matchType; - byte[]? matchValue; - - public MatchExpression(ExpressionMatchType matchType, byte[]? matchValue) - { - this.matchType = matchType; - this.matchValue = matchValue; - } - - public override int Size => - 4 + - (matchValue != null ? 4 + Align(matchValue.Length) : 0); - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)matchType); - if (matchValue != null) - { - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), matchValue.Length); - matchValue.CopyTo(buffer.Slice(8, matchValue.Length)); - buffer.Slice(8 + matchValue.Length, Align(matchValue.Length) - matchValue.Length).Fill((byte)0); - bytesWritten = 8 + Align(matchValue.Length); - } - else - { - bytesWritten = 4; - } - } - - public override string ToString() - { - return matchType switch { - ExpressionMatchType.Exists => "/* exists */", - ExpressionMatchType.Absent => "absent", - ExpressionMatchType.Equal => $"= {ValueToString(matchValue!)}", - ExpressionMatchType.Contains => $"~ {ValueToString(matchValue!)}", - ExpressionMatchType.BeginsWith => $"= {ValueToString(matchValue!)}*", - ExpressionMatchType.EndsWith => $"= *{ValueToString(matchValue!)}", - ExpressionMatchType.LessThan => $"< {ValueToString(matchValue!)}", - ExpressionMatchType.GreaterEqual => $">= {ValueToString(matchValue!)}", - ExpressionMatchType.LessEqual => $"<= {ValueToString(matchValue!)}", - ExpressionMatchType.GreaterThan => $">= {ValueToString(matchValue!)}", - ExpressionMatchType.On => $"= timestamp \"{GetTimestampString(matchValue!)}\"", - ExpressionMatchType.Before => $"< timestamp \"{GetTimestampString(matchValue!)}\"", - ExpressionMatchType.After => $"> timestamp \"{GetTimestampString(matchValue!)}\"", - ExpressionMatchType.OnOrBefore => $"<= timestamp \"{GetTimestampString(matchValue!)}\"", - ExpressionMatchType.OnOrAfter => $">= timestamp \"{GetTimestampString(matchValue!)}\"", - _ => "unknown", - }; - } - } - - class FieldMatchExpression : MatchExpression - { - private readonly ExpressionOperation op; - private readonly object field; - private readonly byte[] fieldBytes; - - public FieldMatchExpression( - ExpressionOperation op, - string field, - ExpressionMatchType matchType, - byte[]? matchValue) - : base(matchType, matchValue) - { - this.op = op; - this.field = field; - fieldBytes = Encoding.ASCII.GetBytes(field); - } - - public override int Size => - 8 + - Align(fieldBytes.Length) + - base.Size; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)op); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), fieldBytes.Length); - fieldBytes.CopyTo(buffer.Slice(8, fieldBytes.Length)); - buffer.Slice(8 + fieldBytes.Length, Align(fieldBytes.Length) - fieldBytes.Length).Fill((byte)0); - bytesWritten = 8 + Align(fieldBytes.Length); - base.Write(buffer.Slice(bytesWritten), out var matchExpressionSize); - bytesWritten += matchExpressionSize; - } - - - public override string ToString() - { - return op switch { - ExpressionOperation.InfoKeyField => $"info[{field}] {base.ToString()}", - ExpressionOperation.EntitlementField => $"entitlement[{field}] {base.ToString()}", - _ => "unknown", - }; - } - } - - class CertExpression : MatchExpression - { - private readonly ExpressionOperation op; - private readonly int certificateIndex; - private readonly byte[] certificateField; - - public CertExpression( - ExpressionOperation op, - int certificateIndex, - byte[] certificateField, - ExpressionMatchType matchType, - byte[]? matchValue) - : base(matchType, matchValue) - { - this.op = op; - this.certificateIndex = certificateIndex; - this.certificateField = certificateField; - } - - public override int Size => - 12 + - Align(certificateField.Length) + - base.Size; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, (uint)op); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4), certificateIndex); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(8), certificateField.Length); - certificateField.CopyTo(buffer.Slice(12, certificateField.Length)); - buffer.Slice(12 + certificateField.Length, Align(certificateField.Length) - certificateField.Length).Fill((byte)0); - bytesWritten = 12 + Align(certificateField.Length); - base.Write(buffer.Slice(bytesWritten), out var matchExpressionSize); - bytesWritten += matchExpressionSize; - } - - - public override string ToString() - { - return op switch { - ExpressionOperation.CertField => $"certificate {CertificateSlotToString(certificateIndex)}[{Encoding.ASCII.GetString(certificateField)}] {base.ToString()}", - ExpressionOperation.CertGeneric => $"certificate {CertificateSlotToString(certificateIndex)}[field.{GetOidString(certificateField)}] {base.ToString()}", - ExpressionOperation.CertPolicy => $"certificate {CertificateSlotToString(certificateIndex)}[policy.{GetOidString(certificateField)}] {base.ToString()}", - ExpressionOperation.CertFieldDate => $"certificate {CertificateSlotToString(certificateIndex)}[timestamp.{GetOidString(certificateField)}] {base.ToString()}", - _ => "unknown", - }; - } - } - - class InfoKeyValueExpression : Expression - { - private readonly object field; - private readonly byte[] fieldBytes; - private readonly byte[] matchValue; - - public InfoKeyValueExpression( - string field, - byte[] matchValue) - { - this.field = field; - this.matchValue = matchValue; - - fieldBytes = Encoding.ASCII.GetBytes(field); - } - - public override int Size => - 12 + - Align(fieldBytes.Length) + - Align(matchValue.Length); - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.InfoKeyValue); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), fieldBytes.Length); - fieldBytes.CopyTo(buffer.Slice(8, fieldBytes.Length)); - buffer.Slice(8 + fieldBytes.Length, Align(fieldBytes.Length) - fieldBytes.Length).Fill((byte)0); - bytesWritten = 8 + Align(fieldBytes.Length); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(bytesWritten, 4), matchValue.Length); - fieldBytes.CopyTo(buffer.Slice(bytesWritten + 4, matchValue.Length)); - buffer.Slice(4 + bytesWritten + matchValue.Length, Align(matchValue.Length) - matchValue.Length).Fill((byte)0); - bytesWritten += 4 + Align(matchValue.Length); - } - - public override string ToString() - { - return $"info[{field}] = {ValueToString(matchValue)}"; - } - } - - class NamedExpression : Expression - { - private readonly ExpressionOperation op; - private readonly byte[] name; - - public NamedExpression( - ExpressionOperation op, - byte[] name) - { - this.op = op; - this.name = name; - } - - public override int Size => - 8 + - Align(name.Length); - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)op); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), name.Length); - name.CopyTo(buffer.Slice(8, name.Length)); - buffer.Slice(8 + name.Length, Align(name.Length) - name.Length).Fill((byte)0); - bytesWritten = 8 + Align(name.Length); - } - - public override string ToString() - { - return op switch { - ExpressionOperation.NamedAnchor => $"anchor apple {ValueToString(name)}", - ExpressionOperation.NamedCode => $"({ValueToString(name)})", - _ => "unknown", - }; - } - } - - class TrustedCertExpression : Expression - { - private readonly int certificateIndex; - - public TrustedCertExpression(int certificateIndex) - { - this.certificateIndex = certificateIndex; - } - - public override int Size => 8; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.TrustedCert); - BinaryPrimitives.WriteInt32BigEndian(buffer.Slice(4, 4), certificateIndex); - bytesWritten = 8; - } - - public override string ToString() - { - return $"certificate {CertificateSlotToString(certificateIndex)} trusted"; - } - } - - class PlatformExpression : Expression - { - private readonly MachPlatform platform; - - public PlatformExpression(MachPlatform platform) - { - this.platform = platform; - } - - public override int Size => 8; - - public override void Write(Span buffer, out int bytesWritten) - { - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(0, 4), (uint)ExpressionOperation.Platform); - BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(4, 4), (uint)platform); - bytesWritten = 8; - } - - public override string ToString() - { - return $"platform = {platform}"; - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs deleted file mode 100644 index 6bf4ae60bd5f2a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.FromBlob.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using Melanzana.MachO; - -namespace Melanzana.CodeSign.Requirements -{ - public abstract partial class Expression - { - private static byte[] GetData(ReadOnlySpan expr, out int bytesRead) - { - var length = BinaryPrimitives.ReadInt32BigEndian(expr); - bytesRead = 4 + Align(length); - return expr.Slice(4, length).ToArray(); - } - - private static byte[]? GetMatchData(ReadOnlySpan expr, ExpressionMatchType matchType, out int bytesRead) - { - if (matchType != ExpressionMatchType.Exists && matchType != ExpressionMatchType.Absent) - { - return GetData(expr, out bytesRead); - } - - bytesRead = 0; - return null; - } - - private static Expression FromBlob(ReadOnlySpan expr, out int bytesRead) - { - if (expr.Length == 0) - throw new NotImplementedException(); - - var op = (ExpressionOperation)BinaryPrimitives.ReadUInt32BigEndian(expr); - switch (op) - { - case ExpressionOperation.False: - bytesRead = 4; - return False; - - case ExpressionOperation.True: - bytesRead = 4; - return True; - - case ExpressionOperation.Ident: - var identifier = GetData(expr.Slice(4), out bytesRead); - bytesRead += 4; - return Ident(Encoding.ASCII.GetString(identifier)); - - case ExpressionOperation.AppleAnchor: - bytesRead = 4; - return AppleAnchor; - - case ExpressionOperation.AnchorHash: - var certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); - var hash = GetData(expr.Slice(8), out bytesRead); - bytesRead += 8; - return AnchorHash(certificateIndex, hash); - - case ExpressionOperation.InfoKeyValue: - var field = GetData(expr.Slice(4), out var fieldBytesRead); - var value = GetData(expr.Slice(4 + fieldBytesRead), out bytesRead); - bytesRead += 4 + fieldBytesRead; - return InfoKeyValue(Encoding.ASCII.GetString(field), Encoding.ASCII.GetString(value)); - - case ExpressionOperation.And: - var left = FromBlob(expr.Slice(4), out var leftBytesRead); - var right = FromBlob(expr.Slice(4 + leftBytesRead), out bytesRead); - bytesRead += 4 + leftBytesRead; - return And(left, right); - - case ExpressionOperation.Or: - left = FromBlob(expr.Slice(4), out leftBytesRead); - right = FromBlob(expr.Slice(4 + leftBytesRead), out bytesRead); - bytesRead += 4 + leftBytesRead; - return Or(left, right); - - case ExpressionOperation.CDHash: - hash = GetData(expr.Slice(4), out bytesRead); - bytesRead += 4; - return CDHash(hash); - - case ExpressionOperation.Not: - var inner = FromBlob(expr.Slice(4), out bytesRead); - bytesRead += 4; - return Not(inner); - - case ExpressionOperation.InfoKeyField: - field = GetData(expr.Slice(4), out fieldBytesRead); - var matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(4 + fieldBytesRead, 4)); - var matchValue = GetMatchData(expr.Slice(8 + fieldBytesRead), matchType, out var matchValueBytesRead); - bytesRead = 8 + fieldBytesRead + matchValueBytesRead; - return InfoKeyField(Encoding.ASCII.GetString(field), matchType, matchValue != null ? Encoding.ASCII.GetString(matchValue) : null); - - case ExpressionOperation.CertField: - case ExpressionOperation.CertGeneric: - case ExpressionOperation.CertPolicy: - case ExpressionOperation.CertFieldDate: - certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); - field = GetData(expr.Slice(8), out fieldBytesRead); - matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(8 + fieldBytesRead, 4)); - matchValue = GetMatchData(expr.Slice(12 + fieldBytesRead), matchType, out matchValueBytesRead); - bytesRead = 12 + fieldBytesRead + matchValueBytesRead; - return new CertExpression(op, certificateIndex, field, matchType, matchValue); - - case ExpressionOperation.TrustedCert: - certificateIndex = BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); - bytesRead = 8; - return TrustedCert(certificateIndex); - - case ExpressionOperation.TrustedCerts: - bytesRead = 4; - return TrustedCerts; - - case ExpressionOperation.AppleGenericAnchor: - bytesRead = 4; - return AppleGenericAnchor; - - case ExpressionOperation.EntitlementField: - field = GetData(expr.Slice(4), out fieldBytesRead); - matchType = (ExpressionMatchType)BinaryPrimitives.ReadUInt32BigEndian(expr.Slice(4 + fieldBytesRead, 4)); - matchValue = GetMatchData(expr.Slice(8 + fieldBytesRead), matchType, out matchValueBytesRead); - bytesRead = 8 + fieldBytesRead + matchValueBytesRead; - return EntitlementField(Encoding.ASCII.GetString(field), matchType, matchValue != null ? Encoding.ASCII.GetString(matchValue) : null); - - case ExpressionOperation.NamedAnchor: - var anchorName = GetData(expr.Slice(4), out bytesRead); - bytesRead += 4; - return NamedAnchor(Encoding.ASCII.GetString(anchorName)); - - case ExpressionOperation.NamedCode: - var codeName = GetData(expr.Slice(4), out bytesRead); - bytesRead += 4; - return NamedCode(Encoding.ASCII.GetString(codeName)); - - case ExpressionOperation.Platform: - var platform = (MachPlatform)BinaryPrimitives.ReadInt32BigEndian(expr.Slice(4, 4)); - bytesRead = 8; - return Platform(platform); - - case ExpressionOperation.Notarized: - bytesRead = 4; - return Notarized; - - case ExpressionOperation.LegacyDevID: - bytesRead = 4; - return LegacyDevID; - - default: - throw new NotSupportedException(); - } - } - - public static Expression FromBlob(ReadOnlySpan expr) - { - return FromBlob(expr, out _); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs deleted file mode 100644 index da58f6a742519e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.Static.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Buffers.Binary; -using System.Text; -using System.Formats.Asn1; -using Melanzana.MachO; - -namespace Melanzana.CodeSign.Requirements -{ - public abstract partial class Expression - { - public static Expression False { get; } = new SimpleExpression(ExpressionOperation.False); - public static Expression True { get; } = new SimpleExpression(ExpressionOperation.True); - public static Expression Ident(string identifier) => new StringExpression(ExpressionOperation.Ident, identifier); - public static Expression AppleAnchor { get; } = new SimpleExpression(ExpressionOperation.AppleAnchor); - public static Expression AnchorHash(int certificateIndex, byte[] anchorHash) => new AnchorHashExpression(certificateIndex, anchorHash); - public static Expression InfoKeyValue(string field, string matchValue) - => new InfoKeyValueExpression(field, Encoding.ASCII.GetBytes(matchValue)); - public static Expression And(Expression left, Expression right) => new BinaryOperatorExpression(ExpressionOperation.And, left, right); - public static Expression Or(Expression left, Expression right) => new BinaryOperatorExpression(ExpressionOperation.Or, left, right); - public static Expression CDHash(byte[] codeDirectoryHash) => new CDHashExpression(codeDirectoryHash); - public static Expression Not(Expression inner) => new UnaryOperatorExpression(ExpressionOperation.Not, inner); - public static Expression InfoKeyField(string field, ExpressionMatchType matchType, string? matchValue = null) - => new FieldMatchExpression(ExpressionOperation.InfoKeyField, field, matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); - public static Expression CertField(int certificateIndex, string certificateField, ExpressionMatchType matchType, string? matchValue = null) - => new CertExpression(ExpressionOperation.CertField, certificateIndex, Encoding.ASCII.GetBytes(certificateField), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); - public static Expression TrustedCert(int certificateIndex) => new TrustedCertExpression(certificateIndex); - public static Expression TrustedCerts { get; } = new SimpleExpression(ExpressionOperation.TrustedCerts); - public static Expression CertGeneric(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, string? matchValue = null) - => new CertExpression(ExpressionOperation.CertGeneric, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); - public static Expression AppleGenericAnchor { get; } = new SimpleExpression(ExpressionOperation.AppleGenericAnchor); - public static Expression EntitlementField(string field, ExpressionMatchType matchType, string? matchValue = null) - => new FieldMatchExpression(ExpressionOperation.EntitlementField, field, matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); - public static Expression CertPolicy(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, string? matchValue = null) - => new CertExpression(ExpressionOperation.CertPolicy, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue != null ? Encoding.ASCII.GetBytes(matchValue) : null); - public static Expression NamedAnchor(string anchorName) => new NamedExpression(ExpressionOperation.NamedAnchor, Encoding.ASCII.GetBytes(anchorName)); - public static Expression NamedCode(string code) => new NamedExpression(ExpressionOperation.NamedCode, Encoding.ASCII.GetBytes(code)); - public static Expression Platform(MachPlatform platform) => new PlatformExpression(platform); - public static Expression Notarized { get; } = new SimpleExpression(ExpressionOperation.Notarized); - public static Expression CertFieldDate(int certificateIndex, string certificateFieldOid, ExpressionMatchType matchType, DateTime? matchValue = null) - => new CertExpression(ExpressionOperation.CertFieldDate, certificateIndex, GetOidBytes(certificateFieldOid), matchType, matchValue.HasValue ? GetTimestampBytes(matchValue.Value) : null); - public static Expression LegacyDevID { get; } = new SimpleExpression(ExpressionOperation.LegacyDevID); - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs deleted file mode 100644 index 488ffb979f9d8e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Expression.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.CodeSign.Requirements -{ - public abstract partial class Expression - { - public abstract int Size { get; } - - public abstract void Write(Span buffer, out int bytesWritten); - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs deleted file mode 100644 index b571ed373bb76f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionMatchType.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Melanzana.CodeSign.Requirements -{ - public enum ExpressionMatchType : int - { - Exists, - Equal, - Contains, - BeginsWith, - EndsWith, - LessThan, - GreaterThan, - LessEqual, - GreaterEqual, - On, - Before, - After, - OnOrBefore, - OnOrAfter, - Absent, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs deleted file mode 100644 index 8ab1c93cc056be..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/ExpressionOperation.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Melanzana.CodeSign.Requirements -{ - public enum ExpressionOperation : int - { - False, - True, - Ident, - AppleAnchor, - AnchorHash, - InfoKeyValue, - And, - Or, - CDHash, - Not, - InfoKeyField, - CertField, - TrustedCert, - TrustedCerts, - CertGeneric, - AppleGenericAnchor, - EntitlementField, - CertPolicy, - NamedAnchor, - NamedCode, - Platform, - Notarized, - CertFieldDate, - LegacyDevID, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs deleted file mode 100644 index 4f5d8b0e437216..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/Requirement.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Buffers.Binary; -using System.Diagnostics; -using Melanzana.CodeSign.Blobs; - -namespace Melanzana.CodeSign.Requirements -{ - public class Requirement - { - public Requirement(Expression expression) - { - Expression = expression; - } - - public Expression Expression { get; private set; } - - public static Requirement FromBlob(ReadOnlySpan blob) - { - var blobMagic = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(0, 4)); - var blobSize = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(4, 4)); - var matchType = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(8, 4)); - Debug.Assert(blobMagic == (uint)BlobMagic.Requirement); - Debug.Assert(blobSize == blob.Length); - Debug.Assert(matchType == 1u); // Expression - return new Requirement(Expression.FromBlob(blob.Slice(12))); - } - - public byte[] AsBlob() - { - byte[] blobBuffer = new byte[Expression.Size + 12]; - - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Requirement); - BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(4, 4), blobBuffer.Length); - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(8, 4), 1u); // Expression - Expression.Write(blobBuffer.AsSpan(12), out var _); - - return blobBuffer; - } - - public override string? ToString() => Expression.ToString(); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs deleted file mode 100644 index 67dbcb6d418e81..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementSet.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Buffers.Binary; -using System.Diagnostics; -using Melanzana.CodeSign.Blobs; - -namespace Melanzana.CodeSign.Requirements -{ - public class RequirementSet : Dictionary - { - public RequirementSet() - { - } - - public static RequirementSet FromBlob(ReadOnlySpan blob) - { - var requirementSet = new RequirementSet(); - var superBlobMagic = BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(0, 4)); - var subBlobCount = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(8, 4)); - Debug.Assert(superBlobMagic == (uint)BlobMagic.Requirements); - for (int i = 0; i < subBlobCount; i++) - { - var requirementType = (RequirementType)BinaryPrimitives.ReadUInt32BigEndian(blob.Slice(12 + i * 8, 4)); - var blobOffset = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(16 + i * 8, 4)); - var blobSize = BinaryPrimitives.ReadInt32BigEndian(blob.Slice(blobOffset + 4, 4)); - requirementSet[requirementType] = Requirement.FromBlob(blob.Slice(blobOffset, blobSize)); - } - return requirementSet; - } - - public byte[] AsBlob() - { - var requirentBlobs = this.Select(i => new { Type = i.Key, Blob = i.Value.AsBlob() }).ToArray(); - var blobBuffer = new byte[12 + requirentBlobs.Sum(i => i.Blob.Length + 8)]; - - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(0, 4), (uint)BlobMagic.Requirements); - BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(4, 4), blobBuffer.Length); - BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(8, 4), requirentBlobs.Length); - - int offset = 12 + (requirentBlobs.Length * 8); - for (int i = 0; i < requirentBlobs.Length; i++) - { - BinaryPrimitives.WriteUInt32BigEndian(blobBuffer.AsSpan(12 + (i * 8), 4), (uint)requirentBlobs[i].Type); - BinaryPrimitives.WriteInt32BigEndian(blobBuffer.AsSpan(16 + (i * 8), 4), offset); - requirentBlobs[i].Blob.CopyTo(blobBuffer.AsSpan(offset, requirentBlobs[i].Blob.Length)); - offset += requirentBlobs[i].Blob.Length; - } - - return blobBuffer; - } - - //public override string? ToString() => Expression.ToString(); - - public static RequirementSet CreateDefault(string bundleIdentifier, string certificateFriendlyName) - { - if (string.IsNullOrEmpty(bundleIdentifier)) - throw new ArgumentNullException(nameof(bundleIdentifier)); - if (string.IsNullOrEmpty(certificateFriendlyName)) - throw new ArgumentNullException(nameof(certificateFriendlyName)); - - var expression = Expression.And( - Expression.Ident(bundleIdentifier), - Expression.And( - Expression.AppleGenericAnchor, - Expression.And( - Expression.CertField(0, "subject.CN", ExpressionMatchType.Equal, certificateFriendlyName), - Expression.CertGeneric(1, "1.2.840.113635.100.6.2.1", ExpressionMatchType.Exists) - ) - ) - ); - return new RequirementSet { { RequirementType.Designated, new Requirement(expression) }}; - } - - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs deleted file mode 100644 index c75bcbe7f32e01..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Requirements/RequirementType.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Melanzana.CodeSign.Requirements -{ - public enum RequirementType : uint - { - Host = 1u, - Guest, - Designated, - Library, - Plugin, - Invalid - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs deleted file mode 100644 index b3246242a934b4..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceBuilder.cs +++ /dev/null @@ -1,98 +0,0 @@ -namespace Melanzana.CodeSign -{ - public class ResourceBuilder - { - private readonly HashSet exclusions = new(); - private readonly List rules = new(); - - public ResourceBuilder() - { - } - - public void AddRule(ResourceRule rule) - { - rules.Add(rule); - } - - public void AddExclusion(string path) - { - exclusions.Add(path); - } - - public ResourceRule? FindRule(string path) - { - ResourceRule? bestRule = null; - - foreach (var candidateRule in rules) - { - if (bestRule == null || candidateRule.Weight >= bestRule.Weight) - { - if (candidateRule.IsMatch(path)) - { - if (bestRule == null || candidateRule.Weight > bestRule.Weight) - { - bestRule = candidateRule; - } - else if (bestRule.Weight == candidateRule.Weight && !bestRule.IsOmitted && candidateRule.IsOmitted) - { - // In case of matching weight compare by IsOmitted. Apple tools do this only - // for watchOS but we opt to do it everywhere. - bestRule = candidateRule; - } - } - } - } - - return bestRule; - } - - private IEnumerable<(string Path, FileSystemInfo Info, ResourceRule Rule)> Scan(string path, string relativePath) - { - var rootDirectoryInfo = new DirectoryInfo(path); - - foreach (var fsEntryInfo in rootDirectoryInfo.EnumerateFileSystemInfos().OrderBy(i => i.Name, StringComparer.Ordinal)) - { - string fsEntryPath = Path.Combine(relativePath, fsEntryInfo.Name); - - if (exclusions.Contains(fsEntryPath, StringComparer.OrdinalIgnoreCase)) - { - continue; - } - - var rule = FindRule(fsEntryPath); - - // TODO: Check symlinks (should be treated as files) - if (fsEntryInfo is FileInfo) - { - if (rule != null && !rule.IsOmitted) - { - yield return (fsEntryPath, fsEntryInfo, rule); - } - } - else if (fsEntryInfo is DirectoryInfo) - { - // Directories cannot be matched with omit/optional rules but - // they can be matched with a rule for nested bundle. - if (rule != null && rule.IsNested && fsEntryInfo.Extension.Length > 0) - { - yield return (fsEntryPath, fsEntryInfo, rule); - } - else - { - foreach (var nestedResult in Scan(fsEntryInfo.FullName, fsEntryPath)) - { - yield return nestedResult; - } - } - } - } - } - - public IEnumerable <(string Path, FileSystemInfo Info, ResourceRule Rule)> Scan(string bundlePath) - { - return Scan(bundlePath, ""); - } - - public IEnumerable Rules => rules; - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs deleted file mode 100644 index 8848cf2a239a3a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/ResourceRule.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Text.RegularExpressions; - -namespace Melanzana.CodeSign -{ - public class ResourceRule - { - /// Resource may be absent at runtime - public bool IsOptional { get; init; } - - /// Resource is not sealed even if present in the bundle - public bool IsOmitted { get; init; } - - /// Recursively signed code - public bool IsNested { get; init; } - - /// Precedence weight of the rule (rules with higher weight override rules with lower weight) - public uint Weight { get; init; } = 1; - - /// Regular expression pattern for match full path in the bundle - public string Pattern { get; private set; } - - private readonly Regex regex; - - public ResourceRule(string pattern) - { - Pattern = pattern; - regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); - } - - public bool IsMatch(string path) => regex.IsMatch(path); - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs deleted file mode 100644 index 5e3219679da567..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.CodeSign/Signer.cs +++ /dev/null @@ -1,459 +0,0 @@ -using Claunia.PropertyList; -using System.Buffers.Binary; -using System.Diagnostics; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using Melanzana.CodeSign.Blobs; -using Melanzana.MachO; -using Melanzana.Streams; -using Melanzana.CodeSign.Requirements; - -namespace Melanzana.CodeSign -{ - public class Signer - { - private readonly CodeSignOptions codeSignOptions; - - public Signer(CodeSignOptions codeSignOptions) - { - this.codeSignOptions = codeSignOptions; - } - - private string GetTeamId() - { - return codeSignOptions.DeveloperCertificate?.GetTeamId() ?? string.Empty; - } - - /// - /// Determine ideal set of hash types necessary for code signing. - /// - /// - /// macOS 10.11.4 and iOS/tvOS 11 have support for SHA-256. If the minimum platform - /// version specified in the executable is equal or higher than those we only - /// generate SHA-256. Otherwise we fallback to generating both SHA-1 and SHA-256. - /// - private static HashType[] GetHashTypesForObjectFile(MachObjectFile objectFile) - { - var buildVersion = objectFile.LoadCommands.OfType().FirstOrDefault(); - if (buildVersion != null) - { - switch (buildVersion.Platform) - { - case MachPlatform.MacOS: - if (buildVersion.MinimumPlatformVersion >= new Version(10, 11, 4)) - return new[] { HashType.SHA256 }; - break; - case MachPlatform.IOS: - case MachPlatform.TvOS: - if (buildVersion.MinimumPlatformVersion.Major >= 11) - return new[] { HashType.SHA256 }; - break; - } - } - return new[] { HashType.SHA1, HashType.SHA256 }; - } - - private void SignMachO(string executablePath, string? bundleIdentifier = null, byte[]? resourceSealBytes = null) - { - var teamId = GetTeamId(); - - bundleIdentifier ??= Path.GetFileName(executablePath); - - byte[]? requirementsBlob = null; - byte[]? entitlementsBlob = null; - byte[]? entitlementsDerBlob = null; - - var hashTypesPerArch = new Dictionary<(MachCpuType cpuType, uint cpuSubType), HashType[]>(); - var cdBuildersPerArch = new Dictionary<(MachCpuType cpuType, uint cpuSubType), CodeDirectoryBuilder[]>(); - - ExecutableSegmentFlags executableSegmentFlags = 0; - - if (codeSignOptions.DeveloperCertificate != null) - { - requirementsBlob = RequirementSet.CreateDefault( - bundleIdentifier, - codeSignOptions.DeveloperCertificate.GetNameInfo(X509NameType.SimpleName, false)).AsBlob(); - } - - if (codeSignOptions.Entitlements is Entitlements entitlements) - { - executableSegmentFlags |= entitlements.GetTaskAllow ? ExecutableSegmentFlags.AllowUnsigned : 0; - executableSegmentFlags |= entitlements.RunUnsignedCode ? ExecutableSegmentFlags.AllowUnsigned : 0; - executableSegmentFlags |= entitlements.Debugger ? ExecutableSegmentFlags.Debugger : 0; - executableSegmentFlags |= entitlements.DynamicCodeSigning ? ExecutableSegmentFlags.Jit : 0; - executableSegmentFlags |= entitlements.SkipLibraryValidation ? ExecutableSegmentFlags.SkipLibraryValidation : 0; - executableSegmentFlags |= entitlements.CanLoadCdHash ? ExecutableSegmentFlags.CanLoadCdHash : 0; - executableSegmentFlags |= entitlements.CanExecuteCdHash ? ExecutableSegmentFlags.CanExecuteCdHash : 0; - - entitlementsBlob = EntitlementsBlob.Create(entitlements); - entitlementsDerBlob = EntitlementsDerBlob.Create(entitlements); - } - - var inputFile = File.OpenRead(executablePath); - var objectFiles = MachReader.Read(inputFile).ToList(); - var codeSignAllocate = new CodeSignAllocate(objectFiles); - foreach (var objectFile in objectFiles) - { - var hashTypes = GetHashTypesForObjectFile(objectFile); - var cdBuilders = new CodeDirectoryBuilder[hashTypes.Length]; - - hashTypesPerArch.Add((objectFile.CpuType, objectFile.CpuSubType), hashTypes); - cdBuildersPerArch.Add((objectFile.CpuType, objectFile.CpuSubType), cdBuilders); - - long signatureSizeEstimate = 18000; // Blob Wrapper (CMS) - for (int i = 0; i < hashTypes.Length; i++) - { - cdBuilders[i] = new CodeDirectoryBuilder(objectFile, bundleIdentifier, teamId) - { - HashType = hashTypes[i], - }; - - cdBuilders[i].ExecutableSegmentFlags |= executableSegmentFlags; - - if (codeSignOptions.DeveloperCertificate == null) - cdBuilders[i].Flags |= CodeDirectoryFlags.Adhoc; - if (requirementsBlob != null) - cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.Requirements, requirementsBlob); - if (entitlementsBlob != null) - cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.Entitlements, entitlementsBlob); - if (entitlementsDerBlob != null) - cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.EntitlementsDer, entitlementsDerBlob); - if (resourceSealBytes != null) - cdBuilders[i].SetSpecialSlotData(CodeDirectorySpecialSlot.ResourceDirectory, resourceSealBytes); - - signatureSizeEstimate += cdBuilders[i].Size(CodeDirectoryVersion.HighestVersion); - } - - signatureSizeEstimate += requirementsBlob?.Length ?? 0; - signatureSizeEstimate += entitlementsBlob?.Length ?? 0; - signatureSizeEstimate += entitlementsBlob?.Length ?? 0; - - var codeSignatureCommand = objectFile.LoadCommands.OfType().FirstOrDefault(); - if (codeSignatureCommand == null || - codeSignatureCommand.FileSize < signatureSizeEstimate) - { - codeSignAllocate.SetArchSize(objectFile, (uint)signatureSizeEstimate); - } - } - - string tempFileName = codeSignAllocate.Allocate(); - inputFile.Close(); - - // Re-read the object files - inputFile = File.OpenRead(tempFileName); - objectFiles = MachReader.Read(inputFile).ToList(); - foreach (var objectFile in objectFiles) - { - var hashTypes = hashTypesPerArch[(objectFile.CpuType, objectFile.CpuSubType)]; - var cdBuilders = cdBuildersPerArch[(objectFile.CpuType, objectFile.CpuSubType)]; - - var blobs = new List<(CodeDirectorySpecialSlot Slot, byte[] Data)>(); - var codeDirectory = cdBuilders[0].Build(objectFile.GetOriginalStream()); - - blobs.Add((CodeDirectorySpecialSlot.CodeDirectory, codeDirectory)); - if (requirementsBlob != null) - blobs.Add((CodeDirectorySpecialSlot.Requirements, requirementsBlob)); - if (entitlementsBlob != null) - blobs.Add((CodeDirectorySpecialSlot.Entitlements, entitlementsBlob)); - if (entitlementsDerBlob != null) - blobs.Add((CodeDirectorySpecialSlot.EntitlementsDer, entitlementsDerBlob)); - - var cdHashes = new byte[hashTypes.Length][]; - var hasher = hashTypes[0].GetIncrementalHash(); - hasher.AppendData(codeDirectory); - cdHashes[0] = hasher.GetHashAndReset(); - for (int i = 1; i < hashTypes.Length; i++) - { - byte[] alternativeCodeDirectory = cdBuilders[i].Build(objectFile.GetOriginalStream()); - blobs.Add((CodeDirectorySpecialSlot.AlternativeCodeDirectory + i - 1, alternativeCodeDirectory)); - hasher = hashTypes[i].GetIncrementalHash(); - hasher.AppendData(alternativeCodeDirectory); - cdHashes[i] = hasher.GetHashAndReset(); - } - - var cmsWrapperBlob = CmsWrapperBlob.Create( - codeSignOptions.DeveloperCertificate, - codeSignOptions.PrivateKey, - codeDirectory, - hashTypes, - cdHashes); - blobs.Add((CodeDirectorySpecialSlot.CmsWrapper, cmsWrapperBlob)); - - /// TODO: Hic sunt leones (all code below) - - // Rewrite LC_CODESIGNATURE data - var codeSignatureCommand = objectFile.LoadCommands.OfType().First(); - - // FIXME: Adjust the size to match LinkEdit section? - long size = blobs.Sum(b => b.Data != null ? b.Data.Length + 8 : 0); - - var embeddedSignatureBuffer = new byte[12 + (blobs.Count * 8)]; - BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(0, 4), (uint)BlobMagic.EmbeddedSignature); - BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(4, 4), (uint)(12 + size)); - BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(8, 4), (uint)blobs.Count); - int bufferOffset = 12; - int dataOffset = embeddedSignatureBuffer.Length; - foreach (var (slot, data) in blobs) - { - BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(bufferOffset, 4), (uint)slot); - BinaryPrimitives.WriteUInt32BigEndian(embeddedSignatureBuffer.AsSpan(bufferOffset + 4, 4), (uint)dataOffset); - dataOffset += data.Length; - bufferOffset += 8; - } - uint codeSignatureSize = codeSignatureCommand.FileSize; - using var codeSignatureStream = codeSignatureCommand.Data.GetWriteStream(); - codeSignatureStream.Write(embeddedSignatureBuffer); - foreach (var (slot, data) in blobs) - { - codeSignatureStream.Write(data); - } - codeSignatureStream.WritePadding(codeSignatureSize - codeSignatureStream.Position); - } - - using var outputFile = File.OpenWrite(executablePath); - MachWriter.Write(outputFile, objectFiles); - inputFile.Close(); - } - - public void SignBundle(Bundle bundle) - { - var resourceSeal = BuildResourceSeal(bundle); - var resourceSealBytes = Encoding.UTF8.GetBytes(resourceSeal.ToXmlPropertyList()); - - Directory.CreateDirectory(Path.Combine(bundle.ContentsPath, "_CodeSignature")); - File.WriteAllBytes(Path.Combine(bundle.ContentsPath, "_CodeSignature", "CodeResources"), resourceSealBytes); - - if (bundle.MainExecutable != null) - { - SignMachO(bundle.MainExecutable, bundle.BundleIdentifier, resourceSealBytes); - } - } - - public void Sign(string path) - { - var attributes = File.GetAttributes(path); - - // Assume a directory is a bundle - if (attributes.HasFlag(FileAttributes.Directory)) - { - var bundle = new Bundle(path); - SignBundle(bundle); - } - else - { - // TODO: Add support for signing regular files, etc. - SignMachO(path); - } - } - - private static NSDictionary BuildResourceRulesPList(IEnumerable rules) - { - var rulesPList = new NSDictionary(); - - foreach (var rule in rules) - { - if (rule.Weight == 1 && !rule.IsNested && !rule.IsOmitted && !rule.IsOptional) - { - rulesPList.Add(rule.Pattern, true); - } - else - { - var rulePList = new NSDictionary(); - if (rule.Weight != 1) - rulePList.Add("weight", (double)rule.Weight); - if (rule.IsOmitted) - rulePList.Add("omit", true); - if (rule.IsOptional) - rulePList.Add("optional", true); - if (rule.IsNested) - rulePList.Add("nested", true); - rulesPList.Add(rule.Pattern, rulePList); - } - } - - return rulesPList; - } - - private NSDictionary BuildResourceSeal(Bundle bundle) - { - var sha1 = IncrementalHash.CreateHash(HashAlgorithmName.SHA1); - var sha256 = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); - var buffer = new byte[65536]; - - var resourceBuilder = new ResourceBuilder(); - bundle.AddResourceRules(resourceBuilder, useV2Rules: true); - - var rules2 = BuildResourceRulesPList(resourceBuilder.Rules); - var files2 = new NSDictionary(); - foreach (var resourceAndRule in resourceBuilder.Scan(bundle.ContentsPath)) - { - var files2Value = new NSDictionary(2); - - if (resourceAndRule.Rule.IsNested) - { - if (codeSignOptions.Deep) - { - Sign(resourceAndRule.Info.FullName); - } - - var nestedInfo = ReadNested(resourceAndRule.Info.FullName); - if (nestedInfo.HasValue) - { - files2Value.Add("cdhash", new NSData(nestedInfo.Value.CodeDirectoryHash)); - if (nestedInfo.Value.DesignatedRequirement != null) - files2Value.Add("requirement", nestedInfo.Value.DesignatedRequirement.ToString()); - } - } - else if (resourceAndRule.Info.LinkTarget != null) - { - files2Value.Add("symlink", resourceAndRule.Info.LinkTarget); - } - else - { - using (var fileStream = File.OpenRead(resourceAndRule.Info.FullName)) - { - int bytesRead; - while ((bytesRead = fileStream.Read(buffer)) > 0) - { - sha1.AppendData(buffer.AsSpan(0, bytesRead)); - sha256.AppendData(buffer.AsSpan(0, bytesRead)); - } - } - - files2Value.Add("hash", new NSData(sha1.GetHashAndReset())); - files2Value.Add("hash2", new NSData(sha256.GetHashAndReset())); - - if (resourceAndRule.Rule.IsOptional) - { - files2Value.Add("optional", true); - } - } - - files2.Add(resourceAndRule.Path, files2Value); - }; - - // Version 1 resources - resourceBuilder = new ResourceBuilder(); - bundle.AddResourceRules(resourceBuilder, useV2Rules: false); - - var rules = BuildResourceRulesPList(resourceBuilder.Rules); - var files = new NSDictionary(); - foreach (var resourceAndRule in resourceBuilder.Scan(bundle.ContentsPath)) - { - NSData hash; - - Debug.Assert(resourceAndRule.Info is FileInfo); - - if (resourceAndRule.Info.LinkTarget != null) - { - continue; - } - - if (files2.TryGetValue(resourceAndRule.Path, out var files2Value)) - { - hash = (NSData)((NSDictionary)files2Value)["hash"]; - } - else - { - using (var fileStream = File.OpenRead(resourceAndRule.Info.FullName)) - { - int bytesRead; - while ((bytesRead = fileStream.Read(buffer)) > 0) - { - sha1.AppendData(buffer.AsSpan(0, bytesRead)); - } - } - - hash = new NSData(sha1.GetHashAndReset()); - } - - if (resourceAndRule.Rule.IsOptional) - { - var filesValue = new NSDictionary(2); - filesValue.Add("hash", hash); - filesValue.Add("optional", true); - files.Add(resourceAndRule.Path, filesValue); - } - else - { - files.Add(resourceAndRule.Path, hash); - } - } - - // Write down the rules and hashes - return new NSDictionary { { "files", files }, { "files2", files2 }, { "rules", rules }, { "rules2", rules2 } }; - } - - private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNestedMachO(string executablePath) - { - using var f = File.OpenRead(executablePath); - var objectFile = MachReader.Read(f).First(); - var codeSignature = objectFile.LoadCommands.OfType().FirstOrDefault(); - if (codeSignature == null) - return null; - - var codeSignatureStream = objectFile.GetStreamAtFileOffset(codeSignature.FileOffset, codeSignature.FileSize); - var superBlob = new byte[codeSignature.FileSize]; - codeSignatureStream.ReadFully(superBlob); - - var superBlobMagic = BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(0, 4)); - var superBlobSize = BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(4, 4)); - var superBlobCount = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(8, 4)); - - Debug.Assert(superBlobMagic == (uint)BlobMagic.EmbeddedSignature); - var slotOffsetDictionary = new Dictionary(superBlobCount); - - for (int i = 0; i < superBlobCount; i++) - { - var slot = (CodeDirectorySpecialSlot)BinaryPrimitives.ReadUInt32BigEndian(superBlob.AsSpan(i * 8 + 12, 4)); - var slotOffset = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(i * 8 + 16, 4)); - slotOffsetDictionary[slot] = slotOffset; - } - - Requirement? designatedRequirement = null; - if (slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.Requirements, out var requirementsOffset)) - { - var requirementsSize = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(requirementsOffset + 4, 4)); - var requirementSet = RequirementSet.FromBlob(superBlob.AsSpan(requirementsOffset, requirementsSize)); - requirementSet.TryGetValue(RequirementType.Designated, out designatedRequirement); - } - - // FIXME: Get correct CD - if (slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.AlternativeCodeDirectory, out var codeDirectoryOffset) || - slotOffsetDictionary.TryGetValue(CodeDirectorySpecialSlot.CodeDirectory, out codeDirectoryOffset)) - { - var codeDirectorySize = BinaryPrimitives.ReadInt32BigEndian(superBlob.AsSpan(codeDirectoryOffset + 4, 4)); - var codeDirectoryBlob = superBlob.AsSpan(codeDirectoryOffset, codeDirectorySize); - var codeDirectoryHeader = CodeDirectoryBaselineHeader.Read(codeDirectoryBlob, out _); - var hasher = codeDirectoryHeader.HashType.GetIncrementalHash(); - hasher.AppendData(codeDirectoryBlob); - return (designatedRequirement, hasher.GetHashAndReset().AsSpan(0, 20).ToArray()); - } - - return null; - } - - private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNestedBundle(string bundlePath) - { - var bundle = new Bundle(bundlePath); - return bundle.MainExecutable != null ? ReadNestedMachO(bundle.MainExecutable) : null; - } - - private static (Requirement? DesignatedRequirement, byte[] CodeDirectoryHash)? ReadNested(string path) - { - var attributes = File.GetAttributes(path); - - // Assume a directory is a bundle - if (attributes.HasFlag(FileAttributes.Directory)) - { - return ReadNestedBundle(path); - } - else - { - // TODO: Add support for signing regular files, etc. - return ReadNestedMachO(path); - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs deleted file mode 100644 index e6d0461ba8554c..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/CreateTests.cs +++ /dev/null @@ -1,176 +0,0 @@ -using Xunit; -using System.IO; -using System.Linq; -using Melanzana.Streams; -using System; - -namespace Melanzana.MachO.Tests -{ - public class CreateTests - { - [Fact] - public void CreateExecutable() - { - // Let's try to build a new macho! - var objectFile = new MachObjectFile(); - - // Header - objectFile.CpuType = MachCpuType.Arm64; - objectFile.FileType = MachFileType.Execute; - objectFile.Flags = MachHeaderFlags.PIE | MachHeaderFlags.TwoLevel | MachHeaderFlags.DynamicLink | MachHeaderFlags.NoUndefinedReferences; - - // Segments - var pageZeroSegment = new MachSegment(objectFile, "__PAGEZERO") - { - VirtualAddress = 0, - Size = 0x100000000, - }; - - var textSegment = new MachSegment(objectFile, "__TEXT") - { - FileOffset = 0, - VirtualAddress = 0x100000000, - Size = 0x4000, - InitialProtection = MachVmProtection.Execute | MachVmProtection.Read, - MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read, - }; - - var textSection = new MachSection(objectFile, "__TEXT", "__text") - { - Log2Alignment = 2, - Type = MachSectionType.Regular, - Attributes = MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, - }; - - using (var textWriter = textSection.GetWriteStream()) - { - textWriter.Write(new byte[] { 0x00, 0x00, 0x80, 0x52 }); // mov w0, #0 - textWriter.Write(new byte[] { 0xc0, 0x03, 0x5f, 0xd6 }); // ret - textSection.FileOffset = 0x4000u - (uint)textWriter.Position; - textSection.VirtualAddress = textSegment.VirtualAddress + textSection.FileOffset; - } - - var linkEditSegment = new MachSegment(objectFile, "__LINKEDIT") - { - VirtualAddress = textSection.VirtualAddress + textSection.Size, - // FileOffset = - // FileSize = - InitialProtection = MachVmProtection.Read, - MaximumProtection = MachVmProtection.Read, - }; - - // TODO: This test is incomplete. We should have a layout calculator and a validation. - } - - [Fact] - public void CreateObjectFile() - { - var objectFile = new MachObjectFile(); - - objectFile.CpuType = MachCpuType.Arm64; - objectFile.CpuSubType = 0; - objectFile.FileType = MachFileType.Object; - objectFile.Flags = MachHeaderFlags.SubsectionsViaSymbols; - objectFile.IsLittleEndian = true; - - var segment = new MachSegment(objectFile, "") - { - InitialProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, - MaximumProtection = MachVmProtection.Execute | MachVmProtection.Read | MachVmProtection.Write, - }; - - var textSection = new MachSection(objectFile, "__TEXT", "__text") - { - Log2Alignment = 2, - Type = MachSectionType.Regular, - Attributes = MachSectionAttributes.SomeInstructions | MachSectionAttributes.PureInstructions, - }; - - var compactUnwindSection = new MachSection(objectFile, "__LD", "__compact_unwind") - { - Log2Alignment = 3, - Type = MachSectionType.Regular, - Attributes = MachSectionAttributes.Debug, - }; - - segment.Sections.Add(textSection); - segment.Sections.Add(compactUnwindSection); - objectFile.LoadCommands.Add(segment); - - using (var textWriter = textSection.GetWriteStream()) - { - textWriter.Write(new byte[] { 0xff, 0x43, 0x00, 0xd1 }); // sub sp, sp, #0x10 - textWriter.Write(new byte[] { 0x00, 0x00, 0x80, 0x52 }); // mov w0, #0 - textWriter.Write(new byte[] { 0xff, 0x0f, 0x00, 0xb9 }); // str wzr, [sp, #0xc] - textWriter.Write(new byte[] { 0xff, 0x43, 0x00, 0x91 }); // add sp, sp, #0x10 - textWriter.Write(new byte[] { 0xc0, 0x03, 0x5f, 0xd6 }); // ret - } - - using (var compactUnwindWriter = compactUnwindSection.GetWriteStream()) - { - // Address of _main - compactUnwindSection.Relocations.Add(new MachRelocation - { - Address = 0, - SymbolOrSectionIndex = 1, // TODO: Better symbolic reference? - Length = 8, - RelocationType = MachRelocationType.Arm64Unsigned, - IsExternal = false, - IsPCRelative = false, - }); - compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); - - compactUnwindWriter.Write(new byte[] { 0x14, 0x00, 0x00, 0x00 }); // Length of _main - compactUnwindWriter.Write(new byte[] { 0x00, 0x10, 0x00, 0x02 }); // Unwind code - compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); // No personality - compactUnwindWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); // No LSDA - } - - // Verify the relocation was written correctly - Assert.NotNull(compactUnwindSection.RelocationData); - Assert.Equal(8u, compactUnwindSection.RelocationData!.Size); - using (var s = compactUnwindSection.RelocationData.GetReadStream()) - { - byte[] r = new byte[8]; - s.ReadFully(r); - Assert.Equal(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06 }, r); - } - - objectFile.LoadCommands.Add(new MachBuildVersion - { - TargetPlatform = MachPlatform.MacOS, - MinimumPlatformVersion = new Version(12, 0, 0), - SdkVersion = new Version(12, 0, 0), - }); - - var symbolTable = new MachSymbolTable(objectFile); - objectFile.LoadCommands.Add(symbolTable); - // FIXME: Values - symbolTable.Symbols.Add(new MachSymbol { Name = "ltmp0", Section = textSection, Value = 0, Descriptor = 0, Type = MachSymbolType.Section }); - symbolTable.Symbols.Add(new MachSymbol { Name = "ltmp1", Section = compactUnwindSection, Value = 0x18, Descriptor = 0, Type = MachSymbolType.Section }); - symbolTable.Symbols.Add(new MachSymbol { Name = "_main", Section = textSection, Value = 0, Descriptor = 0, Type = MachSymbolType.Section | MachSymbolType.External }); - objectFile.LoadCommands.Add(new MachDynamicLinkEditSymbolTable(symbolTable)); - - objectFile.UpdateLayout(); - Assert.Equal(0u, segment.VirtualAddress); - Assert.Equal(0x38u, segment.Size); - Assert.Equal(0x188u, segment.FileOffset); - Assert.Equal(0x38u, segment.FileSize); - Assert.Equal(0u, textSection.VirtualAddress); - Assert.Equal(0x14u, textSection.Size); - Assert.Equal(0x188u, textSection.FileOffset); - Assert.Equal(0x18u, compactUnwindSection.VirtualAddress); - Assert.Equal(0x20u, compactUnwindSection.Size); - Assert.Equal(0x1a0u, compactUnwindSection.FileOffset); - - // Ensure that write doesn't crash - var binaryFile = new MemoryStream(); - MachWriter.Write(binaryFile, objectFile); - Assert.Equal(528, binaryFile.Length); - - // Ensure that the file can be read again - binaryFile.Position = 0; - _ = MachReader.Read(binaryFile); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.fat.out deleted file mode 100755 index be993902e6128edc3e2e86341e48b8ca38bdd2a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 84128 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 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Data/a.out deleted file mode 100755 index ce1e62c9c1815e7e57ab6ca0fa0cb6eac842a59d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 34976 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 diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj deleted file mode 100644 index e32ea378566372..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/Melanzana.MachO.Tests.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - net6.0 - enable - - false - - - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs deleted file mode 100644 index ef4aef8710ec32..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/ReadTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Xunit; -using System.IO; -using System.Linq; -using Melanzana.Streams; -using System; - -namespace Melanzana.MachO.Tests -{ - public class ReadTests - { - [Fact] - public void ReadExecutable() - { - var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.out")!; - var objectFile = MachReader.Read(aOutStream).First(); - - var segments = objectFile.LoadCommands.OfType().ToArray(); - Assert.Equal("__PAGEZERO", segments[0].Name); - Assert.Equal("__TEXT", segments[1].Name); - Assert.Equal("__LINKEDIT", segments[2].Name); - - var symbolTable = objectFile.LoadCommands.OfType().FirstOrDefault(); - Assert.NotNull(symbolTable); - var symbols = symbolTable!.Symbols.ToArray(); - Assert.Equal(2, symbols.Length); - Assert.Equal("__mh_execute_header", symbols[0].Name); - Assert.Equal(0x100000000u, symbols[0].Value); - Assert.Equal("_main", symbols[1].Name); - Assert.Equal(0x100003fa4u, symbols[1].Value); - - var buildVersion = objectFile.LoadCommands.OfType().FirstOrDefault(); - Assert.NotNull(buildVersion); - Assert.Equal(MachPlatform.MacOS, buildVersion!.Platform); - Assert.Equal("12.0.0", buildVersion!.MinimumPlatformVersion.ToString()); - Assert.Equal("12.0.0", buildVersion!.SdkVersion.ToString()); - Assert.Equal(1, buildVersion!.ToolVersions.Count); - Assert.Equal(MachBuildTool.Ld, buildVersion!.ToolVersions[0].BuildTool); - Assert.Equal("711.0.0", buildVersion!.ToolVersions[0].Version.ToString()); - } - - [Fact] - public void ReadObjectFile() - { - var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.o")!; - var objectFile = MachReader.Read(aOutStream).First(); - - var segments = objectFile.LoadCommands.OfType().ToArray(); - Assert.Single(segments); - - var textSection = segments[0].Sections[0]; - var compactUnwindSection = segments[0].Sections[1]; - - Assert.Equal("__TEXT", textSection.SegmentName); - Assert.Equal("__text", textSection.SectionName); - Assert.Equal("__LD", compactUnwindSection.SegmentName); - Assert.Equal("__compact_unwind", compactUnwindSection.SectionName); - - var relocations = compactUnwindSection.Relocations; - Assert.Single(relocations); - var relec0 = relocations.First(); - Assert.Equal(0, relec0.Address); - Assert.False(relec0.IsPCRelative); - Assert.False(relec0.IsExternal); - Assert.Equal(1u, relec0.SymbolOrSectionIndex); - Assert.Equal(8, relec0.Length); - Assert.Equal(MachRelocationType.Arm64Unsigned, relec0.RelocationType); - - var symbolTable = objectFile.LoadCommands.OfType().FirstOrDefault(); - Assert.NotNull(symbolTable); - var symbols = symbolTable!.Symbols.ToArray(); - Assert.Equal("ltmp0", symbols[0].Name); - Assert.Equal(textSection, symbols[0].Section); - Assert.Equal(0u, symbols[0].Value); - Assert.Equal("ltmp1", symbols[1].Name); - Assert.Equal(compactUnwindSection, symbols[1].Section); - Assert.Equal(0x18u, symbols[1].Value); - Assert.Equal("_main", symbols[2].Name); - Assert.Equal(textSection, symbols[2].Section); - Assert.Equal(0u, symbols[2].Value); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs deleted file mode 100644 index 0091d91330fdef..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO.Tests/RoundtripTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Xunit; -using System.IO; -using System.Linq; -using Melanzana.Streams; - -namespace Melanzana.MachO.Tests -{ - public class RoundtripTests - { - private static void TestRoundtrip(Stream aOutStream) - { - var outputStream = new MemoryStream(); - var objectFiles = MachReader.Read(aOutStream).ToList(); - MachWriter.Write(outputStream, objectFiles); - - aOutStream.Position = 0; - outputStream.Position = 0; - Assert.Equal(aOutStream.Length, outputStream.Length); - - var input = new byte[aOutStream.Length]; - var output = new byte[aOutStream.Length]; - aOutStream.ReadFully(input); - outputStream.ReadFully(output); - Assert.Equal(input, output); - } - - [Fact] - public void BasicRoundtrip() - { - var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.out")!; - TestRoundtrip(aOutStream); - } - - [Fact] - public void FatRoundtrip() - { - var aFatOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.fat.out")!; - TestRoundtrip(aFatOutStream); - } - - [Fact] - public void ObjectFileRoundtrip() - { - var aOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.o")!; - TestRoundtrip(aOutStream); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs deleted file mode 100644 index 10a40a357bb87e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildToolVersionHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class BuildToolVersionHeader - { - public MachBuildTool BuildTool; - public uint Version { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs deleted file mode 100644 index e9b0be7a10b05b..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/BuildVersionCommandHeader.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class BuildVersionCommandHeader - { - public MachPlatform Platform; - public uint MinimumPlatformVersion { get; set; } - public uint SdkVersion { get; set; } - public uint NumberOfTools { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs deleted file mode 100644 index 6833845e31900c..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DyldInfoHeader.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class DyldInfoHeader - { - public uint RebaseOffset { get; set; } - public uint RebaseSize { get; set; } - public uint BindOffset { get; set; } - public uint BindSize { get; set; } - public uint WeakBindOffset { get; set; } - public uint WeakBindSize { get; set; } - public uint LazyBindOffset { get; set; } - public uint LazyBindSize { get; set; } - public uint ExportOffset { get; set; } - public uint ExportSize { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs deleted file mode 100644 index 3820a59d03ea15..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DylibCommandHeader.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class DylibCommandHeader - { - public uint NameOffset { get; set; } - public uint Timestamp { get; set; } - public uint CurrentVersion { get; set; } - public uint CompatibilityVersion { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs deleted file mode 100644 index 701a19e288e4c0..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/DynamicSymbolTableCommandHeader.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class DynamicSymbolTableCommandHeader - { - public uint LocalSymbolsIndex { get; set; } - public uint LocalSymbolsCount { get; set; } - public uint ExternalSymbolsIndex { get; set; } - public uint ExternalSymbolsCount { get; set; } - public uint UndefinedSymbolsIndex { get; set; } - public uint UndefinedSymbolsCount { get; set; } - public uint TableOfContentsOffset { get; set; } - public uint TableOfContentsCount { get; set; } - public uint ModuleTableOffset { get; set; } - public uint ModuleTableCount { get; set; } - public uint ExternalReferenceTableOffset { get; set; } - public uint ExternalReferenceTableCount { get; set; } - public uint IndirectSymbolTableOffset { get; set; } - public uint IndirectSymbolTableCount { get; set; } - public uint ExternalRelocationTableOffset { get; set; } - public uint ExternalRelocationTableCount { get; set; } - public uint LocalRelocationTableOffset { get; set; } - public uint LocalRelocationTableCount { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs deleted file mode 100644 index 0e34ef88a70671..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatArchHeader.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class FatArchHeader - { - public MachCpuType CpuType { get; set; } - public uint CpuSubType { get; set; } - public uint Offset { get; set; } - public uint Size { get; set; } - public uint Alignment { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs deleted file mode 100644 index 31a9042c7dfe9f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/FatHeader.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class FatHeader - { - public uint NumberOfFatArchitectures { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs deleted file mode 100644 index 65cde3de4dbaca..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/IMachHeader.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - public interface IMachHeader - { - MachCpuType CpuType { get; set; } - uint CpuSubType { get; set; } - MachFileType FileType { get; set; } - uint NumberOfCommands { get; set; } - uint SizeOfCommands { get; set; } - MachHeaderFlags Flags { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs deleted file mode 100644 index fd3d5b95c5f546..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LinkEditHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class LinkEditHeader - { - public uint FileOffset { get; set; } - public uint FileSize { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs deleted file mode 100644 index a05bdfda4b4acd..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/LoadCommandHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class LoadCommandHeader - { - public MachLoadCommandType CommandType { get; set; } - public uint CommandSize { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs deleted file mode 100644 index ceb7ce40b6f32d..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachFixedName.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Text; - -namespace Melanzana.MachO.BinaryFormat -{ - /// - /// Represents 16-byte null-terminated UTF-8 string - /// - public class MachFixedName - { - public const int BinarySize = 16; - - public static MachFixedName Empty = new MachFixedName(""); - - public MachFixedName(string name) - { - Name = name; - } - - public static MachFixedName Read(ReadOnlySpan buffer, out int bytesRead) - { - bytesRead = BinarySize; - var slice = buffer.Slice(0, BinarySize); - var zeroIndex = slice.IndexOf((byte)0); - if (zeroIndex >= 0) - return new MachFixedName(Encoding.UTF8.GetString(slice.Slice(0, zeroIndex))); - return new MachFixedName(Encoding.UTF8.GetString(slice)); - } - - public void Write(Span buffer, out int bytesWritten) - { - // FIXME: Write this correctly - byte[] utf8Name = Encoding.UTF8.GetBytes(Name); - if (utf8Name.Length >= 16) - { - utf8Name.CopyTo(buffer.Slice(0, 16)); - } - else - { - utf8Name.CopyTo(buffer.Slice(0, utf8Name.Length)); - buffer.Slice(utf8Name.Length, 16 - utf8Name.Length).Clear(); - } - bytesWritten = 16; - } - - public string Name { get; init; } - - public static implicit operator string(MachFixedName n) => n.Name; - public static implicit operator MachFixedName(string n) => new MachFixedName(n); - - public override string ToString() => Name; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs deleted file mode 100644 index c0188f3758acbe..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class MachHeader : IMachHeader - { - public MachCpuType CpuType { get; set; } - public uint CpuSubType { get; set; } - public MachFileType FileType { get; set; } - public uint NumberOfCommands { get; set; } - public uint SizeOfCommands { get; set; } - public MachHeaderFlags Flags { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs deleted file mode 100644 index efee1460539b06..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MachHeader64.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class MachHeader64 : IMachHeader - { - public MachCpuType CpuType { get; set; } - public uint CpuSubType { get; set; } - public MachFileType FileType { get; set; } - public uint NumberOfCommands { get; set; } - public uint SizeOfCommands { get; set; } - public MachHeaderFlags Flags { get; set; } - public uint Reserved { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs deleted file mode 100644 index bb4aca9882761a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/MainCommandHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class MainCommandHeader - { - public ulong FileOffset { get; set; } - public ulong StackSize { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs deleted file mode 100644 index 86142e1b5efbfe..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Section64Header.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class Section64Header - { - public MachFixedName SectionName { get; set; } = MachFixedName.Empty; - public MachFixedName SegmentName { get; set; } = MachFixedName.Empty; - public ulong Address { get; set; } - public ulong Size { get; set; } - public uint FileOffset { get; set; } - public uint Log2Alignment { get; set; } - public uint RelocationOffset { get; set; } - public uint NumberOfReloationEntries { get; set; } - public uint Flags { get; set; } - public uint Reserved1 { get; set; } - public uint Reserved2 { get; set; } - public uint Reserved3 { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs deleted file mode 100644 index d815550702336d..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SectionHeader.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class SectionHeader - { - public MachFixedName SectionName { get; set; } = MachFixedName.Empty; - public MachFixedName SegmentName { get; set; } = MachFixedName.Empty; - public uint Address { get; set; } - public uint Size { get; set; } - public uint FileOffset { get; set; } - public uint Log2Alignment { get; set; } - public uint RelocationOffset { get; set; } - public uint NumberOfReloationEntries { get; set; } - public uint Flags { get; set; } - public uint Reserved1 { get; set; } - public uint Reserved2 { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs deleted file mode 100644 index 6e332edc6c440f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/Segment64Header.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class Segment64Header - { - public MachFixedName Name { get; set; } = MachFixedName.Empty; - public ulong Address { get; set; } - public ulong Size { get; set; } - public ulong FileOffset { get; set; } - public ulong FileSize { get; set; } - public MachVmProtection MaximumProtection { get; set; } - public MachVmProtection InitialProtection { get; set; } - public uint NumberOfSections { get; set; } - public MachSegmentFlags Flags { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs deleted file mode 100644 index e8b66da2c13a1a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SegmentHeader.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class SegmentHeader - { - public MachFixedName Name { get; set; } = MachFixedName.Empty; - public uint Address { get; set; } - public uint Size { get; set; } - public uint FileOffset { get; set; } - public uint FileSize { get; set; } - public MachVmProtection MaximumProtection { get; set; } - public MachVmProtection InitialProtection { get; set; } - public uint NumberOfSections { get; set; } - public MachSegmentFlags Flags { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs deleted file mode 100644 index 987835ff68f035..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolHeader.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class SymbolHeader - { - public uint NameIndex { get; set; } - public byte Type { get; set; } - public byte Section { get; set; } - public ushort Descriptor { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs deleted file mode 100644 index f9dbb996fc1047..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/SymbolTableCommandHeader.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class SymbolTableCommandHeader - { - public uint SymbolTableOffset { get; set; } - public uint NumberOfSymbols { get; set; } - public uint StringTableOffset { get; set; } - public uint StringTableSize { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs deleted file mode 100644 index c93a4a11b90695..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/TwoLevelHintsHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class TwoLevelHintsHeader - { - public uint FileOffset { get; set; } - public uint NumberOfHints { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs deleted file mode 100644 index 6a62b1c2cdcf95..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/BinaryFormat/VersionMinCommandHeader.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO.BinaryFormat -{ - [GenerateReaderWriter] - public partial class VersionMinCommandHeader - { - public uint MinimumPlatformVersion { get; set; } - public uint SdkVersion { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs deleted file mode 100644 index d8d23fabb0d1fb..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildTool.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachBuildTool - { - Clang = 1, - Swift = 2, - Ld = 3, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs deleted file mode 100644 index b3bed8a712dd46..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildToolVersion.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachBuildToolVersion - { - public MachBuildTool BuildTool { get; set; } - - public Version Version { get; set; } = MachBuildVersionBase.EmptyVersion; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs deleted file mode 100644 index 6a6af7cc524126..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersion.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachBuildVersion : MachBuildVersionBase - { - public override MachPlatform Platform => TargetPlatform; - - public MachPlatform TargetPlatform { get; set; } - - public IList ToolVersions { get; set; } = new List(); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs deleted file mode 100644 index 6a896fd7d319d8..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachBuildVersionBase.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Melanzana.MachO -{ - public abstract class MachBuildVersionBase : MachLoadCommand - { - internal static readonly Version EmptyVersion = new Version(0, 0, 0); - - public abstract MachPlatform Platform { get; } - - public Version MinimumPlatformVersion { get; set; } = EmptyVersion; - - public Version SdkVersion { get; set; } = EmptyVersion; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs deleted file mode 100644 index f0f77cd43fff65..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCodeSignature.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachCodeSignature : MachLinkEdit - { - public MachCodeSignature(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachCodeSignature(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs deleted file mode 100644 index 2952e4718ee3f2..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachCustomLoadCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Melanzana.MachO.BinaryFormat; - -namespace Melanzana.MachO -{ - public class MachCustomLoadCommand : MachLoadCommand - { - public MachCustomLoadCommand(MachLoadCommandType type, byte[] data) - { - this.Type = type; - this.Data = data; - } - - public MachLoadCommandType Type { get; set; } - - public byte[] Data { get; set; } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs deleted file mode 100644 index 69a90983b82f86..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDataInCode.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDataInCode : MachLinkEdit - { - public MachDataInCode(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachDataInCode(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs deleted file mode 100644 index ac44b3eb08a16b..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldChainedFixups.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDyldChainedFixups : MachLinkEdit - { - public MachDyldChainedFixups(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachDyldChainedFixups(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs deleted file mode 100644 index 63b61e21322114..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldExportsTrie.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDyldExportsTrie : MachLinkEdit - { - public MachDyldExportsTrie(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachDyldExportsTrie(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs deleted file mode 100644 index 12fb8ffd9c75d8..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfo.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDyldInfo : MachLoadCommand - { - public MachDyldInfo(MachObjectFile objectFile) - { - ArgumentNullException.ThrowIfNull(objectFile); - - RebaseData = new MachLinkEditData(); - BindData = new MachLinkEditData(); - WeakBindData = new MachLinkEditData(); - LazyBindData = new MachLinkEditData(); - ExportData = new MachLinkEditData(); - } - - public MachDyldInfo( - MachObjectFile objectFile, - MachLinkEditData rebaseData, - MachLinkEditData bindData, - MachLinkEditData weakBindData, - MachLinkEditData lazyBindData, - MachLinkEditData exportData) - { - ArgumentNullException.ThrowIfNull(objectFile); - ArgumentNullException.ThrowIfNull(rebaseData); - ArgumentNullException.ThrowIfNull(bindData); - ArgumentNullException.ThrowIfNull(weakBindData); - ArgumentNullException.ThrowIfNull(lazyBindData); - ArgumentNullException.ThrowIfNull(exportData); - - RebaseData = rebaseData; - BindData = bindData; - WeakBindData = weakBindData; - LazyBindData = lazyBindData; - ExportData = exportData; - } - - public MachLinkEditData RebaseData { get; private init; } - public MachLinkEditData BindData { get; private init; } - public MachLinkEditData WeakBindData { get; private init; } - public MachLinkEditData LazyBindData { get; private init; } - public MachLinkEditData ExportData { get; private init; } - - internal override IEnumerable LinkEditData - { - get - { - yield return RebaseData; - yield return BindData; - yield return WeakBindData; - yield return LazyBindData; - yield return ExportData; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs deleted file mode 100644 index f1afd9ea09ac80..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDyldInfoOnly.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDyldInfoOnly : MachDyldInfo - { - public MachDyldInfoOnly(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachDyldInfoOnly( - MachObjectFile objectFile, - MachLinkEditData rebaseData, - MachLinkEditData bindData, - MachLinkEditData weakBindData, - MachLinkEditData lazyBindData, - MachLinkEditData exportData) - : base(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs deleted file mode 100644 index 798aa9aeb0fd9b..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCodeSigningDirs.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachDylibCodeSigningDirs : MachLinkEdit - { - public MachDylibCodeSigningDirs(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachDylibCodeSigningDirs(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs deleted file mode 100644 index 1c35f44ec92a9f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDylibCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Text; -using Melanzana.MachO.BinaryFormat; - -namespace Melanzana.MachO -{ - public abstract class MachDylibCommand : MachLoadCommand - { - public string Name { get; set; } = string.Empty; - - public uint Timestamp { get; set; } - - public uint CurrentVersion { get; set; } - - public uint CompatibilityVersion { get; set; } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs deleted file mode 100644 index 0fcf164962f936..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachDynamicLinkEditSymbolTable.cs +++ /dev/null @@ -1,180 +0,0 @@ -using Melanzana.MachO.BinaryFormat; - -namespace Melanzana.MachO -{ - public class MachDynamicLinkEditSymbolTable : MachLoadCommand - { - internal DynamicSymbolTableCommandHeader Header; - - public MachDynamicLinkEditSymbolTable() - { - this.Header = new DynamicSymbolTableCommandHeader(); - } - - public MachDynamicLinkEditSymbolTable(MachSymbolTable symbolTable) - : this() - { - Span bucketUsed = stackalloc bool[3]; - var symbols = symbolTable.Symbols; - int lastBucket = -1; - bool needsSort = false; - - for (int i = 0; i < symbols.Count; i++) - { - int bucket = - symbols[i].IsUndefined ? 2 : - (symbols[i].IsExternal ? 1 : 0); - - if (bucket != lastBucket) - { - switch (lastBucket) - { - case 0: LocalSymbolsCount = (uint)i - LocalSymbolsIndex; break; - case 1: ExternalSymbolsCount = (uint)i - ExternalSymbolsIndex; break; - case 2: UndefinedSymbolsCount = (uint)i - UndefinedSymbolsIndex; break; - } - - if (bucketUsed[bucket]) - { - // Same types of symbols have to be next to each other - throw new InvalidOperationException("Symbol table is not in correct order"); - } - bucketUsed[bucket] = true; - - switch (bucket) - { - case 0: LocalSymbolsIndex = (uint)i; needsSort = false; break; - case 1: ExternalSymbolsIndex = (uint)i; needsSort = true; break; - case 2: UndefinedSymbolsIndex = (uint)i; needsSort = true; break; - } - lastBucket = bucket; - } - else if (needsSort && string.CompareOrdinal(symbols[i - 1].Name, symbols[i].Name) > 0) - { - // External and undefined symbols have to be lexicographically sorted - throw new InvalidOperationException("Symbol table is not sorted"); - } - } - - switch (lastBucket) - { - case 0: LocalSymbolsCount = (uint)symbols.Count - LocalSymbolsIndex; break; - case 1: ExternalSymbolsCount = (uint)symbols.Count - ExternalSymbolsIndex; break; - case 2: UndefinedSymbolsCount = (uint)symbols.Count - UndefinedSymbolsIndex; break; - } - } - - internal MachDynamicLinkEditSymbolTable(DynamicSymbolTableCommandHeader header) - { - this.Header = header; - } - - public uint LocalSymbolsIndex - { - get => Header.LocalSymbolsIndex; - set => Header.LocalSymbolsIndex = value; - } - - public uint LocalSymbolsCount - { - get => Header.LocalSymbolsCount; - set => Header.LocalSymbolsCount = value; - } - - public uint ExternalSymbolsIndex - { - get => Header.ExternalSymbolsIndex; - set => Header.ExternalSymbolsIndex = value; - } - - public uint ExternalSymbolsCount - { - get => Header.ExternalSymbolsCount; - set => Header.ExternalSymbolsCount = value; - } - - public uint UndefinedSymbolsIndex - { - get => Header.UndefinedSymbolsIndex; - set => Header.UndefinedSymbolsIndex = value; - } - - public uint UndefinedSymbolsCount - { - get => Header.UndefinedSymbolsCount; - set => Header.UndefinedSymbolsCount = value; - } - - public uint TableOfContentsOffset - { - get => Header.TableOfContentsOffset; - set => Header.TableOfContentsOffset = value; - } - - public uint TableOfContentsCount - { - get => Header.TableOfContentsCount; - set => Header.TableOfContentsCount = value; - } - - public uint ModuleTableOffset - { - get => Header.ModuleTableOffset; - set => Header.ModuleTableOffset = value; - } - - public uint ModuleTableCount - { - get => Header.ModuleTableCount; - set => Header.ModuleTableCount = value; - } - - public uint ExternalReferenceTableOffset - { - get => Header.ExternalReferenceTableOffset; - set => Header.ExternalReferenceTableOffset = value; - } - - public uint ExternalReferenceTableCount - { - get => Header.ExternalReferenceTableCount; - set => Header.ExternalReferenceTableCount = value; - } - - public uint IndirectSymbolTableOffset - { - get => Header.IndirectSymbolTableOffset; - set => Header.IndirectSymbolTableOffset = value; - } - - public uint IndirectSymbolTableCount - { - get => Header.IndirectSymbolTableCount; - set => Header.IndirectSymbolTableCount = value; - } - - public uint ExternalRelocationTableOffset - { - get => Header.ExternalRelocationTableOffset; - set => Header.ExternalRelocationTableOffset = value; - } - - public uint ExternalRelocationTableCount - { - get => Header.ExternalRelocationTableCount; - set => Header.ExternalRelocationTableCount = value; - } - - public uint LocalRelocationTableOffset - { - get => Header.LocalRelocationTableOffset; - set => Header.LocalRelocationTableOffset = value; - } - - public uint LocalRelocationTableCount - { - get => Header.LocalRelocationTableCount; - set => Header.LocalRelocationTableCount = value; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs deleted file mode 100644 index e1e06f3404fbe5..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachEntrypointCommand.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Text; -using Melanzana.MachO.BinaryFormat; - -namespace Melanzana.MachO -{ - public class MachEntrypointCommand : MachLoadCommand - { - public ulong FileOffset { get; set; } - - public ulong StackSize { get; set; } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs deleted file mode 100644 index 71ea880385309e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachFunctionStarts.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachFunctionStarts : MachLinkEdit - { - public MachFunctionStarts(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachFunctionStarts(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs deleted file mode 100644 index 2db4417fee5cdf..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkEdit.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Melanzana.MachO -{ - public abstract class MachLinkEdit : MachLoadCommand - { - protected readonly MachObjectFile objectFile; - - protected MachLinkEdit(MachObjectFile objectFile) - { - ArgumentNullException.ThrowIfNull(objectFile); - - Data = new MachLinkEditData(); - this.objectFile = objectFile; - } - - protected MachLinkEdit(MachObjectFile objectFile, MachLinkEditData data) - { - ArgumentNullException.ThrowIfNull(objectFile); - ArgumentNullException.ThrowIfNull(data); - - Data = data; - this.objectFile = objectFile; - } - - public uint FileOffset => Data.FileOffset; - - public uint FileSize => (uint)Data.Size; - - public MachLinkEditData Data { get; private init; } - - internal override IEnumerable LinkEditData - { - get - { - yield return Data; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs deleted file mode 100644 index 2c6dbc27bd3d49..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLinkerOptimizationHint.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachLinkerOptimizationHint : MachLinkEdit - { - public MachLinkerOptimizationHint(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachLinkerOptimizationHint(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs deleted file mode 100644 index 12bf9463f76a53..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadDylibCommand.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachLoadDylibCommand : MachDylibCommand - { - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs deleted file mode 100644 index 5b84bc1d84d0ea..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachLoadWeakDylibCommand.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachLoadWeakDylibCommand : MachDylibCommand - { - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs deleted file mode 100644 index 4ab3a19f290daa..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachReexportDylibCommand.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachReexportDylibCommand : MachDylibCommand - { - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs deleted file mode 100644 index ff3b55e183c81a..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSection.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System.ComponentModel; -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - public class MachSection - { - private readonly MachObjectFile objectFile; - private Stream? dataStream; - private MachLinkEditData? relocationData; - private MachRelocationCollection? relocationCollection; - private ulong size; - - public MachSection(MachObjectFile objectFile, string segmentName, string sectionName) - : this(objectFile, segmentName, sectionName, null) - { - } - - public MachSection(MachObjectFile objectFile, string segmentName, string sectionName, Stream? stream) - : this(objectFile, segmentName, sectionName, stream, null) - { - } - - internal MachSection( - MachObjectFile objectFile, - string segmentName, - string sectionName, - Stream? stream, - MachLinkEditData? relocationData) - { - ArgumentNullException.ThrowIfNull(objectFile); - ArgumentNullException.ThrowIfNull(segmentName); - ArgumentNullException.ThrowIfNull(sectionName); - - this.objectFile = objectFile; - this.SegmentName = segmentName; - this.SectionName = sectionName; - this.dataStream = stream; - this.relocationData = relocationData; - } - - /// - /// Gets or sets the name of this section. - /// - public string SectionName { get; private init; } - - /// - /// Gets or sets the name of the segment. - /// - /// - /// For fully linked executables or dynamic libraries this should always be the same as - /// the name of the containing segment. However, intermediate object files - /// () use compact format where all sections are - /// listed under single segment. - /// - public string SegmentName { get; private init; } - - /// - /// Gets or sets the virtual address of this section. - /// - public ulong VirtualAddress { get; set; } - - public ulong Size - { - get => dataStream != null ? (ulong)dataStream.Length : size; - set - { - size = value; - if (dataStream != null) - { - if (!HasContentChanged) - { - var oldStream = dataStream; - HasContentChanged = true; - dataStream = new UnclosableMemoryStream(); - oldStream?.CopyTo(dataStream); - } - dataStream.SetLength((long)size); - } - } - } - - public uint FileOffset { get; set; } - - /// - /// Gets or sets the alignment requirement of this section. - /// - public uint Log2Alignment { get; set; } - - /// - /// Gets the file offset to relocation entries of this section. - /// - public uint RelocationOffset => RelocationData?.FileOffset ?? 0u; - - /// - /// Gets or sets the number of relocation entries of this section. - /// - public uint NumberOfRelocationEntries => (uint)((RelocationData?.Size ?? 0u) / 8); - - internal uint Flags { get; set; } - - [EditorBrowsable(EditorBrowsableState.Advanced)] - public uint Reserved1 { get; set; } - - [EditorBrowsable(EditorBrowsableState.Advanced)] - public uint Reserved2 { get; set; } - - [EditorBrowsable(EditorBrowsableState.Advanced)] - public uint Reserved3 { get; set; } - - public MachSectionAttributes Attributes - { - get => (MachSectionAttributes)(Flags & ~0xffu); - set => Flags = (Flags & 0xffu) | (uint)value; - } - - public MachSectionType Type - { - get => (MachSectionType)(Flags & 0xff); - set => Flags = (Flags & ~0xffu) | (uint)value; - } - - public bool IsInFile => Size > 0 && Type != MachSectionType.ZeroFill && Type != MachSectionType.GBZeroFill && Type != MachSectionType.ThreadLocalZeroFill; - - internal bool HasContentChanged { get; set; } - - public MachLinkEditData? RelocationData - { - get - { - relocationCollection?.FlushIfDirty(); - return relocationData; - } - } - - public IList Relocations - { - get - { - relocationData ??= new MachLinkEditData(); - relocationCollection ??= new MachRelocationCollection(objectFile, relocationData); - return relocationCollection; - } - } - - public Stream GetReadStream() - { - if (Size == 0 || dataStream == null) - { - return Stream.Null; - } - - return dataStream.Slice(0, (long)this.Size); - } - - public Stream GetWriteStream() - { - HasContentChanged = true; - dataStream = new UnclosableMemoryStream(); - return dataStream; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs deleted file mode 100644 index 32c21dcbdfa47e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionAttributes.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachSectionAttributes : uint - { - LocalRelocations = 0x100, - ExternalRelocations = 0x200, - SomeInstructions = 0x400, - Debug = 0x2000000, - SelfModifyingCode = 0x4000000, - LiveSupport = 0x8000000, - NoDeadStrip = 0x10000000, - StripStaticSymbols = 0x20000000, - NoTableOfContents = 0x40000000, - PureInstructions = 0x80000000, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs deleted file mode 100644 index c0bb2992320de9..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSectionType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachSectionType : byte - { - Regular = 0, - ZeroFill = 1, - CStringLiterals = 2, - FourByteLiterals = 3, - EightByteLiterals = 4, - LiteralPointers = 5, - NonLazySymbolPointers = 6, - LazySymbolPointers = 7, - SymbolStubs = 8, - ModInitFunctionPointers = 9, - ModTermFunctionPointers = 10, - Coalesced = 11, - GBZeroFill = 12, - Interposing = 13, - SixteenByteLiterals = 14, - DTraceObjectFormat = 15, - LazyDylibSymbolPointers = 16, - ThreadLocalRegular = 17, - ThreadLocalZeroFill = 18, - ThreadLocalVariables = 19, - ThreadLocalVariablePointers = 20, - ThreadLocalInitFunctionPointers = 21, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs deleted file mode 100644 index 835fc4e7ff3b69..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegment.cs +++ /dev/null @@ -1,189 +0,0 @@ -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - /// - /// Defines a segment in the object file. - /// - /// - /// Segments represent how parts of the object file are mapped into virtual memory. - /// - /// Segment may contain zero or more sections. Some segments have special properties by - /// convention: - /// - /// - The `__TEXT` segment has to start at file offset zero and it contains the file - /// header and load commands. These metadata are not part of any of the segment's - /// sections though. - /// - The `__LINKEDIT` segment needs to be the last segment in the file. It should not - /// contain any sections. It's contents are mapped by other load commands, such as - /// symbol table, function starts and code signature (collectively derived from - /// class). - /// - public class MachSegment : MachLoadCommand - { - private readonly MachObjectFile objectFile; - private Stream? dataStream; - private ulong size; - private ulong fileSize; - - public MachSegment(MachObjectFile objectFile, string name) - : this(objectFile, name, null) - { - } - - public MachSegment(MachObjectFile objectFile, string name, Stream? stream) - { - this.objectFile = objectFile; - this.dataStream = stream; - this.Name = name; - } - - /// - /// Gets the position of the segement in the object file. - /// - /// - /// The position is relative to the beginning of the architecture-specific object - /// file. In fat binaries it needs to be adjusted to account for the envelope. - /// - public ulong FileOffset { get; set; } - - /// - /// Gets the size of the segment in the file. - /// - /// - /// We preserve the original FileSize when no editing on section contents was - /// performed. ld64 aligns either to 16Kb or 4Kb page size based on compile time - /// options. The __LINKEDIT segment is an exception that doesn't get aligned but - /// since that one doesn't contain sections we don't do the special treatment. - /// - public ulong FileSize - { - get - { - if (IsLinkEditSegment) - { - return objectFile.LinkEditData.Select(d => d.FileOffset + d.Size).Max() - FileOffset; - } - - return Sections.Count > 0 ? fileSize : (ulong)(dataStream?.Length ?? 0); - } - internal set - { - // Used by MachReader and MachObjectFile.UpdateLayout - fileSize = value; - } - } - - /// - /// Gets or sets the name of this segment. - /// - public string Name { get; private set; } = string.Empty; - - /// - /// Gets or sets the virtual address of this section. - /// - public ulong VirtualAddress { get; set; } - - /// - /// Gets or sets the size in bytes occupied in memory by this segment. - /// - public ulong Size - { - get - { - if (IsLinkEditSegment) - { - const uint pageAlignment = 0x4000 - 1; - return (FileSize + pageAlignment) & ~pageAlignment; - } - - return size; - } - set - { - // NOTE: We silently ignore setting Size for __LINKEDIT to make it easier - // for the reader. - size = value; - } - } - - /// - /// Gets or sets the maximum permitted protection of this segment. - /// - public MachVmProtection MaximumProtection { get; set; } - - /// - /// Gets or sets the initial protection of this segment. - /// - public MachVmProtection InitialProtection { get; set; } - - public MachSegmentFlags Flags { get; set; } - - /// - /// List of sections contained in this segment. - /// - public IList Sections { get; } = new List(); - - public bool IsLinkEditSegment => Name == "__LINKEDIT"; - - public Stream GetReadStream() - { - if (Sections.Count != 0) - { - throw new NotSupportedException("Segment can only be read directly if there are no sections"); - } - - if (IsLinkEditSegment) - { - // NOTE: We can support reading the link edit segment by constructing the stream - // from objectFile.LinkEditData on-demand. - throw new NotSupportedException("Reading __LINKEDIT segment is unsupported"); - } - - if (FileSize == 0 || dataStream == null) - { - return Stream.Null; - } - - return dataStream.Slice(0, (long)this.FileSize); - } - - /// - /// Gets the stream for updating the contents of this segment if it has no sections. - /// - /// - /// This method is primarily useful for the `__LINKEDIT` segment. The other primary - /// segments (`__TEXT`, `__DATA`) are divided into sections and each section has to - /// be updated individually. - /// - public Stream GetWriteStream() - { - if (Sections.Count != 0) - { - throw new NotSupportedException("Segment can only be written to directly if there are no sections"); - } - - if (IsLinkEditSegment) - { - throw new NotSupportedException("Writing __LINKEDIT segment is unsupported"); - } - - dataStream = new UnclosableMemoryStream(); - return dataStream; - } - - internal override IEnumerable LinkEditData - { - get - { - foreach (var section in Sections) - { - if (section.RelocationData is MachLinkEditData relocationData) - { - yield return relocationData; - } - } - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs deleted file mode 100644 index c33856a500fc37..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentFlags.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachSegmentFlags : uint - { - HighVirtualMemory = 1, - NoRelocations = 4, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs deleted file mode 100644 index 0c7a122b45a1ba..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSegmentSplitInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachSegmentSplitInfo : MachLinkEdit - { - public MachSegmentSplitInfo(MachObjectFile objectFile) - : base(objectFile) - { - } - - public MachSegmentSplitInfo(MachObjectFile objectFile, MachLinkEditData data) - : base(objectFile, data) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs deleted file mode 100644 index eaf43019fa6ad1..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachSymbolTable.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Diagnostics; - -namespace Melanzana.MachO -{ - public class MachSymbolTable : MachLoadCommand - { - private readonly MachObjectFile objectFile; - private readonly MachLinkEditData symbolTableData; - private readonly MachLinkEditData stringTableData; - private readonly Dictionary sectionMap; - private MachSymbolTableCollection? symbolTableCollection; - - public MachSymbolTable(MachObjectFile objectFile) - { - ArgumentNullException.ThrowIfNull(objectFile); - - this.objectFile = objectFile; - this.symbolTableData = new MachLinkEditData(); - this.stringTableData = new MachLinkEditData(); - this.sectionMap = new Dictionary(); - } - - internal MachSymbolTable( - MachObjectFile objectFile, - MachLinkEditData symbolTableData, - MachLinkEditData stringTableData) - { - ArgumentNullException.ThrowIfNull(objectFile); - ArgumentNullException.ThrowIfNull(symbolTableData); - ArgumentNullException.ThrowIfNull(stringTableData); - - this.objectFile = objectFile; - this.symbolTableData = symbolTableData; - this.stringTableData = stringTableData; - - // Create a section map now since the section indexes may change later - sectionMap = new Dictionary(); - byte sectionIndex = 1; - foreach (var section in objectFile.Segments.SelectMany(segment => segment.Sections)) - { - sectionMap.Add(sectionIndex++, section); - Debug.Assert(sectionIndex != 0); - } - } - - public MachLinkEditData SymbolTableData - { - get - { - symbolTableCollection?.FlushIfDirty(); - return symbolTableData; - } - } - - public MachLinkEditData StringTableData - { - get - { - symbolTableCollection?.FlushIfDirty(); - return stringTableData; - } - } - - public IList Symbols - { - get - { - symbolTableCollection ??= new MachSymbolTableCollection(objectFile, symbolTableData, stringTableData, sectionMap); - return symbolTableCollection; - } - } - - internal override IEnumerable LinkEditData - { - get - { - yield return SymbolTableData; - yield return StringTableData; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs deleted file mode 100644 index 2575f5f4ba8fa5..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachTwoLevelHints.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Diagnostics; - -namespace Melanzana.MachO -{ - public class MachTwoLevelHints : MachLoadCommand - { - public MachTwoLevelHints(MachObjectFile objectFile, MachLinkEditData data) - { - Data = data; - } - - public uint FileOffset => Data.FileOffset; - - public uint FileSize => (uint)Data.Size; - - public MachLinkEditData Data { get; private init; } - - internal override IEnumerable LinkEditData - { - get - { - yield return Data; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs deleted file mode 100644 index a7cdec3462e733..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinIOS.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachVersionMinIOS : MachBuildVersionBase - { - public override MachPlatform Platform => MachPlatform.IOS; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs deleted file mode 100644 index a186089a40be35..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinMacOS.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachVersionMinMacOS : MachBuildVersionBase - { - public override MachPlatform Platform => MachPlatform.MacOS; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs deleted file mode 100644 index 422e9eda986e41..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinTvOS.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachVersionMinTvOS : MachBuildVersionBase - { - public override MachPlatform Platform => MachPlatform.TvOS; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs deleted file mode 100644 index 6018da7cf42370..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/LoadCommands/MachVersionMinWatchOS.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachVersionMinWatchOS : MachBuildVersionBase - { - public override MachPlatform Platform => MachPlatform.WatchOS; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs deleted file mode 100644 index 13b15c94232082..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArm64CpuSubType.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Melanzana.MachO -{ - /// - /// Defines the subtypes of the ARM 64 . - /// Defined in machine.h. - /// - /// - /// This enumeration matches version 7195.141.2 of XNU. - /// - /// - [Flags] - public enum MachArm64CpuSubType : uint - { - /// - /// All ARM64 subtypes. - /// - All = MachCpuSubType.All, - - /// - /// The ARM64v8 CPU architecture subtype. - /// - V8 = 1, - - /// - /// The ARM64e CPU architecture subtype. - /// - E = 2, - - /// - /// Pointer authentication with versioned ABI. - /// - PointerAuthenticationWithVersionedAbi = 0x80000000, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs deleted file mode 100644 index 03b1de1192ef26..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachArmCpuSubType.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace Melanzana.MachO -{ - /// - /// Defines the subtypes of the ARM . - /// Defined in machine.h. - /// - /// - /// This enumeration matches version 7195.141.2 of XNU. - /// - /// - public enum MachArmCpuSubType : uint - { - /// - /// All ARM subtypes. - /// - All = MachCpuSubType.All, - - /// - /// The ARMv4T architecture CPU. Part of the ARM7TDMI family. - /// - V4T = 5, - - /// - /// The ARMv6 architecture CPU. Part of the ARMv6 family. - /// - V6 = 6, - - /// - /// The ARMv5TEJ architecture CPU. Part of the ARM9E family. - /// - V5TEJ = 7, - - /// - /// The XScale family of ARMv5TE CPUs. - /// - XSCALE = 8, - - /// - /// The ARMv7 CPU - /// - V7 = 9, - - /// - /// The ARMv7F CPU. - /// - V7F = 10, - - /// - /// The ARMv7S CPU. - /// - V7S = 11, - - /// - /// The ARMv7K CPU. - /// - V7K = 12, - - /// - /// An ARMv8 architecture CPU. - /// - V8 = 13, - - /// - /// The ARMv6-M architecture CPU. Part of the Cortex-M family. - /// - V6M = 14, - - /// - /// The ARMv7-M architecture CPU. Part of the Cortex-M family. - /// - V7M = 15, - - /// - /// An ARMv7E-M architecture CPU. Part of the Cortex-M family. - /// - V7EM = 16, - - /// - /// An ARMv8M architecture CPU. - /// - V8M = 17, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs deleted file mode 100644 index 79a561c56f47c1..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuSubType.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Melanzana.MachO -{ - /// - /// Defines the general flags for CPU subtypes. Depending on the , - /// you should cast the value to a more specialized enumeration, such as . - /// Defined in machine.h. - /// - /// - /// This enumeration matches version 7195.141.2 of XNU. - /// - /// - public enum MachCpuSubType : uint - { - /// - /// All subtypes. - /// - All = 0, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs deleted file mode 100644 index 2ae2a4c659ec1f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachCpuType.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachCpuType : uint - { - Vax = 1, - M68k = 6, - X86 = 7, - X86_64 = X86 | Architecture64, - M98k = 10, - PaRisc = 11, - Arm = 12, - Arm64 = Arm | Architecture64, - M88k = 13, - Sparc = 14, - I860 = 15, - PowerPC = 18, - PowerPC64 = PowerPC | Architecture64, - Architecture64 = 0x1000000, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs deleted file mode 100644 index 5825de8c8e0a32..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachFileType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachFileType : uint - { - Object = 1, - Execute = 2, - FixedVM = 3, - Core = 4, - Preload = 5, - DynamicLibrary = 6, - DynamicLinker = 7, - Bundle = 8, - DynamicLibraryStub = 9, - Debug = 10, - Kext = 11 - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs deleted file mode 100644 index c7536f1bcbbac7..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachHeaderFlags.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachHeaderFlags : uint - { - NoUndefinedReferences = 0x1, - IncrementalLink = 0x2, - DynamicLink = 0x4, - BindAtLoad = 0x8, - Prebound = 0x10, - SplitSegments = 0x20, - LazyInit = 0x40, - TwoLevel = 0x80, - ForceFlat = 0x100, - NoMultiDefs = 0x200, - NoFixPrebinding = 0x400, - Prebindable = 0x800, - AllModsBound = 0x1000, - SubsectionsViaSymbols = 0x2000, - Canonical = 0x4000, - WeakDefines = 0x8000, - BindsToWeak = 0x10000, - AllowStackExecution = 0x20000, - RootSafe = 0x40000, - SetuidSafe = 0x80000, - NoReexportedDylibs = 0x100000, - PIE = 0x200000, - DeadStrippableDylib = 0x400000, - HasTlvDescriptors = 0x800000, - NoHeapExecution = 0x1000000 - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs deleted file mode 100644 index ba3ea5fa98e564..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachI386CpuSubType.cs +++ /dev/null @@ -1,118 +0,0 @@ -namespace Melanzana.MachO -{ - /// - /// Defines the subtypes of the i386 . - /// Defined in machine.h. - /// - /// - /// This enumeration matches version 7195.141.2 of XNU. - /// - /// - public enum MachI386CpuSubType : uint - { - /// - /// All i386 subtypes - /// - All = 3 + (0 << 4), - - /// - /// The Intel 386 processor. - /// - _386 = 3 + (0 << 4), - - /// - /// The Intel 486 processor. - /// - _486 = 4 + (0 << 4), - - /// - /// The Intel 486SX processor. - /// - _486SX = 4 + (8 << 4), - - /// - /// The Intel 586 processor. - /// - _586 = 5 + (0 << 4), - - /// - /// The Intel Pentium processor. - /// - Pentium = 5 + (0 << 4), - - /// - /// The Intel Pentium Pro processor. - /// - PentiumPro = 6 + (1 << 4), - - /// - /// The Intel Pentium II (M3) processor. - /// - PentiumIIM3 = 6 + (3 << 4), - - /// - /// The Intel Penium II (M5) processor. - /// - PentiumIIM5 = 6 + (5 << 4), - - /// - /// The Intel Celeron processor. - /// - Celeron = 7 + (6 << 4), - - /// - /// The Intel Celeron Mobile processor. - /// - CeleronMobile = 7 + (7 << 4), - - /// - /// The Intel Pentium 3 processor. - /// - Pentium3 = 8 + (0 << 4), - - /// - /// The Intel Pentium 3 M processor. - /// - Pentium3M = 8 + (1 << 4), - - /// - /// The Intel Pentium 3 Xeon processor. - /// - Pentium3Xeon = 8 + (2 << 4), - - /// - /// The Intel Pentium M processor. - /// - PentiumM = 9 + (0 << 4), - - /// - /// The Intel Pentium 4 processor. - /// - Pentium4 = 10 + (0 << 4), - - /// - /// The Intel Pentium 4 M processor. - /// - Pentium4M = 10 + (1 << 4), - - /// - /// The Intel Itanium processor. - /// - Itanium = 11 + (0 << 4), - - /// - /// The Intel Itanium 2 processor. - /// - Itanium2 = 11 + (1 << 4), - - /// - /// The Intel Xeon processor. - /// - Xeon = 12 + (0 << 4), - - /// - /// The Intel Xeon MP processor. - /// - XeonMP = 12 + (1 << 4), - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs deleted file mode 100644 index 06ab7bd1069e9f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLayoutOptions.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Melanzana.MachO -{ - public class MachLayoutOptions - { - public MachLayoutOptions(MachObjectFile objectFile) - { - if (objectFile.FileType == MachFileType.Object) - { - // Unlinked object - BaseAddress = 0; - // There's single segment, so no alignment is necessary - SegmentAlignment = 1; - } - else - { - // Presumably there's a __PAGEZERO section at zero address - BaseAddress = 0; - - SegmentAlignment = objectFile.CpuType switch - { - MachCpuType.Arm64 => 0x4000, - MachCpuType.Arm => 0x4000, - _ => 0x1000, - }; - } - } - - public uint BaseAddress { get; set; } - - public uint SegmentAlignment { get; set; } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs deleted file mode 100644 index fc3e8d1aa51241..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLinkEditData.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - /// - /// Linker data representation. - /// - /// This holds data for relocations, symbol tables, string tables and various - /// other linking related information. It's either part of the __LINKEDIT - /// segment for fully linked files, or appended at the end of the object file - /// for unlinked Mach-O files. - /// - public class MachLinkEditData - { - private Stream dataStream; - - internal MachLinkEditData() - { - this.dataStream = Stream.Null; - this.FileOffset = 0; - } - - internal MachLinkEditData(Stream objectStream, uint offset, uint size) - { - this.dataStream = size == 0 ? Stream.Null : objectStream.Slice(offset, size); - this.FileOffset = offset; - } - - public uint FileOffset { get; set; } - - public ulong Size - { - get => (ulong)dataStream.Length; - set - { - if (dataStream != null) - { - if (!HasContentChanged) - { - HasContentChanged = true; - dataStream = new UnclosableMemoryStream(); - } - dataStream.SetLength((long)value); - } - } - } - - internal bool HasContentChanged { get; set; } - - public Stream GetReadStream() - { - if (dataStream.Length == 0) - { - return Stream.Null; - } - - return dataStream.Slice(0, (long)this.Size); - } - - public Stream GetWriteStream() - { - HasContentChanged = true; - dataStream = new UnclosableMemoryStream(); - return dataStream; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs deleted file mode 100644 index 5c724b4190755e..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommand.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO -{ - public abstract class MachLoadCommand - { - protected MachLoadCommand() - { - } - - internal virtual IEnumerable LinkEditData => Array.Empty(); - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs deleted file mode 100644 index ecffc071ea1a4d..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachLoadCommandType.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachLoadCommandType : uint - { - Segment = 0x1, - SymbolTable = 0x2, - SymbolSegment = 0x3, - Thread = 0x4, - UnixThread = 0x5, - LoadFixedVMSharedLibrary = 0x6, - IdFixedVMSharedLibrary = 0x7, - ObjectIdentification = 0x8, - FixedVMFileInclusion = 0x9, - Prepage = 0xa, - DynamicLinkEditSymbolTable = 0xb, - LoadDylib = 0xc, - IdDylib = 0xd, - LoadDylinker = 0xe, - IdDylinker = 0xf, - PreboundDylib = 0x10, - Routines = 0x11, - SubFramework = 0x12, - SubUmbrella = 0x13, - SubClient = 0x14, - SubLibrary = 0x15, - TowLevelHints = 0x16, - PrebindChecksum = 0x17, - LoadWeakDylib = 0x18 | ReqDyld, - Segment64 = 0x19, - Routines64 = 0x1a, - Uuid = 0x1b, - Rpath = 0x1c | ReqDyld, - CodeSignature = 0x1d, - SegmentSplitInfo = 0x1e, - ReexportDylib = 0x1f | ReqDyld, - LazyLoadDylib = 0x20, - EncryptionInfo = 0x21, - DyldInfo = 0x22, - DyldInfoOnly = 0x22 | ReqDyld, - LoadUpwardDylib = 0x23 | ReqDyld, - VersionMinMacOS = 0x24, - VersionMinIPhoneOS = 0x25, - FunctionStarts = 0x26, - DyldEnvironment = 0x27, - Main = 0x28 | ReqDyld, - DataInCode = 0x29, - SourceVersion = 0x2a, - DylibCodeSigningDRs = 0x2b, - EncryptionInfo64 = 0x2c, - LinkerOption = 0x2d, - LinkerOptimizationHint = 0x2e, - VersionMinTvOS = 0x2f, - VersionMinWatchOS = 0x30, - Note = 0x31, - BuildVersion = 0x32, - DyldExportsTrie = 0x33 | ReqDyld, - DyldChainedFixups = 0x34 | ReqDyld, - FileSetEntry = 0x35, - - /// Flag that marks any command that needs to be understood by DyLD or load will fail - ReqDyld = 0x80000000, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs deleted file mode 100644 index 7a86b5decc7a45..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachMagic.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachMagic : uint - { - MachHeaderLittleEndian = 0xcefaedfe, - MachHeaderBigEndian = 0xfeedface, - MachHeader64LittleEndian = 0xcffaedfe, - MachHeader64BigEndian = 0xfeedfacf, - FatMagicLittleEndian = 0xbebafeca, - FatMagicBigEndian = 0xcafebabe, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs deleted file mode 100644 index b122483b2c2b31..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachObjectFile.cs +++ /dev/null @@ -1,321 +0,0 @@ -using Melanzana.Streams; -using Melanzana.MachO.BinaryFormat; -using System.Text; -using System.Diagnostics; - -namespace Melanzana.MachO -{ - public class MachObjectFile - { - private readonly Stream stream; - - public MachObjectFile() - : this(Stream.Null) - { - } - - internal MachObjectFile(Stream stream) - { - this.stream = stream; - } - - public bool Is64Bit => CpuType.HasFlag(MachCpuType.Architecture64); - - public bool IsLittleEndian { get; set; } - - public MachCpuType CpuType { get; set; } - - public uint CpuSubType { get; set; } - - public MachFileType FileType { get; set; } - - public MachHeaderFlags Flags { get; set; } - - public IList LoadCommands { get; } = new List(); - - /// - /// For object files the relocation, symbol tables and other data are stored at the end of the - /// file but not covered by any segment/section. We maintain a list of these data to make it - /// easier to address. - /// - /// For linked files this points to the real __LINKEDIT segment. We slice it into subsections - /// based on the known LinkEdit commands though. - /// - public IEnumerable LinkEditData => LoadCommands.SelectMany(command => command.LinkEditData); - - public IEnumerable Segments => LoadCommands.OfType(); - - /// - /// Get the lowest file offset of any section in the file. This allows calculating space that is - /// reserved for adding new load commands (header pad). - /// - public ulong GetLowestSectionFileOffset() - { - ulong lowestFileOffset = ulong.MaxValue; - - foreach (var segment in Segments) - { - foreach (var section in segment.Sections) - { - if (section.IsInFile && - section.FileOffset < lowestFileOffset) - { - lowestFileOffset = section.FileOffset; - } - } - } - - return lowestFileOffset == ulong.MaxValue ? 0 : lowestFileOffset; - } - - public ulong GetSize() - { - // Assume the size is the highest file offset+size of any segment - return Segments.Max(s => s.FileOffset + s.FileSize); - } - - public ulong GetSigningLimit() - { - var codeSignature = LoadCommands.OfType().FirstOrDefault(); - if (codeSignature != null) - { - // If code signature is present it has to be at the end of the file - return codeSignature.FileOffset; - } - else - { - // If no code signature is present then we return the whole file size - return GetSize(); - } - } - - /// - /// Gets a stream for a given part of range of the file. - /// - /// - /// The range must be fully contained in a single section or segment with no sections. - /// Accessing file header or link commands through this API is currently not supported. - /// - public Stream GetStreamAtFileOffset(uint fileOffset, uint fileSize) - { - // FIXME: Should we dispose the original stream? At the moment it would be no-op - // anyway since it's always SliceStream or UnclosableMemoryStream. - - foreach (var segment in Segments) - { - if (fileOffset >= segment.FileOffset && - fileOffset < segment.FileOffset + segment.FileSize) - { - if (segment.Sections.Count == 0) - { - return segment.GetReadStream().Slice( - (long)(fileOffset - segment.FileOffset), - fileSize); - } - - foreach (var section in segment.Sections) - { - if (fileOffset >= section.FileOffset && - fileOffset < section.FileOffset + section.Size) - { - return section.GetReadStream().Slice( - (long)(fileOffset - section.FileOffset), - fileSize); - } - } - - return Stream.Null; - } - } - - return Stream.Null; - } - - public Stream GetStreamAtVirtualAddress(ulong address, uint length) - { - // FIXME: Should we dispose the original stream? At the moment it would be no-op - // anyway since it's always SliceStream or UnclosableMemoryStream. - - foreach (var segment in Segments) - { - if (address >= segment.VirtualAddress && - address < segment.VirtualAddress + segment.Size) - { - if (segment.Sections.Count == 0) - { - return segment.GetReadStream().Slice( - (long)(address - segment.VirtualAddress), - (long)Math.Min(length, segment.VirtualAddress + segment.FileSize - address)); - } - - foreach (var section in segment.Sections) - { - if (address >= section.VirtualAddress && - address < section.VirtualAddress + section.Size) - { - return section.GetReadStream().Slice( - (long)(address - section.VirtualAddress), - (long)Math.Min(length, section.VirtualAddress + section.Size - address)); - } - } - - return Stream.Null; - } - } - - return Stream.Null; - } - - public Stream GetOriginalStream() - { - if (stream == null) - return Stream.Null; - - return stream.Slice(0, stream.Length); - } - - /// - /// Update layout of segments, sections and link edit data to valid - /// non-overlapping values that can be written to disk. - /// - /// Option bag to specify additional requirements for the layout - public void UpdateLayout(MachLayoutOptions? options = null) - { - // If no layout options were specified then infer the details - // from the object file. - if (options == null) - { - options = new MachLayoutOptions(this); - } - - ulong segmentAlignment = options.SegmentAlignment; - ulong fileOffset = 0; - - // First we need to place the load commands - - // 4 bytes magic number - fileOffset += 4u; - // Mach header - fileOffset += (ulong)(Is64Bit ? MachHeader64.BinarySize : MachHeader.BinarySize); - // Calculate size of load command - foreach (var loadCommand in LoadCommands) - { - fileOffset += LoadCommandHeader.BinarySize; - - switch (loadCommand) - { - case MachSegment segment: - if (Is64Bit) - { - fileOffset += (ulong)(Segment64Header.BinarySize + segment.Sections.Count * Section64Header.BinarySize); - } - else - { - fileOffset += (ulong)(SegmentHeader.BinarySize + segment.Sections.Count * SectionHeader.BinarySize); - } - break; - - case MachCodeSignature: - case MachDylibCodeSigningDirs: - case MachSegmentSplitInfo: - case MachFunctionStarts: - case MachDataInCode: - case MachLinkerOptimizationHint: - case MachDyldExportsTrie: - case MachDyldChainedFixups: - fileOffset += LinkEditHeader.BinarySize; - break; - - case MachLoadDylibCommand: - case MachLoadWeakDylibCommand: - case MachReexportDylibCommand: - fileOffset += (ulong)AlignedSize( - DylibCommandHeader.BinarySize + - Encoding.UTF8.GetByteCount(((MachDylibCommand)loadCommand).Name) + 1, - Is64Bit); - break; - - case MachEntrypointCommand entrypointCommand: - fileOffset += MainCommandHeader.BinarySize; - break; - - case MachVersionMinMacOS: - case MachVersionMinIOS: - case MachVersionMinTvOS: - case MachVersionMinWatchOS: - fileOffset += VersionMinCommandHeader.BinarySize; - break; - - case MachBuildVersion versionCommand: - fileOffset += (ulong)(BuildVersionCommandHeader.BinarySize + (versionCommand.ToolVersions.Count * BuildToolVersionHeader.BinarySize)); - break; - - case MachSymbolTable: - fileOffset += SymbolTableCommandHeader.BinarySize; - break; - - case MachDynamicLinkEditSymbolTable: - fileOffset += DynamicSymbolTableCommandHeader.BinarySize; - break; - - case MachCustomLoadCommand customLoadCommand: - fileOffset += (ulong)customLoadCommand.Data.Length; - break; - } - } - - fileOffset = (fileOffset + segmentAlignment) & ~segmentAlignment; - ulong virtualAddress = options.BaseAddress; - foreach (var segment in Segments) - { - ulong segmentFileSize = 0; - ulong segmentSize = 0; - - segment.VirtualAddress = virtualAddress; - segment.FileOffset = fileOffset; - - if (!segment.IsLinkEditSegment && segment.Sections.Count > 0) - { - foreach (var section in segment.Sections) - { - ulong alignment = 1u << (int)section.Log2Alignment; - - fileOffset = (fileOffset + alignment - 1) & ~(alignment - 1); - virtualAddress = (virtualAddress + alignment - 1) & ~(alignment - 1); - - if (section.Type is not MachSectionType.ZeroFill or MachSectionType.GBZeroFill or MachSectionType.ThreadLocalZeroFill) - { - section.FileOffset = (uint)fileOffset; - fileOffset += section.Size; - segmentFileSize = Math.Max(segmentFileSize, fileOffset - segment.FileOffset); - } - else - { - // The offset is unused for virtual sections. - section.FileOffset = 0; - } - - section.VirtualAddress = virtualAddress; - virtualAddress += section.Size; - - segmentSize = Math.Max(segmentSize, virtualAddress - segment.VirtualAddress); - } - - segment.FileSize = (segmentFileSize + segmentAlignment - 1) & ~(segmentAlignment - 1); - segment.Size = (segmentSize + segmentAlignment - 1) & ~(segmentAlignment - 1); - - virtualAddress = (virtualAddress + segmentAlignment - 1) & ~(segmentAlignment - 1); - } - } - - var linkEditData = new List(LinkEditData); - foreach (var data in linkEditData) - { - data.FileOffset = (uint)fileOffset; - fileOffset += data.Size; - } - - static int AlignedSize(int size, bool is64bit) => is64bit ? (size + 7) & ~7 : (size + 3) & ~3; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs deleted file mode 100644 index 6c67d6dd1728e5..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachPlatform.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachPlatform : uint - { - MacOS = 1, - IOS = 2, - TvOS = 3, - WatchOS = 4, - BridgeOS = 5, - MacCatalyst = 6, - IOSSimulator = 7, - TvOSSimulator = 8, - WatchOSSimulator = 9, - DriverKit = 10, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs deleted file mode 100644 index c5b19a494a00d9..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachReader.cs +++ /dev/null @@ -1,371 +0,0 @@ -using System.Buffers.Binary; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using Melanzana.MachO.BinaryFormat; -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - public static class MachReader - { - private static MachSegment ReadSegment(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) - { - var segmentHeader = SegmentHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - - var machSegment = segmentHeader.NumberOfSections == 0 && segmentHeader.FileSize != 0 ? - new MachSegment(objectFile, segmentHeader.Name, stream.Slice(segmentHeader.FileOffset, segmentHeader.FileSize)) : - new MachSegment(objectFile, segmentHeader.Name); - machSegment.FileOffset = segmentHeader.FileOffset; - machSegment.FileSize = segmentHeader.FileSize; - machSegment.VirtualAddress = segmentHeader.Address; - machSegment.Size = segmentHeader.Size; - machSegment.MaximumProtection = segmentHeader.MaximumProtection; - machSegment.InitialProtection = segmentHeader.InitialProtection; - machSegment.Flags = segmentHeader.Flags; - - for (int s = 0; s < segmentHeader.NumberOfSections; s++) - { - var sectionHeader = SectionHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize + SegmentHeader.BinarySize + s * SectionHeader.BinarySize), objectFile.IsLittleEndian, out var _); - var sectionType = (MachSectionType)(sectionHeader.Flags & 0xff); - MachSection section; - - if (sectionHeader.Size != 0 && - sectionType != MachSectionType.ZeroFill && - sectionType != MachSectionType.GBZeroFill && - sectionType != MachSectionType.ThreadLocalZeroFill) - { - section = new MachSection( - objectFile, - sectionHeader.SegmentName, - sectionHeader.SectionName, - stream.Slice(sectionHeader.FileOffset, sectionHeader.Size), - new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)); - } - else - { - section = new MachSection( - objectFile, - sectionHeader.SegmentName, - sectionHeader.SectionName, - null, - new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)) - { - Size = sectionHeader.Size - }; - } - - section.VirtualAddress = sectionHeader.Address; - section.FileOffset = sectionHeader.FileOffset; - section.Log2Alignment = sectionHeader.Log2Alignment; - section.Flags = sectionHeader.Flags; - section.Reserved1 = sectionHeader.Reserved1; - section.Reserved2 = sectionHeader.Reserved2; - machSegment.Sections.Add(section); - } - - return machSegment; - } - - private static MachSegment ReadSegment64(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) - { - var segmentHeader = Segment64Header.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - - var machSegment = segmentHeader.NumberOfSections == 0 && segmentHeader.FileSize != 0 ? - new MachSegment(objectFile, segmentHeader.Name, stream.Slice((long)segmentHeader.FileOffset, (long)segmentHeader.FileSize)) : - new MachSegment(objectFile, segmentHeader.Name); - machSegment.FileOffset = segmentHeader.FileOffset; - machSegment.FileSize = segmentHeader.FileSize; - machSegment.VirtualAddress = segmentHeader.Address; - machSegment.Size = segmentHeader.Size; - machSegment.MaximumProtection = segmentHeader.MaximumProtection; - machSegment.InitialProtection = segmentHeader.InitialProtection; - machSegment.Flags = segmentHeader.Flags; - - for (int s = 0; s < segmentHeader.NumberOfSections; s++) - { - var sectionHeader = Section64Header.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize + Segment64Header.BinarySize + s * Section64Header.BinarySize), objectFile.IsLittleEndian, out var _); - var sectionType = (MachSectionType)(sectionHeader.Flags & 0xff); - MachSection section; - - if (sectionHeader.Size != 0 && - sectionType != MachSectionType.ZeroFill && - sectionType != MachSectionType.GBZeroFill && - sectionType != MachSectionType.ThreadLocalZeroFill) - { - section = new MachSection( - objectFile, - sectionHeader.SegmentName, - sectionHeader.SectionName, - stream.Slice(sectionHeader.FileOffset, (long)sectionHeader.Size), - new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)); - } - else - { - section = new MachSection( - objectFile, - sectionHeader.SegmentName, - sectionHeader.SectionName, - null, - new MachLinkEditData(stream, sectionHeader.RelocationOffset, sectionHeader.NumberOfReloationEntries * 8)) - { - Size = sectionHeader.Size - }; - } - - section.VirtualAddress = sectionHeader.Address; - section.FileOffset = sectionHeader.FileOffset; - section.Log2Alignment = sectionHeader.Log2Alignment; - section.Flags = sectionHeader.Flags; - section.Reserved1 = sectionHeader.Reserved1; - section.Reserved2 = sectionHeader.Reserved2; - section.Reserved3 = sectionHeader.Reserved3; - machSegment.Sections.Add(section); - } - - return machSegment; - } - - private static MachLinkEditData ReadLinkEdit(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) - { - var linkEditHeader = LinkEditHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - return new MachLinkEditData(stream, linkEditHeader.FileOffset, linkEditHeader.FileSize); - } - - private static T ReadDylibCommand(ReadOnlySpan loadCommandPtr, uint commandSize, bool isLittleEndian) - where T : MachDylibCommand, new() - { - var dylibCommandHeader = DylibCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); - - Debug.Assert(dylibCommandHeader.NameOffset == LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize); - var nameSlice = loadCommandPtr.Slice((int)dylibCommandHeader.NameOffset, (int)commandSize - (int)dylibCommandHeader.NameOffset); - int zeroIndex = nameSlice.IndexOf((byte)0); - string name = zeroIndex >= 0 ? Encoding.UTF8.GetString(nameSlice.Slice(0, zeroIndex)) : Encoding.UTF8.GetString(nameSlice); - - return new T - { - Name = name, - Timestamp = dylibCommandHeader.Timestamp, - CurrentVersion = dylibCommandHeader.CurrentVersion, - CompatibilityVersion = dylibCommandHeader.CompatibilityVersion, - }; - } - - private static MachEntrypointCommand ReadMainCommand(ReadOnlySpan loadCommandPtr, bool isLittleEndian) - { - var mainCommandHeader = MainCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); - - return new MachEntrypointCommand - { - FileOffset = mainCommandHeader.FileOffset, - StackSize = mainCommandHeader.StackSize, - }; - } - - private static Version ConvertVersion(uint version) - => new Version((int)(version >> 16), (int)((version >> 8) & 0xff), (int)(version & 0xff)); - - private static T ReadVersionMinCommand(ReadOnlySpan loadCommandPtr, bool isLittleEndian) - where T : MachBuildVersionBase, new() - { - var versionMinCommandHeader = VersionMinCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); - - return new T - { - MinimumPlatformVersion = ConvertVersion(versionMinCommandHeader.MinimumPlatformVersion), - SdkVersion = ConvertVersion(versionMinCommandHeader.SdkVersion), - }; - } - - private static MachBuildVersion ReadBuildVersion(ReadOnlySpan loadCommandPtr, bool isLittleEndian) - { - var buildVersionCommandHeader = BuildVersionCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); - var buildVersion = new MachBuildVersion - { - TargetPlatform = buildVersionCommandHeader.Platform, - MinimumPlatformVersion = ConvertVersion(buildVersionCommandHeader.MinimumPlatformVersion), - SdkVersion = ConvertVersion(buildVersionCommandHeader.SdkVersion), - }; - - - loadCommandPtr = loadCommandPtr.Slice(LoadCommandHeader.BinarySize + BuildVersionCommandHeader.BinarySize); - for (int i = 0; i < buildVersionCommandHeader.NumberOfTools; i++) - { - var buildToolVersionHeader = BuildToolVersionHeader.Read(loadCommandPtr, isLittleEndian, out var _); - buildVersion.ToolVersions.Add(new MachBuildToolVersion - { - BuildTool = buildToolVersionHeader.BuildTool, - Version = ConvertVersion(buildToolVersionHeader.Version), - }); - loadCommandPtr = loadCommandPtr.Slice(BuildToolVersionHeader.BinarySize); - } - - return buildVersion; - } - - private static MachSymbolTable ReadSymbolTable(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) - { - var symbolTableHeader = SymbolTableCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - - uint symbolTableSize = - symbolTableHeader.NumberOfSymbols * - (SymbolHeader.BinarySize + (objectFile.Is64Bit ? 8u : 4u)); - - return new MachSymbolTable( - objectFile, - new MachLinkEditData(stream, symbolTableHeader.SymbolTableOffset, symbolTableSize), - new MachLinkEditData(stream, symbolTableHeader.StringTableOffset, symbolTableHeader.StringTableSize)); - } - - private static MachDynamicLinkEditSymbolTable ReadDynamicLinkEditSymbolTable(ReadOnlySpan loadCommandPtr, bool isLittleEndian) - { - var dynamicSymbolTableHeader = DynamicSymbolTableCommandHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), isLittleEndian, out var _); - - // TODO: Clean up - return new MachDynamicLinkEditSymbolTable(dynamicSymbolTableHeader); - } - - private static MachDyldInfo ReadDyldInfo( - MachLoadCommandType loadCommandType, - ReadOnlySpan loadCommandPtr, - MachObjectFile objectFile, - Stream stream) - { - var dyldInfoHeader = DyldInfoHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - - var rebaseData = new MachLinkEditData(stream, dyldInfoHeader.RebaseOffset, dyldInfoHeader.RebaseSize); - var bindData = new MachLinkEditData(stream, dyldInfoHeader.BindOffset, dyldInfoHeader.BindSize); - var weakBindData = new MachLinkEditData(stream, dyldInfoHeader.WeakBindOffset, dyldInfoHeader.WeakBindSize); - var lazyBindData = new MachLinkEditData(stream, dyldInfoHeader.LazyBindOffset, dyldInfoHeader.LazyBindSize); - var exportData = new MachLinkEditData(stream, dyldInfoHeader.ExportOffset, dyldInfoHeader.ExportSize); - - if (loadCommandType == MachLoadCommandType.DyldInfo) - { - return new MachDyldInfo(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData); - } - - return new MachDyldInfoOnly(objectFile, rebaseData, bindData, weakBindData, lazyBindData, exportData); - } - - private static MachTwoLevelHints ReadTwoLevelHints(ReadOnlySpan loadCommandPtr, MachObjectFile objectFile, Stream stream) - { - var twoLevelHintsHeader = TwoLevelHintsHeader.Read(loadCommandPtr.Slice(LoadCommandHeader.BinarySize), objectFile.IsLittleEndian, out var _); - - return new MachTwoLevelHints(objectFile, - new MachLinkEditData( - stream, - twoLevelHintsHeader.FileOffset, - twoLevelHintsHeader.NumberOfHints * sizeof(uint))); - } - - private static MachObjectFile ReadSingle(FatArchHeader? fatArchHeader, MachMagic magic, Stream stream) - { - Span headerBuffer = stackalloc byte[Math.Max(MachHeader.BinarySize, MachHeader64.BinarySize)]; - MachObjectFile objectFile; - IMachHeader machHeader; - bool isLittleEndian; - - switch (magic) - { - case MachMagic.MachHeaderLittleEndian: - case MachMagic.MachHeaderBigEndian: - stream.Read(headerBuffer.Slice(0, MachHeader.BinarySize)); - isLittleEndian = magic == MachMagic.MachHeaderLittleEndian; - machHeader = MachHeader.Read(headerBuffer, isLittleEndian, out var _); - Debug.Assert(!machHeader.CpuType.HasFlag(MachCpuType.Architecture64)); - objectFile = new MachObjectFile(stream); - break; - - case MachMagic.MachHeader64LittleEndian: - case MachMagic.MachHeader64BigEndian: - stream.Read(headerBuffer.Slice(0, MachHeader64.BinarySize)); - isLittleEndian = magic == MachMagic.MachHeader64LittleEndian; - machHeader = MachHeader64.Read(headerBuffer, isLittleEndian, out var _); - Debug.Assert(machHeader.CpuType.HasFlag(MachCpuType.Architecture64)); - objectFile = new MachObjectFile(stream); - break; - - default: - throw new NotSupportedException(); - } - - objectFile.IsLittleEndian = isLittleEndian; - objectFile.CpuType = machHeader.CpuType; - objectFile.CpuSubType = machHeader.CpuSubType; - objectFile.FileType = machHeader.FileType; - objectFile.Flags = machHeader.Flags; - - // Read load commands - // - // Mach-O uses the load command both to describe the segments/sections and content - // within them. The commands, like "Code Signature" overlap with the segments. For - // code signature in particular it will overlap with the LINKEDIT segment. - var loadCommands = new byte[machHeader.SizeOfCommands]; - Span loadCommandPtr = loadCommands; - stream.ReadFully(loadCommands); - for (int i = 0; i < machHeader.NumberOfCommands; i++) - { - var loadCommandHeader = LoadCommandHeader.Read(loadCommandPtr, isLittleEndian, out var _); - objectFile.LoadCommands.Add(loadCommandHeader.CommandType switch - { - MachLoadCommandType.Segment => ReadSegment(loadCommandPtr, objectFile, stream), - MachLoadCommandType.Segment64 => ReadSegment64(loadCommandPtr, objectFile, stream), - MachLoadCommandType.CodeSignature => new MachCodeSignature(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.DylibCodeSigningDRs => new MachDylibCodeSigningDirs(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.SegmentSplitInfo => new MachSegmentSplitInfo(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.FunctionStarts => new MachFunctionStarts(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.DataInCode => new MachDataInCode(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.LinkerOptimizationHint => new MachLinkerOptimizationHint(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.DyldExportsTrie => new MachDyldExportsTrie(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.DyldChainedFixups => new MachDyldChainedFixups(objectFile, ReadLinkEdit(loadCommandPtr, objectFile, stream)), - MachLoadCommandType.LoadDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), - MachLoadCommandType.LoadWeakDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), - MachLoadCommandType.ReexportDylib => ReadDylibCommand(loadCommandPtr, loadCommandHeader.CommandSize, isLittleEndian), - MachLoadCommandType.Main => ReadMainCommand(loadCommandPtr, isLittleEndian), - MachLoadCommandType.VersionMinMacOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), - MachLoadCommandType.VersionMinIPhoneOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), - MachLoadCommandType.VersionMinTvOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), - MachLoadCommandType.VersionMinWatchOS => ReadVersionMinCommand(loadCommandPtr, isLittleEndian), - MachLoadCommandType.BuildVersion => ReadBuildVersion(loadCommandPtr, isLittleEndian), - MachLoadCommandType.SymbolTable => ReadSymbolTable(loadCommandPtr, objectFile, stream), - MachLoadCommandType.DynamicLinkEditSymbolTable => ReadDynamicLinkEditSymbolTable(loadCommandPtr, isLittleEndian), - MachLoadCommandType.DyldInfo => ReadDyldInfo(loadCommandHeader.CommandType, loadCommandPtr, objectFile, stream), - MachLoadCommandType.DyldInfoOnly => ReadDyldInfo(loadCommandHeader.CommandType, loadCommandPtr, objectFile, stream), - MachLoadCommandType.TowLevelHints => ReadTwoLevelHints(loadCommandPtr, objectFile, stream), - _ => new MachCustomLoadCommand(loadCommandHeader.CommandType, loadCommandPtr.Slice(LoadCommandHeader.BinarySize, (int)loadCommandHeader.CommandSize - LoadCommandHeader.BinarySize).ToArray()), - }); - loadCommandPtr = loadCommandPtr.Slice((int)loadCommandHeader.CommandSize); - } - - return objectFile; - } - - public static IEnumerable Read(Stream stream) - { - var magicBuffer = new byte[4]; - stream.ReadFully(magicBuffer); - - var magic = (MachMagic)BinaryPrimitives.ReadUInt32BigEndian(magicBuffer); - if (magic == MachMagic.FatMagicLittleEndian || magic == MachMagic.FatMagicBigEndian) - { - var headerBuffer = new byte[Math.Max(FatHeader.BinarySize, FatArchHeader.BinarySize)]; - stream.ReadFully(headerBuffer.AsSpan(0, FatHeader.BinarySize)); - var fatHeader = FatHeader.Read(headerBuffer, isLittleEndian: magic == MachMagic.FatMagicLittleEndian, out var _); - for (int i = 0; i < fatHeader.NumberOfFatArchitectures; i++) - { - stream.ReadFully(headerBuffer.AsSpan(0, FatArchHeader.BinarySize)); - var fatArchHeader = FatArchHeader.Read(headerBuffer, isLittleEndian: magic == MachMagic.FatMagicLittleEndian, out var _); - - var machOSlice = stream.Slice(fatArchHeader.Offset, fatArchHeader.Size); - machOSlice.ReadFully(magicBuffer); - magic = (MachMagic)BinaryPrimitives.ReadUInt32BigEndian(magicBuffer); - yield return ReadSingle(fatArchHeader, magic, machOSlice); - } - } - else - { - yield return ReadSingle(null, magic, stream); - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs deleted file mode 100644 index 43455f2bf2cd2f..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocation.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Melanzana.MachO -{ - public class MachRelocation - { - /// - /// Address from the start of the section. - /// - public int Address { get; init; } - - /// - /// Symbol index (for internal symbols) or section index (for external symbols). - /// - public uint SymbolOrSectionIndex { get; init; } - - /// - /// Specifies whether the relocation is program counter relative. - /// - public bool IsPCRelative { get; init; } - - /// - /// Specifies whether the relocation is external. - /// - public bool IsExternal { get; init; } - - /// - /// Length of the relocation in bytes (valid values are 1, 2, 4, and 8). - /// - public byte Length { get; init; } - - /// - /// Machine specific relocation type. - /// - public MachRelocationType RelocationType { get; init; } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs deleted file mode 100644 index 13d104896325ff..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationCollection.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System.Buffers.Binary; -using System.Collections; -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - public class MachRelocationCollection : IList - { - private readonly MachObjectFile objectFile; - private readonly MachLinkEditData relocationData; - private readonly List innerList; - private bool isDirty; - - internal MachRelocationCollection(MachObjectFile objectFile, MachLinkEditData relocationData) - { - int relocationCount = (int)(relocationData.Size / 8); - - this.objectFile = objectFile; - this.relocationData = relocationData; - this.innerList = new List(relocationCount); - this.isDirty = false; - - // Read existing relocations - using var relocationStream = relocationData.GetReadStream(); - Span relocationBuffer = stackalloc byte[8]; - - for (uint i = 0; i < relocationCount; i++) - { - relocationStream.ReadFully(relocationBuffer); - - int address = - objectFile.IsLittleEndian ? - BinaryPrimitives.ReadInt32LittleEndian(relocationBuffer) : - BinaryPrimitives.ReadInt32BigEndian(relocationBuffer); - - uint info = - objectFile.IsLittleEndian ? - BinaryPrimitives.ReadUInt32LittleEndian(relocationBuffer.Slice(4)) : - BinaryPrimitives.ReadUInt32BigEndian(relocationBuffer.Slice(4)); - - innerList.Add(new MachRelocation - { - Address = address, - SymbolOrSectionIndex = info & 0xff_ff_ff, - IsPCRelative = (info & 0x1_00_00_00) > 0, - Length = ((info >> 25) & 3) switch { 0 => 1, 1 => 2, 2 => 4, _ => 8 }, - IsExternal = (info & 0x8_00_00_00) > 0, - RelocationType = (MachRelocationType)(info >> 28) - }); - } - } - - public MachRelocation this[int index] - { - get => innerList[index]; - set - { - innerList[index] = value; - isDirty = true; - } - } - - public int Count => innerList.Count; - - public bool IsReadOnly => false; - - public void Add(MachRelocation item) - { - innerList.Add(item); - isDirty = true; - } - - public void Clear() - { - innerList.Clear(); - isDirty = true; - } - - public void Insert(int index, MachRelocation item) - { - innerList.Insert(index, item); - isDirty = true; - } - - public bool Remove(MachRelocation item) - { - if (innerList.Remove(item)) - { - isDirty = true; - return true; - } - - return false; - } - - public void RemoveAt(int index) - { - innerList.RemoveAt(index); - isDirty = true; - } - - IEnumerator IEnumerable.GetEnumerator() => innerList.GetEnumerator(); - - public bool Contains(MachRelocation item) => innerList.Contains(item); - - public void CopyTo(MachRelocation[] array, int arrayIndex) => innerList.CopyTo(array, arrayIndex); - - public IEnumerator GetEnumerator() => innerList.GetEnumerator(); - - public int IndexOf(MachRelocation item) => innerList.IndexOf(item); - - internal void FlushIfDirty() - { - if (isDirty) - { - Span relocationBuffer = stackalloc byte[8]; - using var stream = relocationData.GetWriteStream(); - uint info; - - foreach (var relocation in innerList) - { - info = relocation.SymbolOrSectionIndex; - info |= relocation.IsPCRelative ? 0x1_00_00_00u : 0u; - info |= relocation.Length switch { 1 => 0u << 25, 2 => 1u << 25, 4 => 2u << 25, _ => 3u << 25 }; - info |= relocation.IsExternal ? 0x8_00_00_00u : 0u; - info |= (uint)relocation.RelocationType << 28; - - if (objectFile.IsLittleEndian) - { - BinaryPrimitives.WriteInt32LittleEndian(relocationBuffer, relocation.Address); - BinaryPrimitives.WriteUInt32LittleEndian(relocationBuffer.Slice(4), info); - } - else - { - BinaryPrimitives.WriteInt32BigEndian(relocationBuffer, relocation.Address); - BinaryPrimitives.WriteUInt32BigEndian(relocationBuffer.Slice(4), info); - } - - stream.Write(relocationBuffer); - } - - isDirty = false; - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs deleted file mode 100644 index 6454696b1d1ebb..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachRelocationType.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Melanzana.MachO -{ - public enum MachRelocationType : byte - { - GenericVanilla = 0, - GenericPair = 1, - GenericSectionDiff = 2, - GenericPreboundLazyPtr = 3, - GenericLocalSectionDiff = 4, - GenericTlv = 5, - - X86_64Unsigned = 0, - X86_64Signed = 1, - X86_64Branch = 2, - X86_64GotLoad = 3, - X86_64Got = 4, - X86_64Subtractor = 5, - X86_64Signed1 = 6, - X86_64Signed2 = 7, - X86_64Signed4 = 8, - X86_64Tlv = 9, - - Arm64Unsigned = 0, - Arm64Subtractor = 1, - Arm64Branch26 = 2, - Arm64Page21 = 3, - Arm64PageOffset21 = 4, - Arm64GotLoadPage21 = 5, - Arm64GotLoadPageOffset21 = 6, - Arm64PointerToGot = 7, - Arm64TlvpLoadPage21 = 8, - Arm64TlvpLoadPageOffset21 = 9, - Arm64Addend = 10, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs deleted file mode 100644 index ecce79785a38b1..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbol.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Diagnostics; - -namespace Melanzana.MachO -{ - public class MachSymbol - { - public string Name { get; init; } = string.Empty; - public MachSymbolType Type { get; init; } - public MachSection? Section { get; init; } - public MachSymbolDescriptor Descriptor { get; init; } - public ulong Value { get; init; } - - public bool IsExternal => Type.HasFlag(MachSymbolType.External); - public bool IsUndefined => (Type & MachSymbolType.TypeMask) == MachSymbolType.Undefined; - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs deleted file mode 100644 index 07a3c17c6e2e20..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolDescriptor.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachSymbolDescriptor : ushort - { - ReferenceTypeMask = 0xf, - UndefinedNonLazy = 0, - UndefinedLazy = 1, - Defined = 2, - PrivateDefined = 3, - PrivateUndefinedNonLazy = 4, - PrivateUndefinedLazy = 5, - - ReferencedDynamically = 0x10, - NoDeadStrip = 0x20, - WeakReference = 0x40, - WeakDefinition = 0x80, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs deleted file mode 100644 index 2fd1341e667787..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolTableCollection.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System.Buffers.Binary; -using System.Collections; -using System.Diagnostics; -using System.Text; -using Melanzana.MachO.BinaryFormat; -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - internal class MachSymbolTableCollection : IList - { - private readonly MachObjectFile objectFile; - private readonly MachLinkEditData symbolTableData; - private readonly MachLinkEditData stringTableData; - private readonly List innerList = new(); - - bool isDirty; - - public MachSymbolTableCollection( - MachObjectFile objectFile, - MachLinkEditData symbolTableData, - MachLinkEditData stringTableData, - Dictionary sectionMap) - { - this.objectFile = objectFile; - this.symbolTableData = symbolTableData; - this.stringTableData = stringTableData; - - // Read existing symbols - if (symbolTableData.Size > 0) - { - byte[] stringTable = new byte[stringTableData.Size]; - using var stringTableStream = stringTableData.GetReadStream(); - stringTableStream.ReadFully(stringTable); - - uint symbolSize = SymbolHeader.BinarySize + (objectFile.Is64Bit ? 8u : 4u); - innerList.Capacity = (int)(symbolTableData.Size / symbolSize); - - byte[] symbolBuffer = new byte[symbolSize]; - using var symbolTableStream = symbolTableData.GetReadStream(); - while (symbolTableStream.Position < symbolTableStream.Length) - { - symbolTableStream.ReadFully(symbolBuffer); - var symbolHeader = SymbolHeader.Read(symbolBuffer, objectFile.IsLittleEndian, out var _); - ulong symbolValue; - if (objectFile.IsLittleEndian) - { - symbolValue = objectFile.Is64Bit ? - BinaryPrimitives.ReadUInt64LittleEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)) : - BinaryPrimitives.ReadUInt32LittleEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)); - } - else - { - symbolValue = objectFile.Is64Bit ? - BinaryPrimitives.ReadUInt64BigEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)) : - BinaryPrimitives.ReadUInt32BigEndian(symbolBuffer.AsSpan(SymbolHeader.BinarySize)); - } - - string name = string.Empty; - if (symbolHeader.NameIndex != 0) - { - int nameLength = stringTable.AsSpan((int)symbolHeader.NameIndex).IndexOf((byte)0); - Debug.Assert(nameLength >= 0); - name = Encoding.UTF8.GetString(stringTable.AsSpan((int)symbolHeader.NameIndex, nameLength)); - } - - var symbol = new MachSymbol - { - Name = name, - Descriptor = (MachSymbolDescriptor)symbolHeader.Descriptor, - Section = symbolHeader.Section == 0 ? null : sectionMap[symbolHeader.Section], - Type = (MachSymbolType)symbolHeader.Type, - Value = symbolValue, - }; - - innerList.Add(symbol); - } - } - } - - public int Count => innerList.Count; - - public bool IsReadOnly => false; - - public MachSymbol this[int index] - { - get => innerList[index]; - set - { - innerList[index] = value; - isDirty = true; - } - } - - public void Add(MachSymbol symbol) - { - innerList.Add(symbol); - isDirty = true; - } - - public void Clear() - { - innerList.Clear(); - isDirty = true; - } - - public bool Contains(MachSymbol symbol) - { - return innerList.Contains(symbol); - } - - public void CopyTo(MachSymbol[] array, int arrayIndex) - { - innerList.CopyTo(array, arrayIndex); - } - - public IEnumerator GetEnumerator() - { - return innerList.GetEnumerator(); - } - - public bool Remove(MachSymbol item) - { - if (innerList.Remove(item)) - { - isDirty = true; - return true; - } - - return false; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void FlushIfDirty() - { - if (isDirty) - { - var sectionMap = new Dictionary(); - byte sectionIndex = 1; - foreach (var section in objectFile.Segments.SelectMany(segment => segment.Sections)) - { - sectionMap.Add(section, sectionIndex++); - Debug.Assert(sectionIndex != 0); - } - - using var stringTableWriter = stringTableData.GetWriteStream(); - using var symbolTableWriter = symbolTableData.GetWriteStream(); - - // Start the table with a NUL byte. - stringTableWriter.WriteByte(0); - - SymbolHeader symbolHeader = new SymbolHeader(); - Span symbolHeaderBuffer = stackalloc byte[SymbolHeader.BinarySize]; - Span symbolValueBuffer = new byte[objectFile.Is64Bit ? 8 : 4]; - - foreach (var symbol in innerList) - { - var nameBytes = Encoding.UTF8.GetBytes(symbol.Name); - var nameOffset = stringTableWriter.Position; - - stringTableWriter.Write(nameBytes); - stringTableWriter.WriteByte(0); - - symbolHeader.NameIndex = (uint)nameOffset; - symbolHeader.Section = symbol.Section == null ? (byte)0 : sectionMap[symbol.Section]; - symbolHeader.Descriptor = (ushort)symbol.Descriptor; - symbolHeader.Type = (byte)symbol.Type; - - symbolHeader.Write(symbolHeaderBuffer, objectFile.IsLittleEndian, out _); - symbolTableWriter.Write(symbolHeaderBuffer); - - if (objectFile.Is64Bit) - { - if (objectFile.IsLittleEndian) - { - BinaryPrimitives.WriteUInt64LittleEndian(symbolValueBuffer, symbol.Value); - } - else - { - BinaryPrimitives.WriteUInt64BigEndian(symbolValueBuffer, symbol.Value); - } - } - else if (objectFile.IsLittleEndian) - { - BinaryPrimitives.WriteUInt32LittleEndian(symbolValueBuffer, (uint)symbol.Value); - } - else - { - BinaryPrimitives.WriteUInt32BigEndian(symbolValueBuffer, (uint)symbol.Value); - } - - symbolTableWriter.Write(symbolValueBuffer); - } - - // Pad the string table - int alignment = objectFile.Is64Bit ? 8 : 4; - while ((stringTableWriter.Position & (alignment - 1)) != 0) - stringTableWriter.WriteByte(0); - - isDirty = false; - } - } - - public int IndexOf(MachSymbol symbol) => innerList.IndexOf(symbol); - - public void Insert(int index, MachSymbol symbol) - { - innerList.Insert(index, symbol); - isDirty = true; - } - - public void RemoveAt(int index) - { - innerList.RemoveAt(index); - isDirty = true; - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs deleted file mode 100644 index ccad0268e701c5..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachSymbolType.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachSymbolType : byte - { - Stab = 0xe0, - PrivateExternal = 0x10, - - TypeMask = 0xe, - - Undefined = 0, - External = 1, - Section = 0xe, - Prebound = 0xc, - Indirect = 0xa, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs deleted file mode 100644 index 435e185cd52d13..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachVmProtection.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Melanzana.MachO -{ - [Flags] - public enum MachVmProtection : uint - { - None = 0x0, - Read = 0x1, - Write = 0x2, - Execute = 0x4, - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs deleted file mode 100644 index dadbd8073ee147..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachWriter.cs +++ /dev/null @@ -1,562 +0,0 @@ -using System.Buffers.Binary; -using System.Diagnostics; -using System.IO; -using System.Text; -using Melanzana.MachO.BinaryFormat; -using Melanzana.Streams; - -namespace Melanzana.MachO -{ - public static class MachWriter - { - private static void WriteLoadCommandHeader(Stream stream, MachLoadCommandType commandType, int commandSize, bool isLittleEndian) - { - Span loadCommandHeaderBuffer = stackalloc byte[LoadCommandHeader.BinarySize]; - var loadCommandHeader = new LoadCommandHeader - { - CommandType = commandType, - CommandSize = (uint)commandSize, - }; - loadCommandHeader.Write(loadCommandHeaderBuffer, isLittleEndian, out var _); - stream.Write(loadCommandHeaderBuffer); - } - - private static void WriteSegment(Stream stream, MachSegment segment, bool isLittleEndian, bool is64bit) - { - if (is64bit) - { - Span sectionBuffer = stackalloc byte[Section64Header.BinarySize]; - Span segmentBuffer = stackalloc byte[Segment64Header.BinarySize]; - - WriteLoadCommandHeader( - stream, - MachLoadCommandType.Segment64, - LoadCommandHeader.BinarySize + Segment64Header.BinarySize + segment.Sections.Count * Section64Header.BinarySize, - isLittleEndian); - - var segmentHeader = new Segment64Header - { - Name = segment.Name, - Address = segment.VirtualAddress, - Size = segment.Size, - FileOffset = (ulong)segment.FileOffset, - FileSize = (ulong)segment.FileSize, - MaximumProtection = segment.MaximumProtection, - InitialProtection = segment.InitialProtection, - NumberOfSections = (uint)segment.Sections.Count, - Flags = segment.Flags, - }; - segmentHeader.Write(segmentBuffer, isLittleEndian, out var _); - stream.Write(segmentBuffer); - - foreach (var section in segment.Sections) - { - var sectionHeader = new Section64Header - { - SectionName = section.SectionName, - SegmentName = section.SegmentName, - Address = section.VirtualAddress, - Size = section.Size, - FileOffset = section.FileOffset, - Log2Alignment = section.Log2Alignment, - RelocationOffset = section.RelocationOffset, - NumberOfReloationEntries = section.NumberOfRelocationEntries, - Flags = section.Flags, - Reserved1 = section.Reserved1, - Reserved2 = section.Reserved2, - Reserved3 = section.Reserved3, - }; - sectionHeader.Write(sectionBuffer, isLittleEndian, out var _); - stream.Write(sectionBuffer); - } - } - else - { - Span sectionBuffer = stackalloc byte[SectionHeader.BinarySize]; - Span segmentBuffer = stackalloc byte[SegmentHeader.BinarySize]; - - WriteLoadCommandHeader( - stream, - MachLoadCommandType.Segment, - LoadCommandHeader.BinarySize + SegmentHeader.BinarySize + segment.Sections.Count * SectionHeader.BinarySize, - isLittleEndian); - - // FIXME: Validation - - var segmentHeader = new SegmentHeader - { - Name = segment.Name, - Address = (uint)segment.VirtualAddress, - Size = (uint)segment.Size, - FileOffset = (uint)segment.FileOffset, - FileSize = (uint)segment.FileSize, - MaximumProtection = segment.MaximumProtection, - InitialProtection = segment.InitialProtection, - NumberOfSections = (uint)segment.Sections.Count, - Flags = segment.Flags, - }; - segmentHeader.Write(segmentBuffer, isLittleEndian, out var _); - stream.Write(segmentBuffer); - - foreach (var section in segment.Sections) - { - var sectionHeader = new SectionHeader - { - SectionName = section.SectionName, - SegmentName = section.SegmentName, - Address = (uint)section.VirtualAddress, - Size = (uint)section.Size, - FileOffset = section.FileOffset, - Log2Alignment = section.Log2Alignment, - RelocationOffset = section.RelocationOffset, - NumberOfReloationEntries = section.NumberOfRelocationEntries, - Flags = section.Flags, - Reserved1 = section.Reserved1, - Reserved2 = section.Reserved2, - }; - sectionHeader.Write(sectionBuffer, isLittleEndian, out var _); - stream.Write(sectionBuffer); - } - } - } - - private static void WriteLinkEdit(Stream stream, MachLoadCommandType commandType, MachLinkEdit linkEdit, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - commandType, - LoadCommandHeader.BinarySize + LinkEditHeader.BinarySize, - isLittleEndian); - - var linkEditHeaderBuffer = new byte[LinkEditHeader.BinarySize]; - var linkEditHeader = new LinkEditHeader - { - FileOffset = linkEdit.FileOffset, - FileSize = linkEdit.FileSize, - }; - linkEditHeader.Write(linkEditHeaderBuffer, isLittleEndian, out var _); - stream.Write(linkEditHeaderBuffer); - } - - private static int AlignedSize(int size, bool is64bit) - => is64bit ? (size + 7) & ~7 : (size + 3) & ~3; - - private static void WriteDylibCommand(Stream stream, MachLoadCommandType commandType, MachDylibCommand dylibCommand, bool isLittleEndian, bool is64Bit) - { - byte[] nameBytes = Encoding.UTF8.GetBytes(dylibCommand.Name); - int commandSize = AlignedSize(LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize + nameBytes.Length + 1, is64Bit); - - WriteLoadCommandHeader( - stream, - commandType, - commandSize, - isLittleEndian); - - Span dylibCommandHeaderBuffer = stackalloc byte[DylibCommandHeader.BinarySize]; - var dylibCommandHeader = new DylibCommandHeader - { - NameOffset = LoadCommandHeader.BinarySize + DylibCommandHeader.BinarySize, - Timestamp = dylibCommand.Timestamp, - CurrentVersion = dylibCommand.CurrentVersion, - CompatibilityVersion = dylibCommand.CompatibilityVersion, - }; - dylibCommandHeader.Write(dylibCommandHeaderBuffer, isLittleEndian, out var _); - stream.Write(dylibCommandHeaderBuffer); - stream.Write(nameBytes); - // The name is always written with terminating `\0` and aligned to platform - // pointer size. - stream.WritePadding(commandSize - dylibCommandHeader.NameOffset - nameBytes.Length); - } - - private static void WriteMainCommand(Stream stream, MachEntrypointCommand entrypointCommand, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - MachLoadCommandType.Main, - LoadCommandHeader.BinarySize + MainCommandHeader.BinarySize, - isLittleEndian); - - Span mainCommandHeaderBuffer = stackalloc byte[MainCommandHeader.BinarySize]; - var mainCommandHeader = new MainCommandHeader - { - FileOffset = entrypointCommand.FileOffset, - StackSize = entrypointCommand.StackSize, - }; - mainCommandHeader.Write(mainCommandHeaderBuffer, isLittleEndian, out var _); - stream.Write(mainCommandHeaderBuffer); - } - - private static uint ConvertVersion(Version version) - => ((uint)version.Major << 16) | (uint)((version.Minor & 0xff) << 8) | (uint)(version.Build & 0xff); - - private static void WriteVersionMinCommand(Stream stream, MachLoadCommandType commandType, MachBuildVersionBase versionCommand, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - commandType, - LoadCommandHeader.BinarySize + VersionMinCommandHeader.BinarySize, - isLittleEndian); - - Span versionMinHeaderBuffer = stackalloc byte[VersionMinCommandHeader.BinarySize]; - var versionMinHeader = new VersionMinCommandHeader - { - MinimumPlatformVersion = ConvertVersion(versionCommand.MinimumPlatformVersion), - SdkVersion = ConvertVersion(versionCommand.SdkVersion), - }; - versionMinHeader.Write(versionMinHeaderBuffer, isLittleEndian, out var _); - stream.Write(versionMinHeaderBuffer); - } - - private static void WriteBuildVersion(Stream stream, MachBuildVersion versionCommand, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - MachLoadCommandType.BuildVersion, - LoadCommandHeader.BinarySize + BuildVersionCommandHeader.BinarySize + (versionCommand.ToolVersions.Count * BuildToolVersionHeader.BinarySize), - isLittleEndian); - - Span buildVersionBuffer = stackalloc byte[BuildVersionCommandHeader.BinarySize]; - Span buildToolVersionBuffer = stackalloc byte[BuildToolVersionHeader.BinarySize]; - var buildVersionHeader = new BuildVersionCommandHeader - { - Platform = versionCommand.Platform, - MinimumPlatformVersion = ConvertVersion(versionCommand.MinimumPlatformVersion), - SdkVersion = ConvertVersion(versionCommand.SdkVersion), - NumberOfTools = (uint)versionCommand.ToolVersions.Count, - }; - buildVersionHeader.Write(buildVersionBuffer, isLittleEndian, out var _); - stream.Write(buildVersionBuffer); - - foreach (var toolVersion in versionCommand.ToolVersions) - { - var buildToolVersionHeader = new BuildToolVersionHeader - { - BuildTool = toolVersion.BuildTool, - Version = ConvertVersion(toolVersion.Version), - }; - buildToolVersionHeader.Write(buildToolVersionBuffer, isLittleEndian, out var _); - stream.Write(buildToolVersionBuffer); - } - } - - private static void WriteSymbolTableCommand(Stream stream, MachSymbolTable symbolTable, bool isLittleEndian, bool is64Bit) - { - WriteLoadCommandHeader( - stream, - MachLoadCommandType.SymbolTable, - LoadCommandHeader.BinarySize + SymbolTableCommandHeader.BinarySize, - isLittleEndian); - - uint symbolSize = SymbolHeader.BinarySize + (is64Bit ? 8u : 4u); - - Span symbolTableHeaderBuffer = stackalloc byte[SymbolTableCommandHeader.BinarySize]; - var symbolTableHeader = new SymbolTableCommandHeader - { - SymbolTableOffset = symbolTable.SymbolTableData.FileOffset, - NumberOfSymbols = (uint)(symbolTable.SymbolTableData.Size / symbolSize), - StringTableOffset = symbolTable.StringTableData.FileOffset, - StringTableSize = (uint)symbolTable.StringTableData.Size, - }; - symbolTableHeader.Write(symbolTableHeaderBuffer, isLittleEndian, out var _); - stream.Write(symbolTableHeaderBuffer); - } - - private static void WriteDynamicLinkEditSymbolTableCommand(Stream stream, MachDynamicLinkEditSymbolTable dySymbolTable, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - MachLoadCommandType.DynamicLinkEditSymbolTable, - LoadCommandHeader.BinarySize + DynamicSymbolTableCommandHeader.BinarySize, - isLittleEndian); - - Span symbolTableHeaderBuffer = stackalloc byte[DynamicSymbolTableCommandHeader.BinarySize]; - var symbolTableHeader = dySymbolTable.Header; - symbolTableHeader.Write(symbolTableHeaderBuffer, isLittleEndian, out var _); - stream.Write(symbolTableHeaderBuffer); - } - - private static void WriteDyldInfoCommand(Stream stream, MachLoadCommandType commandType, MachDyldInfo dyldInfo, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - commandType, - LoadCommandHeader.BinarySize + DyldInfoHeader.BinarySize, - isLittleEndian); - - Span dyldInfoHeaderBuffer = stackalloc byte[DyldInfoHeader.BinarySize]; - var dyldInfoHeader = new DyldInfoHeader - { - RebaseOffset = dyldInfo.RebaseData.FileOffset, - RebaseSize = (uint)dyldInfo.RebaseData.Size, - BindOffset = dyldInfo.BindData.FileOffset, - BindSize = (uint)dyldInfo.BindData.Size, - WeakBindOffset = dyldInfo.WeakBindData.FileOffset, - WeakBindSize = (uint)dyldInfo.WeakBindData.Size, - LazyBindOffset = dyldInfo.LazyBindData.FileOffset, - LazyBindSize = (uint)dyldInfo.LazyBindData.Size, - ExportOffset = dyldInfo.ExportData.FileOffset, - ExportSize = (uint)dyldInfo.ExportData.Size, - }; - dyldInfoHeader.Write(dyldInfoHeaderBuffer, isLittleEndian, out var _); - stream.Write(dyldInfoHeaderBuffer); - } - - private static void WriteTwoLevelHintsCommand(Stream stream, MachTwoLevelHints twoLevelHints, bool isLittleEndian) - { - WriteLoadCommandHeader( - stream, - MachLoadCommandType.TowLevelHints, - LoadCommandHeader.BinarySize + DyldInfoHeader.BinarySize, - isLittleEndian); - - Span twoLevelHintsHeaderBuffer = stackalloc byte[TwoLevelHintsHeader.BinarySize]; - var twoLevelHintsHeader = new TwoLevelHintsHeader - { - FileOffset = twoLevelHints.Data.FileOffset, - NumberOfHints = (uint)(twoLevelHints.Data.Size / sizeof(uint)) - }; - twoLevelHintsHeader.Write(twoLevelHintsHeaderBuffer, isLittleEndian, out var _); - stream.Write(twoLevelHintsHeaderBuffer); - } - - public static void Write(Stream stream, MachObjectFile objectFile) - { - long initialOffset = stream.Position; - bool isLittleEndian = objectFile.IsLittleEndian; - var machMagicBuffer = new byte[4]; - var machHeaderBuffer = new byte[Math.Max(MachHeader.BinarySize, MachHeader64.BinarySize)]; - - uint magic = isLittleEndian ? - (objectFile.Is64Bit ? (uint)MachMagic.MachHeader64LittleEndian : (uint)MachMagic.MachHeaderLittleEndian) : - (objectFile.Is64Bit ? (uint)MachMagic.MachHeader64BigEndian : (uint)MachMagic.MachHeaderBigEndian); - BinaryPrimitives.WriteUInt32BigEndian(machMagicBuffer, magic); - - var loadCommandsStream = new MemoryStream(); - foreach (var loadCommand in objectFile.LoadCommands) - { - switch (loadCommand) - { - case MachSegment segment: WriteSegment(loadCommandsStream, segment, isLittleEndian, objectFile.Is64Bit); break; - case MachCodeSignature codeSignature: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.CodeSignature, codeSignature, isLittleEndian); break; - case MachDylibCodeSigningDirs codeSigningDirs: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DylibCodeSigningDRs, codeSigningDirs, isLittleEndian); break; - case MachSegmentSplitInfo segmentSplitInfo: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.SegmentSplitInfo, segmentSplitInfo, isLittleEndian); break; - case MachFunctionStarts functionStarts: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.FunctionStarts, functionStarts, isLittleEndian); break; - case MachDataInCode dataInCode: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DataInCode, dataInCode, isLittleEndian); break; - case MachLinkerOptimizationHint linkerOptimizationHint: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.LinkerOptimizationHint, linkerOptimizationHint, isLittleEndian); break; - case MachDyldExportsTrie dyldExportsTrie: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DyldExportsTrie, dyldExportsTrie, isLittleEndian); break; - case MachDyldChainedFixups dyldChainedFixups: WriteLinkEdit(loadCommandsStream, MachLoadCommandType.DyldChainedFixups, dyldChainedFixups, isLittleEndian); break; - case MachLoadDylibCommand loadDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.LoadDylib, loadDylibCommand, isLittleEndian, objectFile.Is64Bit); break; - case MachLoadWeakDylibCommand loadWeakDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.LoadWeakDylib, loadWeakDylibCommand, isLittleEndian, objectFile.Is64Bit); break; - case MachReexportDylibCommand reexportDylibCommand: WriteDylibCommand(loadCommandsStream, MachLoadCommandType.ReexportDylib, reexportDylibCommand, isLittleEndian, objectFile.Is64Bit); break; - case MachEntrypointCommand entrypointCommand: WriteMainCommand(loadCommandsStream, entrypointCommand, isLittleEndian); break; - case MachVersionMinMacOS macOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinMacOS, macOSBuildVersion, isLittleEndian); break; - case MachVersionMinIOS iOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinIPhoneOS, iOSBuildVersion, isLittleEndian); break; - case MachVersionMinTvOS tvOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinTvOS, tvOSBuildVersion, isLittleEndian); break; - case MachVersionMinWatchOS watchOSBuildVersion: WriteVersionMinCommand(loadCommandsStream, MachLoadCommandType.VersionMinWatchOS, watchOSBuildVersion, isLittleEndian); break; - case MachBuildVersion buildVersion: WriteBuildVersion(loadCommandsStream, buildVersion, isLittleEndian); break; - case MachSymbolTable symbolTable: WriteSymbolTableCommand(loadCommandsStream, symbolTable, isLittleEndian, objectFile.Is64Bit); break; - case MachDynamicLinkEditSymbolTable dySymbolTable: WriteDynamicLinkEditSymbolTableCommand(loadCommandsStream, dySymbolTable, isLittleEndian); break; - case MachDyldInfoOnly dyldInfoOnly: WriteDyldInfoCommand(loadCommandsStream, MachLoadCommandType.DyldInfoOnly, dyldInfoOnly, isLittleEndian); break; - case MachDyldInfo dyldInfo: WriteDyldInfoCommand(loadCommandsStream, MachLoadCommandType.DyldInfo, dyldInfo, isLittleEndian); break; - case MachTwoLevelHints twoLevelHints: WriteTwoLevelHintsCommand(loadCommandsStream, twoLevelHints, isLittleEndian); break; - case MachCustomLoadCommand customLoadCommand: - WriteLoadCommandHeader(loadCommandsStream, customLoadCommand.Type, customLoadCommand.Data.Length + LoadCommandHeader.BinarySize, isLittleEndian); - loadCommandsStream.Write(customLoadCommand.Data); - break; - default: - Debug.Fail("Unknown load command"); - break; - } - } - - if (objectFile.Is64Bit) - { - var machHeader = new MachHeader64 - { - CpuType = objectFile.CpuType, - CpuSubType = objectFile.CpuSubType, - FileType = objectFile.FileType, - NumberOfCommands = (uint)objectFile.LoadCommands.Count, - SizeOfCommands = (uint)loadCommandsStream.Length, - Flags = objectFile.Flags, - Reserved = 0, // TODO - }; - - stream.Write(machMagicBuffer); - machHeader.Write(machHeaderBuffer, isLittleEndian, out int bytesWritten); - stream.Write(machHeaderBuffer.AsSpan(0, bytesWritten)); - } - else - { - var machHeader = new MachHeader - { - CpuType = objectFile.CpuType, - CpuSubType = objectFile.CpuSubType, - FileType = objectFile.FileType, - NumberOfCommands = (uint)objectFile.LoadCommands.Count, - SizeOfCommands = (uint)loadCommandsStream.Length, - Flags = objectFile.Flags, - }; - - stream.Write(machMagicBuffer); - machHeader.Write(machHeaderBuffer, isLittleEndian, out int bytesWritten); - stream.Write(machHeaderBuffer.AsSpan(0, bytesWritten)); - } - - loadCommandsStream.Position = 0; - loadCommandsStream.CopyTo(stream); - - // Save the current position within the Mach-O file. Now we need to output the segments - // and fill in the gaps as we go. - ulong currentOffset = (ulong)(stream.Position - initialOffset); - var orderedSegments = objectFile.Segments.OrderBy(s => s.FileOffset).ToList(); - - foreach (var segment in orderedSegments) - { - if (segment.FileSize != 0) - { - if (segment.Sections.Count == 0) - { - Debug.Assert(segment.FileOffset >= currentOffset); - - if (segment.FileOffset > currentOffset) - { - ulong paddingSize = segment.FileOffset - currentOffset; - stream.WritePadding((long)paddingSize); - currentOffset += paddingSize; - } - - if (segment.IsLinkEditSegment) - { - // __LINKEDIT always has to be the last segment in object file, so break - // out of the loop. - break; - } - - using var segmentStream = segment.GetReadStream(); - segmentStream.CopyTo(stream); - currentOffset += (ulong)segmentStream.Length; - } - else - { - byte paddingByte = 0; - - foreach (var section in segment.Sections) - { - if (section.IsInFile) - { - Debug.Assert(section.FileOffset >= currentOffset); - - if (section.FileOffset > currentOffset) - { - ulong paddingSize = section.FileOffset - currentOffset; - stream.WritePadding((long)paddingSize, paddingByte); - currentOffset += paddingSize; - } - - using var sectionStream = section.GetReadStream(); - sectionStream.CopyTo(stream); - currentOffset += (ulong)sectionStream.Length; - - bool isCodeSection = - section.Type == MachSectionType.Regular && - section.Attributes.HasFlag(MachSectionAttributes.SomeInstructions) && - section.Attributes.HasFlag(MachSectionAttributes.PureInstructions); - - if (isCodeSection) - { - // Padding of code sections is done with NOP bytes if possible - paddingByte = objectFile.CpuType switch - { - // TODO: Arm32 / Thumb - MachCpuType.X86_64 => (byte)0x90, - MachCpuType.X86 => (byte)0x90, - _ => (byte)0, - }; - } - else - { - paddingByte = 0; - } - } - } - } - } - } - - // We are either writing an unlinked object file or a __LINKEDIT segment - var linkEditData = new List(objectFile.LinkEditData); - - // Sort by file offset first - linkEditData.Sort((sectionA, sectionB) => - sectionA.FileOffset < sectionB.FileOffset ? -1 : - (sectionA.FileOffset > sectionB.FileOffset ? 1 : 0)); - - foreach (var data in linkEditData) - { - if (data.FileOffset > currentOffset) - { - ulong paddingSize = data.FileOffset - currentOffset; - stream.WritePadding((long)paddingSize); - currentOffset += paddingSize; - } - - using var segmentStream = data.GetReadStream(); - segmentStream.CopyTo(stream); - currentOffset += (ulong)segmentStream.Length; - } - } - - public static void Write(Stream stream, IList objectFiles) - { - if (objectFiles.Count == 1) - { - Write(stream, objectFiles[0]); - } - else if (objectFiles.Count > 1) - { - var fatMagic = new byte[4]; - var fatHeader = new FatHeader { NumberOfFatArchitectures = (uint)objectFiles.Count }; - var fatHeaderBytes = new byte[FatHeader.BinarySize]; - var fatArchHeaderBytes = new byte[FatArchHeader.BinarySize]; - - BinaryPrimitives.WriteUInt32BigEndian(fatMagic, (uint)MachMagic.FatMagicBigEndian); - fatHeader.Write(fatHeaderBytes, isLittleEndian: false, out var _); - stream.Write(fatMagic); - stream.Write(fatHeaderBytes); - - uint offset = (uint)(4 + FatHeader.BinarySize + objectFiles.Count * FatArchHeader.BinarySize); - uint alignment = 0x4000; - foreach (var objectFile in objectFiles) - { - uint size = (uint)objectFile.GetSize(); - - offset = (offset + alignment - 1) & ~(alignment - 1); - var fatArchHeader = new FatArchHeader - { - CpuType = objectFile.CpuType, - CpuSubType = objectFile.CpuSubType, - Offset = offset, - Size = size, - Alignment = (uint)Math.Log2(alignment), - }; - - fatArchHeader.Write(fatArchHeaderBytes, isLittleEndian: false, out var _); - stream.Write(fatArchHeaderBytes); - - offset += size; - } - - offset = (uint)(4 + FatHeader.BinarySize + objectFiles.Count * FatArchHeader.BinarySize); - foreach (var objectFile in objectFiles) - { - uint size = (uint)objectFile.GetSize(); - uint alignedOffset = (offset + alignment - 1) & ~(alignment - 1); - stream.WritePadding(alignedOffset - offset); - Write(stream, objectFile); - offset = alignedOffset + size; - } - } - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs deleted file mode 100644 index cdf397c7754207..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/MachX8664CpuSubType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Melanzana.MachO -{ - /// - /// Defines the subtypes of the x86_64 . - /// Defined in machine.h. - /// - /// - /// This enumeration matches version 7195.141.2 of XNU. - /// - /// - public enum X8664CpuSubType : uint - { - /// - /// All x86_64 CPUs - /// - All = 3, - - /// - /// Haswell feature subset. - /// - Haswell = 8, - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj deleted file mode 100644 index d88ee4f08d4742..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/Melanzana.MachO.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net6.0 - enable - enable - - true - $(BaseIntermediateOutputPath)/GeneratedFiles - - - - - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md b/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md deleted file mode 100644 index 88e4610f88cd32..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.MachO/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Mach-O manipulation library - -The `Melanzana.MachO` library implements object model for manipulation of Mach-O files. It allows reading files from disk into the in-memory object model, modifying it and then writing it back to disk. Additionally, universal binaries targeting more architectures can be read and written. - -## Status - -- `MachObjectFile` implements the in-memory representation of Mach-O file; it allows access to header fields and load commands (including sections and segments) -- Universal binaries and Mach-O files can be read using `MachReader.Read` method into the in-memory object model -- Universal binaries and Mach-O files can be written to disk using `MachWriter.Write` method from the in-memory object model -- Segments (`MachSegment`) and sections (`MachSection`) can be manipulated and content can be rewritten, the model is unified for 32-/64-bit Mach-O files - -Minimal set of load commands is mapped to the strongly typed object model (eg. dynamicly linked dependencies, required platform versions). - -Validation is completely missing. - -## Acknowledgments - -Many design decisions in this library were inspired by [LibObjectFile](https://github.com/xoofx/LibObjectFile), [LIEF project](https://github.com/lief-project/LIEF) and [go-macho](https://github.com/blacktop/go-macho). diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj deleted file mode 100644 index 132c02c59c2364..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/Melanzana.Streams.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs deleted file mode 100644 index 71e8fba1b8e0cf..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/SliceStream.cs +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (c) Alexandre Mutel. All rights reserved. -// This file is licensed under the BSD-Clause 2 license. -// See the license.txt file in the project root for more information. - -using System; -using System.IO; -using System.Buffers; - -namespace Melanzana.Streams -{ - /// - /// Defines a stream as a slice of another existing stream. - /// - public class SliceStream : Stream - { - private Stream _baseStream; - private readonly long _length; - private readonly long _basePosition; - private long _localPosition; - - public SliceStream(Stream baseStream, long position, long length) - { - if (baseStream == null) throw new ArgumentNullException(nameof(baseStream)); - if (!baseStream.CanSeek) throw new ArgumentException("Invalid base stream that can't be seek."); - if (position < 0) throw new ArgumentOutOfRangeException(nameof(position)); - if (length < 0) throw new ArgumentOutOfRangeException(nameof(length)); - if (position + length > baseStream.Length) throw new ArgumentOutOfRangeException(nameof(position), $"The position {position} + length {length} > baseStream.Length {baseStream.Length}"); - - _baseStream = baseStream; - _length = length; - _basePosition = position; - } - public override int Read(byte[] buffer, int offset, int count) - { - ThrowIfDisposed(); - - long remaining = _length - _localPosition; - if (remaining <= 0) return 0; - if (remaining < count) count = (int)remaining; - - var savedPosition = _baseStream.Position; - _baseStream.Position = _basePosition + _localPosition; - int read = _baseStream.Read(buffer, offset, count); - _localPosition += read; - _baseStream.Position = savedPosition; - - return read; - } - private void ThrowIfDisposed() - { - if (_baseStream == null) throw new ObjectDisposedException(GetType().Name); - } - public override long Length - { - get { ThrowIfDisposed(); return _length; } - } - public override bool CanRead - { - get { ThrowIfDisposed(); return _baseStream.CanRead; } - } - public override bool CanWrite - { - get { ThrowIfDisposed(); return _baseStream.CanWrite; } - } - public override bool CanSeek - { - get { ThrowIfDisposed(); return _baseStream.CanSeek; } - } - public override long Position - { - get - { - ThrowIfDisposed(); - return _localPosition; - } - set => Seek(value, SeekOrigin.Begin); - } - public override long Seek(long offset, SeekOrigin origin) - { - long newPosition = _localPosition; - switch (origin) - { - case SeekOrigin.Begin: - newPosition = offset; - break; - case SeekOrigin.Current: - newPosition += offset; - break; - case SeekOrigin.End: - newPosition = _length - offset; - break; - default: - throw new ArgumentOutOfRangeException(nameof(origin), origin, null); - } - - if (newPosition < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is < 0"); - if (newPosition > _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is > Length {_length}"); - - // Check that we can seek on the origin stream - _baseStream.Position = _basePosition + newPosition; - _localPosition = newPosition; - - return newPosition; - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override void Flush() - { - ThrowIfDisposed(); _baseStream.Flush(); - } - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing) - { - /*if (_baseStream != null) - { - try - { - _baseStream.Dispose(); - } - catch - { - // ignored - }*/ - _baseStream = Stream.Null; - //} - } - } - public override void Write(byte[] buffer, int offset, int count) - { - ThrowIfDisposed(); - if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); - if (count == 0) return; - - var isOverLength = _localPosition + count > Length; - var maxLength = isOverLength ? (int)(Length - _localPosition) : count; - var savedPosition = _baseStream.Position; - _baseStream.Position = _basePosition + _localPosition; - _baseStream.Write(buffer, offset, maxLength); - _baseStream.Position = savedPosition; - _localPosition += maxLength; - if (isOverLength) - { - throw new InvalidOperationException("Cannot write outside of this stream slice"); - } - } - - public override void CopyTo(Stream destination, int bufferSize) - { - var savedPosition = _baseStream.Position; - _baseStream.Position = _basePosition + _localPosition; - - byte[] buffer = ArrayPool.Shared.Rent(bufferSize); - try - { - int bytesRead; - long remaining = _length - _localPosition; - while (remaining > 0 && (bytesRead = _baseStream.Read(buffer, 0, (int)Math.Min(buffer.Length, remaining))) != 0) - { - _localPosition += bytesRead; - remaining = _length - _localPosition; - destination.Write(buffer, 0, bytesRead); - } - } - finally - { - ArrayPool.Shared.Return(buffer); - } - - _baseStream.Position = savedPosition; - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs deleted file mode 100644 index 5ae88af1ec1da8..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/StreamExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Melanzana.Streams -{ - public static class StreamExtensions - { - public static Stream Slice(this Stream stream, long offset, long size) - { - //if (stream is MemoryStream memoryStream && memoryStream.TryGetBuffer()) - // return new MemoryStream(memoryStream.GetBuffer(), (int)offset, (int)size); - return new SliceStream(stream, offset, size); - } - - public static void ReadFully(this Stream stream, Span buffer) - { - int totalRead = 0; - int bytesRead; - while ((bytesRead = stream.Read(buffer.Slice(totalRead))) > 0 && buffer.Length < totalRead) - totalRead += bytesRead; - if (bytesRead <= 0) - throw new EndOfStreamException(); - } - - public static void WritePadding(this Stream stream, long paddingSize, byte paddingByte = 0) - { - Span paddingBuffer = stackalloc byte[4096]; - paddingBuffer.Fill(paddingByte); - while (paddingSize > 0) - { - long chunkSize = paddingSize > paddingBuffer.Length ? paddingBuffer.Length : paddingSize; - stream.Write(paddingBuffer.Slice(0, (int)chunkSize)); - paddingSize -= chunkSize; - } - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs b/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs deleted file mode 100644 index 7dc4e6bd0688d4..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/Melanzana.Streams/UnclosableMemoryStream.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Melanzana.Streams -{ - public class UnclosableMemoryStream : MemoryStream - { - protected override void Dispose(bool disposing) - { - } - } -} \ No newline at end of file diff --git a/src/coreclr/tools/aot/external/Melanzana/README.md b/src/coreclr/tools/aot/external/Melanzana/README.md deleted file mode 100644 index 7210ddf21d63c2..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Project "Melanzana" - -Implements framework for Apple Code Signing of bundles and Mach-O files in .NET. - -## Status - -The code is very much work in progress. It can sign simple application bundles and Mach-O executables. - -There's a simple command line tool for testing that can sign with ad-hoc signatures, certificates from system keychain, or certificates from Azure Key Vault. For Azure Key Vault the only supported authentication is logging in with the Azure CLI tool. diff --git a/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs b/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs deleted file mode 100644 index 0154e81150d9d3..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/codesign/Program.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Azure.Identity; -using Azure.Security.KeyVault.Certificates; -using Claunia.PropertyList; -using System.CommandLine; -using System.Security.Cryptography.X509Certificates; -using RSAKeyVaultProvider; - -namespace Melanzana.CodeSign -{ - public class Program - { - public static int Main(string[] args) - { - var identity = new Argument("identity", "Name of signing identity or \"-\" for ad-hoc signing"); - var path = new Argument("path", "Path to bundle or executable on disk"); - var entitlements = new Option("--entitlements", "Path to entitlements to embed into the signature"); - var azureKekVaultUrl = new Option("--azure-key-vault-url", "URL to an Azure Key Vault"); - - var signCommand = new Command("sign", "Sign code at path using given identity") - { - identity, - path, - entitlements, - azureKekVaultUrl, - }; - - signCommand.SetHandler(HandleSign, identity, path, entitlements, azureKekVaultUrl); - - return new RootCommand { signCommand }.Invoke(args); - } - - private static X509Certificate2? FindCertificate(string identity) - { - if (identity == "-") - { - // Ad-hoc signing - return null; - } - - var store = new X509Store(StoreLocation.CurrentUser); - store.Open(OpenFlags.ReadOnly); - X509Certificate2Collection collection; - - if (identity.Length == 40 && identity.All(Uri.IsHexDigit)) - { - collection = store.Certificates.Find( - X509FindType.FindByThumbprint, - identity, - true); - } - else - { - collection = store.Certificates.Find( - X509FindType.FindBySubjectName, - identity, - true); - } - - var certificate = collection.Where(c => c.IsAppleDeveloperCertificate()).FirstOrDefault(); - if (certificate == null) - { - throw new Exception($"Certificate for identity \"{identity}\" not found"); - } - - return certificate; - } - - public static void HandleSign( - string identity, - string path, - string? entitlements, - string? azureKeyVaultUrl) - { - var codeSignOptions = new CodeSignOptions(); - - if (String.IsNullOrEmpty(azureKeyVaultUrl)) - { - codeSignOptions.DeveloperCertificate = FindCertificate(identity); - } - else - { - // Azure key vault - var credential = new AzureCliCredential(); - var certClient = new CertificateClient(new Uri(azureKeyVaultUrl), credential); - var azureCertificate = certClient.GetCertificate(identity).Value; - codeSignOptions.DeveloperCertificate = new X509Certificate2(azureCertificate.Cer); - codeSignOptions.PrivateKey = RSAFactory.Create(credential, azureCertificate.KeyId, codeSignOptions.DeveloperCertificate); - } - - if (!String.IsNullOrEmpty(entitlements)) - { - codeSignOptions.Entitlements = new Entitlements( - (NSDictionary)PropertyListParser.Parse( - new FileInfo(entitlements) - ) - ); - } - - var signer = new Signer(codeSignOptions); - signer.Sign(path); - } - } -} diff --git a/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj b/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj deleted file mode 100644 index 71f2a18b66a712..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/codesign/codesign.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - - - - diff --git a/src/coreclr/tools/aot/external/Melanzana/version.json b/src/coreclr/tools/aot/external/Melanzana/version.json deleted file mode 100644 index 75c8ef3d38975d..00000000000000 --- a/src/coreclr/tools/aot/external/Melanzana/version.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.1", - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/heads/releases/*" - ] -} From f17b3081a78878aa9cd72549dc9e880e7467272c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 9 Dec 2023 18:06:06 +0100 Subject: [PATCH 108/144] Rename LlvmObjectWriter to LegacyObjectWriter to prevent conflict with NativeAOT-LLVM branch --- .../{LlvmObjectWriter.cs => LegacyObjectWriter.cs} | 8 ++++---- .../Compiler/ObjectWriter/ObjectWriter.cs | 2 +- .../aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/{LlvmObjectWriter.cs => LegacyObjectWriter.cs} (99%) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LegacyObjectWriter.cs similarity index 99% rename from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs rename to src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LegacyObjectWriter.cs index 31f7f31a693a29..0a77e36b433025 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LlvmObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/LegacyObjectWriter.cs @@ -21,7 +21,7 @@ namespace ILCompiler.ObjectWriter /// /// Object writer using src/Native/ObjWriter /// - internal sealed class LlvmObjectWriter : IDisposable, ITypesDebugInfoWriter + internal sealed class LegacyObjectWriter : IDisposable, ITypesDebugInfoWriter { private readonly ObjectWritingOptions _options; @@ -908,7 +908,7 @@ public void EmitSymbolDefinition(int currentOffset) private IntPtr _nativeObjectWriter = IntPtr.Zero; - public LlvmObjectWriter(string objectFilePath, NodeFactory factory, ObjectWritingOptions options) + public LegacyObjectWriter(string objectFilePath, NodeFactory factory, ObjectWritingOptions options) { var triple = GetLLVMTripleFromTarget(factory.Target); @@ -951,7 +951,7 @@ public void Dispose(bool bDisposing) } } - ~LlvmObjectWriter() + ~LegacyObjectWriter() { Dispose(false); } @@ -1006,7 +1006,7 @@ public void ResetByteRunInterruptionOffsets(ObjectData nodeContents) public static void EmitObject(string objectFilePath, IReadOnlyCollection nodes, NodeFactory factory, ObjectWritingOptions options, IObjectDumper dumper, Logger logger) { - LlvmObjectWriter objectWriter = new LlvmObjectWriter(objectFilePath, factory, options); + LegacyObjectWriter objectWriter = new LegacyObjectWriter(objectFilePath, factory, options); bool succeeded = false; try diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index e3f15340539f54..acf01d357101a9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -465,7 +465,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection - + all contentfiles @@ -602,7 +602,7 @@ - + From 004b5c5908d5a1fd156eb180532346d813aa986b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 9 Dec 2023 18:51:47 +0100 Subject: [PATCH 109/144] Mach-O: Swap the order of symbol table and string table to make strip command happy --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 92c29f9076e4b7..6ca878191d597d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -182,8 +182,8 @@ protected override void EmitObjectFile(string objectFilePath) stringTable.ReserveString(symbol.Name); } - uint stringTableOffset = fileOffset; - uint symbolTableOffset = stringTableOffset + ((stringTable.Size + 7u) & ~7u); + uint symbolTableOffset = fileOffset; + uint stringTableOffset = symbolTableOffset + ((uint)_symbolTable.Count * 16u); MachSymbolTableCommandHeader symbolTableHeader = new MachSymbolTableCommandHeader { SymbolTableOffset = symbolTableOffset, @@ -256,12 +256,12 @@ protected override void EmitObjectFile(string objectFilePath) } // Write string and symbol table - stringTable.Write(outputFileStream); outputFileStream.Position = symbolTableOffset; foreach (MachSymbol symbol in _symbolTable) { symbol.Write(outputFileStream, stringTable); } + stringTable.Write(outputFileStream); } protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) From e5d6e72a60f66afe413dbb69a2e1fe10c56968cc Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 10 Dec 2023 11:02:37 +0100 Subject: [PATCH 110/144] Fix the CPU type/subtype --- .../Compiler/ObjectWriter/MachNative.cs | 6 ++++ .../Compiler/ObjectWriter/MachObjectWriter.cs | 34 ++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs index b8f65a9c91bc51..30b18a1dc1793b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs @@ -12,6 +12,12 @@ internal static class MachNative // File header flags public const uint MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000; + // CPU type/subtype + public const uint CPU_TYPE_ARM64 = 0x1000000 | 12; + public const uint CPU_TYPE_X86_64 = 0x1000000 | 7; + public const uint CPU_SUBTYPE_ARM64_ALL = 0; + public const uint CPU_SUBTYPE_X86_64_ALL = 3; + // Load command types public const uint LC_SYMTAB = 0x2; public const uint LC_DYSYMTAB = 0xb; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 6ca878191d597d..876e011afa02bb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -21,7 +21,8 @@ internal sealed class MachObjectWriter : UnixObjectWriter private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); private readonly TargetOS _targetOS; - private readonly MachCpuType _cpuType; + private readonly uint _cpuType; + private readonly uint _cpuSubType; private readonly List _sections = new(); // Exception handling sections @@ -41,11 +42,13 @@ public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) switch (factory.Target.Architecture) { case TargetArchitecture.ARM64: - _cpuType = MachCpuType.Arm64; + _cpuType = MachNative.CPU_TYPE_ARM64; + _cpuSubType = MachNative.CPU_SUBTYPE_ARM64_ALL; _compactUnwindDwarfCode = 0x3_00_00_00u; break; case TargetArchitecture.X64: - _cpuType = MachCpuType.X86_64; + _cpuType = MachNative.CPU_TYPE_X86_64; + _cpuSubType = MachNative.CPU_SUBTYPE_X86_64_ALL; _compactUnwindDwarfCode = 0x4_00_00_00u; break; default: @@ -149,7 +152,7 @@ protected override void EmitObjectFile(string objectFilePath) MachHeader64 machHeader = new MachHeader64 { CpuType = _cpuType, - CpuSubType = 0, + CpuSubType = _cpuSubType, FileType = MachNative.MH_OBJECT, NumberOfCommands = loadCommandsCount, SizeOfCommands = loadCommandsSize, @@ -210,7 +213,7 @@ protected override void EmitObjectFile(string objectFilePath) buildVersion.Platform = MachNative.PLATFORM_MACCATALYST; buildVersion.MinimumPlatformVersion = _cpuType switch { - MachCpuType.X86_64 => 0x0d_05_00u, // 13.5.0 + MachNative.CPU_TYPE_X86_64 => 0x0d_05_00u, // 13.5.0 _ => 0x0e_02_00u, // 14.2.0 }; break; @@ -384,7 +387,7 @@ protected internal override void EmitRelocation( if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) { - Debug.Assert(_cpuType == MachCpuType.Arm64); + Debug.Assert(_cpuType == MachNative.CPU_TYPE_ARM64); Debug.Assert(addend == 0); } else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) @@ -400,7 +403,7 @@ protected internal override void EmitRelocation( } else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) { - if (_cpuType == MachCpuType.Arm64) + if (_cpuType == MachNative.CPU_TYPE_ARM64) { // On ARM64 we need to represent PC relative relocations as // subtraction and the PC offset is baked into the addend. @@ -433,7 +436,7 @@ protected internal override void EmitRelocation( } else if (relocType == RelocType.IMAGE_REL_BASED_REL32) { - Debug.Assert(_cpuType != MachCpuType.Arm64); + Debug.Assert(_cpuType != MachNative.CPU_TYPE_ARM64); if (addend != 0) { BinaryPrimitives.WriteInt32LittleEndian( @@ -509,7 +512,7 @@ protected override void EmitSymbolTable( protected override void EmitRelocations(int sectionIndex, List relocationList) { - if (_cpuType == MachCpuType.Arm64) + if (_cpuType == MachNative.CPU_TYPE_ARM64) { EmitRelocationsArm64(sectionIndex, relocationList); } @@ -761,7 +764,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt { uint encoding = _compactUnwindDwarfCode; - if (_cpuType == MachCpuType.Arm64) + if (_cpuType == MachNative.CPU_TYPE_ARM64) { if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) { @@ -782,18 +785,9 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); - public enum MachCpuType : uint - { - X86 = 7, - X86_64 = X86 | Architecture64, - Arm = 12, - Arm64 = Arm | Architecture64, - Architecture64 = 0x1000000, - } - private struct MachHeader64 { - public MachCpuType CpuType { get; set; } + public uint CpuType { get; set; } public uint CpuSubType { get; set; } public uint FileType { get; set; } public uint NumberOfCommands { get; set; } From d38b91a9374e71ab4821ec1b8ce96968f5c2ac09 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 10 Dec 2023 12:00:10 +0100 Subject: [PATCH 111/144] Fix Release build --- .../Compiler/ObjectWriter/MachObjectWriter.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 876e011afa02bb..815077506b7d83 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -834,7 +834,8 @@ public void Write(FileStream stream) BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.LC_SEGMENT_64); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)(HeaderSize + NumberOfSections * MachSection.HeaderSize)); - Debug.Assert(Encoding.UTF8.TryGetBytes(Name, buffer.Slice(8, 16), out _)); + bool encoded = Encoding.UTF8.TryGetBytes(Name, buffer.Slice(8, 16), out _); + Debug.Assert(encoded); BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(24, 8), Address); BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(32, 8), Size); BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(40, 8), FileOffset); @@ -888,8 +889,10 @@ public void WriteHeader(FileStream stream) Span buffer = stackalloc byte[HeaderSize]; buffer.Clear(); - Debug.Assert(Encoding.UTF8.TryGetBytes(SectionName, buffer.Slice(0, 16), out _)); - Debug.Assert(Encoding.UTF8.TryGetBytes(SegmentName, buffer.Slice(16, 16), out _)); + bool encoded = Encoding.UTF8.TryGetBytes(SectionName, buffer.Slice(0, 16), out _); + Debug.Assert(encoded); + encoded = Encoding.UTF8.TryGetBytes(SegmentName, buffer.Slice(16, 16), out _); + Debug.Assert(encoded); BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(32, 8), VirtualAddress); BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(40, 8), Size); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(48, 4), FileOffset); From 57133a9d773b78f9ec64424a34a249ca0a82148f Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Dec 2023 10:49:58 +0100 Subject: [PATCH 112/144] Eliminate relocations for known symbols within the same section --- .../Compiler/ObjectWriter/ObjectWriter.cs | 82 ++++++++++++++----- 1 file changed, 61 insertions(+), 21 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index acf01d357101a9..b39abda6ac5015 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -18,6 +19,7 @@ public abstract class ObjectWriter : IDisposable { protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); protected sealed record SymbolicRelocation(long Offset, RelocType Type, string SymbolName, long Addend = 0); + protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Data, Relocation[] Relocations); protected readonly NodeFactory _nodeFactory; protected readonly ObjectWritingOptions _options; @@ -164,7 +166,34 @@ protected internal virtual void EmitRelocation( string symbolName, long addend) { - _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + if (_definedSymbols.TryGetValue(symbolName, out SymbolDefinition definedSymbol) && + definedSymbol.SectionIndex == sectionIndex && + relocType is RelocType.IMAGE_REL_BASED_REL32 or RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + { + // Resolve the relocation to already defined symbol and write it into data + switch (relocType) + { + case RelocType.IMAGE_REL_BASED_REL32: + addend += BinaryPrimitives.ReadInt32LittleEndian(data); + addend -= 4; + BinaryPrimitives.WriteInt32LittleEndian(data, (int)(definedSymbol.Value - offset) + (int)addend); + break; + + case RelocType.IMAGE_REL_BASED_RELPTR32: + addend += BinaryPrimitives.ReadInt32LittleEndian(data); + BinaryPrimitives.WriteInt32LittleEndian(data, (int)(definedSymbol.Value - offset) + (int)addend); + break; + + case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: + var ins = BinaryPrimitives.ReadUInt32LittleEndian(data) & 0xFC000000; + BinaryPrimitives.WriteUInt32LittleEndian(data, ((uint)(int)(definedSymbol.Value - offset) & 0x3FFFFFF) | ins); + break; + } + } + else + { + _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); + } } protected bool SectionHasRelocations(int sectionIndex) @@ -322,6 +351,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection blocksToRelocate = new(); foreach (DependencyNode depNode in nodes) { ObjectNode node = depNode as ObjectNode; @@ -370,26 +400,11 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Mon, 11 Dec 2023 11:17:53 +0100 Subject: [PATCH 113/144] Fix IMAGE_REL_BASED_ARM64_BRANCH26 --- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index b39abda6ac5015..900d22e557cb1f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -186,7 +186,7 @@ protected internal virtual void EmitRelocation( case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: var ins = BinaryPrimitives.ReadUInt32LittleEndian(data) & 0xFC000000; - BinaryPrimitives.WriteUInt32LittleEndian(data, ((uint)(int)(definedSymbol.Value - offset) & 0x3FFFFFF) | ins); + BinaryPrimitives.WriteUInt32LittleEndian(data, (((uint)(int)(definedSymbol.Value - offset) & 0x3FFFFFF) >> 2) | ins); break; } } From a4312a129d23759ab161f47562fda658ab56abc5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Dec 2023 12:36:08 +0100 Subject: [PATCH 114/144] Attempt to fix CI errors --- .../Compiler/ObjectWriter/ObjectWriter.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index 900d22e557cb1f..d8a7be47767a66 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -24,6 +24,7 @@ protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Da protected readonly NodeFactory _nodeFactory; protected readonly ObjectWritingOptions _options; private readonly bool _isSingleFileCompilation; + private readonly bool _usesSubsectionsViaSymbols; private readonly Dictionary _mangledNameMap = new(); @@ -45,6 +46,7 @@ protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) _nodeFactory = factory; _options = options; _isSingleFileCompilation = _nodeFactory.CompilationModuleGroup.IsSingleFileCompilation; + _usesSubsectionsViaSymbols = factory.Target.IsOSXLike; // Padding byte for code sections (NOP for x86/x64) _insPaddingByte = factory.Target.Architecture switch @@ -112,7 +114,7 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string com protected bool ShouldShareSymbol(ObjectNode node) { - if (_nodeFactory.Target.IsOSXLike) + if (_usesSubsectionsViaSymbols) return false; return ShouldShareSymbol(node, node.GetSection(_nodeFactory)); @@ -120,7 +122,7 @@ protected bool ShouldShareSymbol(ObjectNode node) protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) { - if (_nodeFactory.Target.IsOSXLike) + if (_usesSubsectionsViaSymbols) return false; // Foldable sections are always COMDATs @@ -166,7 +168,8 @@ protected internal virtual void EmitRelocation( string symbolName, long addend) { - if (_definedSymbols.TryGetValue(symbolName, out SymbolDefinition definedSymbol) && + if (!_usesSubsectionsViaSymbols && + _definedSymbols.TryGetValue(symbolName, out SymbolDefinition definedSymbol) && definedSymbol.SectionIndex == sectionIndex && relocType is RelocType.IMAGE_REL_BASED_REL32 or RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) { @@ -186,7 +189,7 @@ protected internal virtual void EmitRelocation( case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: var ins = BinaryPrimitives.ReadUInt32LittleEndian(data) & 0xFC000000; - BinaryPrimitives.WriteUInt32LittleEndian(data, (((uint)(int)(definedSymbol.Value - offset) & 0x3FFFFFF) >> 2) | ins); + BinaryPrimitives.WriteUInt32LittleEndian(data, (((uint)(int)(definedSymbol.Value - offset) >> 2) & 0x3FFFFFF) | ins); break; } } @@ -442,6 +445,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Mon, 11 Dec 2023 14:32:02 +0100 Subject: [PATCH 115/144] Fix incorrect addends in COFF --- .../Compiler/ObjectWriter/ObjectWriter.cs | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index d8a7be47767a66..bfbea4cc7b80ae 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -153,14 +153,7 @@ protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, s return new ObjectNodeSection(standardSectionPrefix + section.Name, section.Type, key); } - /// - /// Emits a single relocation into a given section. - /// - /// - /// The relocation is not resolved until is called - /// later when symbol table is already generated. - /// - protected internal virtual void EmitRelocation( + private void EmitOrResolveRelocation( int sectionIndex, long offset, Span data, @@ -169,9 +162,9 @@ protected internal virtual void EmitRelocation( long addend) { if (!_usesSubsectionsViaSymbols && + relocType is RelocType.IMAGE_REL_BASED_REL32 or RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 && _definedSymbols.TryGetValue(symbolName, out SymbolDefinition definedSymbol) && - definedSymbol.SectionIndex == sectionIndex && - relocType is RelocType.IMAGE_REL_BASED_REL32 or RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + definedSymbol.SectionIndex == sectionIndex) { // Resolve the relocation to already defined symbol and write it into data switch (relocType) @@ -180,23 +173,39 @@ protected internal virtual void EmitRelocation( addend += BinaryPrimitives.ReadInt32LittleEndian(data); addend -= 4; BinaryPrimitives.WriteInt32LittleEndian(data, (int)(definedSymbol.Value - offset) + (int)addend); - break; + return; case RelocType.IMAGE_REL_BASED_RELPTR32: addend += BinaryPrimitives.ReadInt32LittleEndian(data); BinaryPrimitives.WriteInt32LittleEndian(data, (int)(definedSymbol.Value - offset) + (int)addend); - break; + return; case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: var ins = BinaryPrimitives.ReadUInt32LittleEndian(data) & 0xFC000000; BinaryPrimitives.WriteUInt32LittleEndian(data, (((uint)(int)(definedSymbol.Value - offset) >> 2) & 0x3FFFFFF) | ins); - break; + return; } } - else - { - _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); - } + + EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); + } + + /// + /// Emits a single relocation into a given section. + /// + /// + /// The relocation is not resolved until is called + /// later when symbol table is already generated. + /// + protected internal virtual void EmitRelocation( + int sectionIndex, + long offset, + Span data, + RelocType relocType, + string symbolName, + long addend) + { + _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } protected bool SectionHasRelocations(int sectionIndex) @@ -427,7 +436,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection Date: Mon, 11 Dec 2023 16:00:46 +0100 Subject: [PATCH 116/144] Fix ELF rela section flags; omit frame symbols for ELF --- .../Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs | 6 +++--- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 1 + .../Compiler/ObjectWriter/ElfObjectWriter.cs | 2 +- .../Compiler/ObjectWriter/MachObjectWriter.cs | 2 ++ .../Compiler/ObjectWriter/UnixObjectWriter.cs | 8 ++++++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 24309da3afe211..45d6f432ca95a2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -141,7 +141,7 @@ private void WriteFde(DwarfFde fde, uint cieOffset) stream.Write(tempBuffer.Slice(0, 4)); BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(stream.Position - cieOffset)); stream.Write(tempBuffer.Slice(0, 4)); - WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName); + WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName, fde.PcStartSymbolOffset); WriteSize(fde.Cie.PointerEncoding, fde.PcLength); if (fde.Cie.FdesHaveAugmentationData) @@ -172,7 +172,7 @@ private uint AddressSize(byte encoding) } } - private void WriteAddress(byte encoding, string symbolName) + private void WriteAddress(byte encoding, string symbolName, long symbolOffset = 0) { if (symbolName != null) { @@ -182,7 +182,7 @@ private void WriteAddress(byte encoding, string symbolName) DW_EH_PE_absptr => RelocType.IMAGE_REL_BASED_DIR64, _ => throw new NotSupportedException() }; - _sectionWriter.EmitSymbolReference(relocationType, symbolName); + _sectionWriter.EmitSymbolReference(relocationType, symbolName, symbolOffset); } else { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index 66551cc20219aa..fd7c3375981fc9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -12,6 +12,7 @@ internal sealed class DwarfFde { public DwarfCie Cie; public string PcStartSymbolName; + public long PcStartSymbolOffset; public ulong PcLength; public string LsdaSymbolName; public string PersonalitySymbolName; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 2ab1ff361503b9..a9c3283c47aa65 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -545,7 +545,7 @@ private void EmitObjectFile(FileStream outputFileStream) { NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), Type = ElfNative.SHT_RELA, - Flags = section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u, + Flags = (section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u) | ElfNative.SHF_INFO_LINK, Address = 0u, Offset = section.SectionHeader.Offset + section.SectionHeader.Size, Size = (ulong)section.RelocationStream.Length, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 815077506b7d83..ea0cc04a1031f3 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -783,6 +783,8 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt return encoding != _compactUnwindDwarfCode; } + protected override bool UseFrameNames => true; + private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); private struct MachHeader64 diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 84cf60b87f8927..68d594ef256fd2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -61,6 +61,8 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa protected virtual bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) => false; + protected virtual bool UseFrameNames => false; + protected override void EmitUnwindInfo( SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo, @@ -69,6 +71,7 @@ protected override void EmitUnwindInfo( if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) { + bool useFrameNames = UseFrameNames; SectionWriter lsdaSectionWriter; Span tempBuffer = stackalloc byte[4]; @@ -95,7 +98,7 @@ protected override void EmitUnwindInfo( string framSymbolName = $"_fram{i}{currentSymbolName}"; lsdaSectionWriter.EmitSymbolDefinition(lsdaSymbolName); - if (start != 0) + if (start != 0 && useFrameNames) { sectionWriter.EmitSymbolDefinition(framSymbolName, start); } @@ -141,13 +144,14 @@ protected override void EmitUnwindInfo( } } - string startSymbolName = start != 0 ? framSymbolName : currentSymbolName; + string startSymbolName = useFrameNames && start != 0 ? framSymbolName : currentSymbolName; ulong length = (ulong)(end - start); if (!EmitCompactUnwinding(startSymbolName, length, lsdaSymbolName, blob)) { var fde = new DwarfFde(_dwarfCie, DwarfFde.CfiCodeToInstructions(_dwarfCie, blob)) { PcStartSymbolName = startSymbolName, + PcStartSymbolOffset = useFrameNames ? 0 : start, PcLength = (ulong)(end - start), LsdaSymbolName = lsdaSymbolName, }; From 96635dae6a83a91e8b3e8a1a6b154ec8dc37080d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Dec 2023 20:37:14 +0100 Subject: [PATCH 117/144] Split the writing and reading part of section data --- .../CodeView/CodeViewFileTableBuilder.cs | 21 +- .../CodeView/CodeViewSymbolsBuilder.cs | 6 +- .../CodeView/CodeViewTypesBuilder.cs | 22 +- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 16 +- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 18 +- .../ObjectWriter/Dwarf/DwarfBuilder.cs | 28 +-- .../ObjectWriter/Dwarf/DwarfEhFrame.cs | 50 ++-- .../ObjectWriter/Dwarf/DwarfInfoWriter.cs | 40 ++-- .../Dwarf/DwarfLineProgramTableWriter.cs | 40 ++-- .../Dwarf/DwarfLineSequenceWriter.cs | 49 ++-- .../Compiler/ObjectWriter/ObjectWriter.cs | 22 +- .../ObjectWriter/ObjectWriterStream.cs | 217 ------------------ .../Compiler/ObjectWriter/SectionData.cs | 176 ++++++++++++++ .../Compiler/ObjectWriter/SectionWriter.cs | 66 +++++- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 20 +- .../ILCompiler.Compiler.csproj | 2 +- 16 files changed, 391 insertions(+), 402 deletions(-) delete mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriterStream.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs index af84e8743fde89..234374e1cc1bfc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs @@ -54,21 +54,14 @@ public uint GetFileIndex(string fileName) } } - public void Write(Stream sectionStream) + public void Write(SectionWriter sectionWriter) { - Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; - - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)DebugSymbolsSubsectionType.FileChecksums); - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), (uint)_fileTableWriter.Length); - sectionStream.Write(subsectionHeader); - _fileTableWriter.Position = 0; - _fileTableWriter.CopyTo(sectionStream); - - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)DebugSymbolsSubsectionType.StringTable); - BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), (uint)_stringTableWriter.Length); - sectionStream.Write(subsectionHeader); - _stringTableWriter.Position = 0; - _stringTableWriter.CopyTo(sectionStream); + sectionWriter.WriteLittleEndian((uint)DebugSymbolsSubsectionType.FileChecksums); + sectionWriter.WriteLittleEndian((uint)_fileTableWriter.Length); + sectionWriter.EmitData(_fileTableWriter.GetBuffer().AsMemory(0, (int)_fileTableWriter.Length)); + sectionWriter.WriteLittleEndian((uint)DebugSymbolsSubsectionType.StringTable); + sectionWriter.WriteLittleEndian((uint)_stringTableWriter.Length); + sectionWriter.EmitData(_stringTableWriter.GetBuffer().AsMemory(0, (int)_stringTableWriter.Length)); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs index e65be3456153eb..5f2350d460c782 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs @@ -51,7 +51,7 @@ public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, SectionWrit // Write CodeView version header Span versionBuffer = stackalloc byte[sizeof(uint)]; BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); - sectionWriter.Stream.Write(versionBuffer); + sectionWriter.Write(versionBuffer); } // Maps an ICorDebugInfo register number to the corresponding CodeView @@ -310,7 +310,7 @@ public void Dispose() Span subsectionHeader = stackalloc byte[sizeof(uint) + sizeof(uint)]; BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader, (uint)_kind); BinaryPrimitives.WriteUInt32LittleEndian(subsectionHeader.Slice(4), _size); - _sectionWriter.Stream.Write(subsectionHeader); + _sectionWriter.Write(subsectionHeader); foreach (var (offset, relocType, symbolName) in _relocations) { @@ -324,7 +324,7 @@ public void Dispose() foreach (byte[] data in _data) { - _sectionWriter.Stream.Write(data); + _sectionWriter.Write(data); } _sectionWriter.EmitAlignment(4); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs index a0ca102b167521..c8bd37545472cc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs @@ -39,7 +39,7 @@ namespace ILCompiler.ObjectWriter internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter { private NameMangler _nameMangler; - private Stream _outputStream; + private SectionWriter _sectionWriter; private int _targetPointerSize; private uint _classVTableTypeIndex; @@ -50,10 +50,10 @@ internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter public IList<(string, uint)> UserDefinedTypes => _userDefinedTypes; - public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, Stream outputStream) + public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, SectionWriter sectionWriter) { _nameMangler = nameMangler; - _outputStream = outputStream; + _sectionWriter = sectionWriter; _targetPointerSize = targetArchitecture switch { TargetArchitecture.ARM => 4, @@ -64,7 +64,7 @@ public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetAr // Write CodeView version header Span versionBuffer = stackalloc byte[sizeof(uint)]; BinaryPrimitives.WriteUInt32LittleEndian(versionBuffer, 4); - _outputStream.Write(versionBuffer); + _sectionWriter.Write(versionBuffer); // We pretend that the MethodTable pointer in System.Object is VTable shape. // We use the same "Vtable" for all types because the vtable shape debug @@ -418,9 +418,9 @@ public void Dispose() Debug.Assert(length <= ushort.MaxValue); Span lengthBuffer = stackalloc byte[sizeof(ushort)]; BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); - _debugTypesBuilder._outputStream.Write(lengthBuffer); - _debugTypesBuilder._outputStream.Write(_bufferWriter.WrittenSpan); - _debugTypesBuilder._outputStream.Write(stackalloc byte[padding]); + _debugTypesBuilder._sectionWriter.Write(lengthBuffer); + _debugTypesBuilder._sectionWriter.Write(_bufferWriter.WrittenSpan); + _debugTypesBuilder._sectionWriter.Write(stackalloc byte[padding]); _bufferWriter.Clear(); } @@ -517,11 +517,9 @@ public void EndListEntry() // Flush the current record up to _lastListMemberStart and write LF_INDEX to reference it. int length = sizeof(ushort) + _lastListMemberStart; int padding = ((length + 3) & ~3) - length; - Span lengthBuffer = stackalloc byte[sizeof(ushort)]; - BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); - _debugTypesBuilder._outputStream.Write(lengthBuffer); - _debugTypesBuilder._outputStream.Write(_bufferWriter.WrittenSpan.Slice(0, _lastListMemberStart)); - _debugTypesBuilder._outputStream.Write(stackalloc byte[padding]); + _debugTypesBuilder._sectionWriter.WriteLittleEndian((ushort)(length + padding - sizeof(ushort))); + _debugTypesBuilder._sectionWriter.Write(_bufferWriter.WrittenSpan.Slice(0, _lastListMemberStart)); + _debugTypesBuilder._sectionWriter.Write(stackalloc byte[padding]); byte[] overflow = _bufferWriter.WrittenSpan.Slice(_lastListMemberStart).ToArray(); _bufferWriter.Clear(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index b1f8052bf4f8fc..e96b0736ed7452 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -274,11 +274,9 @@ protected override void EmitSymbolTable( // Create section with control flow guard symbols SectionWriter gfidsSectionWriter = GetOrCreateSection(GfidsSection); - Span tempBuffer = stackalloc byte[4]; foreach (var symbolName in _referencedMethods) { - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, _symbolNameToIndex[symbolName]); - gfidsSectionWriter.Stream.Write(tempBuffer); + gfidsSectionWriter.WriteLittleEndian(_symbolNameToIndex[symbolName]); } // Emit the feat.00 symbol that controls various linker behaviors @@ -436,13 +434,13 @@ protected override void EmitUnwindInfo( xdataSectionWriter.EmitSymbolDefinition(unwindSymbolName); // Emit UNWIND_INFO - xdataSectionWriter.Stream.Write(blob); + xdataSectionWriter.Write(blob); FrameInfoFlags flags = frameInfo.Flags; if (i != 0) { - xdataSectionWriter.Stream.WriteByte((byte)flags); + xdataSectionWriter.WriteByte((byte)flags); } else { @@ -452,7 +450,7 @@ protected override void EmitUnwindInfo( flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - xdataSectionWriter.Stream.WriteByte((byte)flags); + xdataSectionWriter.WriteByte((byte)flags); if (associatedDataNode != null) { @@ -468,7 +466,7 @@ protected override void EmitUnwindInfo( if (nodeWithCodeInfo.GCInfo != null) { - xdataSectionWriter.Stream.Write(nodeWithCodeInfo.GCInfo); + xdataSectionWriter.Write(nodeWithCodeInfo.GCInfo); } } @@ -614,7 +612,7 @@ protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() _debugTypesSectionWriter.EmitAlignment(4); _debugTypesBuilder = new CodeViewTypesBuilder( _nodeFactory.NameMangler, _nodeFactory.Target.Architecture, - _debugTypesSectionWriter.Stream); + _debugTypesSectionWriter); return _debugTypesBuilder; } @@ -665,7 +663,7 @@ protected override void EmitDebugFunctionInfo( protected override void EmitDebugSections(IDictionary definedSymbols) { _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); - _debugFileTableBuilder.Write(_debugSymbolSectionWriter.Stream); + _debugFileTableBuilder.Write(_debugSymbolSectionWriter); } private sealed class CoffHeader diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index cafdbf5acc9d59..f5c53d577aab1c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -22,32 +22,32 @@ public DwarfAbbrev(ushort[] definition) public int AbbreviationCode { get; set; } - public void Write(ObjectWriterStream stream, int targetPointerSize) + public void Write(SectionWriter writer, int targetPointerSize) { - stream.WriteULEB128((ulong)AbbreviationCode); - stream.WriteULEB128(Tag); - stream.WriteULEB128(HasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no); + writer.WriteULEB128((ulong)AbbreviationCode); + writer.WriteULEB128(Tag); + writer.WriteULEB128(HasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no); for (int i = 2; i < _definition.Length; i++) { // Attribute - stream.WriteULEB128(_definition[i++]); + writer.WriteULEB128(_definition[i++]); // Form if (_definition[i] != DW_FORM_size) { - stream.WriteULEB128(_definition[i]); + writer.WriteULEB128(_definition[i]); } else if (targetPointerSize == 8) { - stream.WriteULEB128(DW_FORM_data8); + writer.WriteULEB128(DW_FORM_data8); } else if (targetPointerSize == 4) { - stream.WriteULEB128(DW_FORM_data4); + writer.WriteULEB128(DW_FORM_data4); } } - stream.Write([0, 0]); + writer.Write([0, 0]); } public static DwarfAbbrev CompileUnit = new([ diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs index f2048a309ee48e..25da10934675c1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs @@ -122,13 +122,13 @@ public void WriteInfoTable( { // Length byte[] sizeBuffer = new byte[sizeof(uint)]; - infoSectionWriter.Stream.AppendData(sizeBuffer); + infoSectionWriter.EmitData(sizeBuffer); // Version - infoSectionWriter.Stream.WriteLittleEndian((ushort)(_useDwarf5 ? 5u : 4u)); + infoSectionWriter.WriteLittleEndian((ushort)(_useDwarf5 ? 5u : 4u)); if (_useDwarf5) { // Unit type, Address Size - infoSectionWriter.Stream.Write([DW_UT_compile, _targetPointerSize]); + infoSectionWriter.Write([DW_UT_compile, _targetPointerSize]); // Abbrev offset infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); } @@ -137,12 +137,12 @@ public void WriteInfoTable( // Abbrev offset infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_abbrev", 0); // Address Size - infoSectionWriter.Stream.Write([_targetPointerSize]); + infoSectionWriter.Write([_targetPointerSize]); } using (DwarfInfoWriter dwarfInfoWriter = new( infoSectionWriter, - stringSectionWriter.Stream, + stringSectionWriter, abbrevSectionWriter, locSectionWriter, rangeSectionWriter, @@ -199,10 +199,10 @@ public void WriteInfoTable( } // End of compile unit - infoSectionWriter.Stream.Write([(byte)0]); + infoSectionWriter.WriteByte(0); // Update the size - BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(infoSectionWriter.Stream.Length - sizeof(uint))); + BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(infoSectionWriter.Position - sizeof(uint))); } private void WriteLineInfoTable(SectionWriter lineSectionWriter) @@ -225,13 +225,13 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) { // Length var sizeBuffer = new byte[sizeof(uint)]; - arangeSectionWriter.Stream.AppendData(sizeBuffer); + arangeSectionWriter.EmitData(sizeBuffer); // Version - arangeSectionWriter.Stream.WriteLittleEndian(2); + arangeSectionWriter.WriteLittleEndian(2); // Debug Info Offset arangeSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_info", 0); // Address size, Segment selector size - arangeSectionWriter.Stream.Write([_targetPointerSize, 0]); + arangeSectionWriter.Write([_targetPointerSize, 0]); // Ranges have to be aligned arangeSectionWriter.EmitAlignment(_targetPointerSize * 2); foreach (var sectionInfo in _sections) @@ -239,14 +239,14 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) arangeSectionWriter.EmitSymbolReference(_codeRelocType, sectionInfo.SectionSymbolName, 0); switch (_targetPointerSize) { - case 8: arangeSectionWriter.Stream.WriteLittleEndian(sectionInfo.Size); break; - case 4: arangeSectionWriter.Stream.WriteLittleEndian((uint)sectionInfo.Size); break; + case 8: arangeSectionWriter.WriteLittleEndian(sectionInfo.Size); break; + case 4: arangeSectionWriter.WriteLittleEndian((uint)sectionInfo.Size); break; default: throw new NotSupportedException(); } } - arangeSectionWriter.Stream.Write(stackalloc byte[_targetPointerSize * 2]); + arangeSectionWriter.Write(stackalloc byte[_targetPointerSize * 2]); // Update the size - BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(arangeSectionWriter.Stream.Length - sizeof(uint))); + BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(arangeSectionWriter.Position - sizeof(uint))); } public uint GetPrimitiveTypeIndex(TypeDesc type) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 45d6f432ca95a2..0c9b7396057f31 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -27,7 +27,7 @@ public DwarfEhFrame(SectionWriter sectionWriter, bool is64Bit) public void AddCie(DwarfCie cie) { - _cieOffset.Add(cie, (uint)_sectionWriter.Stream.Position); + _cieOffset.Add(cie, (uint)_sectionWriter.Position); WriteCie(cie); } @@ -49,7 +49,6 @@ private void WriteCie(DwarfCie cie) Utf8StringBuilder augmentationString = new Utf8StringBuilder(); uint augmentationLength = 0; Span tempBuffer = stackalloc byte[8]; - var stream = _sectionWriter.Stream; if (cie.FdesHaveAugmentationData) { @@ -88,39 +87,38 @@ private void WriteCie(DwarfCie cie) uint padding = ((length + 7u) & ~7u) - length; BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - stream.Write(tempBuffer); + _sectionWriter.Write(tempBuffer); - stream.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version - stream.Write(augmentationString.UnderlyingArray); + _sectionWriter.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version + _sectionWriter.Write(augmentationString.UnderlyingArray); - stream.WriteULEB128(cie.CodeAlignFactor); - stream.WriteSLEB128(cie.DataAlignFactor); - stream.WriteULEB128(cie.ReturnAddressRegister); + _sectionWriter.WriteULEB128(cie.CodeAlignFactor); + _sectionWriter.WriteSLEB128(cie.DataAlignFactor); + _sectionWriter.WriteULEB128(cie.ReturnAddressRegister); - stream.WriteULEB128(augmentationLength); + _sectionWriter.WriteULEB128(augmentationLength); if (cie.PersonalitySymbolName != null) { - stream.WriteByte(cie.PersonalityEncoding); + _sectionWriter.WriteByte(cie.PersonalityEncoding); WriteAddress(cie.PersonalityEncoding, cie.PersonalitySymbolName); } if (cie.LsdaEncoding != 0) { - stream.WriteByte(cie.LsdaEncoding); + _sectionWriter.WriteByte(cie.LsdaEncoding); } if (cie.PointerEncoding != 0) { - stream.WriteByte(cie.PointerEncoding); + _sectionWriter.WriteByte(cie.PointerEncoding); } - stream.Write(cie.Instructions); + _sectionWriter.Write(cie.Instructions); - stream.Write(stackalloc byte[(int)padding]); + _sectionWriter.Write(stackalloc byte[(int)padding]); } private void WriteFde(DwarfFde fde, uint cieOffset) { Span tempBuffer = stackalloc byte[8]; - var stream = _sectionWriter.Stream; uint augmentationLength = fde.Cie.FdesHaveAugmentationData ? @@ -138,15 +136,15 @@ private void WriteFde(DwarfFde fde, uint cieOffset) uint padding = ((length + 7u) & ~7u) - length; BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - stream.Write(tempBuffer.Slice(0, 4)); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(stream.Position - cieOffset)); - stream.Write(tempBuffer.Slice(0, 4)); + _sectionWriter.Write(tempBuffer.Slice(0, 4)); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(_sectionWriter.Position - cieOffset)); + _sectionWriter.Write(tempBuffer.Slice(0, 4)); WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName, fde.PcStartSymbolOffset); WriteSize(fde.Cie.PointerEncoding, fde.PcLength); if (fde.Cie.FdesHaveAugmentationData) { - stream.WriteByte((byte)(augmentationLength - 1)); + _sectionWriter.WriteByte((byte)(augmentationLength - 1)); if (fde.Cie.PersonalityEncoding != 0) { WriteAddress(fde.Cie.PersonalityEncoding, fde.PersonalitySymbolName); @@ -157,8 +155,8 @@ private void WriteFde(DwarfFde fde, uint cieOffset) } } - stream.Write(fde.Instructions); - stream.Write(stackalloc byte[(int)padding]); + _sectionWriter.Write(fde.Instructions); + _sectionWriter.Write(stackalloc byte[(int)padding]); } private uint AddressSize(byte encoding) @@ -187,22 +185,20 @@ private void WriteAddress(byte encoding, string symbolName, long symbolOffset = else { Span address = stackalloc byte[(int)AddressSize(encoding)]; - _sectionWriter.Stream.Write(address); + _sectionWriter.Write(address); } } private void WriteSize(byte encoding, ulong size) { - Span buffer = stackalloc byte[(int)AddressSize(encoding)]; - if (buffer.Length == 4) + if (AddressSize(encoding) == 4) { - BinaryPrimitives.WriteUInt32LittleEndian(buffer, (uint)size); + _sectionWriter.WriteLittleEndian((uint)size); } else { - BinaryPrimitives.WriteUInt64LittleEndian(buffer, size); + _sectionWriter.WriteLittleEndian(size); } - _sectionWriter.Stream.Write(buffer); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index e03389e5a85fb9..a2bda448429532 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -15,7 +15,7 @@ internal sealed class DwarfInfoWriter : IDisposable private sealed record InfoReference(uint TypeIndex, int Position, byte[] Data); private readonly SectionWriter _infoSectionWriter; - private readonly ObjectWriterStream _stringTableWriter; + private readonly SectionWriter _stringTableWriter; private readonly SectionWriter _abbrevSectionWriter; private readonly SectionWriter _locSectionWriter; private readonly SectionWriter _rangeSectionWriter; @@ -28,7 +28,7 @@ private sealed record InfoReference(uint TypeIndex, int Position, byte[] Data); public DwarfInfoWriter( SectionWriter infoSectionWriter, - ObjectWriterStream stringTableWriter, + SectionWriter stringTableWriter, SectionWriter abbrevSectionWriter, SectionWriter locSectionWriter, SectionWriter rangeSectionWriter, @@ -47,7 +47,7 @@ public DwarfInfoWriter( public TargetArchitecture TargetArchitecture => _builder.TargetArchitecture; public int FrameRegister => _builder.FrameRegister; public byte TargetPointerSize => _builder.TargetPointerSize; - public long Position => _infoSectionWriter.Stream.Position; + public long Position => _infoSectionWriter.Position; public void WriteStartDIE(DwarfAbbrev abbrev) { @@ -76,12 +76,12 @@ public void WriteEndDIE() } } - public void Write(ReadOnlySpan buffer) => _infoSectionWriter.Stream.Write(buffer); - public void WriteULEB128(ulong value) => _infoSectionWriter.Stream.WriteULEB128(value); - public void WriteUInt8(byte value) => _infoSectionWriter.Stream.WriteLittleEndian(value); - public void WriteUInt16(ushort value) => _infoSectionWriter.Stream.WriteLittleEndian(value); - public void WriteUInt32(uint value) => _infoSectionWriter.Stream.WriteLittleEndian(value); - public void WriteUInt64(ulong value) => _infoSectionWriter.Stream.WriteLittleEndian(value); + public void Write(ReadOnlySpan buffer) => _infoSectionWriter.Write(buffer); + public void WriteULEB128(ulong value) => _infoSectionWriter.WriteULEB128(value); + public void WriteUInt8(byte value) => _infoSectionWriter.WriteLittleEndian(value); + public void WriteUInt16(ushort value) => _infoSectionWriter.WriteLittleEndian(value); + public void WriteUInt32(uint value) => _infoSectionWriter.WriteLittleEndian(value); + public void WriteUInt64(ulong value) => _infoSectionWriter.WriteLittleEndian(value); public void WriteAddressSize(ulong value) { @@ -116,8 +116,8 @@ public void WriteInfoReference(uint typeIndex) { // Late bound forward reference var data = new byte[sizeof(uint)]; - _lateBoundReferences.Add(new InfoReference(typeIndex, (int)_infoSectionWriter.Stream.Position, data)); - _infoSectionWriter.Stream.AppendData(data); + _lateBoundReferences.Add(new InfoReference(typeIndex, (int)_infoSectionWriter.Position, data)); + _infoSectionWriter.EmitData(data); } else { @@ -152,7 +152,7 @@ public void WriteExpression(DwarfExpressionBuilder expressionBuilder) public void WriteStartLocationList() { - long offset = _locSectionWriter.Stream.Position; + long offset = _locSectionWriter.Position; Debug.Assert(offset < uint.MaxValue); _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_loc", (int)offset); } @@ -162,18 +162,18 @@ public void WriteLocationListExpression(string methodName, long startOffset, lon _ = expressionBuilder; _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, startOffset); _locSectionWriter.EmitSymbolReference(_codeRelocType, methodName, endOffset); - _locSectionWriter.Stream.WriteLittleEndian((ushort)_expressionBufferWriter.WrittenCount); - _locSectionWriter.Stream.Write(_expressionBufferWriter.WrittenSpan); + _locSectionWriter.WriteLittleEndian((ushort)_expressionBufferWriter.WrittenCount); + _locSectionWriter.Write(_expressionBufferWriter.WrittenSpan); } public void WriteEndLocationList() { - _locSectionWriter.Stream.Write(stackalloc byte[TargetPointerSize * 2]); + _locSectionWriter.Write(stackalloc byte[TargetPointerSize * 2]); } public void WriteStartRangeList() { - long offset = _rangeSectionWriter.Stream.Position; + long offset = _rangeSectionWriter.Position; Debug.Assert(offset < uint.MaxValue); _infoSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_HIGHLOW, ".debug_ranges", offset); } @@ -186,7 +186,7 @@ public void WriteRangeListEntry(string symbolName, long startOffset, long endOff public void WriteEndRangeList() { - _rangeSectionWriter.Stream.Write(stackalloc byte[TargetPointerSize * 2]); + _rangeSectionWriter.Write(stackalloc byte[TargetPointerSize * 2]); } public void Dispose() @@ -194,7 +194,7 @@ public void Dispose() // Debug.Assert(_dieStack.Count == 0); // Flush late bound forward references - int streamOffset = (int)_infoSectionWriter.Stream.Position; + int streamOffset = (int)_infoSectionWriter.Position; foreach (var lateBoundReference in _lateBoundReferences) { uint offset = _builder.ResolveOffset(lateBoundReference.TypeIndex); @@ -210,9 +210,9 @@ public void Dispose() // Write abbreviation section foreach (var abbrev in _usedAbbrevs) { - abbrev.Write(_abbrevSectionWriter.Stream, TargetPointerSize); + abbrev.Write(_abbrevSectionWriter, TargetPointerSize); } - _abbrevSectionWriter.Stream.Write([0, 0]); + _abbrevSectionWriter.Write([0, 0]); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs index 4acbb6a10cde40..d185bad1db80aa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineProgramTableWriter.cs @@ -51,27 +51,27 @@ public DwarfLineProgramTableWriter( // Length _sizeBuffer = new byte[sizeof(uint)]; - lineSectionWriter.Stream.AppendData(_sizeBuffer); + lineSectionWriter.EmitData(_sizeBuffer); // Version - lineSectionWriter.Stream.WriteLittleEndian(4); + lineSectionWriter.WriteLittleEndian(4); // Header Length var headerSizeBuffer = new byte[sizeof(uint)]; - lineSectionWriter.Stream.AppendData(headerSizeBuffer); - var headerStart = lineSectionWriter.Stream.Position; - lineSectionWriter.Stream.WriteByte(minimumInstructionLength); - lineSectionWriter.Stream.WriteByte(MaximumOperationsPerInstruction); + lineSectionWriter.EmitData(headerSizeBuffer); + var headerStart = lineSectionWriter.Position; + lineSectionWriter.WriteByte(minimumInstructionLength); + lineSectionWriter.WriteByte(MaximumOperationsPerInstruction); // default_is_stmt - lineSectionWriter.Stream.WriteByte(1); + lineSectionWriter.WriteByte(1); // line_base - lineSectionWriter.Stream.WriteByte(unchecked((byte)LineBase)); + lineSectionWriter.WriteByte(unchecked((byte)LineBase)); // line_range - lineSectionWriter.Stream.WriteByte(LineRange); + lineSectionWriter.WriteByte(LineRange); // opcode_base - lineSectionWriter.Stream.WriteByte(OpCodeBase); + lineSectionWriter.WriteByte(OpCodeBase); // standard_opcode_lengths foreach (var opcodeLength in StandardOpCodeLengths) { - lineSectionWriter.Stream.WriteULEB128(opcodeLength); + lineSectionWriter.WriteULEB128(opcodeLength); } // Directory names @@ -82,13 +82,13 @@ public DwarfLineProgramTableWriter( !string.IsNullOrEmpty(directoryName) && !_directoryNameToIndex.ContainsKey(directoryName)) { - lineSectionWriter.Stream.WriteUtf8String(directoryName); + lineSectionWriter.WriteUtf8String(directoryName); _directoryNameToIndex.Add(directoryName, directoryIndex); directoryIndex++; } } // Terminate directory list (empty string) - lineSectionWriter.Stream.WriteByte(0); + lineSectionWriter.WriteByte(0); // File names uint fileNameIndex = 1; @@ -96,25 +96,25 @@ public DwarfLineProgramTableWriter( { directoryIndex = fileName.Directory is string directoryName && !string.IsNullOrEmpty(directoryName) ? _directoryNameToIndex[directoryName] : 0; - lineSectionWriter.Stream.WriteUtf8String(fileName.Name); - lineSectionWriter.Stream.WriteULEB128(directoryIndex); - lineSectionWriter.Stream.WriteULEB128(fileName.Time); - lineSectionWriter.Stream.WriteULEB128(fileName.Size); + lineSectionWriter.WriteUtf8String(fileName.Name); + lineSectionWriter.WriteULEB128(directoryIndex); + lineSectionWriter.WriteULEB128(fileName.Time); + lineSectionWriter.WriteULEB128(fileName.Size); _fileNameToIndex[fileName] = fileNameIndex; fileNameIndex++; } // Terminate file name list (empty string) - lineSectionWriter.Stream.WriteByte(0); + lineSectionWriter.WriteByte(0); // Update header size - BinaryPrimitives.WriteInt32LittleEndian(headerSizeBuffer, (int)(lineSectionWriter.Stream.Position - headerStart)); + BinaryPrimitives.WriteInt32LittleEndian(headerSizeBuffer, (int)(lineSectionWriter.Position - headerStart)); } public void Dispose() { // Update size - BinaryPrimitives.WriteInt32LittleEndian(_sizeBuffer, (int)(_lineSectionWriter.Stream.Position - sizeof(uint))); + BinaryPrimitives.WriteInt32LittleEndian(_sizeBuffer, (int)(_lineSectionWriter.Position - sizeof(uint))); } public void WriteLineSequence(DwarfLineSequenceWriter lineSequenceWriter) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs index 1b8d85c0b9da30..2fa8650b0afa89 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfLineSequenceWriter.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Buffers; using System.Diagnostics; using ILCompiler.DependencyAnalysis; using static ILCompiler.ObjectWriter.DwarfNative; @@ -9,7 +10,7 @@ namespace ILCompiler.ObjectWriter { internal sealed class DwarfLineSequenceWriter { - private readonly ObjectWriterStream _writer; + private readonly ArrayBufferWriter _writer; private readonly string _sectionName; private readonly byte _minimumInstructionLength; private readonly uint _maxDeltaAddressPerSpecialCode; @@ -22,7 +23,7 @@ internal sealed class DwarfLineSequenceWriter public DwarfLineSequenceWriter(string sectionName, byte minimumInstructionLength) { - _writer = new ObjectWriterStream(); + _writer = new ArrayBufferWriter(); _sectionName = sectionName; // Calculations hard code this @@ -33,20 +34,30 @@ public DwarfLineSequenceWriter(string sectionName, byte minimumInstructionLength _minimumInstructionLength = minimumInstructionLength; } + private void WriteByte(byte value) + { + _writer.GetSpan(1)[0] = value; + _writer.Advance(1); + } + + private void WriteULEB128(ulong value) => DwarfHelper.WriteULEB128(_writer, value); + + private void WriteSLEB128(long value) => DwarfHelper.WriteSLEB128(_writer, value); + public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePoint sequencePoint) { if (_column != sequencePoint.ColNumber) { _column = sequencePoint.ColNumber; - _writer.WriteByte(DW_LNS_set_column); - _writer.WriteULEB128((uint)_column); + WriteByte(DW_LNS_set_column); + WriteULEB128((uint)_column); } if (_fileNameIndex != fileNameIndex) { _fileNameIndex = fileNameIndex; - _writer.WriteByte(DW_LNS_set_file); - _writer.WriteULEB128((uint)_fileNameIndex); + WriteByte(DW_LNS_set_file); + WriteULEB128((uint)_fileNameIndex); } int deltaLine = sequencePoint.LineNumber - _line; @@ -58,8 +69,8 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo if (!canEncodeLineInSpecialCode) { - _writer.WriteByte(DW_LNS_advance_line); - _writer.WriteSLEB128(deltaLine); + WriteByte(DW_LNS_advance_line); + WriteSLEB128(deltaLine); deltaLine = 0; } } @@ -68,7 +79,7 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo if (deltaAddress > _maxDeltaAddressPerSpecialCode && deltaAddress <= (2U * _maxDeltaAddressPerSpecialCode)) { deltaAddress -= _maxDeltaAddressPerSpecialCode; - _writer.WriteByte(DW_LNS_const_add_pc); + WriteByte(DW_LNS_const_add_pc); } if (deltaAddress > 0 || deltaLine != 0) @@ -79,20 +90,20 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo DwarfLineProgramTableWriter.OpCodeBase + (ulong)(deltaLine - DwarfLineProgramTableWriter.LineBase); if (opcode > 255) { - _writer.WriteByte(DW_LNS_advance_pc); - _writer.WriteULEB128((uint)operationAdvance); + WriteByte(DW_LNS_advance_pc); + WriteULEB128((uint)operationAdvance); if (deltaLine != 0) { - _writer.WriteByte((byte)(DwarfLineProgramTableWriter.OpCodeBase + deltaLine - DwarfLineProgramTableWriter.LineBase)); + WriteByte((byte)(DwarfLineProgramTableWriter.OpCodeBase + deltaLine - DwarfLineProgramTableWriter.LineBase)); } else { - _writer.WriteByte(DW_LNS_copy); + WriteByte(DW_LNS_copy); } } else { - _writer.WriteByte((byte)opcode); + WriteByte((byte)opcode); } } @@ -103,15 +114,11 @@ public void EmitLineInfo(int fileNameIndex, long methodAddress, NativeSequencePo public void Write(SectionWriter lineSection, byte targetPointerSize, RelocType codeRelocType) { // Set the address to beginning of section - lineSection.Stream.Write([0, (byte)(1u + targetPointerSize), DW_LNE_set_address]); + lineSection.Write([0, (byte)(1u + targetPointerSize), DW_LNE_set_address]); lineSection.EmitSymbolReference(codeRelocType, _sectionName, 0); - // TODO: Optimize - _writer.Position = 0; - _writer.CopyTo(lineSection.Stream); - - // FIXME: Double row? - lineSection.Stream.Write([0, 1, DW_LNE_end_sequence]); + lineSection.Write(_writer.WrittenSpan); + lineSection.Write([0, 1, DW_LNE_end_sequence]); } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index bfbea4cc7b80ae..a40a94bcbef52e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -32,7 +32,7 @@ protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Da // Standard sections private readonly Dictionary _sectionNameToSectionIndex = new(StringComparer.Ordinal); - private readonly List _sectionIndexToStream = new(); + private readonly List _sectionIndexToData = new(); private readonly List> _sectionIndexToRelocations = new(); // Symbol table @@ -60,10 +60,10 @@ protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) public void Dispose() { // Close all the streams - foreach (ObjectWriterStream sectionStream in _sectionIndexToStream) + /*foreach (ObjectWriterStream sectionStream in _sectionIndexToStream) { sectionStream.Close(); - } + }*/ } protected abstract void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream); @@ -87,14 +87,14 @@ public void Dispose() protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string comdatName = null, string symbolName = null) { int sectionIndex; - ObjectWriterStream sectionStream; + SectionData sectionData; if (comdatName is not null || !_sectionNameToSectionIndex.TryGetValue(section.Name, out sectionIndex)) { - sectionStream = new ObjectWriterStream(section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); - sectionIndex = _sectionIndexToStream.Count; - CreateSection(section, comdatName, symbolName, sectionStream); - _sectionIndexToStream.Add(sectionStream); + sectionData = new SectionData(section.Type == SectionType.Executable ? _insPaddingByte : (byte)0); + sectionIndex = _sectionIndexToData.Count; + CreateSection(section, comdatName, symbolName, sectionData.GetReadStream()); + _sectionIndexToData.Add(sectionData); _sectionIndexToRelocations.Add(new()); if (comdatName is null) { @@ -103,13 +103,13 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string com } else { - sectionStream = _sectionIndexToStream[sectionIndex]; + sectionData = _sectionIndexToData[sectionIndex]; } return new SectionWriter( this, sectionIndex, - sectionStream); + sectionData); } protected bool ShouldShareSymbol(ObjectNode node) @@ -414,7 +414,7 @@ protected void EmitObject(string objectFilePath, IReadOnlyCollection - /// Optimized append-only stream for writing sections. - /// - /// - /// Implements a stream of chained buffers. It supports appending existing - /// read-only buffers without copying. - /// - public sealed class ObjectWriterStream : Stream - { - private readonly ArrayBufferWriter _appendBuffer = new(); - private readonly List> _buffers = new(); - private long _length; - private int _bufferIndex; - private int _bufferPosition; - private long _position; - private readonly byte[] _padding = new byte[16]; - - public override bool CanRead => true; - - public override bool CanSeek => true; - - public override bool CanWrite => true; - - public override long Length => _length + _appendBuffer.WrittenCount; - - public override long Position - { - get => _position + _appendBuffer.WrittenCount; - set - { - // Flush any non-appended data - FlushAppendBuffer(); - - // Seek to the correct buffer - _position = 0; - _bufferIndex = 0; - _bufferPosition = 0; - while (_position < value && _bufferIndex < _buffers.Count) - { - if (_buffers[_bufferIndex].Length < value - _position) - { - _position += _buffers[_bufferIndex].Length; - _bufferIndex++; - } - else - { - _bufferPosition = (int)(value - _position); - _position = value; - break; - } - } - } - } - - public ObjectWriterStream(byte paddingByte = 0) - { - _padding.AsSpan().Fill(paddingByte); - } - - public override void Flush() - { - FlushAppendBuffer(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - return Read(buffer.AsSpan(offset, count)); - } - - public override int Read(Span buffer) - { - int bytesRead = 0; - - // _bufferIndex and _bufferPosition is only valid after seeking when - // _position < _length - while (_position < _length && _bufferIndex < _buffers.Count) - { - ReadOnlySpan currentBuffer = _buffers[_bufferIndex].Span.Slice(_bufferPosition); - - if (currentBuffer.Length >= buffer.Length) - { - currentBuffer.Slice(0, buffer.Length).CopyTo(buffer); - bytesRead += buffer.Length; - _position += buffer.Length; - _bufferPosition += buffer.Length; - return bytesRead; - } - - currentBuffer.CopyTo(buffer); - buffer = buffer.Slice(currentBuffer.Length); - bytesRead += currentBuffer.Length; - _position += currentBuffer.Length; - _bufferIndex++; - _bufferPosition = 0; - } - - return bytesRead; - } - - public override long Seek(long offset, SeekOrigin origin) - { - Position = origin switch - { - SeekOrigin.End => Length + offset, - SeekOrigin.Current => Position + offset, - SeekOrigin.Begin => offset, - _ => throw new ArgumentOutOfRangeException(nameof(origin)) - }; - return Position; - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override void Write(byte[] buffer, int offset, int count) - { - Write(buffer.AsSpan(offset, count)); - } - - public override void Write(ReadOnlySpan buffer) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - buffer.CopyTo(_appendBuffer.GetSpan(buffer.Length)); - _appendBuffer.Advance(buffer.Length); - } - - public void AppendData(ReadOnlyMemory data) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - FlushAppendBuffer(); - _buffers.Add(data); - _length += data.Length; - _position += data.Length; - } - - public void AppendPadding(int paddingLength) - { - if (paddingLength > 0) - { - if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) - { - _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Fill(_padding[0]); - _appendBuffer.Advance(paddingLength); - } - else - { - AppendData(_padding.AsMemory(0, paddingLength)); - } - } - } - - public void WriteULEB128(ulong value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - DwarfHelper.WriteULEB128(_appendBuffer, value); - } - - public void WriteSLEB128(long value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - DwarfHelper.WriteSLEB128(_appendBuffer, value); - } - - public override void WriteByte(byte value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - Span buffer = _appendBuffer.GetSpan(1); - buffer[0] = value; - _appendBuffer.Advance(1); - } - - public void WriteLittleEndian(T value) - where T : IBinaryInteger - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - Span buffer = _appendBuffer.GetSpan(value.GetByteCount()); - _appendBuffer.Advance(value.WriteLittleEndian(buffer)); - } - - public void WriteUtf8String(string value) - { - Debug.Assert(_position == _length, "ObjectWriterStream only supports appending to the end"); - int size = Encoding.UTF8.GetByteCount(value) + 1; - Span buffer = _appendBuffer.GetSpan(size); - Encoding.UTF8.GetBytes(value, buffer); - buffer[size - 1] = 0; - _appendBuffer.Advance(size); - } - - private void FlushAppendBuffer() - { - if (_appendBuffer.WrittenCount > 0) - { - _buffers.Add(_appendBuffer.WrittenSpan.ToArray()); - _position += _appendBuffer.WrittenCount; - _length += _appendBuffer.WrittenCount; - _appendBuffer.Clear(); - } - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs new file mode 100644 index 00000000000000..4022fa79992531 --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs @@ -0,0 +1,176 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Numerics; +using System.Text; + +namespace ILCompiler.ObjectWriter +{ + /// + /// Optimized append-only structure for writing sections. + /// + /// + /// Implements a stream of chained buffers. It supports appending existing + /// read-only buffers without copying. + /// + internal sealed class SectionData + { + private readonly ArrayBufferWriter _appendBuffer = new(); + private readonly List> _buffers = new(); + private long _length; + private readonly byte[] _padding = new byte[16]; + + public SectionData(byte paddingByte = 0) + { + _padding.AsSpan().Fill(paddingByte); + } + + private void FlushAppendBuffer() + { + if (_appendBuffer.WrittenCount > 0) + { + _buffers.Add(_appendBuffer.WrittenSpan.ToArray()); + _length += _appendBuffer.WrittenCount; + _appendBuffer.Clear(); + } + } + + public void AppendData(ReadOnlyMemory data) + { + FlushAppendBuffer(); + _buffers.Add(data); + _length += data.Length; + } + + public void AppendPadding(int paddingLength) + { + if (paddingLength > 0) + { + if (_appendBuffer.WrittenCount > 0 || paddingLength > _padding.Length) + { + _appendBuffer.GetSpan(paddingLength).Slice(0, paddingLength).Fill(_padding[0]); + _appendBuffer.Advance(paddingLength); + } + else + { + AppendData(_padding.AsMemory(0, paddingLength)); + } + } + } + + public IBufferWriter BufferWriter => _appendBuffer; + + public long Length => _length + _appendBuffer.WrittenCount; + + public Stream GetReadStream() => new ReadStream(this); + + private sealed class ReadStream : Stream + { + private readonly SectionData _sectionData; + private int _bufferIndex; + private int _bufferPosition; + private long _position; + + public override bool CanRead => true; + public override bool CanSeek => true; + public override bool CanWrite => false; + public override long Length => _sectionData.Length; + + public override long Position + { + get => _position; + set + { + // Flush any non-appended data + _sectionData.FlushAppendBuffer(); + + // Seek to the correct buffer + _position = 0; + _bufferIndex = 0; + _bufferPosition = 0; + while (_position < value && _bufferIndex < _sectionData._buffers.Count) + { + if (_sectionData._buffers[_bufferIndex].Length < value - _position) + { + _position += _sectionData._buffers[_bufferIndex].Length; + _bufferIndex++; + } + else + { + _bufferPosition = (int)(value - _position); + _position = value; + break; + } + } + } + } + + public ReadStream(SectionData sectionData) + { + _sectionData = sectionData; + } + + public override void Flush() => throw new NotSupportedException(); + + public override int Read(byte[] buffer, int offset, int count) + { + return Read(buffer.AsSpan(offset, count)); + } + + public override int Read(Span buffer) + { + int bytesRead = 0; + + // Flush any non-appended data + _sectionData.FlushAppendBuffer(); + + // _bufferIndex and _bufferPosition is only valid after seeking when + // _position < _length + while (_position < _sectionData._length && _bufferIndex < _sectionData._buffers.Count) + { + ReadOnlySpan currentBuffer = _sectionData._buffers[_bufferIndex].Span.Slice(_bufferPosition); + + if (currentBuffer.Length >= buffer.Length) + { + currentBuffer.Slice(0, buffer.Length).CopyTo(buffer); + bytesRead += buffer.Length; + _position += buffer.Length; + _bufferPosition += buffer.Length; + return bytesRead; + } + + currentBuffer.CopyTo(buffer); + buffer = buffer.Slice(currentBuffer.Length); + bytesRead += currentBuffer.Length; + _position += currentBuffer.Length; + _bufferIndex++; + _bufferPosition = 0; + } + + return bytesRead; + } + + public override long Seek(long offset, SeekOrigin origin) + { + Position = origin switch + { + SeekOrigin.End => Length + offset, + SeekOrigin.Current => Position + offset, + SeekOrigin.Begin => offset, + _ => throw new ArgumentOutOfRangeException(nameof(origin)) + }; + return Position; + } + + public override void SetLength(long value) => throw new NotSupportedException(); + public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); + public override void Write(ReadOnlySpan buffer) => throw new NotSupportedException(); + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index 5d7e8f23ac189f..5bcfa2a2a5336c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers; +using System.Numerics; +using System.Text; using ILCompiler.DependencyAnalysis; namespace ILCompiler.ObjectWriter @@ -9,31 +12,32 @@ namespace ILCompiler.ObjectWriter public struct SectionWriter { private readonly ObjectWriter _objectWriter; + private readonly SectionData _sectionData; public int SectionIndex { get; init; } - public ObjectWriterStream Stream { get; init; } internal SectionWriter( ObjectWriter objectWriter, int sectionIndex, - ObjectWriterStream stream) + SectionData sectionData) { _objectWriter = objectWriter; SectionIndex = sectionIndex; - Stream = stream; + _sectionData = sectionData; } public readonly void EmitData(ReadOnlyMemory data) { - Stream.AppendData(data); + _sectionData.AppendData(data); } public readonly void EmitAlignment(int alignment) { _objectWriter.UpdateSectionAlignment(SectionIndex, alignment); - int padding = (int)(((Stream.Position + alignment - 1) & ~(alignment - 1)) - Stream.Position); - Stream.AppendPadding(padding); + long position = Position; + int padding = (int)(((position + alignment - 1) & ~(alignment - 1)) - position); + _sectionData.AppendPadding(padding); } public readonly void EmitRelocation( @@ -45,7 +49,7 @@ public readonly void EmitRelocation( { _objectWriter.EmitRelocation( SectionIndex, - Stream.Position + relativeOffset, + Position + relativeOffset, data, relocType, symbolName, @@ -61,7 +65,7 @@ public readonly void EmitSymbolDefinition( _objectWriter.EmitSymbolDefinition( SectionIndex, symbolName, - Stream.Position + relativeOffset, + Position + relativeOffset, size, global); } @@ -71,16 +75,56 @@ public readonly void EmitSymbolReference( string symbolName, long addend = 0) { - Span buffer = stackalloc byte[relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint)]; + IBufferWriter bufferWriter = _sectionData.BufferWriter; + int size = relocType == RelocType.IMAGE_REL_BASED_DIR64 ? sizeof(ulong) : sizeof(uint); + Span buffer = bufferWriter.GetSpan(size); buffer.Clear(); _objectWriter.EmitRelocation( SectionIndex, - Stream.Position, + Position, buffer, relocType, symbolName, addend); - Stream.Write(buffer); + bufferWriter.Advance(size); } + + public readonly void Write(ReadOnlySpan value) + { + IBufferWriter bufferWriter = _sectionData.BufferWriter; + value.CopyTo(bufferWriter.GetSpan(value.Length)); + bufferWriter.Advance(value.Length); + } + + public readonly void WriteULEB128(ulong value) => DwarfHelper.WriteULEB128(_sectionData.BufferWriter, value); + + public readonly void WriteSLEB128(long value) => DwarfHelper.WriteSLEB128(_sectionData.BufferWriter, value); + + public readonly void WriteByte(byte value) + { + IBufferWriter bufferWriter = _sectionData.BufferWriter; + bufferWriter.GetSpan(1)[0] = value; + bufferWriter.Advance(1); + } + + public readonly void WriteLittleEndian(T value) + where T : IBinaryInteger + { + IBufferWriter bufferWriter = _sectionData.BufferWriter; + Span buffer = bufferWriter.GetSpan(value.GetByteCount()); + bufferWriter.Advance(value.WriteLittleEndian(buffer)); + } + + public readonly void WriteUtf8String(string value) + { + IBufferWriter bufferWriter = _sectionData.BufferWriter; + int size = Encoding.UTF8.GetByteCount(value) + 1; + Span buffer = bufferWriter.GetSpan(size); + Encoding.UTF8.GetBytes(value, buffer); + buffer[size - 1] = 0; + bufferWriter.Advance(size); + } + + public readonly long Position => _sectionData.Length; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 68d594ef256fd2..b2f8689cf3dcab 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -69,11 +69,10 @@ protected override void EmitUnwindInfo( string currentSymbolName) { if (nodeWithCodeInfo.FrameInfos is FrameInfo[] frameInfos && - nodeWithCodeInfo is ISymbolDefinitionNode symbolDefinitionNode) + nodeWithCodeInfo is ISymbolDefinitionNode) { bool useFrameNames = UseFrameNames; SectionWriter lsdaSectionWriter; - Span tempBuffer = stackalloc byte[4]; if (ShouldShareSymbol((ObjectNode)nodeWithCodeInfo)) { @@ -84,14 +83,13 @@ protected override void EmitUnwindInfo( lsdaSectionWriter = _lsdaSectionWriter; } - long mainLsdaOffset = lsdaSectionWriter.Stream.Position; + long mainLsdaOffset = lsdaSectionWriter.Position; for (int i = 0; i < frameInfos.Length; i++) { FrameInfo frameInfo = frameInfos[i]; int start = frameInfo.StartOffset; int end = frameInfo.EndOffset; - int len = frameInfo.BlobData.Length; byte[] blob = frameInfo.BlobData; string lsdaSymbolName = $"_lsda{i}{currentSymbolName}"; @@ -107,14 +105,10 @@ protected override void EmitUnwindInfo( if (i != 0) { - lsdaSectionWriter.Stream.WriteByte((byte)flags); - - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(mainLsdaOffset - lsdaSectionWriter.Stream.Position)); - lsdaSectionWriter.Stream.Write(tempBuffer); - + lsdaSectionWriter.WriteByte((byte)flags); + lsdaSectionWriter.WriteLittleEndian((int)(mainLsdaOffset - lsdaSectionWriter.Position)); // Emit relative offset from the main function - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(start - frameInfos[0].StartOffset)); - lsdaSectionWriter.Stream.Write(tempBuffer); + lsdaSectionWriter.WriteLittleEndian((uint)(start - frameInfos[0].StartOffset)); } else { @@ -124,7 +118,7 @@ protected override void EmitUnwindInfo( flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; - lsdaSectionWriter.Stream.WriteByte((byte)flags); + lsdaSectionWriter.WriteByte((byte)flags); if (associatedDataNode != null) { @@ -140,7 +134,7 @@ protected override void EmitUnwindInfo( if (nodeWithCodeInfo.GCInfo != null) { - lsdaSectionWriter.Stream.Write(nodeWithCodeInfo.GCInfo); + lsdaSectionWriter.Write(nodeWithCodeInfo.GCInfo); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index 6b842e0640f335..8f253d68a90bbd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -604,7 +604,6 @@ - @@ -612,6 +611,7 @@ + From 17c3001d397cb2a4a9e6d5245ef9b3b1ccbf92fa Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Dec 2023 21:02:56 +0100 Subject: [PATCH 118/144] Cleanup --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 27 ++++--- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 10 +-- .../Compiler/ObjectWriter/MachObjectWriter.cs | 16 ++-- .../Compiler/ObjectWriter/ObjectWriter.cs | 78 ++++++++----------- .../ObjectWriter/StringTableBuilder.cs | 2 +- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 28 +++---- 6 files changed, 72 insertions(+), 89 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index e96b0736ed7452..204b59c42a4ca0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -65,7 +65,7 @@ public CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) }; } - protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) + private protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { var sectionHeader = new CoffSectionHeader { @@ -230,12 +230,12 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - protected override void EmitReferencedMethod(string symbolName) + private protected override void EmitReferencedMethod(string symbolName) { _referencedMethods.Add(symbolName); } - protected override void EmitSymbolTable( + private protected override void EmitSymbolTable( IDictionary definedSymbols, SortedSet undefinedSymbols) { @@ -290,7 +290,7 @@ protected override void EmitSymbolTable( } } - protected override void EmitRelocations(int sectionIndex, List relocationList) + private protected override void EmitRelocations(int sectionIndex, List relocationList) { CoffSectionHeader sectionHeader = _sections[sectionIndex].Header; List coffRelocations = _sections[sectionIndex].Relocations; @@ -387,17 +387,16 @@ protected override void EmitRelocations(int sectionIndex, List tempBuffer = stackalloc byte[4]; bool shareSymbol = ShouldShareSymbol((ObjectNode)nodeWithCodeInfo); for (int i = 0; i < frameInfos.Length; i++) @@ -484,11 +483,11 @@ protected override void EmitUnwindInfo( } } - protected override void EmitSectionsAndLayout() + private protected override void EmitSectionsAndLayout() { } - protected override void EmitObjectFile(string objectFilePath) + private protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); var stringTable = new CoffStringTable(); @@ -591,14 +590,14 @@ protected override void EmitObjectFile(string objectFilePath) stringTable.Write(outputFileStream); } - protected override void CreateEhSections() + private protected override void CreateEhSections() { // Create .xdata and .pdata _xdataSectionWriter = GetOrCreateSection(ObjectNodeSection.XDataSection); _pdataSectionWriter = GetOrCreateSection(PDataSection); } - protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() + private protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { _debugFileTableBuilder = new CodeViewFileTableBuilder(); @@ -616,7 +615,7 @@ protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() return _debugTypesBuilder; } - protected override void EmitDebugFunctionInfo( + private protected override void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, SymbolDefinition methodSymbol, @@ -660,13 +659,13 @@ protected override void EmitDebugFunctionInfo( } } - protected override void EmitDebugSections(IDictionary definedSymbols) + private protected override void EmitDebugSections(IDictionary definedSymbols) { _debugSymbolsBuilder.WriteUserDefinedTypes(_debugTypesBuilder.UserDefinedTypes); _debugFileTableBuilder.Write(_debugSymbolSectionWriter); } - private sealed class CoffHeader + private struct CoffHeader { public Machine Machine { get; set; } public uint NumberOfSections { get; set; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index a9c3283c47aa65..5162ebb59f936f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -39,7 +39,7 @@ public ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) _symbols.Add(new ElfSymbol {}); } - protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) + private protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { string sectionName = section.Name == "rdata" ? ".rodata" : @@ -177,7 +177,7 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - protected override void EmitSymbolTable( + private protected override void EmitSymbolTable( IDictionary definedSymbols, SortedSet undefinedSymbols) { @@ -228,7 +228,7 @@ protected override void EmitSymbolTable( } } - protected override void EmitRelocations(int sectionIndex, List relocationList) + private protected override void EmitRelocations(int sectionIndex, List relocationList) { switch (_machine) { @@ -351,11 +351,11 @@ private void EmitRelocationsARM64(int sectionIndex, List rel } } - protected override void EmitSectionsAndLayout() + private protected override void EmitSectionsAndLayout() { } - protected override void EmitObjectFile(string objectFilePath) + private protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); switch (_machine) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index ea0cc04a1031f3..2539c9c5c0d14f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -58,7 +58,7 @@ public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) _targetOS = factory.Target.OperatingSystem; } - protected override void EmitSectionsAndLayout() + private protected override void EmitSectionsAndLayout() { // Layout sections. At this point we don't really care if the file offsets are correct // but we need to compute the virtual addresses to populate the symbol table. @@ -127,7 +127,7 @@ private void LayoutSections(ref uint fileOffset, out uint segmentFileSize, out u } } - protected override void EmitObjectFile(string objectFilePath) + private protected override void EmitObjectFile(string objectFilePath) { _sections.Add(_compactUnwindSection); @@ -267,7 +267,7 @@ protected override void EmitObjectFile(string objectFilePath) stringTable.Write(outputFileStream); } - protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) + private protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { string segmentName = section.Name switch { @@ -450,7 +450,7 @@ protected internal override void EmitRelocation( base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } - protected override void EmitSymbolTable( + private protected override void EmitSymbolTable( IDictionary definedSymbols, SortedSet undefinedSymbols) { @@ -510,7 +510,7 @@ protected override void EmitSymbolTable( EmitCompactUnwindTable(definedSymbols); } - protected override void EmitRelocations(int sectionIndex, List relocationList) + private protected override void EmitRelocations(int sectionIndex, List relocationList) { if (_cpuType == MachNative.CPU_TYPE_ARM64) { @@ -737,7 +737,7 @@ void EmitCompactUnwindSymbol(string symbolName) } } - protected override string ExternCName(string name) => "_" + name; + private protected override string ExternCName(string name) => "_" + name; // This represents the following DWARF code: // DW_CFA_advance_loc: 4 @@ -760,7 +760,7 @@ void EmitCompactUnwindSymbol(string symbolName) 0x08, 0x01, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00 }; - protected override bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) + private protected override bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) { uint encoding = _compactUnwindDwarfCode; @@ -783,7 +783,7 @@ protected override bool EmitCompactUnwinding(string startSymbolName, ulong lengt return encoding != _compactUnwindDwarfCode; } - protected override bool UseFrameNames => true; + private protected override bool UseFrameNames => true; private static bool IsSectionSymbolName(string symbolName) => symbolName.StartsWith('l'); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index a40a94bcbef52e..ce24d109423da1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -15,14 +15,14 @@ namespace ILCompiler.ObjectWriter { - public abstract class ObjectWriter : IDisposable + public abstract class ObjectWriter { - protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); - protected sealed record SymbolicRelocation(long Offset, RelocType Type, string SymbolName, long Addend = 0); - protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Data, Relocation[] Relocations); + private protected sealed record SymbolDefinition(int SectionIndex, long Value, int Size = 0, bool Global = false); + private protected sealed record SymbolicRelocation(long Offset, RelocType Type, string SymbolName, long Addend = 0); + private protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Data, Relocation[] Relocations); - protected readonly NodeFactory _nodeFactory; - protected readonly ObjectWritingOptions _options; + private protected readonly NodeFactory _nodeFactory; + private protected readonly ObjectWritingOptions _options; private readonly bool _isSingleFileCompilation; private readonly bool _usesSubsectionsViaSymbols; @@ -41,7 +41,7 @@ protected sealed record BlockToRelocate(int SectionIndex, long Offset, byte[] Da // Debugging private UserDefinedTypeDescriptor _userDefinedTypeDescriptor; - protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) + private protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) { _nodeFactory = factory; _options = options; @@ -57,16 +57,7 @@ protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options) }; } - public void Dispose() - { - // Close all the streams - /*foreach (ObjectWriterStream sectionStream in _sectionIndexToStream) - { - sectionStream.Close(); - }*/ - } - - protected abstract void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream); + private protected abstract void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream); protected internal abstract void UpdateSectionAlignment(int sectionIndex, int alignment); @@ -84,7 +75,7 @@ public void Dispose() /// For associated sections, such as exception or debugging information, the /// will be different. /// - protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string comdatName = null, string symbolName = null) + private protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string comdatName = null, string symbolName = null) { int sectionIndex; SectionData sectionData; @@ -112,7 +103,7 @@ protected SectionWriter GetOrCreateSection(ObjectNodeSection section, string com sectionData); } - protected bool ShouldShareSymbol(ObjectNode node) + private protected bool ShouldShareSymbol(ObjectNode node) { if (_usesSubsectionsViaSymbols) return false; @@ -120,7 +111,7 @@ protected bool ShouldShareSymbol(ObjectNode node) return ShouldShareSymbol(node, node.GetSection(_nodeFactory)); } - protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) + private protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) { if (_usesSubsectionsViaSymbols) return false; @@ -144,7 +135,7 @@ protected bool ShouldShareSymbol(ObjectNode node, ObjectNodeSection section) return true; } - protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, string key) + private protected static ObjectNodeSection GetSharedSection(ObjectNodeSection section, string key) { string standardSectionPrefix = ""; if (section.IsStandardSection) @@ -208,12 +199,12 @@ protected internal virtual void EmitRelocation( _sectionIndexToRelocations[sectionIndex].Add(new SymbolicRelocation(offset, relocType, symbolName, addend)); } - protected bool SectionHasRelocations(int sectionIndex) + private protected bool SectionHasRelocations(int sectionIndex) { return _sectionIndexToRelocations[sectionIndex].Count > 0; } - protected virtual void EmitReferencedMethod(string symbolName) { } + private protected virtual void EmitReferencedMethod(string symbolName) { } /// /// Emit symbolic relocations into object file as format specific @@ -222,7 +213,7 @@ protected virtual void EmitReferencedMethod(string symbolName) { } /// /// This methods is guaranteed to run after . /// - protected abstract void EmitRelocations(int sectionIndex, List relocationList); + private protected abstract void EmitRelocations(int sectionIndex, List relocationList); /// /// Emit new symbol definition at specified location in a given section. @@ -248,13 +239,13 @@ protected internal void EmitSymbolDefinition( /// /// Emit symbolic definitions into object file symbols. /// - protected abstract void EmitSymbolTable( + private protected abstract void EmitSymbolTable( IDictionary definedSymbols, SortedSet undefinedSymbols); - protected virtual string ExternCName(string name) => name; + private protected virtual string ExternCName(string name) => name; - protected string GetMangledName(ISymbolNode symbolNode) + private protected string GetMangledName(ISymbolNode symbolNode) { string symbolName; @@ -267,12 +258,12 @@ protected string GetMangledName(ISymbolNode symbolNode) return symbolName; } - protected abstract void EmitUnwindInfo( + private protected abstract void EmitUnwindInfo( SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo, string currentSymbolName); - protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) + private protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMetadata debugVar) { uint typeIndex; try @@ -297,11 +288,11 @@ protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugVarInfoMe return typeIndex; } - protected abstract void EmitSectionsAndLayout(); + private protected abstract void EmitSectionsAndLayout(); - protected abstract void EmitObjectFile(string objectFilePath); + private protected abstract void EmitObjectFile(string objectFilePath); - protected abstract void CreateEhSections(); + private protected abstract void CreateEhSections(); private SortedSet GetUndefinedSymbols() { @@ -317,18 +308,18 @@ private SortedSet GetUndefinedSymbols() return undefinedSymbolSet; } - protected abstract ITypesDebugInfoWriter CreateDebugInfoBuilder(); + private protected abstract ITypesDebugInfoWriter CreateDebugInfoBuilder(); - protected abstract void EmitDebugFunctionInfo( + private protected abstract void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, SymbolDefinition methodSymbol, INodeWithDebugInfo debugNode, bool hasSequencePoints); - protected abstract void EmitDebugSections(IDictionary definedSymbols); + private protected abstract void EmitDebugSections(IDictionary definedSymbols); - protected void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) + private void EmitObject(string objectFilePath, IReadOnlyCollection nodes, IObjectDumper dumper, Logger logger) { // Pre-create some of the sections GetOrCreateSection(ObjectNodeSection.TextSection); @@ -520,19 +511,12 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection _reservedStrings = new(StringComparer.Ordinal); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index b2f8689cf3dcab..809ca86059ae88 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -14,11 +14,11 @@ namespace ILCompiler.ObjectWriter { internal abstract class UnixObjectWriter : ObjectWriter { - private sealed record SectionDefinition(string SymbolName, Stream SectionStream); + private sealed record UnixSectionDefinition(string SymbolName, Stream SectionStream); // Debugging private DwarfBuilder _dwarfBuilder; - private readonly List _sections = new(); + private readonly List _sections = new(); // Exception handling sections private SectionWriter _lsdaSectionWriter; @@ -43,7 +43,7 @@ protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) { } - protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) + private protected override void CreateSection(ObjectNodeSection section, string comdatName, string symbolName, Stream sectionStream) { if (section.Type != SectionType.Debug && section != LsdaSection && @@ -51,7 +51,7 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa (comdatName is null || Equals(comdatName, symbolName))) { // Record code and data sections that can be referenced from debugging information - _sections.Add(new SectionDefinition(symbolName, sectionStream)); + _sections.Add(new UnixSectionDefinition(symbolName, sectionStream)); } else { @@ -59,11 +59,11 @@ protected override void CreateSection(ObjectNodeSection section, string comdatNa } } - protected virtual bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) => false; + private protected virtual bool EmitCompactUnwinding(string startSymbolName, ulong length, string lsdaSymbolName, byte[] blob) => false; - protected virtual bool UseFrameNames => false; + private protected virtual bool UseFrameNames => false; - protected override void EmitUnwindInfo( + private protected override void EmitUnwindInfo( SectionWriter sectionWriter, INodeWithCodeInfo nodeWithCodeInfo, string currentSymbolName) @@ -156,7 +156,7 @@ protected override void EmitUnwindInfo( } } - protected override void EmitDebugFunctionInfo( + private protected override void EmitDebugFunctionInfo( uint methodTypeIndex, string methodName, SymbolDefinition methodSymbol, @@ -170,7 +170,7 @@ protected override void EmitDebugFunctionInfo( clauses = nodeWithCodeInfo.DebugEHClauseInfos; } - if (_sections[methodSymbol.SectionIndex] is SectionDefinition section) + if (_sections[methodSymbol.SectionIndex] is UnixSectionDefinition section) { _dwarfBuilder.EmitSubprogramInfo( methodName, @@ -192,9 +192,9 @@ protected override void EmitDebugFunctionInfo( } } - protected override void EmitDebugSections(IDictionary definedSymbols) + private protected override void EmitDebugSections(IDictionary definedSymbols) { - foreach (SectionDefinition section in _sections) + foreach (UnixSectionDefinition section in _sections) { if (section is not null) { @@ -221,7 +221,7 @@ protected override void EmitDebugSections(IDictionary symbolName => { if (definedSymbols.TryGetValue(ExternCName(symbolName), out SymbolDefinition symbolDef) && - _sections[symbolDef.SectionIndex] is SectionDefinition section) + _sections[symbolDef.SectionIndex] is UnixSectionDefinition section) { return (section.SymbolName, symbolDef.Value); } @@ -229,7 +229,7 @@ protected override void EmitDebugSections(IDictionary }); } - protected override void CreateEhSections() + private protected override void CreateEhSections() { SectionWriter ehFrameSectionWriter; @@ -252,7 +252,7 @@ protected override void CreateEhSections() _dwarfEhFrame.AddCie(_dwarfCie); } - protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() + private protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() { return _dwarfBuilder = new DwarfBuilder( _nodeFactory.NameMangler, From 6dde29b4119d2432c769be57bc99ff996ad052ff Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 11 Dec 2023 21:06:30 +0100 Subject: [PATCH 119/144] Pattern matching consistency --- .../Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs | 2 +- .../Compiler/ObjectWriter/MachObjectWriter.cs | 4 ++-- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 4 ++-- .../Compiler/ObjectWriter/StringTableBuilder.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs index 5f2350d460c782..bd78e52ba7cd94 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs @@ -238,7 +238,7 @@ public void EmitLineInfo( foreach (var sequencePoint in sequencePoints) { - if (lastFileName == null || lastFileName != sequencePoint.FileName) + if (lastFileName is null || lastFileName != sequencePoint.FileName) { if (codes.Count > 0) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 2539c9c5c0d14f..4d87ec64e34f9c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -716,7 +716,7 @@ private void EmitCompactUnwindTable(IDictionary define void EmitCompactUnwindSymbol(string symbolName) { Span tempBuffer = stackalloc byte[8]; - if (symbolName != null) + if (symbolName is not null) { SymbolDefinition symbol = definedSymbols[symbolName]; MachSection section = _sections[symbol.SectionIndex]; @@ -776,7 +776,7 @@ private protected override bool EmitCompactUnwinding(string startSymbolName, ulo _compactUnwindCodes.Add(new CompactUnwindCode( PcStartSymbolName: startSymbolName, PcLength: (uint)length, - Code: encoding | (encoding != _compactUnwindDwarfCode && lsdaSymbolName != null ? 0x40000000u : 0), // UNWIND_HAS_LSDA + Code: encoding | (encoding != _compactUnwindDwarfCode && lsdaSymbolName is not null ? 0x40000000u : 0), // UNWIND_HAS_LSDA LsdaSymbolName: encoding != _compactUnwindDwarfCode ? lsdaSymbolName : null )); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index ce24d109423da1..fd5ec5e212deaa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -401,7 +401,7 @@ private void EmitObject(string objectFilePath, IReadOnlyCollection Date: Mon, 11 Dec 2023 22:00:44 +0100 Subject: [PATCH 120/144] Comments, more cleanup --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 55 ++++++++++++++----- .../Compiler/ObjectWriter/ElfNative.cs | 17 ++++++ .../Compiler/ObjectWriter/ElfObjectWriter.cs | 22 ++++++-- .../Compiler/ObjectWriter/MachNative.cs | 3 + .../Compiler/ObjectWriter/MachObjectWriter.cs | 36 ++++++++++++ .../Compiler/ObjectWriter/ObjectWriter.cs | 4 +- .../Compiler/ObjectWriter/SectionData.cs | 8 ++- .../Compiler/ObjectWriter/SectionWriter.cs | 2 +- .../ObjectWriter/StringTableBuilder.cs | 1 - .../Compiler/ObjectWriter/UnixObjectWriter.cs | 14 +++-- 10 files changed, 135 insertions(+), 27 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 204b59c42a4ca0..ee3334457296bb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -24,6 +24,30 @@ namespace ILCompiler.ObjectWriter { + /// + /// COFF object file format writer for Windows targets. + /// + /// + /// The PE/COFF object format is described in the official specifciation at + /// https://learn.microsoft.com/en-us/windows/win32/debug/pe-format. However, + /// numerous extensions are missing in the specification. The most notable + /// ones are listed below. + /// + /// Object files with more than 65279 sections use an extended big object + /// file format that is recognized by the Microsoft linker. Many of the + /// internal file structures are different. The code below denotes it by + /// "BigObj" in parameters and variables. + /// + /// Section names longer than 8 bytes need to be written indirectly in the + /// string table. The PE/COFF specification describes the /NNNNNNN syntax + /// for referencing them. However, if the string table gets big enough the + /// syntax no longer works. There's an undocumented //BBBBBB syntax where + /// base64 offset is used instead. + /// + /// CodeView debugging format uses 16-bit section index relocations. Once + /// the number of sections exceeds 2^16 the same file format is still used. + /// The linker treats the CodeView relocations symbolically. + /// internal sealed class CoffObjectWriter : ObjectWriter { private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName, string SymbolName); @@ -446,24 +470,26 @@ private protected override void EmitUnwindInfo( MethodExceptionHandlingInfoNode ehInfo = nodeWithCodeInfo.EHInfo; ISymbolNode associatedDataNode = nodeWithCodeInfo.GetAssociatedDataNode(_nodeFactory) as ISymbolNode; - flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; - flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; + flags |= ehInfo is not null ? FrameInfoFlags.HasEHInfo : 0; + flags |= associatedDataNode is not null ? FrameInfoFlags.HasAssociatedData : 0; xdataSectionWriter.WriteByte((byte)flags); - if (associatedDataNode != null) + if (associatedDataNode is not null) { - string symbolName = GetMangledName(associatedDataNode); - xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); + xdataSectionWriter.EmitSymbolReference( + RelocType.IMAGE_REL_BASED_ADDR32NB, + GetMangledName(associatedDataNode)); } - if (ehInfo != null) + if (ehInfo is not null) { - string symbolName = GetMangledName(ehInfo); - xdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, symbolName, 0); + xdataSectionWriter.EmitSymbolReference( + RelocType.IMAGE_REL_BASED_ADDR32NB, + GetMangledName(ehInfo)); } - if (nodeWithCodeInfo.GCInfo != null) + if (nodeWithCodeInfo.GCInfo is not null) { xdataSectionWriter.Write(nodeWithCodeInfo.GCInfo); } @@ -483,10 +509,6 @@ private protected override void EmitUnwindInfo( } } - private protected override void EmitSectionsAndLayout() - { - } - private protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); @@ -1049,8 +1071,15 @@ private sealed class CoffStringTable : StringTableBuilder } } + /// + /// Checksum algorithm used for COMDAT sections. This is similar to standard + /// CRC32 but starts with 0 as initial value instead of ~0. + /// private static class JamCrc32 { + // NOTE: + // This can be generated by Crc32ReflectedTable.Generate(0xEDB88320u); + // We embed the pre-generated version since it's small. private static uint[] Table = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs index 4a11a726fc3efb..77037bf4918a78 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -2,21 +2,30 @@ // The .NET Foundation licenses this file to you under the MIT license. namespace ILCompiler.ObjectWriter { + /// + /// Native constants for the ELF file format. + /// internal static class ElfNative { + // ELF version public const byte EV_CURRENT = 1; + // File type public const ushort ET_REL = 1; + // File bitness public const byte ELFCLASS32 = 1; public const byte ELFCLASS64 = 2; + // File endianness public const byte ELFDATA2LSB = 1; + // Architecture public const ushort EM_386 = 3; public const ushort EM_X86_64 = 62; public const ushort EM_AARCH64 = 183; + // Section header type public const uint SHT_NULL = 0; public const uint SHT_PROGBITS = 1; public const uint SHT_SYMTAB = 2; @@ -36,6 +45,7 @@ internal static class ElfNative public const uint SHT_SYMTAB_SHNDX = 18; public const uint SHT_IA_64_UNWIND = 1879048193; + // Section header flags public const uint SHF_WRITE = 1; public const uint SHF_ALLOC = 2; public const uint SHF_EXECINSTR = 4; @@ -48,10 +58,12 @@ internal static class ElfNative public const uint SHF_TLS = 1024; public const uint SHF_COMPRESSED = 2048; + // Section header special index numbers public const uint SHN_UNDEF = 0; public const uint SHN_LORESERVE = 65280; public const uint SHN_XINDEX = 65535; + // Symbol type public const byte STT_NOTYPE = 0; public const byte STT_OBJECT = 1; public const byte STT_FUNC = 2; @@ -60,15 +72,18 @@ internal static class ElfNative public const byte STT_COMMON = 5; public const byte STT_TLS = 6; + // Symbol visibility public const byte STV_DEFAULT = 0; public const byte STV_INTERNAL = 1; public const byte STV_HIDDEN = 2; public const byte STV_PROTECTED = 3; + // Symbol binding public const byte STB_LOCAL = 0; public const byte STB_GLOBAL = 1; public const byte STB_WEAK = 2; + // Relocations (x86) public const uint R_386_NONE = 0; public const uint R_386_32 = 1; public const uint R_386_PC32 = 2; @@ -111,6 +126,7 @@ internal static class ElfNative public const uint R_386_TLS_DESC = 41; public const uint R_386_IRELATIVE = 42; + // Relocations (x64) public const uint R_X86_64_NONE = 0; public const uint R_X86_64_64 = 1; public const uint R_X86_64_PC32 = 2; @@ -151,6 +167,7 @@ internal static class ElfNative public const uint R_X86_64_IRELATIVE = 37; public const uint R_X86_64_RELATIVE64 = 38; + // Relocations (arm64) public const uint R_AARCH64_NONE = 0; public const uint R_AARCH64_P32_ABS32 = 1; public const uint R_AARCH64_P32_COPY = 180; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 5162ebb59f936f..b18ba2e0b2f2aa 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -13,6 +13,21 @@ namespace ILCompiler.ObjectWriter { + /// + /// ELF object file format writer for Linux/Unix targets. + /// + /// + /// ELF object format is described by the official specification hosted + /// at https://refspecs.linuxfoundation.org/elf/elf.pdf. Different + /// architectures specify the details in the ABI specification. + /// + /// Like COFF there are several quirks related to large number of sections + /// (> 65279). Some of the fields in the ELF file header are moved to the + /// first (NULL) section header. The symbol table that is normally a single + /// section in the file is extended with a second .symtab_shndx section + /// to accomodate the section indexes that don't fit within the regular + /// section number field. + /// internal sealed class ElfObjectWriter : UnixObjectWriter { private readonly ushort _machine; @@ -249,6 +264,9 @@ private protected override void EmitRelocations(int sectionIndex, List relocationList) { + // TODO: We are emitting .rela sections on x86 which is technically wrong. We should be + // using .rel sections with the addend embedded in the data. Since x86 is not an officially + // supported platform this is left for future enhancement. if (relocationList.Count > 0) { Span relocationEntry = stackalloc byte[12]; @@ -351,10 +369,6 @@ private void EmitRelocationsARM64(int sectionIndex, List rel } } - private protected override void EmitSectionsAndLayout() - { - } - private protected override void EmitObjectFile(string objectFilePath) { using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs index 30b18a1dc1793b..dec6a7cc2171d6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. namespace ILCompiler.ObjectWriter { + /// + /// Native constants for the Mach-O file format. + /// internal static class MachNative { public const uint MH_MAGIC_64 = 0xfeedfacf; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 4d87ec64e34f9c..ce4b762ce8e148 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -16,6 +16,42 @@ namespace ILCompiler.ObjectWriter { + /// + /// Mach-O object file format writer for Apple macOS and iOS-like targets. + /// + /// + /// Old version of the Mach-O file format specification is mirrored at + /// https://github.com/aidansteele/osx-abi-macho-file-format-reference. + /// + /// There are some notable differences when compared to ELF or COFF: + /// - The maximum number of sections in object file is limited to 255. + /// - Sections are subdivided by their symbols and treated by the + /// linker as subsections (often referred to as atoms by the linker). + /// + /// The consequences of these design decisions is the COMDAT sections are + /// modeled in entirely different way. Dead code elimination works on the + /// atom level, so relative relocations within the same section have to be + /// preserved. + /// + /// Debug information uses the standard DWARF format. It is, however, not + /// linked into the intermediate executable files. Instead the linker creates + /// a map between the final executable and the object files. Debuggers like + /// lldb then use this map to read the debug information from the object + /// file directly. As a consequence the DWARF information is not generated + /// with relocations for the DWARF sections themselves since it's never + /// needed. + /// + /// While Mach-O uses the DWARF exception handling information for unwind + /// tables it also supports a compact representation for common prolog types. + /// Unofficial reference of the format can be found at + /// https://faultlore.com/blah/compact-unwinding/. It's necessary to emit + /// at least the stub entries pointing to the DWARF information but due + /// to limits in the linked file format it's advisable to use the compact + /// encoding whenever possible. + /// + /// The Apple linker is extremely picky in which relocation types are allowed + /// inside the DWARF sections, both for debugging and exception handling. + /// internal sealed class MachObjectWriter : UnixObjectWriter { private sealed record CompactUnwindCode(string PcStartSymbolName, uint PcLength, uint Code, string LsdaSymbolName = null, string PersonalitySymbolName = null); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index fd5ec5e212deaa..c87916a417effd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -288,7 +288,9 @@ private protected uint GetVarTypeIndex(bool isStateMachineMoveNextMethod, DebugV return typeIndex; } - private protected abstract void EmitSectionsAndLayout(); + private protected virtual void EmitSectionsAndLayout() + { + } private protected abstract void EmitObjectFile(string objectFilePath); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs index 4022fa79992531..9ae566487981a7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionData.cs @@ -16,8 +16,9 @@ namespace ILCompiler.ObjectWriter /// Optimized append-only structure for writing sections. /// /// - /// Implements a stream of chained buffers. It supports appending existing - /// read-only buffers without copying. + /// The section data are kept in memory as a list of buffers. It supports + /// appending existing read-only buffers without copying (such as buffer + /// from ObjectNode.ObjectData). /// internal sealed class SectionData { @@ -68,6 +69,9 @@ public void AppendPadding(int paddingLength) public long Length => _length + _appendBuffer.WrittenCount; + /// + /// Gets a read-only stream accessing the section data. + /// public Stream GetReadStream() => new ReadStream(this); private sealed class ReadStream : Stream diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index 5bcfa2a2a5336c..957582ce310668 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -9,7 +9,7 @@ namespace ILCompiler.ObjectWriter { - public struct SectionWriter + internal struct SectionWriter { private readonly ObjectWriter _objectWriter; private readonly SectionData _sectionData; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs index e87f5a3461d32f..81f7315d225e4a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/StringTableBuilder.cs @@ -42,7 +42,6 @@ public void ReserveString(string text) private void FlushReservedStrings() { - // TODO: Use CollectionsMarshal.AsSpan string[] reservedStrings = _reservedStrings.ToArray(); // Pre-sort the string based on their matching suffix diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index 809ca86059ae88..b80f4c28780f23 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -12,6 +12,10 @@ namespace ILCompiler.ObjectWriter { + /// + /// Base implementation for ELF and Mach-O object file format writers. Implements + /// the common code for DWARF debugging and exception handling information. + /// internal abstract class UnixObjectWriter : ObjectWriter { private sealed record UnixSectionDefinition(string SymbolName, Stream SectionStream); @@ -115,24 +119,24 @@ private protected override void EmitUnwindInfo( MethodExceptionHandlingInfoNode ehInfo = nodeWithCodeInfo.EHInfo; ISymbolNode associatedDataNode = nodeWithCodeInfo.GetAssociatedDataNode(_nodeFactory) as ISymbolNode; - flags |= ehInfo != null ? FrameInfoFlags.HasEHInfo : 0; - flags |= associatedDataNode != null ? FrameInfoFlags.HasAssociatedData : 0; + flags |= ehInfo is not null ? FrameInfoFlags.HasEHInfo : 0; + flags |= associatedDataNode is not null ? FrameInfoFlags.HasAssociatedData : 0; lsdaSectionWriter.WriteByte((byte)flags); - if (associatedDataNode != null) + if (associatedDataNode is not null) { string symbolName = GetMangledName(associatedDataNode); lsdaSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); } - if (ehInfo != null) + if (ehInfo is not null) { string symbolName = GetMangledName(ehInfo); lsdaSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_RELPTR32, symbolName, 0); } - if (nodeWithCodeInfo.GCInfo != null) + if (nodeWithCodeInfo.GCInfo is not null) { lsdaSectionWriter.Write(nodeWithCodeInfo.GCInfo); } From 2f7bda3175b7c6f5df40052caca0d3e41963953c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 13 Dec 2023 21:20:19 +0100 Subject: [PATCH 121/144] Refactor ULEB128 writing in CfiCodeToInstructions --- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 33 +++-------------- .../ObjectWriter/Dwarf/DwarfHelper.cs | 36 +++++++++++-------- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index fd7c3375981fc9..2a5720be1f7311 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -44,7 +44,6 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) byte codeOffset = 0; byte lastCodeOffset = 0; int offset = 0; - uint temp; while (offset < blobData.Length) { codeOffset = Math.Max(codeOffset, blobData[offset++]); @@ -86,46 +85,22 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) else { cfiCode[cfiCodeOffset++] = DW_CFA_offset_extended; - temp = (uint)dwarfReg; - do - { - cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); - temp >>= 7; - } - while (temp > 0); + cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)dwarfReg); } - temp = (uint)((cfiOffset - cfaOffset) / cie.DataAlignFactor); - do - { - cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); - temp >>= 7; - } - while (temp > 0); + cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)((cfiOffset - cfaOffset) / cie.DataAlignFactor)); break; case CFI_OPCODE.CFI_ADJUST_CFA_OFFSET: cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa_offset; cfaOffset += cfiOffset; - temp = (uint)(cfaOffset); - do - { - cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); - temp >>= 7; - } - while (temp > 0); + cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)cfaOffset); break; case CFI_OPCODE.CFI_DEF_CFA: cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa; cfiCode[cfiCodeOffset++] = (byte)dwarfReg; cfaOffset = cfiOffset; - temp = (uint)(cfaOffset); - do - { - cfiCode[cfiCodeOffset++] = (byte)((temp & 0x7f) | ((temp >= 0x80) ? 0x80u : 0)); - temp >>= 7; - } - while (temp > 0); + cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)cfaOffset); break; } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs index 214e5842010b5d..0a53f38fab7268 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Buffers; using System.Numerics; @@ -25,34 +26,36 @@ public static uint SizeOfSLEB128(long value) return (x * 37) >> 8; } - public static void WriteULEB128(IBufferWriter writer, ulong value) + public static int WriteULEB128(Span buffer, ulong value) { if (value >= 0x80) { - int size = (int)SizeOfULEB128(value); - var buffer = writer.GetSpan(size); + int pos = 0; do { - buffer[0] = (byte)((value & 0x7f) | ((value >= 0x80) ? 0x80u : 0)); - buffer = buffer.Slice(1); + buffer[pos++] = (byte)((value & 0x7f) | ((value >= 0x80) ? 0x80u : 0)); value >>= 7; } while (value > 0); - writer.Advance(size); + return pos; } else { - var buffer = writer.GetSpan(1); buffer[0] = (byte)value; - writer.Advance(1); + return 1; } } - public static void WriteSLEB128(IBufferWriter writer, long value) + public static void WriteULEB128(IBufferWriter writer, ulong value) + { + Span buffer = writer.GetSpan((int)SizeOfULEB128(value)); + writer.Advance(WriteULEB128(buffer, value)); + } + + public static int WriteSLEB128(Span buffer, long value) { - int size = (int)SizeOfSLEB128(value); - var buffer = writer.GetSpan(size); bool cont = true; + int pos = 0; while (cont) { var b = (byte)((byte)value & 0x7f); @@ -66,10 +69,15 @@ public static void WriteSLEB128(IBufferWriter writer, long value) { b |= 0x80; } - buffer[0] = b; - buffer = buffer.Slice(1); + buffer[pos++] = b; } - writer.Advance(size); + return pos; + } + + public static void WriteSLEB128(IBufferWriter writer, long value) + { + Span buffer = writer.GetSpan((int)SizeOfSLEB128(value)); + writer.Advance(WriteSLEB128(buffer, value)); } } } From df31fc609ee1201015e3d9020bc2963c2c88fec8 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 14 Dec 2023 10:20:24 +0100 Subject: [PATCH 122/144] Make JamCrc32 table a read-only span with collection initializer --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index ee3334457296bb..275e54bfbfc825 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -1077,58 +1077,58 @@ private sealed class CoffStringTable : StringTableBuilder /// private static class JamCrc32 { - // NOTE: - // This can be generated by Crc32ReflectedTable.Generate(0xEDB88320u); - // We embed the pre-generated version since it's small. - private static uint[] Table = - { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d - }; - public static uint CalculateChecksum(Stream stream) { + // NOTE: + // This can be generated by Crc32ReflectedTable.Generate(0xEDB88320u); + // We embed the pre-generated version since it's small. + ReadOnlySpan table = + [ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + ]; + uint crc = 0; Span buffer = stackalloc byte[4096]; while (stream.Position < stream.Length) @@ -1136,7 +1136,7 @@ public static uint CalculateChecksum(Stream stream) int length = stream.Read(buffer); for (int i = 0; i < length; i++) { - crc = Table[(crc ^ buffer[i]) & 0xff] ^ (crc >> 8); + crc = table[(byte)(crc ^ buffer[i])] ^ (crc >> 8); } } return crc; From dd168d1dea95999c8804ce341559703d59d94dfa Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 17 Dec 2023 17:06:48 +0100 Subject: [PATCH 123/144] IsOSXLike -> IsApplePlatform --- .../ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs index c87916a417effd..9699c9551a2f19 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs @@ -46,7 +46,7 @@ private protected ObjectWriter(NodeFactory factory, ObjectWritingOptions options _nodeFactory = factory; _options = options; _isSingleFileCompilation = _nodeFactory.CompilationModuleGroup.IsSingleFileCompilation; - _usesSubsectionsViaSymbols = factory.Target.IsOSXLike; + _usesSubsectionsViaSymbols = factory.Target.IsApplePlatform; // Padding byte for code sections (NOP for x86/x64) _insPaddingByte = factory.Target.Architecture switch @@ -516,7 +516,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection Date: Sun, 17 Dec 2023 17:24:19 +0100 Subject: [PATCH 124/144] Follow up on 'using static' for relocations and *Native --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 93 ++++---- .../Compiler/ObjectWriter/ElfNative.cs | 3 + .../Compiler/ObjectWriter/ElfObjectWriter.cs | 207 +++++++++--------- .../Compiler/ObjectWriter/MachObjectWriter.cs | 134 ++++++------ 4 files changed, 221 insertions(+), 216 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 275e54bfbfc825..1bf5f1927756ba 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -12,15 +12,12 @@ using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; using System.Text; - using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; - -using Internal.Text; using Internal.TypeSystem; using Internal.TypeSystem.TypesDebugInfo; -using Internal.JitInterface; -using ObjectData = ILCompiler.DependencyAnalysis.ObjectNode.ObjectData; +using static ILCompiler.DependencyAnalysis.RelocType; +using static ILCompiler.ObjectWriter.CoffObjectWriter.CoffRelocationType; namespace ILCompiler.ObjectWriter { @@ -193,14 +190,14 @@ protected internal override void EmitRelocation( { switch (relocType) { - case RelocType.IMAGE_REL_BASED_ARM64_BRANCH26: - case RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: - case RelocType.IMAGE_REL_SECREL: - case RelocType.IMAGE_REL_SECTION: + case IMAGE_REL_BASED_ARM64_BRANCH26: + case IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: + case IMAGE_REL_SECREL: + case IMAGE_REL_SECTION: Debug.Assert(addend == 0); break; - case RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: + case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: if (addend != 0) { uint addInstr = BinaryPrimitives.ReadUInt32LittleEndian(data); @@ -210,7 +207,7 @@ protected internal override void EmitRelocation( } break; - case RelocType.IMAGE_REL_BASED_DIR64: + case IMAGE_REL_BASED_DIR64: if (addend != 0) { BinaryPrimitives.WriteInt64LittleEndian( @@ -221,7 +218,7 @@ protected internal override void EmitRelocation( } break; - case RelocType.IMAGE_REL_BASED_RELPTR32: + case IMAGE_REL_BASED_RELPTR32: addend += 4; if (addend != 0) { @@ -233,10 +230,10 @@ protected internal override void EmitRelocation( } break; - case RelocType.IMAGE_REL_BASED_REL32: - case RelocType.IMAGE_REL_BASED_ADDR32NB: - case RelocType.IMAGE_REL_BASED_ABSOLUTE: - case RelocType.IMAGE_REL_BASED_HIGHLOW: + case IMAGE_REL_BASED_REL32: + case IMAGE_REL_BASED_ADDR32NB: + case IMAGE_REL_BASED_ABSOLUTE: + case IMAGE_REL_BASED_HIGHLOW: if (addend != 0) { BinaryPrimitives.WriteInt32LittleEndian( @@ -343,13 +340,13 @@ private protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_I386_DIR32NB, - RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_I386_DIR32NB, - RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_I386_DIR32, - RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_I386_REL32, - RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_I386_REL32, - RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_I386_SECREL, - RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_I386_SECTION, + IMAGE_REL_BASED_ABSOLUTE => IMAGE_REL_I386_DIR32NB, + IMAGE_REL_BASED_ADDR32NB => IMAGE_REL_I386_DIR32NB, + IMAGE_REL_BASED_HIGHLOW => IMAGE_REL_I386_DIR32, + IMAGE_REL_BASED_REL32 => IMAGE_REL_I386_REL32, + IMAGE_REL_BASED_RELPTR32 => IMAGE_REL_I386_REL32, + IMAGE_REL_SECREL => IMAGE_REL_I386_SECREL, + IMAGE_REL_SECTION => IMAGE_REL_I386_SECTION, _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") }, }); @@ -365,14 +362,14 @@ private protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, - RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_AMD64_ADDR32NB, - RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_AMD64_ADDR32, - RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_AMD64_ADDR64, - RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, - RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_AMD64_REL32, - RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_AMD64_SECREL, - RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_AMD64_SECTION, + IMAGE_REL_BASED_ABSOLUTE => IMAGE_REL_AMD64_ADDR32NB, + IMAGE_REL_BASED_ADDR32NB => IMAGE_REL_AMD64_ADDR32NB, + IMAGE_REL_BASED_HIGHLOW => IMAGE_REL_AMD64_ADDR32, + IMAGE_REL_BASED_DIR64 => IMAGE_REL_AMD64_ADDR64, + IMAGE_REL_BASED_REL32 => IMAGE_REL_AMD64_REL32, + IMAGE_REL_BASED_RELPTR32 => IMAGE_REL_AMD64_REL32, + IMAGE_REL_SECREL => IMAGE_REL_AMD64_SECREL, + IMAGE_REL_SECTION => IMAGE_REL_AMD64_SECTION, _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") }, }); @@ -388,17 +385,17 @@ private protected override void EmitRelocations(int sectionIndex, List CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, - RelocType.IMAGE_REL_BASED_ADDR32NB => CoffRelocationType.IMAGE_REL_ARM64_ADDR32NB, - RelocType.IMAGE_REL_BASED_HIGHLOW => CoffRelocationType.IMAGE_REL_ARM64_ADDR32, - RelocType.IMAGE_REL_BASED_DIR64 => CoffRelocationType.IMAGE_REL_ARM64_ADDR64, - RelocType.IMAGE_REL_BASED_REL32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, - RelocType.IMAGE_REL_BASED_RELPTR32 => CoffRelocationType.IMAGE_REL_ARM64_REL32, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => CoffRelocationType.IMAGE_REL_ARM64_BRANCH26, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => CoffRelocationType.IMAGE_REL_ARM64_PAGEBASE_REL21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => CoffRelocationType.IMAGE_REL_ARM64_PAGEOFFSET_12A, - RelocType.IMAGE_REL_SECREL => CoffRelocationType.IMAGE_REL_ARM64_SECREL, - RelocType.IMAGE_REL_SECTION => CoffRelocationType.IMAGE_REL_ARM64_SECTION, + IMAGE_REL_BASED_ABSOLUTE => IMAGE_REL_ARM64_ADDR32NB, + IMAGE_REL_BASED_ADDR32NB => IMAGE_REL_ARM64_ADDR32NB, + IMAGE_REL_BASED_HIGHLOW => IMAGE_REL_ARM64_ADDR32, + IMAGE_REL_BASED_DIR64 => IMAGE_REL_ARM64_ADDR64, + IMAGE_REL_BASED_REL32 => IMAGE_REL_ARM64_REL32, + IMAGE_REL_BASED_RELPTR32 => IMAGE_REL_ARM64_REL32, + IMAGE_REL_BASED_ARM64_BRANCH26 => IMAGE_REL_ARM64_BRANCH26, + IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => IMAGE_REL_ARM64_PAGEBASE_REL21, + IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => IMAGE_REL_ARM64_PAGEOFFSET_12A, + IMAGE_REL_SECREL => IMAGE_REL_ARM64_SECREL, + IMAGE_REL_SECTION => IMAGE_REL_ARM64_SECTION, _ => throw new NotSupportedException($"Unsupported relocation: {relocation.Type}") }, }); @@ -478,14 +475,14 @@ private protected override void EmitUnwindInfo( if (associatedDataNode is not null) { xdataSectionWriter.EmitSymbolReference( - RelocType.IMAGE_REL_BASED_ADDR32NB, + IMAGE_REL_BASED_ADDR32NB, GetMangledName(associatedDataNode)); } if (ehInfo is not null) { xdataSectionWriter.EmitSymbolReference( - RelocType.IMAGE_REL_BASED_ADDR32NB, + IMAGE_REL_BASED_ADDR32NB, GetMangledName(ehInfo)); } @@ -497,14 +494,14 @@ private protected override void EmitUnwindInfo( // Emit RUNTIME_FUNCTION pdataSectionWriter.EmitAlignment(4); - pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); + pdataSectionWriter.EmitSymbolReference(IMAGE_REL_BASED_ADDR32NB, currentSymbolName, start); // Only x64 has the End symbol if (_machine == Machine.Amd64) { - pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, currentSymbolName, end); + pdataSectionWriter.EmitSymbolReference(IMAGE_REL_BASED_ADDR32NB, currentSymbolName, end); } // Unwind info pointer - pdataSectionWriter.EmitSymbolReference(RelocType.IMAGE_REL_BASED_ADDR32NB, unwindSymbolName, 0); + pdataSectionWriter.EmitSymbolReference(IMAGE_REL_BASED_ADDR32NB, unwindSymbolName, 0); } } } @@ -854,7 +851,7 @@ public void Write(FileStream stream, CoffStringTable stringTable) } } - private enum CoffRelocationType + internal enum CoffRelocationType { IMAGE_REL_I386_ABSOLUTE = 0, IMAGE_REL_I386_DIR32 = 6, diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs index 77037bf4918a78..5f6d0eea5d7636 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -63,6 +63,9 @@ internal static class ElfNative public const uint SHN_LORESERVE = 65280; public const uint SHN_XINDEX = 65535; + // Section group type + public const uint GRP_COMDAT = 1; + // Symbol type public const byte STT_NOTYPE = 0; public const byte STT_OBJECT = 1; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index b18ba2e0b2f2aa..b6a50dd5608c6c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -10,6 +10,8 @@ using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; +using static ILCompiler.DependencyAnalysis.RelocType; +using static ILCompiler.ObjectWriter.ElfNative; namespace ILCompiler.ObjectWriter { @@ -44,9 +46,9 @@ public ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) { _machine = factory.Target.Architecture switch { - TargetArchitecture.X86 => ElfNative.EM_386, - TargetArchitecture.X64 => ElfNative.EM_X86_64, - TargetArchitecture.ARM64 => ElfNative.EM_AARCH64, + TargetArchitecture.X86 => EM_386, + TargetArchitecture.X64 => EM_X86_64, + TargetArchitecture.ARM64 => EM_AARCH64, _ => throw new NotSupportedException("Unsupported architecture") }; @@ -66,29 +68,29 @@ private protected override void CreateSection(ObjectNodeSection section, string if (section.Type == SectionType.Uninitialized) { - type = ElfNative.SHT_NOBITS; - flags = ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE; + type = SHT_NOBITS; + flags = SHF_ALLOC | SHF_WRITE; } else if (section == ObjectNodeSection.TLSSection) { - type = ElfNative.SHT_PROGBITS; - flags = ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE | ElfNative.SHF_TLS; + type = SHT_PROGBITS; + flags = SHF_ALLOC | SHF_WRITE | SHF_TLS; } else { - type = section.Name == ".eh_frame" && _machine == ElfNative.EM_X86_64 ? ElfNative.SHT_IA_64_UNWIND : ElfNative.SHT_PROGBITS; + type = section.Name == ".eh_frame" && _machine == EM_X86_64 ? SHT_IA_64_UNWIND : SHT_PROGBITS; flags = section.Type switch { - SectionType.Executable => ElfNative.SHF_ALLOC | ElfNative.SHF_EXECINSTR, - SectionType.Writeable => ElfNative.SHF_ALLOC | ElfNative.SHF_WRITE, - SectionType.Debug => sectionName == ".debug_str" ? ElfNative.SHF_MERGE | ElfNative.SHF_STRINGS : 0, - _ => ElfNative.SHF_ALLOC, + SectionType.Executable => SHF_ALLOC | SHF_EXECINSTR, + SectionType.Writeable => SHF_ALLOC | SHF_WRITE, + SectionType.Debug => sectionName == ".debug_str" ? SHF_MERGE | SHF_STRINGS : 0, + _ => SHF_ALLOC, }; } if (comdatName is not null) { - flags |= ElfNative.SHF_GROUP; + flags |= SHF_GROUP; if (!_comdatNameToElfSection.TryGetValue(comdatName, out groupSection)) { Span tempBuffer = stackalloc byte[sizeof(uint)]; @@ -96,7 +98,7 @@ private protected override void CreateSection(ObjectNodeSection section, string { SectionHeader = new ElfSectionHeader { - Type = ElfNative.SHT_GROUP, + Type = SHT_GROUP, Alignment = 4, EntrySize = (uint)sizeof(uint), }, @@ -105,7 +107,7 @@ private protected override void CreateSection(ObjectNodeSection section, string }; // Write group flags - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, /*ElfNative.GRP_COMDAT*/1u); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, GRP_COMDAT); groupSection.Stream.Write(tempBuffer); _comdatNameToElfSection.Add(comdatName, groupSection); @@ -131,7 +133,7 @@ private protected override void CreateSection(ObjectNodeSection section, string _symbols.Add(new ElfSymbol { Section = _sections[sectionIndex], - Info = ElfNative.STT_SECTION, + Info = STT_SECTION, }); } @@ -156,37 +158,38 @@ protected internal override void EmitRelocation( // to produce correct addends in the `.rela` sections which override // the destination with the addend from relocation table. - if (relocType == RelocType.IMAGE_REL_BASED_REL32 || - relocType == RelocType.IMAGE_REL_BASED_RELPTR32 || - relocType == RelocType.IMAGE_REL_TLSGD || - relocType == RelocType.IMAGE_REL_TPOFF || - relocType == RelocType.IMAGE_REL_BASED_HIGHLOW) + switch (relocType) { - addend += BinaryPrimitives.ReadInt32LittleEndian(data); - BinaryPrimitives.WriteInt32LittleEndian(data, 0); - } - else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) - { - ulong a = BinaryPrimitives.ReadUInt64LittleEndian(data); - addend += checked((long)a); - BinaryPrimitives.WriteUInt64LittleEndian(data, 0); - } - else if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 || - relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 || - relocType == RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A || - relocType == RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 || - relocType == RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC || - relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 || - relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 || - relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 || - relocType == RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL) - { - // NOTE: Zero addend in code is currently always used for these. - // R2R object writer has the same assumption. - } - else - { - throw new NotSupportedException($"Unsupported relocation: {relocType}"); + case IMAGE_REL_BASED_REL32: + case IMAGE_REL_BASED_RELPTR32: + case IMAGE_REL_BASED_HIGHLOW: + case IMAGE_REL_TLSGD: + case IMAGE_REL_TPOFF: + addend += BinaryPrimitives.ReadInt32LittleEndian(data); + BinaryPrimitives.WriteInt32LittleEndian(data, 0); + break; + + case IMAGE_REL_BASED_DIR64: + ulong a = BinaryPrimitives.ReadUInt64LittleEndian(data); + addend += checked((long)a); + BinaryPrimitives.WriteUInt64LittleEndian(data, 0); + break; + + case IMAGE_REL_BASED_ARM64_BRANCH26: + case IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: + case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: + case IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12: + case IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC: + case IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21: + case IMAGE_REL_AARCH64_TLSDESC_LD64_LO12: + case IMAGE_REL_AARCH64_TLSDESC_ADD_LO12: + case IMAGE_REL_AARCH64_TLSDESC_CALL: + // NOTE: Zero addend in code is currently always used for these. + // R2R object writer has the same assumption. + break; + + default: + throw new NotSupportedException($"Unsupported relocation: {relocType}"); } base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); @@ -201,16 +204,16 @@ private protected override void EmitSymbolTable( { var section = _sections[definition.SectionIndex]; var type = - (section.SectionHeader.Flags & ElfNative.SHF_TLS) == ElfNative.SHF_TLS ? ElfNative.STT_TLS : - definition.Size > 0 ? ElfNative.STT_FUNC : ElfNative.STT_NOTYPE; + (section.SectionHeader.Flags & SHF_TLS) == SHF_TLS ? STT_TLS : + definition.Size > 0 ? STT_FUNC : STT_NOTYPE; sortedSymbols.Add(new ElfSymbol { Name = name, Value = (ulong)definition.Value, Size = (ulong)definition.Size, Section = _sections[definition.SectionIndex], - Info = (byte)(type | (ElfNative.STB_GLOBAL << 4)), - Other = definition.Global ? ElfNative.STV_DEFAULT : ElfNative.STV_HIDDEN, + Info = (byte)(type | (STB_GLOBAL << 4)), + Other = definition.Global ? STV_DEFAULT : STV_HIDDEN, }); } @@ -221,7 +224,7 @@ private protected override void EmitSymbolTable( sortedSymbols.Add(new ElfSymbol { Name = externSymbol, - Info = (ElfNative.STB_GLOBAL << 4), + Info = (STB_GLOBAL << 4), }); } } @@ -247,13 +250,13 @@ private protected override void EmitRelocations(int sectionIndex, List reloc uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_386_32, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_386_PC32, - RelocType.IMAGE_REL_BASED_REL32 => ElfNative.R_386_PLT32, - RelocType.IMAGE_REL_TLSGD => ElfNative.R_386_TLS_GD, - RelocType.IMAGE_REL_TPOFF => ElfNative.R_386_TLS_TPOFF, + IMAGE_REL_BASED_HIGHLOW => R_386_32, + IMAGE_REL_BASED_RELPTR32 => R_386_PC32, + IMAGE_REL_BASED_REL32 => R_386_PLT32, + IMAGE_REL_TLSGD => R_386_TLS_GD, + IMAGE_REL_TPOFF => R_386_TLS_TPOFF, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; long addend = symbolicRelocation.Addend; - if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + if (symbolicRelocation.Type == IMAGE_REL_BASED_REL32) { addend -= 4; } @@ -311,17 +314,17 @@ private void EmitRelocationsX64(int sectionIndex, List reloc uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_X86_64_32, - RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_X86_64_64, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_X86_64_PC32, - RelocType.IMAGE_REL_BASED_REL32 => ElfNative.R_X86_64_PLT32, - RelocType.IMAGE_REL_TLSGD => ElfNative.R_X86_64_TLSGD, - RelocType.IMAGE_REL_TPOFF => ElfNative.R_X86_64_TPOFF32, + IMAGE_REL_BASED_HIGHLOW => R_X86_64_32, + IMAGE_REL_BASED_DIR64 => R_X86_64_64, + IMAGE_REL_BASED_RELPTR32 => R_X86_64_PC32, + IMAGE_REL_BASED_REL32 => R_X86_64_PLT32, + IMAGE_REL_TLSGD => R_X86_64_TLSGD, + IMAGE_REL_TPOFF => R_X86_64_TPOFF32, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; long addend = symbolicRelocation.Addend; - if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_REL32) + if (symbolicRelocation.Type == IMAGE_REL_BASED_REL32) { addend -= 4; } @@ -346,18 +349,18 @@ private void EmitRelocationsARM64(int sectionIndex, List rel uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; uint type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_DIR64 => ElfNative.R_AARCH64_ABS64, - RelocType.IMAGE_REL_BASED_HIGHLOW => ElfNative.R_AARCH64_ABS32, - RelocType.IMAGE_REL_BASED_RELPTR32 => ElfNative.R_AARCH64_PREL32, - RelocType.IMAGE_REL_BASED_ARM64_BRANCH26 => ElfNative.R_AARCH64_CALL26, - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ElfNative.R_AARCH64_ADR_PREL_PG_HI21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ElfNative.R_AARCH64_ADD_ABS_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_HI12, - RelocType.IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => ElfNative.R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => ElfNative.R_AARCH64_TLSDESC_ADR_PAGE21, - RelocType.IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => ElfNative.R_AARCH64_TLSDESC_LD64_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => ElfNative.R_AARCH64_TLSDESC_ADD_LO12, - RelocType.IMAGE_REL_AARCH64_TLSDESC_CALL => ElfNative.R_AARCH64_TLSDESC_CALL, + IMAGE_REL_BASED_DIR64 => R_AARCH64_ABS64, + IMAGE_REL_BASED_HIGHLOW => R_AARCH64_ABS32, + IMAGE_REL_BASED_RELPTR32 => R_AARCH64_PREL32, + IMAGE_REL_BASED_ARM64_BRANCH26 => R_AARCH64_CALL26, + IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => R_AARCH64_ADR_PREL_PG_HI21, + IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => R_AARCH64_ADD_ABS_LO12_NC, + IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12 => R_AARCH64_TLSLE_ADD_TPREL_HI12, + IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC => R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21 => R_AARCH64_TLSDESC_ADR_PAGE21, + IMAGE_REL_AARCH64_TLSDESC_LD64_LO12 => R_AARCH64_TLSDESC_LD64_LO12, + IMAGE_REL_AARCH64_TLSDESC_ADD_LO12 => R_AARCH64_TLSDESC_ADD_LO12, + IMAGE_REL_AARCH64_TLSDESC_CALL => R_AARCH64_TLSDESC_CALL, _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) }; @@ -374,7 +377,7 @@ private protected override void EmitObjectFile(string objectFilePath) using var outputFileStream = new FileStream(objectFilePath, FileMode.Create); switch (_machine) { - case ElfNative.EM_386: + case EM_386: EmitObjectFile(outputFileStream); break; default: @@ -397,7 +400,7 @@ private void EmitObjectFile(FileStream outputFileStream) // Add marker for non-executable stack _sections.Add(new ElfSectionDefinition { - SectionHeader = new ElfSectionHeader { Type = ElfNative.SHT_PROGBITS }, + SectionHeader = new ElfSectionHeader { Type = SHT_PROGBITS }, Name = ".note.GNU-stack", Stream = Stream.Null, }); @@ -427,7 +430,7 @@ private void EmitObjectFile(FileStream outputFileStream) section.SectionHeader.Offset = currentOffset; section.SectionHeader.Size = (ulong)section.Stream.Length; - if (section.SectionHeader.Type != ElfNative.SHT_NOBITS) + if (section.SectionHeader.Type != SHT_NOBITS) { currentOffset += (ulong)section.Stream.Length; } @@ -452,7 +455,7 @@ private void EmitObjectFile(FileStream outputFileStream) // Reserve names for the predefined sections _stringTable.ReserveString(".strtab"); _stringTable.ReserveString(".symtab"); - if (sectionCount >= ElfNative.SHN_LORESERVE) + if (sectionCount >= SHN_LORESERVE) { _stringTable.ReserveString(".symtab_shndx"); hasSymTabExtendedIndices = true; @@ -480,21 +483,21 @@ private void EmitObjectFile(FileStream outputFileStream) // Write the ELF file header ElfHeader elfHeader = new ElfHeader { - Type = ElfNative.ET_REL, + Type = ET_REL, Machine = _machine, - Version = ElfNative.EV_CURRENT, + Version = EV_CURRENT, SegmentHeaderEntrySize = 0x38, SectionHeaderOffset = currentOffset, SectionHeaderEntrySize = (ushort)ElfSectionHeader.GetSize(), - SectionHeaderEntryCount = sectionCount < ElfNative.SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, - StringTableIndex = strTabSectionIndex < ElfNative.SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)ElfNative.SHN_XINDEX, + SectionHeaderEntryCount = sectionCount < SHN_LORESERVE ? (ushort)sectionCount : (ushort)0u, + StringTableIndex = strTabSectionIndex < SHN_LORESERVE ? (ushort)strTabSectionIndex : (ushort)SHN_XINDEX, }; elfHeader.Write(outputFileStream); // Write the section contents and relocations foreach (var section in _sections) { - if (section.SectionHeader.Type != ElfNative.SHT_NOBITS) + if (section.SectionHeader.Type != SHT_NOBITS) { outputFileStream.Position = (long)section.SectionHeader.Offset; section.Stream.Position = 0; @@ -523,7 +526,7 @@ private void EmitObjectFile(FileStream outputFileStream) foreach (var symbol in _symbols) { uint index = symbol.Section?.SectionIndex ?? 0; - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, index >= ElfNative.SHN_LORESERVE ? index : 0); + BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, index >= SHN_LORESERVE ? index : 0); outputFileStream.Write(tempBuffer); } } @@ -534,12 +537,12 @@ private void EmitObjectFile(FileStream outputFileStream) ElfSectionHeader nullSectionHeader = new ElfSectionHeader { NameIndex = 0, - Type = ElfNative.SHT_NULL, + Type = SHT_NULL, Flags = 0u, Address = 0u, Offset = 0u, - Size = sectionCount >= ElfNative.SHN_LORESERVE ? sectionCount : 0u, - Link = strTabSectionIndex >= ElfNative.SHN_LORESERVE ? strTabSectionIndex : 0u, + Size = sectionCount >= SHN_LORESERVE ? sectionCount : 0u, + Link = strTabSectionIndex >= SHN_LORESERVE ? strTabSectionIndex : 0u, Info = 0u, Alignment = 0u, EntrySize = 0u, @@ -552,14 +555,14 @@ private void EmitObjectFile(FileStream outputFileStream) section.SectionHeader.NameIndex = _stringTable.GetStringOffset(section.Name); section.SectionHeader.Write(outputFileStream); - if (section.SectionHeader.Type != ElfNative.SHT_NOBITS && + if (section.SectionHeader.Type != SHT_NOBITS && section.RelocationStream != Stream.Null) { ElfSectionHeader relaSectionHeader = new ElfSectionHeader { NameIndex = _stringTable.GetStringOffset(".rela" + section.Name), - Type = ElfNative.SHT_RELA, - Flags = (section.GroupSection is not null ? ElfNative.SHF_GROUP : 0u) | ElfNative.SHF_INFO_LINK, + Type = SHT_RELA, + Flags = (section.GroupSection is not null ? SHF_GROUP : 0u) | SHF_INFO_LINK, Address = 0u, Offset = section.SectionHeader.Offset + section.SectionHeader.Size, Size = (ulong)section.RelocationStream.Length, @@ -576,7 +579,7 @@ private void EmitObjectFile(FileStream outputFileStream) ElfSectionHeader stringTableSectionHeader = new ElfSectionHeader { NameIndex = _stringTable.GetStringOffset(".strtab"), - Type = ElfNative.SHT_STRTAB, + Type = SHT_STRTAB, Flags = 0u, Address = 0u, Offset = stringTableOffset, @@ -592,7 +595,7 @@ private void EmitObjectFile(FileStream outputFileStream) ElfSectionHeader symbolTableSectionHeader = new ElfSectionHeader { NameIndex = _stringTable.GetStringOffset(".symtab"), - Type = ElfNative.SHT_SYMTAB, + Type = SHT_SYMTAB, Flags = 0u, Address = 0u, Offset = symbolTableOffset, @@ -612,7 +615,7 @@ private void EmitObjectFile(FileStream outputFileStream) ElfSectionHeader sectionHeader = new ElfSectionHeader { NameIndex = _stringTable.GetStringOffset(".symtab_shndx"), - Type = ElfNative.SHT_SYMTAB_SHNDX, + Type = SHT_SYMTAB_SHNDX, Flags = 0u, Address = 0u, Offset = symbolTableExtendedIndicesOffset, @@ -686,8 +689,8 @@ public void Write(FileStream stream) buffer.Clear(); Magic.CopyTo(buffer.Slice(0, Magic.Length)); - buffer[4] = typeof(TSize) == typeof(uint) ? ElfNative.ELFCLASS32 : ElfNative.ELFCLASS64; - buffer[5] = ElfNative.ELFDATA2LSB; + buffer[4] = typeof(TSize) == typeof(uint) ? ELFCLASS32 : ELFCLASS64; + buffer[5] = ELFDATA2LSB; buffer[6] = 1; var tempBuffer = buffer.Slice(16); tempBuffer = tempBuffer.Slice(((IBinaryInteger)Type).WriteLittleEndian(tempBuffer)); @@ -779,8 +782,8 @@ public void Write(FileStream stream, ElfStringTable stringTable) Span buffer = stackalloc byte[GetSize()]; ushort sectionIndex; - sectionIndex = Section is { SectionIndex: >= ElfNative.SHN_LORESERVE } ? - (ushort)ElfNative.SHN_XINDEX : + sectionIndex = Section is { SectionIndex: >= SHN_LORESERVE } ? + (ushort)SHN_XINDEX : (Section is not null ? (ushort)Section.SectionIndex : (ushort)0u); BinaryPrimitives.WriteUInt32LittleEndian(buffer, Name is not null ? stringTable.GetStringOffset(Name) : 0); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index ce4b762ce8e148..0b61271ebf8932 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -13,6 +13,8 @@ using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; +using static ILCompiler.DependencyAnalysis.RelocType; +using static ILCompiler.ObjectWriter.MachNative; namespace ILCompiler.ObjectWriter { @@ -78,13 +80,13 @@ public MachObjectWriter(NodeFactory factory, ObjectWritingOptions options) switch (factory.Target.Architecture) { case TargetArchitecture.ARM64: - _cpuType = MachNative.CPU_TYPE_ARM64; - _cpuSubType = MachNative.CPU_SUBTYPE_ARM64_ALL; + _cpuType = CPU_TYPE_ARM64; + _cpuSubType = CPU_SUBTYPE_ARM64_ALL; _compactUnwindDwarfCode = 0x3_00_00_00u; break; case TargetArchitecture.X64: - _cpuType = MachNative.CPU_TYPE_X86_64; - _cpuSubType = MachNative.CPU_SUBTYPE_X86_64_ALL; + _cpuType = CPU_TYPE_X86_64; + _cpuSubType = CPU_SUBTYPE_X86_64_ALL; _compactUnwindDwarfCode = 0x4_00_00_00u; break; default: @@ -112,7 +114,7 @@ private protected override void EmitSectionsAndLayout() Section = section, Value = section.VirtualAddress, Descriptor = 0, - Type = MachNative.N_SECT, + Type = N_SECT, }; _symbolTable.Add(machSymbol); _symbolNameToIndex[machSymbol.Name] = sectionIndex; @@ -189,10 +191,10 @@ private protected override void EmitObjectFile(string objectFilePath) { CpuType = _cpuType, CpuSubType = _cpuSubType, - FileType = MachNative.MH_OBJECT, + FileType = MH_OBJECT, NumberOfCommands = loadCommandsCount, SizeOfCommands = loadCommandsSize, - Flags = MachNative.MH_SUBSECTIONS_VIA_SYMBOLS, + Flags = MH_SUBSECTIONS_VIA_SYMBOLS, Reserved = 0, }; machHeader.Write(outputFileStream); @@ -200,8 +202,8 @@ private protected override void EmitObjectFile(string objectFilePath) MachSegment64Header machSegment64Header = new MachSegment64Header { Name = "", - InitialProtection = MachNative.VM_PROT_READ | MachNative.VM_PROT_WRITE | MachNative.VM_PROT_EXECUTE, - MaximumProtection = MachNative.VM_PROT_READ | MachNative.VM_PROT_WRITE | MachNative.VM_PROT_EXECUTE, + InitialProtection = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, + MaximumProtection = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE, Address = 0, Size = segmentSize, FileOffset = segmentFileOffset, @@ -241,15 +243,15 @@ private protected override void EmitObjectFile(string objectFilePath) switch (_targetOS) { case TargetOS.OSX: - buildVersion.Platform = MachNative.PLATFORM_MACOS; + buildVersion.Platform = PLATFORM_MACOS; buildVersion.MinimumPlatformVersion = 0x0a_0c_00; // 10.12.0 break; case TargetOS.MacCatalyst: - buildVersion.Platform = MachNative.PLATFORM_MACCATALYST; + buildVersion.Platform = PLATFORM_MACCATALYST; buildVersion.MinimumPlatformVersion = _cpuType switch { - MachNative.CPU_TYPE_X86_64 => 0x0d_05_00u, // 13.5.0 + CPU_TYPE_X86_64 => 0x0d_05_00u, // 13.5.0 _ => 0x0e_02_00u, // 14.2.0 }; break; @@ -260,10 +262,10 @@ private protected override void EmitObjectFile(string objectFilePath) case TargetOS.tvOSSimulator: buildVersion.Platform = _targetOS switch { - TargetOS.iOS => MachNative.PLATFORM_IOS, - TargetOS.iOSSimulator => MachNative.PLATFORM_IOSSIMULATOR, - TargetOS.tvOS => MachNative.PLATFORM_TVOS, - TargetOS.tvOSSimulator => MachNative.PLATFORM_TVOSSIMULATOR, + TargetOS.iOS => PLATFORM_IOS, + TargetOS.iOSSimulator => PLATFORM_IOSSIMULATOR, + TargetOS.tvOS => PLATFORM_TVOS, + TargetOS.tvOSSimulator => PLATFORM_TVOSSIMULATOR, _ => 0, }; buildVersion.MinimumPlatformVersion = 0x0b_00_00; // 11.0.0 @@ -336,19 +338,19 @@ private protected override void CreateSection(ObjectNodeSection section, string uint flags = section.Name switch { - "bss" => MachNative.S_ZEROFILL, - ".eh_frame" => MachNative.S_COALESCED, - _ => section.Type == SectionType.Uninitialized ? MachNative.S_ZEROFILL : MachNative.S_REGULAR + "bss" => S_ZEROFILL, + ".eh_frame" => S_COALESCED, + _ => section.Type == SectionType.Uninitialized ? S_ZEROFILL : S_REGULAR }; flags |= section.Name switch { - ".dotnet_eh_table" => MachNative.S_ATTR_DEBUG, - ".eh_frame" => MachNative.S_ATTR_LIVE_SUPPORT | MachNative.S_ATTR_STRIP_STATIC_SYMS | MachNative.S_ATTR_NO_TOC, + ".dotnet_eh_table" => S_ATTR_DEBUG, + ".eh_frame" => S_ATTR_LIVE_SUPPORT | S_ATTR_STRIP_STATIC_SYMS | S_ATTR_NO_TOC, _ => section.Type switch { - SectionType.Executable => MachNative.S_ATTR_SOME_INSTRUCTIONS | MachNative.S_ATTR_PURE_INSTRUCTIONS, - SectionType.Debug => MachNative.S_ATTR_DEBUG, + SectionType.Executable => S_ATTR_SOME_INSTRUCTIONS | S_ATTR_PURE_INSTRUCTIONS, + SectionType.Debug => S_ATTR_DEBUG, _ => 0 } }; @@ -380,11 +382,11 @@ protected internal override void EmitRelocation( string symbolName, long addend) { - if (relocType is RelocType.IMAGE_REL_BASED_DIR64 or RelocType.IMAGE_REL_BASED_HIGHLOW) + if (relocType is IMAGE_REL_BASED_DIR64 or IMAGE_REL_BASED_HIGHLOW) { // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly MachSection machSection = _sections[sectionIndex]; - if ((machSection.Flags & MachNative.S_ATTR_DEBUG) != 0 && + if ((machSection.Flags & S_ATTR_DEBUG) != 0 && machSection.SegmentName == "__DWARF") { // DWARF section to DWARF section relocation @@ -392,10 +394,10 @@ protected internal override void EmitRelocation( { switch (relocType) { - case RelocType.IMAGE_REL_BASED_DIR64: + case IMAGE_REL_BASED_DIR64: BinaryPrimitives.WriteInt64LittleEndian(data, addend); break; - case RelocType.IMAGE_REL_BASED_HIGHLOW: + case IMAGE_REL_BASED_HIGHLOW: BinaryPrimitives.WriteUInt32LittleEndian(data, (uint)addend); break; default: @@ -407,7 +409,7 @@ protected internal override void EmitRelocation( else { Debug.Assert(IsSectionSymbolName(symbolName)); - Debug.Assert(relocType == RelocType.IMAGE_REL_BASED_DIR64); + Debug.Assert(relocType == IMAGE_REL_BASED_DIR64); int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; BinaryPrimitives.WriteUInt64LittleEndian(data, _sections[targetSectionIndex].VirtualAddress + (ulong)addend); base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); @@ -421,12 +423,12 @@ protected internal override void EmitRelocation( // data. The exceptions are IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 // and IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A. - if (relocType == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + if (relocType == IMAGE_REL_BASED_ARM64_BRANCH26) { - Debug.Assert(_cpuType == MachNative.CPU_TYPE_ARM64); + Debug.Assert(_cpuType == CPU_TYPE_ARM64); Debug.Assert(addend == 0); } - else if (relocType == RelocType.IMAGE_REL_BASED_DIR64) + else if (relocType == IMAGE_REL_BASED_DIR64) { if (addend != 0) { @@ -437,9 +439,9 @@ protected internal override void EmitRelocation( addend = 0; } } - else if (relocType == RelocType.IMAGE_REL_BASED_RELPTR32) + else if (relocType == IMAGE_REL_BASED_RELPTR32) { - if (_cpuType == MachNative.CPU_TYPE_ARM64) + if (_cpuType == CPU_TYPE_ARM64) { // On ARM64 we need to represent PC relative relocations as // subtraction and the PC offset is baked into the addend. @@ -470,9 +472,9 @@ protected internal override void EmitRelocation( } addend = 0; } - else if (relocType == RelocType.IMAGE_REL_BASED_REL32) + else if (relocType == IMAGE_REL_BASED_REL32) { - Debug.Assert(_cpuType != MachNative.CPU_TYPE_ARM64); + Debug.Assert(_cpuType != CPU_TYPE_ARM64); if (addend != 0) { BinaryPrimitives.WriteInt32LittleEndian( @@ -507,7 +509,7 @@ private protected override void EmitSymbolTable( Section = section, Value = section.VirtualAddress + (ulong)definition.Value, Descriptor = 0, - Type = MachNative.N_SECT | MachNative.N_EXT, + Type = N_SECT | N_EXT, }); } sortedDefinedSymbols.Sort((symA, symB) => string.CompareOrdinal(symA.Name, symB.Name)); @@ -532,7 +534,7 @@ private protected override void EmitSymbolTable( Section = null, Value = 0, Descriptor = 0, - Type = MachNative.N_UNDF | MachNative.N_EXT, + Type = N_UNDF | N_EXT, }; _symbolTable.Add(machSymbol); _symbolNameToIndex[externSymbol] = symbolIndex; @@ -548,7 +550,7 @@ private protected override void EmitSymbolTable( private protected override void EmitRelocations(int sectionIndex, List relocationList) { - if (_cpuType == MachNative.CPU_TYPE_ARM64) + if (_cpuType == CPU_TYPE_ARM64) { EmitRelocationsArm64(sectionIndex, relocationList); } @@ -567,7 +569,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) + if (symbolicRelocation.Type == IMAGE_REL_BASED_DIR64) { bool isExternal = !IsSectionSymbolName(symbolicRelocation.SymbolName); sectionRelocations.Add( @@ -576,12 +578,12 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, - RelocationType = MachNative.X86_64_RELOC_UNSIGNED, + RelocationType = X86_64_RELOC_UNSIGNED, IsExternal = isExternal, IsPCRelative = false, }); } - else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32 && sectionIndex == EhFrameSectionIndex) + else if (symbolicRelocation.Type == IMAGE_REL_BASED_RELPTR32 && sectionIndex == EhFrameSectionIndex) { sectionRelocations.Add( new MachRelocation @@ -589,7 +591,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, - RelocationType = MachNative.X86_64_RELOC_SUBTRACTOR, + RelocationType = X86_64_RELOC_SUBTRACTOR, IsExternal = true, IsPCRelative = false, }); @@ -599,12 +601,12 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachNative.X86_64_RELOC_UNSIGNED, + RelocationType = X86_64_RELOC_UNSIGNED, IsExternal = true, IsPCRelative = false, }); } - else if (symbolicRelocation.Type is RelocType.IMAGE_REL_BASED_RELPTR32 or RelocType.IMAGE_REL_BASED_REL32) + else if (symbolicRelocation.Type is IMAGE_REL_BASED_RELPTR32 or IMAGE_REL_BASED_REL32) { sectionRelocations.Add( new MachRelocation @@ -612,7 +614,7 @@ private void EmitRelocationsX64(int sectionIndex, List reloc Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachNative.X86_64_RELOC_BRANCH, + RelocationType = X86_64_RELOC_BRANCH, IsExternal = true, IsPCRelative = true, }); @@ -633,7 +635,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel { uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; - if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_ARM64_BRANCH26) + if (symbolicRelocation.Type == IMAGE_REL_BASED_ARM64_BRANCH26) { sectionRelocations.Add( new MachRelocation @@ -641,12 +643,12 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachNative.ARM64_RELOC_BRANCH26, + RelocationType = ARM64_RELOC_BRANCH26, IsExternal = true, IsPCRelative = true, }); } - else if (symbolicRelocation.Type is RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 or RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) + else if (symbolicRelocation.Type is IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 or IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A) { if (symbolicRelocation.Addend != 0) { @@ -656,7 +658,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)symbolicRelocation.Addend, Length = 4, - RelocationType = MachNative.ARM64_RELOC_ADDEND, + RelocationType = ARM64_RELOC_ADDEND, IsExternal = false, IsPCRelative = false, }); @@ -664,8 +666,8 @@ private void EmitRelocationsArm64(int sectionIndex, List rel byte type = symbolicRelocation.Type switch { - RelocType.IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => MachNative.ARM64_RELOC_PAGE21, - RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => MachNative.ARM64_RELOC_PAGEOFF12, + IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 => ARM64_RELOC_PAGE21, + IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A => ARM64_RELOC_PAGEOFF12, _ => 0 }; @@ -677,10 +679,10 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Length = 4, RelocationType = type, IsExternal = true, - IsPCRelative = symbolicRelocation.Type != RelocType.IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A, + IsPCRelative = symbolicRelocation.Type != IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A, }); } - else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_DIR64) + else if (symbolicRelocation.Type == IMAGE_REL_BASED_DIR64) { bool isExternal = !IsSectionSymbolName(symbolicRelocation.SymbolName); sectionRelocations.Add( @@ -689,12 +691,12 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = isExternal ? symbolIndex : symbolIndex + 1, Length = 8, - RelocationType = MachNative.ARM64_RELOC_UNSIGNED, + RelocationType = ARM64_RELOC_UNSIGNED, IsExternal = isExternal, IsPCRelative = false, }); } - else if (symbolicRelocation.Type == RelocType.IMAGE_REL_BASED_RELPTR32) + else if (symbolicRelocation.Type == IMAGE_REL_BASED_RELPTR32) { // This one is tough... needs to be represented by ARM64_RELOC_SUBTRACTOR + ARM64_RELOC_UNSIGNED. sectionRelocations.Add( @@ -703,7 +705,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = (uint)sectionIndex, Length = 4, - RelocationType = MachNative.ARM64_RELOC_SUBTRACTOR, + RelocationType = ARM64_RELOC_SUBTRACTOR, IsExternal = true, IsPCRelative = false, }); @@ -713,7 +715,7 @@ private void EmitRelocationsArm64(int sectionIndex, List rel Address = (int)symbolicRelocation.Offset, SymbolOrSectionIndex = symbolIndex, Length = 4, - RelocationType = MachNative.ARM64_RELOC_UNSIGNED, + RelocationType = ARM64_RELOC_UNSIGNED, IsExternal = true, IsPCRelative = false, }); @@ -734,7 +736,7 @@ private void EmitCompactUnwindTable(IDictionary define _compactUnwindSection = new MachSection("__LD", "__compact_unwind", _compactUnwindStream) { Log2Alignment = 3, - Flags = MachNative.S_REGULAR | MachNative.S_ATTR_DEBUG, + Flags = S_REGULAR | S_ATTR_DEBUG, }; IList symbols = _symbolTable; @@ -763,7 +765,7 @@ void EmitCompactUnwindSymbol(string symbolName) Address = (int)_compactUnwindStream.Position, SymbolOrSectionIndex = (byte)(1 + symbol.SectionIndex), // 1-based Length = 8, - RelocationType = MachNative.ARM64_RELOC_UNSIGNED, + RelocationType = ARM64_RELOC_UNSIGNED, IsExternal = false, IsPCRelative = false, } @@ -800,7 +802,7 @@ private protected override bool EmitCompactUnwinding(string startSymbolName, ulo { uint encoding = _compactUnwindDwarfCode; - if (_cpuType == MachNative.CPU_TYPE_ARM64) + if (_cpuType == CPU_TYPE_ARM64) { if (blob.AsSpan().SequenceEqual(DwarfArm64EmptyFrame)) { @@ -839,7 +841,7 @@ public void Write(FileStream stream) { Span buffer = stackalloc byte[HeaderSize]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.MH_MAGIC_64); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MH_MAGIC_64); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)CpuType); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), CpuSubType); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), FileType); @@ -870,7 +872,7 @@ public void Write(FileStream stream) { Span buffer = stackalloc byte[HeaderSize]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.LC_SEGMENT_64); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), LC_SEGMENT_64); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)(HeaderSize + NumberOfSections * MachSection.HeaderSize)); bool encoded = Encoding.UTF8.TryGetBytes(Name, buffer.Slice(8, 16), out _); Debug.Assert(encoded); @@ -903,7 +905,7 @@ private sealed class MachSection public uint Flags { get; set; } public uint Type => Flags & 0xff; - public bool IsInFile => Size > 0 && Type != MachNative.S_ZEROFILL && Type != MachNative.S_GB_ZEROFILL && Type != MachNative.S_THREAD_LOCAL_ZEROFILL; + public bool IsInFile => Size > 0 && Type != S_ZEROFILL && Type != S_GB_ZEROFILL && Type != S_THREAD_LOCAL_ZEROFILL; public IList Relocations => relocationCollection ??= new List(); public Stream Stream => dataStream; @@ -1002,7 +1004,7 @@ public void Write(FileStream stream) { Span buffer = stackalloc byte[HeaderSize]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), (uint)MachNative.LC_SYMTAB); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), LC_SYMTAB); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), SymbolTableOffset); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), NumberOfSymbols); @@ -1040,7 +1042,7 @@ public void Write(FileStream stream) { Span buffer = stackalloc byte[HeaderSize]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), (uint)MachNative.LC_DYSYMTAB); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), LC_DYSYMTAB); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), LocalSymbolsIndex); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), LocalSymbolsCount); @@ -1077,7 +1079,7 @@ public void Write(FileStream stream) { Span buffer = stackalloc byte[HeaderSize]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), MachNative.LC_BUILD_VERSION); + BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(0, 4), LC_BUILD_VERSION); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4, 4), (uint)HeaderSize); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8, 4), Platform); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(12, 4), MinimumPlatformVersion); From deb4df20d804ecb553f1db52747ac25b7085b38c Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 17 Dec 2023 23:41:40 +0100 Subject: [PATCH 125/144] Use Relocation.ReadValue/WriteValue instead of manual implementation of the same --- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 78 +++------ .../Compiler/ObjectWriter/ElfObjectWriter.cs | 41 +---- .../Compiler/ObjectWriter/MachObjectWriter.cs | 151 ++++++++---------- 3 files changed, 92 insertions(+), 178 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 1bf5f1927756ba..155824e0ccd868 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -180,7 +180,7 @@ protected internal override void UpdateSectionAlignment(int sectionIndex, int al } } - protected internal override void EmitRelocation( + protected internal override unsafe void EmitRelocation( int sectionIndex, long offset, Span data, @@ -188,67 +188,27 @@ protected internal override void EmitRelocation( string symbolName, long addend) { - switch (relocType) + if (relocType is IMAGE_REL_BASED_RELPTR32) { - case IMAGE_REL_BASED_ARM64_BRANCH26: - case IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: - case IMAGE_REL_SECREL: - case IMAGE_REL_SECTION: - Debug.Assert(addend == 0); - break; - - case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: - if (addend != 0) - { - uint addInstr = BinaryPrimitives.ReadUInt32LittleEndian(data); - addInstr &= 0xFFC003FF; // keep bits 31-22, 9-0 - addInstr |= (uint)(addend << 10); // Occupy 21-10. - BinaryPrimitives.WriteUInt32LittleEndian(data, addInstr); // write the assembled instruction - } - break; - - case IMAGE_REL_BASED_DIR64: - if (addend != 0) - { - BinaryPrimitives.WriteInt64LittleEndian( - data, - BinaryPrimitives.ReadInt64LittleEndian(data) + - addend); - addend = 0; - } - break; - - case IMAGE_REL_BASED_RELPTR32: - addend += 4; - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)addend); - addend = 0; - } - break; - - case IMAGE_REL_BASED_REL32: - case IMAGE_REL_BASED_ADDR32NB: - case IMAGE_REL_BASED_ABSOLUTE: - case IMAGE_REL_BASED_HIGHLOW: - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)addend); - addend = 0; - } - break; - - default: - throw new NotSupportedException($"Unsupported relocation: {relocType}"); + addend += 4; + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + (int)addend); + } + } + else if (addend != 0) + { + fixed (byte *pData = data) + { + long inlineValue = Relocation.ReadValue(relocType, (void*)pData); + Relocation.WriteValue(relocType, (void*)pData, inlineValue + addend); + } } - base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, 0); } private protected override void EmitReferencedMethod(string symbolName) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index b6a50dd5608c6c..7c2d3653248d73 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -146,7 +146,7 @@ protected internal override void UpdateSectionAlignment(int sectionIndex, int al elfSection.SectionHeader.Alignment = Math.Max(elfSection.SectionHeader.Alignment, (ulong)alignment); } - protected internal override void EmitRelocation( + protected internal override unsafe void EmitRelocation( int sectionIndex, long offset, Span data, @@ -157,39 +157,14 @@ protected internal override void EmitRelocation( // We read the addend from the data and clear it. This is necessary // to produce correct addends in the `.rela` sections which override // the destination with the addend from relocation table. - - switch (relocType) + fixed (byte *pData = data) { - case IMAGE_REL_BASED_REL32: - case IMAGE_REL_BASED_RELPTR32: - case IMAGE_REL_BASED_HIGHLOW: - case IMAGE_REL_TLSGD: - case IMAGE_REL_TPOFF: - addend += BinaryPrimitives.ReadInt32LittleEndian(data); - BinaryPrimitives.WriteInt32LittleEndian(data, 0); - break; - - case IMAGE_REL_BASED_DIR64: - ulong a = BinaryPrimitives.ReadUInt64LittleEndian(data); - addend += checked((long)a); - BinaryPrimitives.WriteUInt64LittleEndian(data, 0); - break; - - case IMAGE_REL_BASED_ARM64_BRANCH26: - case IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: - case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: - case IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_HI12: - case IMAGE_REL_AARCH64_TLSLE_ADD_TPREL_LO12_NC: - case IMAGE_REL_AARCH64_TLSDESC_ADR_PAGE21: - case IMAGE_REL_AARCH64_TLSDESC_LD64_LO12: - case IMAGE_REL_AARCH64_TLSDESC_ADD_LO12: - case IMAGE_REL_AARCH64_TLSDESC_CALL: - // NOTE: Zero addend in code is currently always used for these. - // R2R object writer has the same assumption. - break; - - default: - throw new NotSupportedException($"Unsupported relocation: {relocType}"); + long inlineValue = Relocation.ReadValue(relocType, (void*)pData); + if (inlineValue != 0) + { + addend += inlineValue; + Relocation.WriteValue(relocType, (void*)pData, 0); + } } base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index 0b61271ebf8932..d3186021698a71 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -374,7 +374,7 @@ protected internal override void UpdateSectionAlignment(int sectionIndex, int al machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment)); } - protected internal override void EmitRelocation( + protected internal override unsafe void EmitRelocation( int sectionIndex, long offset, Span data, @@ -382,107 +382,83 @@ protected internal override void EmitRelocation( string symbolName, long addend) { - if (relocType is IMAGE_REL_BASED_DIR64 or IMAGE_REL_BASED_HIGHLOW) + // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly + if (relocType is IMAGE_REL_BASED_DIR64 or IMAGE_REL_BASED_HIGHLOW && + _sections[sectionIndex].IsDwarfSection) { - // Mach-O doesn't use relocations between DWARF sections, so embed the offsets directly - MachSection machSection = _sections[sectionIndex]; - if ((machSection.Flags & S_ATTR_DEBUG) != 0 && - machSection.SegmentName == "__DWARF") + // DWARF section to DWARF section relocation + if (symbolName.StartsWith('.')) { - // DWARF section to DWARF section relocation - if (symbolName.StartsWith('.')) + switch (relocType) { - switch (relocType) - { - case IMAGE_REL_BASED_DIR64: - BinaryPrimitives.WriteInt64LittleEndian(data, addend); - break; - case IMAGE_REL_BASED_HIGHLOW: - BinaryPrimitives.WriteUInt32LittleEndian(data, (uint)addend); - break; - default: - throw new NotSupportedException("Unsupported relocation in debug section"); - } - return; - } - // DWARF section to code/data section relocation - else - { - Debug.Assert(IsSectionSymbolName(symbolName)); - Debug.Assert(relocType == IMAGE_REL_BASED_DIR64); - int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; - BinaryPrimitives.WriteUInt64LittleEndian(data, _sections[targetSectionIndex].VirtualAddress + (ulong)addend); - base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); + case IMAGE_REL_BASED_DIR64: + BinaryPrimitives.WriteInt64LittleEndian(data, addend); + break; + case IMAGE_REL_BASED_HIGHLOW: + BinaryPrimitives.WriteUInt32LittleEndian(data, (uint)addend); + break; + default: + throw new NotSupportedException("Unsupported relocation in debug section"); } - return; } - } - - // For most relocations we write the addend directly into the - // data. The exceptions are IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 - // and IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A. - - if (relocType == IMAGE_REL_BASED_ARM64_BRANCH26) - { - Debug.Assert(_cpuType == CPU_TYPE_ARM64); - Debug.Assert(addend == 0); - } - else if (relocType == IMAGE_REL_BASED_DIR64) - { - if (addend != 0) + // DWARF section to code/data section relocation + else { - BinaryPrimitives.WriteInt64LittleEndian( - data, - BinaryPrimitives.ReadInt64LittleEndian(data) + - addend); - addend = 0; + Debug.Assert(IsSectionSymbolName(symbolName)); + Debug.Assert(relocType == IMAGE_REL_BASED_DIR64); + int targetSectionIndex = (int)_symbolNameToIndex[symbolName]; + BinaryPrimitives.WriteUInt64LittleEndian(data, _sections[targetSectionIndex].VirtualAddress + (ulong)addend); + base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); } + + return; } - else if (relocType == IMAGE_REL_BASED_RELPTR32) + + switch (relocType) { - if (_cpuType == CPU_TYPE_ARM64) - { - // On ARM64 we need to represent PC relative relocations as - // subtraction and the PC offset is baked into the addend. - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)(addend - offset)); - } - else if (sectionIndex == EhFrameSectionIndex) - { - // ld64 requires X86_64_RELOC_SUBTRACTOR + X86_64_RELOC_UNSIGNED - // for DWARF CFI sections - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)(addend - offset)); - } - else - { - addend += 4; - if (addend != 0) + case IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: + case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: + // Addend is handled through ARM64_RELOC_ADDEND + break; + + case IMAGE_REL_BASED_RELPTR32: + if (_cpuType == CPU_TYPE_ARM64 || sectionIndex == EhFrameSectionIndex) { + // On ARM64 we need to represent PC relative relocations as + // subtraction and the PC offset is baked into the addend. + // On x64, ld64 requires X86_64_RELOC_SUBTRACTOR + X86_64_RELOC_UNSIGNED + // for DWARF .eh_frame section. BinaryPrimitives.WriteInt32LittleEndian( data, BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)addend); + (int)(addend - offset)); + } + else + { + addend += 4; + if (addend != 0) + { + BinaryPrimitives.WriteInt32LittleEndian( + data, + BinaryPrimitives.ReadInt32LittleEndian(data) + + (int)addend); + } } - } - addend = 0; - } - else if (relocType == IMAGE_REL_BASED_REL32) - { - Debug.Assert(_cpuType != CPU_TYPE_ARM64); - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)addend); addend = 0; - } + break; + + default: + if (addend != 0) + { + fixed (byte *pData = data) + { + long inlineValue = Relocation.ReadValue(relocType, (void*)pData); + Relocation.WriteValue(relocType, (void*)pData, inlineValue + addend); + addend = 0; + } + } + break; } base.EmitRelocation(sectionIndex, offset, data, relocType, symbolName, addend); @@ -907,6 +883,8 @@ private sealed class MachSection public uint Type => Flags & 0xff; public bool IsInFile => Size > 0 && Type != S_ZEROFILL && Type != S_GB_ZEROFILL && Type != S_THREAD_LOCAL_ZEROFILL; + public bool IsDwarfSection { get; } + public IList Relocations => relocationCollection ??= new List(); public Stream Stream => dataStream; public byte SectionIndex { get; set; } @@ -920,6 +898,7 @@ public MachSection(string segmentName, string sectionName, Stream stream) this.SegmentName = segmentName; this.SectionName = sectionName; + this.IsDwarfSection = segmentName == "__DWARF"; this.dataStream = stream; this.relocationCollection = null; } From 9c24e714c86cb54f71314a1acd5db6736a3f242d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 18 Dec 2023 00:15:56 +0100 Subject: [PATCH 126/144] Fix handling of IMAGE_REL_BASED_RELPTR32 in the last commit --- .../Common/Compiler/DependencyAnalysis/Relocation.cs | 1 + .../Compiler/ObjectWriter/CoffObjectWriter.cs | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs index 6c12dbbd1e607e..2007690435e4f8 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs @@ -426,6 +426,7 @@ public static unsafe void WriteValue(RelocType relocType, void* location, long v case RelocType.IMAGE_REL_BASED_ABSOLUTE: case RelocType.IMAGE_REL_BASED_HIGHLOW: case RelocType.IMAGE_REL_BASED_REL32: + case RelocType.IMAGE_REL_BASED_RELPTR32: case RelocType.IMAGE_REL_BASED_ADDR32NB: case RelocType.IMAGE_REL_SYMBOL_SIZE: case RelocType.IMAGE_REL_FILE_ABSOLUTE: diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 155824e0ccd868..04b6a2409dda6b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -191,15 +191,9 @@ protected internal override unsafe void EmitRelocation( if (relocType is IMAGE_REL_BASED_RELPTR32) { addend += 4; - if (addend != 0) - { - BinaryPrimitives.WriteInt32LittleEndian( - data, - BinaryPrimitives.ReadInt32LittleEndian(data) + - (int)addend); - } } - else if (addend != 0) + + if (addend != 0) { fixed (byte *pData = data) { From 2c92fd5ab3e225985d72b76d0d81a3515aeca3dd Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 18 Dec 2023 18:38:29 +0100 Subject: [PATCH 127/144] Add missing enum values in Relocation.WriteValue --- .../tools/Common/Compiler/DependencyAnalysis/Relocation.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs index 2007690435e4f8..18713ba7cb79cd 100644 --- a/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs +++ b/src/coreclr/tools/Common/Compiler/DependencyAnalysis/Relocation.cs @@ -424,10 +424,13 @@ public static unsafe void WriteValue(RelocType relocType, void* location, long v switch (relocType) { case RelocType.IMAGE_REL_BASED_ABSOLUTE: + case RelocType.IMAGE_REL_BASED_ADDR32NB: case RelocType.IMAGE_REL_BASED_HIGHLOW: case RelocType.IMAGE_REL_BASED_REL32: case RelocType.IMAGE_REL_BASED_RELPTR32: - case RelocType.IMAGE_REL_BASED_ADDR32NB: + case RelocType.IMAGE_REL_SECREL: + case RelocType.IMAGE_REL_TLSGD: + case RelocType.IMAGE_REL_TPOFF: case RelocType.IMAGE_REL_SYMBOL_SIZE: case RelocType.IMAGE_REL_FILE_ABSOLUTE: *(int*)location = (int)value; From 4cce3742588cc69bc6d53b86aa02fe747f56f0b6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 08:34:02 +0100 Subject: [PATCH 128/144] Apply readonly on class members where appropriate --- .../CodeView/CodeViewFileTableBuilder.cs | 6 +++--- .../CodeView/CodeViewTypesBuilder.cs | 12 +++++------ .../Compiler/ObjectWriter/CoffObjectWriter.cs | 20 +++++++++---------- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 2 +- .../ObjectWriter/Dwarf/DwarfEhFrame.cs | 7 +++---- .../Dwarf/DwarfExpressionBuilder.cs | 6 +++--- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 4 ++-- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs index 234374e1cc1bfc..49f70b405a1a67 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs @@ -15,9 +15,9 @@ namespace ILCompiler.ObjectWriter { internal sealed class CodeViewFileTableBuilder { - private MemoryStream _stringTableWriter = new(); - private MemoryStream _fileTableWriter = new(); - private Dictionary _fileNameToIndex = new(); + private readonly MemoryStream _stringTableWriter = new(); + private readonly MemoryStream _fileTableWriter = new(); + private readonly Dictionary _fileNameToIndex = new(); public CodeViewFileTableBuilder() { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs index c8bd37545472cc..dddb3d45c40ada 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs @@ -38,13 +38,13 @@ namespace ILCompiler.ObjectWriter /// internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter { - private NameMangler _nameMangler; - private SectionWriter _sectionWriter; - private int _targetPointerSize; + private readonly NameMangler _nameMangler; + private readonly SectionWriter _sectionWriter; + private readonly int _targetPointerSize; - private uint _classVTableTypeIndex; - private uint _vfuncTabTypeIndex; - private List<(string, uint)> _userDefinedTypes = new(); + private readonly uint _classVTableTypeIndex; + private readonly uint _vfuncTabTypeIndex; + private readonly List<(string, uint)> _userDefinedTypes = new(); private uint _nextTypeIndex = 0x1000; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 04b6a2409dda6b..10464b83d5d821 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -49,14 +49,14 @@ internal sealed class CoffObjectWriter : ObjectWriter { private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, List Relocations, string ComdatName, string SymbolName); - private Machine _machine; - private List _sections = new(); + private readonly Machine _machine; + private readonly List _sections = new(); // Symbol table - private List _symbols = new(); - private Dictionary _symbolNameToIndex = new(StringComparer.Ordinal); - private Dictionary _sectionNumberToComdatAuxRecord = new(); - private HashSet _referencedMethods = new(); + private readonly List _symbols = new(); + private readonly Dictionary _symbolNameToIndex = new(StringComparer.Ordinal); + private readonly Dictionary _sectionNumberToComdatAuxRecord = new(); + private readonly HashSet _referencedMethods = new(); // Exception handling private SectionWriter _xdataSectionWriter; @@ -69,10 +69,10 @@ private sealed record SectionDefinition(CoffSectionHeader Header, Stream Stream, private CodeViewSymbolsBuilder _debugSymbolsBuilder; private CodeViewTypesBuilder _debugTypesBuilder; - private ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); - private ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); - private ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); - private ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); + private static readonly ObjectNodeSection PDataSection = new ObjectNodeSection("pdata", SectionType.ReadOnly); + private static readonly ObjectNodeSection GfidsSection = new ObjectNodeSection(".gfids$y", SectionType.ReadOnly); + private static readonly ObjectNodeSection DebugTypesSection = new ObjectNodeSection(".debug$T", SectionType.ReadOnly); + private static readonly ObjectNodeSection DebugSymbolSection = new ObjectNodeSection(".debug$S", SectionType.ReadOnly); public CoffObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index f5c53d577aab1c..4e2a9613c02839 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -7,7 +7,7 @@ namespace ILCompiler.ObjectWriter { internal sealed class DwarfAbbrev { - private ushort[] _definition; + private readonly ushort[] _definition; public static ushort DW_FORM_size = 0xdead; // Dummy value diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 0c9b7396057f31..ef098581385c39 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -14,15 +14,14 @@ namespace ILCompiler.ObjectWriter { internal sealed class DwarfEhFrame { - private SectionWriter _sectionWriter; - private bool _is64Bit; - private Dictionary _cieOffset; + private readonly SectionWriter _sectionWriter; + private readonly bool _is64Bit; + private readonly Dictionary _cieOffset = new(); public DwarfEhFrame(SectionWriter sectionWriter, bool is64Bit) { _sectionWriter = sectionWriter; _is64Bit = is64Bit; - _cieOffset = new Dictionary(); } public void AddCie(DwarfCie cie) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs index 3627123d96bd23..98fb159e047746 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfExpressionBuilder.cs @@ -10,9 +10,9 @@ namespace ILCompiler.ObjectWriter { internal ref struct DwarfExpressionBuilder { - private TargetArchitecture _architecture; - private byte _targetPointerSize; - private IBufferWriter _writer; + private readonly TargetArchitecture _architecture; + private readonly byte _targetPointerSize; + private readonly IBufferWriter _writer; public DwarfExpressionBuilder(TargetArchitecture architecture, byte targetPointerSize, IBufferWriter writer) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index 2a5720be1f7311..d42571c4167f3b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -10,13 +10,13 @@ namespace ILCompiler.ObjectWriter { internal sealed class DwarfFde { - public DwarfCie Cie; + public readonly DwarfCie Cie; public string PcStartSymbolName; public long PcStartSymbolOffset; public ulong PcLength; public string LsdaSymbolName; public string PersonalitySymbolName; - public byte[] Instructions; + public readonly byte[] Instructions; public DwarfFde(DwarfCie cie, byte[] instructions) { From 1c10dced9a9d192c843f0713b3005aaf66c64678 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 08:35:20 +0100 Subject: [PATCH 129/144] Zero-initialize stackalloc --- .../Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs index 49f70b405a1a67..f5df97d36b267d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs @@ -22,7 +22,7 @@ internal sealed class CodeViewFileTableBuilder public CodeViewFileTableBuilder() { // Insert empty entry at the beginning of string table - _stringTableWriter.Write(stackalloc byte[2]); + _stringTableWriter.Write(stackalloc byte[2] { 0, 0 }); } public uint GetFileIndex(string fileName) From af416b8d3e7bfeab2985b8eed7e2f5589f28a33b Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 08:39:11 +0100 Subject: [PATCH 130/144] Add comments; few missed readonly members --- .../CodeView/CodeViewFileTableBuilder.cs | 3 +++ .../CodeView/CodeViewSymbolsBuilder.cs | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs index f5df97d36b267d..817ab7a40f71fb 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewFileTableBuilder.cs @@ -29,6 +29,9 @@ public uint GetFileIndex(string fileName) { if (fileName == "") { + // Match the placeholder value from LLVM. We need to use a non-empty + // string to ensure that the null terminator of the UTF-8 representation + // is not treated as the terminator of the whole file name table. fileName = ""; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs index bd78e52ba7cd94..e8faabae519391 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewSymbolsBuilder.cs @@ -40,8 +40,8 @@ namespace ILCompiler.ObjectWriter /// internal sealed class CodeViewSymbolsBuilder { - private TargetArchitecture _targetArchitecture; - private SectionWriter _sectionWriter; + private readonly TargetArchitecture _targetArchitecture; + private readonly SectionWriter _sectionWriter; public CodeViewSymbolsBuilder(TargetArchitecture targetArchitecture, SectionWriter sectionWriter) { @@ -243,8 +243,10 @@ public void EmitLineInfo( if (codes.Count > 0) { recordWriter.Write(fileIndex); + // Number of code pairs (ie. offset + sequence code) recordWriter.Write((uint)(codes.Count / 2)); - recordWriter.Write((uint)(12 + 4 * codes.Count)); + // Record size including this header + recordWriter.Write((uint)(3 * sizeof(uint) + codes.Count * sizeof(uint))); foreach (uint code in codes) { recordWriter.Write((uint)code); @@ -293,11 +295,11 @@ private SubsectionWriter GetSubsection(DebugSymbolsSubsectionType subsectionKind private sealed class SubsectionWriter : IDisposable { - private DebugSymbolsSubsectionType _kind; - private SectionWriter _sectionWriter; + private readonly DebugSymbolsSubsectionType _kind; + private readonly SectionWriter _sectionWriter; internal uint _size; - internal List _data = new(); - internal List<(uint, RelocType, string)> _relocations = new(); + internal readonly List _data = new(); + internal readonly List<(uint, RelocType, string)> _relocations = new(); public SubsectionWriter(DebugSymbolsSubsectionType kind, SectionWriter sectionWriter) { @@ -345,9 +347,9 @@ public RecordWriter StartRecord(CodeViewSymbolDefinition recordType) private ref struct RecordWriter { - private SubsectionWriter _subsectionWriter; - private ArrayBufferWriter _bufferWriter; - private bool _hasLengthPrefix; + private readonly SubsectionWriter _subsectionWriter; + private readonly ArrayBufferWriter _bufferWriter; + private readonly bool _hasLengthPrefix; public RecordWriter(SubsectionWriter subsectionWriter, bool hasLengthPrefix) { From 8e5ed26aeaaf72526366c235254fedb08bcaf4cd Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 08:41:19 +0100 Subject: [PATCH 131/144] Use 'static readonly' for reminder of ObjectNodeSection members --- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index b80f4c28780f23..a76db546ff00ed 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -32,15 +32,15 @@ private sealed record UnixSectionDefinition(string SymbolName, Stream SectionStr protected int EhFrameSectionIndex => _ehFrameSectionIndex; - private static ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null); - private static ObjectNodeSection EhFrameSection = new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null); - private readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); - private readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); - private readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); - private readonly ObjectNodeSection DebugLocSection = new ObjectNodeSection(".debug_loc", SectionType.Debug); - private readonly ObjectNodeSection DebugRangesSection = new ObjectNodeSection(".debug_ranges", SectionType.Debug); - private readonly ObjectNodeSection DebugLineSection = new ObjectNodeSection(".debug_line", SectionType.Debug); - private readonly ObjectNodeSection DebugARangesSection = new ObjectNodeSection(".debug_aranges", SectionType.Debug); + private static readonly ObjectNodeSection LsdaSection = new ObjectNodeSection(".dotnet_eh_table", SectionType.ReadOnly, null); + private static readonly ObjectNodeSection EhFrameSection = new ObjectNodeSection(".eh_frame", SectionType.ReadOnly, null); + private static readonly ObjectNodeSection DebugInfoSection = new ObjectNodeSection(".debug_info", SectionType.Debug); + private static readonly ObjectNodeSection DebugStringSection = new ObjectNodeSection(".debug_str", SectionType.Debug); + private static readonly ObjectNodeSection DebugAbbrevSection = new ObjectNodeSection(".debug_abbrev", SectionType.Debug); + private static readonly ObjectNodeSection DebugLocSection = new ObjectNodeSection(".debug_loc", SectionType.Debug); + private static readonly ObjectNodeSection DebugRangesSection = new ObjectNodeSection(".debug_ranges", SectionType.Debug); + private static readonly ObjectNodeSection DebugLineSection = new ObjectNodeSection(".debug_line", SectionType.Debug); + private static readonly ObjectNodeSection DebugARangesSection = new ObjectNodeSection(".debug_aranges", SectionType.Debug); protected UnixObjectWriter(NodeFactory factory, ObjectWritingOptions options) : base(factory, options) From 2f3df76e5c926e9e4cedce147d88f7c7c6def571 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 08:45:27 +0100 Subject: [PATCH 132/144] Pass target pointer size to CodeViewTypesBuilder instead of target architecture --- .../ObjectWriter/CodeView/CodeViewTypesBuilder.cs | 11 +++-------- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs index dddb3d45c40ada..662e9edc8b52b8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs @@ -50,16 +50,11 @@ internal sealed class CodeViewTypesBuilder : ITypesDebugInfoWriter public IList<(string, uint)> UserDefinedTypes => _userDefinedTypes; - public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetArchitecture, SectionWriter sectionWriter) + public CodeViewTypesBuilder(NameMangler nameMangler, int targetPointerSize, SectionWriter sectionWriter) { _nameMangler = nameMangler; _sectionWriter = sectionWriter; - _targetPointerSize = targetArchitecture switch - { - TargetArchitecture.ARM => 4, - TargetArchitecture.X86 => 4, - _ => 8, - }; + _targetPointerSize = targetPointerSize; // Write CodeView version header Span versionBuffer = stackalloc byte[sizeof(uint)]; @@ -79,7 +74,7 @@ public CodeViewTypesBuilder(NameMangler nameMangler, TargetArchitecture targetAr using (LeafRecordWriter record = StartLeafRecord(LF_POINTER)) { record.Write(_classVTableTypeIndex); - record.Write((uint)((_targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | CV_PTR_MODE_LVREF)); + record.Write((uint)((targetPointerSize == 8 ? CV_PTR_64 : CV_PTR_NEAR32) | CV_PTR_MODE_LVREF)); } _vfuncTabTypeIndex = _nextTypeIndex++; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index 10464b83d5d821..da5340d8b1db41 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -583,7 +583,7 @@ private protected override ITypesDebugInfoWriter CreateDebugInfoBuilder() _debugTypesSectionWriter = GetOrCreateSection(DebugTypesSection); _debugTypesSectionWriter.EmitAlignment(4); _debugTypesBuilder = new CodeViewTypesBuilder( - _nodeFactory.NameMangler, _nodeFactory.Target.Architecture, + _nodeFactory.NameMangler, _nodeFactory.Target.PointerSize, _debugTypesSectionWriter); return _debugTypesBuilder; } From e9709273fbcfeec4968f288dd01fac6a68dd77c7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 11:12:24 +0100 Subject: [PATCH 133/144] Set attribute values in CodeViewTypesBuilder --- .../ObjectWriter/CodeView/CodeViewNative.cs | 20 +++++++++++++ .../CodeView/CodeViewTypesBuilder.cs | 29 ++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs index 5186df320a0826..20e6ebd14c896a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs @@ -2091,6 +2091,26 @@ public enum CodeViewRegister : ushort CV_AMD64_YMM15D3 = 687, } + // Matches CV_access_e + public enum CodeViewMemberAccess : byte + { + CV_private = 1, + CV_protected = 2, + CV_public = 3, + } + + // Matches CV_methodprop_e + public enum CodeViewMethodKind : byte + { + CV_MTvanilla = 0, + CV_MTvirtual = 1, + CV_MTstatic = 2, + CV_MTfriend = 3, + CV_MTintro = 4, + CV_MTpurevirt = 5, + CV_MTpureintro = 6, + } + public enum CodeViewSymbolDefinition : ushort { S_COMPILE = 0x0001, // Compile flags symbol diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs index 662e9edc8b52b8..ba600a349d4b89 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs @@ -144,7 +144,7 @@ public uint GetArrayTypeIndex( if (classDescriptor.BaseClassId != 0) { fieldListRecord.StartListEntry(LF_BCLASS); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)0); // Attributes fieldListRecord.Write(classDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset fieldListRecord.EndListEntry(); @@ -153,7 +153,7 @@ public uint GetArrayTypeIndex( } fieldListRecord.StartListEntry(LF_MEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write("count"); @@ -166,7 +166,7 @@ public uint GetArrayTypeIndex( for (uint i = 0; i < arrayDescriptor.Rank; ++i) { fieldListRecord.StartListEntry(LF_MEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write($"length{i}"); @@ -178,7 +178,7 @@ public uint GetArrayTypeIndex( for (uint i = 0; i < arrayDescriptor.Rank; ++i) { fieldListRecord.StartListEntry(LF_MEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(T_INT4); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write($"bounds{i}"); @@ -189,7 +189,7 @@ public uint GetArrayTypeIndex( } fieldListRecord.StartListEntry(LF_MEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(arrayRecordTypeIndex); fieldListRecord.WriteEncodedInteger(offset); fieldListRecord.Write("values"); @@ -205,7 +205,7 @@ public uint GetArrayTypeIndex( Debug.Assert(memberCount <= ushort.MaxValue); Debug.Assert(arrayDescriptor.Size <= ushort.MaxValue); record.Write((ushort)memberCount); // Number of elements in class - record.Write((ushort)0); // TODO: Options + record.Write((ushort)0); // Class options (CodeViewPropertyFlags) record.Write(fieldListTypeIndex); // Field descriptor index record.Write((uint)0); // Derived-from descriptor index record.Write((uint)0); // Vtshape descriptor index @@ -228,7 +228,7 @@ public uint GetEnumTypeIndex( foreach (EnumRecordTypeDescriptor record in typeRecords) { fieldListRecord.StartListEntry(LF_ENUMERATE); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.WriteEncodedInteger(record.Value); fieldListRecord.Write(record.Name); fieldListRecord.EndListEntry(); @@ -241,7 +241,7 @@ public uint GetEnumTypeIndex( { Debug.Assert(typeRecords.Length <= ushort.MaxValue); record.Write((ushort)typeRecords.Length); // Number of elements in class - record.Write((ushort)0); // TODO: Attributes + record.Write((ushort)0); // Class options (CodeViewPropertyFlags) record.Write(typeDescriptor.ElementType); record.Write(fieldListTypeIndex); record.Write(typeDescriptor.Name); @@ -258,7 +258,7 @@ public uint GetClassTypeIndex(ClassTypeDescriptor classDescriptor) using (LeafRecordWriter record = StartLeafRecord(classDescriptor.IsStruct == 1 ? LF_STRUCTURE : LF_CLASS)) { record.Write((ushort)0); // Number of elements in class - record.Write((ushort)CV_PROP_FORWARD_REFERENCE); + record.Write((ushort)CV_PROP_FORWARD_REFERENCE); // Class options (CodeViewPropertyFlags) record.Write((uint)0); // Field descriptor index record.Write((uint)0); // Derived-from descriptor index record.Write((uint)0); // Vtshape descriptor index @@ -282,7 +282,7 @@ public uint GetCompleteClassTypeIndex( if (classTypeDescriptor.BaseClassId != 0) { fieldListRecord.StartListEntry(LF_BCLASS); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)0); // Attributes fieldListRecord.Write(classTypeDescriptor.BaseClassId); fieldListRecord.WriteEncodedInteger(0); // Offset fieldListRecord.EndListEntry(); @@ -302,7 +302,7 @@ public uint GetCompleteClassTypeIndex( if (desc.Offset == 0xFFFFFFFF) { fieldListRecord.StartListEntry(LF_STMEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.Write(desc.Name); fieldListRecord.EndListEntry(); @@ -310,7 +310,7 @@ public uint GetCompleteClassTypeIndex( else { fieldListRecord.StartListEntry(LF_MEMBER); - fieldListRecord.Write((ushort)0); // TODO: Attributes + fieldListRecord.Write((ushort)CodeViewMemberAccess.CV_public); fieldListRecord.Write(desc.FieldTypeIndex); fieldListRecord.WriteEncodedInteger(desc.Offset); fieldListRecord.Write(desc.Name); @@ -326,7 +326,7 @@ public uint GetCompleteClassTypeIndex( { Debug.Assert(memberCount <= ushort.MaxValue); record.Write((ushort)memberCount); // Number of elements in class - record.Write((ushort)0); // TODO: Options + record.Write((ushort)0); // Class options (CodeViewPropertyFlags) record.Write(fieldListTypeIndex); // Field descriptor index record.Write((uint)0); // Derived-from descriptor index record.Write((uint)0); // Vtshape descriptor index @@ -360,7 +360,8 @@ public uint GetMemberFunctionTypeIndex(MemberFunctionTypeDescriptor memberDescri record.Write(memberDescriptor.ContainingClass); record.Write(memberDescriptor.TypeIndexOfThisPointer); record.Write((byte)memberDescriptor.CallingConvention); - record.Write((byte)0); // TODO: Attributes + // TODO: Evaluate if we should mark constructors + record.Write((byte)0); // Function options (CV_funcattr_t) record.Write((ushort)memberDescriptor.NumberOfArguments); record.Write(argumentListTypeIndex); record.Write((uint)memberDescriptor.ThisAdjust); From 666d65409b12bf83fe39db49bb9b4170a5d83fa2 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 4 Jan 2024 11:23:59 +0100 Subject: [PATCH 134/144] Use upper case hex constants for consistency --- .../ObjectWriter/CodeView/CodeViewNative.cs | 302 +++++++++--------- .../Compiler/ObjectWriter/CoffObjectWriter.cs | 94 +++--- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 2 +- .../ObjectWriter/Dwarf/DwarfEhFrame.cs | 4 +- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 6 +- .../ObjectWriter/Dwarf/DwarfHelper.cs | 4 +- .../ObjectWriter/Dwarf/DwarfNative.cs | 42 +-- .../Compiler/ObjectWriter/ElfObjectWriter.cs | 4 +- .../Compiler/ObjectWriter/MachNative.cs | 10 +- .../Compiler/ObjectWriter/MachObjectWriter.cs | 10 +- 10 files changed, 239 insertions(+), 239 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs index 20e6ebd14c896a..431ef42dc27ad4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewNative.cs @@ -34,7 +34,7 @@ public enum CodeViewType : ushort T_NOTTRANS = 0x0007, // type not translated by cvpack T_BIT = 0x0060, // bit T_PASCHAR = 0x0061, // Pascal CHAR - T_BOOL32FF = 0x0062, // 32-bit BOOL where true is 0xffffffff + T_BOOL32FF = 0x0062, // 32-bit BOOL where true is 0xFFFFFFFF // Character types T_CHAR = 0x0010, // 8 bit signed @@ -72,22 +72,22 @@ public enum CodeViewType : ushort T_64PWCHAR = 0x0671, // 64 bit pointer to a wide char // Really a 16-bit unicode char - T_CHAR16 = 0x007a, // 16-bit unicode char - T_PCHAR16 = 0x017a, // 16 bit pointer to a 16-bit unicode char - T_PFCHAR16 = 0x027a, // 16:16 far pointer to a 16-bit unicode char - T_PHCHAR16 = 0x037a, // 16:16 huge pointer to a 16-bit unicode char - T_32PCHAR16 = 0x047a, // 32 bit pointer to a 16-bit unicode char - T_32PFCHAR16 = 0x057a, // 16:32 pointer to a 16-bit unicode char - T_64PCHAR16 = 0x067a, // 64 bit pointer to a 16-bit unicode char + T_CHAR16 = 0x007A, // 16-bit unicode char + T_PCHAR16 = 0x017A, // 16 bit pointer to a 16-bit unicode char + T_PFCHAR16 = 0x027A, // 16:16 far pointer to a 16-bit unicode char + T_PHCHAR16 = 0x037A, // 16:16 huge pointer to a 16-bit unicode char + T_32PCHAR16 = 0x047A, // 32 bit pointer to a 16-bit unicode char + T_32PFCHAR16 = 0x057A, // 16:32 pointer to a 16-bit unicode char + T_64PCHAR16 = 0x067A, // 64 bit pointer to a 16-bit unicode char // Really a 32-bit unicode char - T_CHAR32 = 0x007b, // 32-bit unicode char - T_PCHAR32 = 0x017b, // 16 bit pointer to a 32-bit unicode char - T_PFCHAR32 = 0x027b, // 16:16 far pointer to a 32-bit unicode char - T_PHCHAR32 = 0x037b, // 16:16 huge pointer to a 32-bit unicode char - T_32PCHAR32 = 0x047b, // 32 bit pointer to a 32-bit unicode char - T_32PFCHAR32 = 0x057b, // 16:32 pointer to a 32-bit unicode char - T_64PCHAR32 = 0x067b, // 64 bit pointer to a 32-bit unicode char + T_CHAR32 = 0x007B, // 32-bit unicode char + T_PCHAR32 = 0x017B, // 16 bit pointer to a 32-bit unicode char + T_PFCHAR32 = 0x027B, // 16:16 far pointer to a 32-bit unicode char + T_PHCHAR32 = 0x037B, // 16:16 huge pointer to a 32-bit unicode char + T_32PCHAR32 = 0x047B, // 32 bit pointer to a 32-bit unicode char + T_32PFCHAR32 = 0x057B, // 16:32 pointer to a 32-bit unicode char + T_64PCHAR32 = 0x067B, // 64 bit pointer to a 32-bit unicode char // 8-bit int types T_INT1 = 0x0068, // 8 bit signed int @@ -374,12 +374,12 @@ public enum CodeViewType : ushort T_32PFBOOL64 = 0x0533, // 16:32 pointer to 64 bit boolean T_64PBOOL64 = 0x0633, // 64 bit pointer to 64 bit boolean - T_NCVPTR = 0x01f0, // CV Internal type for created near pointers - T_FCVPTR = 0x02f0, // CV Internal type for created far pointers - T_HCVPTR = 0x03f0, // CV Internal type for created huge pointers - T_32NCVPTR = 0x04f0, // CV Internal type for created near 32-bit pointers - T_32FCVPTR = 0x05f0, // CV Internal type for created far 32-bit pointers - T_64NCVPTR = 0x06f0, // CV Internal type for created near 64-bit pointers + T_NCVPTR = 0x01F0, // CV Internal type for created near pointers + T_FCVPTR = 0x02F0, // CV Internal type for created far pointers + T_HCVPTR = 0x03F0, // CV Internal type for created huge pointers + T_32NCVPTR = 0x04F0, // CV Internal type for created near 32-bit pointers + T_32FCVPTR = 0x05F0, // CV Internal type for created far 32-bit pointers + T_64NCVPTR = 0x06F0, // CV Internal type for created near 64-bit pointers } /// Type enum for pointer records @@ -400,10 +400,10 @@ public enum CodeViewPointer : uint CV_PTR_BASE_SEGADDR = 0x07, // based on segment address of base CV_PTR_BASE_TYPE = 0x08, // based on type CV_PTR_BASE_SELF = 0x09, // based on self - CV_PTR_NEAR32 = 0x0a, // 32 bit pointer - CV_PTR_FAR32 = 0x0b, // 16:32 pointer - CV_PTR_64 = 0x0c, // 64 bit pointer - CV_PTR_UNUSEDPTR = 0x0d, // first unused pointer type + CV_PTR_NEAR32 = 0x0A, // 32 bit pointer + CV_PTR_FAR32 = 0x0B, // 16:32 pointer + CV_PTR_64 = 0x0C, // 64 bit pointer + CV_PTR_UNUSEDPTR = 0x0D, // first unused pointer type CV_PTR_MODE_PTR = 0x00 << 5, // "normal" pointer CV_PTR_MODE_REF = 0x01 << 5, // "old" reference @@ -441,7 +441,7 @@ public enum CodeViewPropertyFlags : ushort // Matches DEBUG_S_SUBSECTION_TYPE in cvinfo.h public enum DebugSymbolsSubsectionType : uint { - Symbols = 0xf1, + Symbols = 0xF1, Lines, StringTable, FileChecksums, @@ -471,12 +471,12 @@ public enum LeafRecordType LF_ENUM_16t = 0x0007, LF_PROCEDURE_16t = 0x0008, LF_MFUNCTION_16t = 0x0009, - LF_VTSHAPE = 0x000a, - LF_COBOL0_16t = 0x000b, - LF_COBOL1 = 0x000c, - LF_BARRAY_16t = 0x000d, - LF_LABEL = 0x000e, - LF_NULL = 0x000f, + LF_VTSHAPE = 0x000A, + LF_COBOL0_16t = 0x000B, + LF_COBOL1 = 0x000C, + LF_BARRAY_16t = 0x000D, + LF_LABEL = 0x000E, + LF_NULL = 0x000F, LF_NOTTRAN = 0x0010, LF_DIMARRAY_16t = 0x0011, LF_VFTPATH_16t = 0x0012, @@ -496,9 +496,9 @@ public enum LeafRecordType LF_METHODLIST_16t = 0x0207, LF_DIMCONU_16t = 0x0208, LF_DIMCONLU_16t = 0x0209, - LF_DIMVARU_16t = 0x020a, - LF_DIMVARLU_16t = 0x020b, - LF_REFSYM = 0x020c, + LF_DIMVARU_16t = 0x020A, + LF_DIMVARLU_16t = 0x020B, + LF_REFSYM = 0x020C, LF_BCLASS_16t = 0x0400, LF_VBCLASS_16t = 0x0401, @@ -510,10 +510,10 @@ public enum LeafRecordType LF_STMEMBER_16t = 0x0407, LF_METHOD_16t = 0x0408, LF_NESTTYPE_16t = 0x0409, - LF_VFUNCTAB_16t = 0x040a, - LF_FRIENDCLS_16t = 0x040b, - LF_ONEMETHOD_16t = 0x040c, - LF_VFUNCOFF_16t = 0x040d, + LF_VFUNCTAB_16t = 0x040A, + LF_FRIENDCLS_16t = 0x040B, + LF_ONEMETHOD_16t = 0x040C, + LF_VFUNCOFF_16t = 0x040D, // 32-bit type index versions of leaves, all have the 0x1000 bit set LF_TI16_MAX = 0x1000, @@ -527,12 +527,12 @@ public enum LeafRecordType LF_ENUM_ST = 0x1007, LF_PROCEDURE = 0x1008, LF_MFUNCTION = 0x1009, - LF_COBOL0 = 0x100a, - LF_BARRAY = 0x100b, - LF_DIMARRAY_ST = 0x100c, - LF_VFTPATH = 0x100d, - LF_PRECOMP_ST = 0x100e, // not referenced from symbol - LF_OEM = 0x100f, // oem definable type string + LF_COBOL0 = 0x100A, + LF_BARRAY = 0x100B, + LF_DIMARRAY_ST = 0x100C, + LF_VFTPATH = 0x100D, + LF_PRECOMP_ST = 0x100E, // not referenced from symbol + LF_OEM = 0x100F, // oem definable type string LF_ALIAS_ST = 0x1010, // alias (typedef) type LF_OEM2 = 0x1011, // oem definable type string @@ -547,7 +547,7 @@ public enum LeafRecordType LF_DIMCONU = 0x1207, LF_DIMCONLU = 0x1208, LF_DIMVARU = 0x1209, - LF_DIMVARLU = 0x120a, + LF_DIMVARLU = 0x120A, LF_BCLASS = 0x1400, LF_VBCLASS = 0x1401, @@ -559,12 +559,12 @@ public enum LeafRecordType LF_METHOD_ST = 0x1407, LF_NESTTYPE_ST = 0x1408, LF_VFUNCTAB = 0x1409, - LF_FRIENDCLS = 0x140a, - LF_ONEMETHOD_ST = 0x140b, - LF_VFUNCOFF = 0x140c, - LF_NESTTYPEEX_ST = 0x140d, - LF_MEMBERMODIFY_ST = 0x140e, - LF_MANAGED_ST = 0x140f, + LF_FRIENDCLS = 0x140A, + LF_ONEMETHOD_ST = 0x140B, + LF_VFUNCOFF = 0x140C, + LF_NESTTYPEEX_ST = 0x140D, + LF_MEMBERMODIFY_ST = 0x140E, + LF_MANAGED_ST = 0x140F, // Types w/ SZ names LF_ST_MAX = 0x1500, @@ -578,12 +578,12 @@ public enum LeafRecordType LF_ENUM = 0x1507, LF_DIMARRAY = 0x1508, LF_PRECOMP = 0x1509, // not referenced from symbol - LF_ALIAS = 0x150a, // alias (typedef) type - LF_DEFARG = 0x150b, - LF_FRIENDFCN = 0x150c, - LF_MEMBER = 0x150d, - LF_STMEMBER = 0x150e, - LF_METHOD = 0x150f, + LF_ALIAS = 0x150A, // alias (typedef) type + LF_DEFARG = 0x150B, + LF_FRIENDFCN = 0x150C, + LF_MEMBER = 0x150D, + LF_STMEMBER = 0x150E, + LF_METHOD = 0x150F, LF_NESTTYPE = 0x1510, LF_ONEMETHOD = 0x1511, LF_NESTTYPEEX = 0x1512, @@ -595,11 +595,11 @@ public enum LeafRecordType LF_HLSL = 0x1517, LF_MODIFIER_EX = 0x1518, LF_INTERFACE = 0x1519, - LF_BINTERFACE = 0x151a, - LF_VECTOR = 0x151b, - LF_MATRIX = 0x151c, + LF_BINTERFACE = 0x151A, + LF_VECTOR = 0x151B, + LF_MATRIX = 0x151C, - LF_VFTABLE = 0x151d, // a virtual function table + LF_VFTABLE = 0x151D, // a virtual function table LF_ENDOFLEAFRECORD = LF_VFTABLE, LF_TYPE_LAST, // one greater than the last type record @@ -629,39 +629,39 @@ public enum LeafRecordType LF_REAL80 = 0x8007, LF_REAL128 = 0x8008, LF_QUADWORD = 0x8009, - LF_UQUADWORD = 0x800a, - LF_REAL48 = 0x800b, - LF_COMPLEX32 = 0x800c, - LF_COMPLEX64 = 0x800d, - LF_COMPLEX80 = 0x800e, - LF_COMPLEX128 = 0x800f, + LF_UQUADWORD = 0x800A, + LF_REAL48 = 0x800B, + LF_COMPLEX32 = 0x800C, + LF_COMPLEX64 = 0x800D, + LF_COMPLEX80 = 0x800E, + LF_COMPLEX128 = 0x800F, LF_VARSTRING = 0x8010, LF_OCTWORD = 0x8017, LF_UOCTWORD = 0x8018, LF_DECIMAL = 0x8019, - LF_DATE = 0x801a, - LF_UTF8STRING = 0x801b, - - LF_REAL16 = 0x801c, - - LF_PAD0 = 0xf0, - LF_PAD1 = 0xf1, - LF_PAD2 = 0xf2, - LF_PAD3 = 0xf3, - LF_PAD4 = 0xf4, - LF_PAD5 = 0xf5, - LF_PAD6 = 0xf6, - LF_PAD7 = 0xf7, - LF_PAD8 = 0xf8, - LF_PAD9 = 0xf9, - LF_PAD10 = 0xfa, - LF_PAD11 = 0xfb, - LF_PAD12 = 0xfc, - LF_PAD13 = 0xfd, - LF_PAD14 = 0xfe, - LF_PAD15 = 0xff, + LF_DATE = 0x801A, + LF_UTF8STRING = 0x801B, + + LF_REAL16 = 0x801C, + + LF_PAD0 = 0xF0, + LF_PAD1 = 0xF1, + LF_PAD2 = 0xF2, + LF_PAD3 = 0xF3, + LF_PAD4 = 0xF4, + LF_PAD5 = 0xF5, + LF_PAD6 = 0xF6, + LF_PAD7 = 0xF7, + LF_PAD8 = 0xF8, + LF_PAD9 = 0xF9, + LF_PAD10 = 0xFA, + LF_PAD11 = 0xFB, + LF_PAD12 = 0xFC, + LF_PAD13 = 0xFD, + LF_PAD14 = 0xFE, + LF_PAD15 = 0xFF, } // Matches CV_HREG_e in cvinfo.h @@ -2122,11 +2122,11 @@ public enum CodeViewSymbolDefinition : ushort S_SKIP = 0x0007, // Reserve symbol space in $$Symbols table S_CVRESERVE = 0x0008, // Reserved symbol for CV internal use S_OBJNAME_ST = 0x0009, // path to object file name - S_ENDARG = 0x000a, // end of argument/return list - S_COBOLUDT_16t = 0x000b, // special UDT for cobol that does not symbol pack - S_MANYREG_16t = 0x000c, // multiple register variable - S_RETURN = 0x000d, // return description symbol - S_ENTRYTHIS = 0x000e, // description of this pointer on entry + S_ENDARG = 0x000A, // end of argument/return list + S_COBOLUDT_16t = 0x000B, // special UDT for cobol that does not symbol pack + S_MANYREG_16t = 0x000C, // multiple register variable + S_RETURN = 0x000D, // return description symbol + S_ENTRYTHIS = 0x000E, // description of this pointer on entry S_BPREL16 = 0x0100, // BP-relative S_LDATA16 = 0x0101, // Module-local symbol @@ -2138,9 +2138,9 @@ public enum CodeViewSymbolDefinition : ushort S_BLOCK16 = 0x0107, // block start S_WITH16 = 0x0108, // with start S_LABEL16 = 0x0109, // code label - S_CEXMODEL16 = 0x010a, // change execution model - S_VFTABLE16 = 0x010b, // address of virtual function table - S_REGREL16 = 0x010c, // register relative address + S_CEXMODEL16 = 0x010A, // change execution model + S_VFTABLE16 = 0x010B, // address of virtual function table + S_REGREL16 = 0x010C, // register relative address S_BPREL32_16t = 0x0200, // BP-relative S_LDATA32_16t = 0x0201, // Module-local symbol @@ -2152,12 +2152,12 @@ public enum CodeViewSymbolDefinition : ushort S_BLOCK32_ST = 0x0207, // block start S_WITH32_ST = 0x0208, // with start S_LABEL32_ST = 0x0209, // code label - S_CEXMODEL32 = 0x020a, // change execution model - S_VFTABLE32_16t = 0x020b, // address of virtual function table - S_REGREL32_16t = 0x020c, // register relative address - S_LTHREAD32_16t = 0x020d, // local thread storage - S_GTHREAD32_16t = 0x020e, // global thread storage - S_SLINK32 = 0x020f, // static link for MIPS EH implementation + S_CEXMODEL32 = 0x020A, // change execution model + S_VFTABLE32_16t = 0x020B, // address of virtual function table + S_REGREL32_16t = 0x020C, // register relative address + S_LTHREAD32_16t = 0x020D, // local thread storage + S_GTHREAD32_16t = 0x020E, // global thread storage + S_SLINK32 = 0x020F, // static link for MIPS EH implementation S_LPROCMIPS_16t = 0x0300, // Local procedure start S_GPROCMIPS_16t = 0x0301, // Global procedure start @@ -2185,12 +2185,12 @@ public enum CodeViewSymbolDefinition : ushort S_LDATA32_ST = 0x1007, // Module-local symbol S_GDATA32_ST = 0x1008, // Global data symbol S_PUB32_ST = 0x1009, // a public symbol (CV internal reserved) - S_LPROC32_ST = 0x100a, // Local procedure start - S_GPROC32_ST = 0x100b, // Global procedure start - S_VFTABLE32 = 0x100c, // address of virtual function table - S_REGREL32_ST = 0x100d, // register relative address - S_LTHREAD32_ST = 0x100e, // local thread storage - S_GTHREAD32_ST = 0x100f, // global thread storage + S_LPROC32_ST = 0x100A, // Local procedure start + S_GPROC32_ST = 0x100B, // Global procedure start + S_VFTABLE32 = 0x100C, // address of virtual function table + S_REGREL32_ST = 0x100D, // register relative address + S_LTHREAD32_ST = 0x100E, // local thread storage + S_GTHREAD32_ST = 0x100F, // global thread storage S_LPROCMIPS_ST = 0x1010, // Local procedure start S_GPROCMIPS_ST = 0x1011, // Global procedure start @@ -2211,12 +2211,12 @@ public enum CodeViewSymbolDefinition : ushort S_ANNOTATION = 0x1019, // Annotation string literals // Symbols to support managed code debugging - S_GMANPROC_ST = 0x101a, // Global proc - S_LMANPROC_ST = 0x101b, // Local proc - S_RESERVED1 = 0x101c, // reserved - S_RESERVED2 = 0x101d, // reserved - S_RESERVED3 = 0x101e, // reserved - S_RESERVED4 = 0x101f, // reserved + S_GMANPROC_ST = 0x101A, // Global proc + S_LMANPROC_ST = 0x101B, // Local proc + S_RESERVED1 = 0x101C, // reserved + S_RESERVED2 = 0x101D, // reserved + S_RESERVED3 = 0x101E, // reserved + S_RESERVED4 = 0x101F, // reserved S_LMANDATA_ST = 0x1020, S_GMANDATA_ST = 0x1021, S_MANFRAMEREL_ST = 0x1022, @@ -2240,12 +2240,12 @@ public enum CodeViewSymbolDefinition : ushort S_CONSTANT = 0x1107, // constant symbol S_UDT = 0x1108, // User defined type S_COBOLUDT = 0x1109, // special UDT for cobol that does not symbol pack - S_MANYREG = 0x110a, // multiple register variable - S_BPREL32 = 0x110b, // BP-relative - S_LDATA32 = 0x110c, // Module-local symbol - S_GDATA32 = 0x110d, // Global data symbol - S_PUB32 = 0x110e, // a public symbol (CV internal reserved) - S_LPROC32 = 0x110f, // Local procedure start + S_MANYREG = 0x110A, // multiple register variable + S_BPREL32 = 0x110B, // BP-relative + S_LDATA32 = 0x110C, // Module-local symbol + S_GDATA32 = 0x110D, // Global data symbol + S_PUB32 = 0x110E, // a public symbol (CV internal reserved) + S_LPROC32 = 0x110F, // Local procedure start S_GPROC32 = 0x1110, // Global procedure start S_REGREL32 = 0x1111, // register relative address S_LTHREAD32 = 0x1112, // local thread storage @@ -2257,15 +2257,15 @@ public enum CodeViewSymbolDefinition : ushort S_MANYREG2 = 0x1117, // multiple register variable S_LPROCIA64 = 0x1118, // Local procedure start (IA64) S_GPROCIA64 = 0x1119, // Global procedure start (IA64) - S_LOCALSLOT = 0x111a, // local IL sym with field for local slot index + S_LOCALSLOT = 0x111A, // local IL sym with field for local slot index S_SLOT = S_LOCALSLOT, // alias for LOCALSLOT - S_PARAMSLOT = 0x111b, // local IL sym with field for parameter slot index + S_PARAMSLOT = 0x111B, // local IL sym with field for parameter slot index // symbols to support managed code debugging - S_LMANDATA = 0x111c, - S_GMANDATA = 0x111d, - S_MANFRAMEREL = 0x111e, - S_MANREGISTER = 0x111f, + S_LMANDATA = 0x111C, + S_GMANDATA = 0x111D, + S_MANFRAMEREL = 0x111E, + S_MANREGISTER = 0x111F, S_MANSLOT = 0x1120, S_MANMANYREG = 0x1121, S_MANREGREL = 0x1122, @@ -2280,16 +2280,16 @@ public enum CodeViewSymbolDefinition : ushort S_TOKENREF = 0x1129, // Reference to one of the many MANPROCSYM's // continuation of managed symbols - S_GMANPROC = 0x112a, // Global proc - S_LMANPROC = 0x112b, // Local proc + S_GMANPROC = 0x112A, // Global proc + S_LMANPROC = 0x112B, // Local proc // short, light-weight thunks - S_TRAMPOLINE = 0x112c, // trampoline thunks - S_MANCONSTANT = 0x112d, // constants with metadata type info + S_TRAMPOLINE = 0x112C, // trampoline thunks + S_MANCONSTANT = 0x112D, // constants with metadata type info // native attributed local/parms - S_ATTR_FRAMEREL = 0x112e, // relative to virtual frame ptr - S_ATTR_REGISTER = 0x112f, // stored in a register + S_ATTR_FRAMEREL = 0x112E, // relative to virtual frame ptr + S_ATTR_REGISTER = 0x112F, // stored in a register S_ATTR_REGREL = 0x1130, // relative to register (alternate frame ptr) S_ATTR_MANYREG = 0x1131, // stored in >1 register @@ -2305,15 +2305,15 @@ public enum CodeViewSymbolDefinition : ushort S_EXPORT = 0x1138, // A export S_CALLSITEINFO = 0x1139, // Indirect call site information - S_FRAMECOOKIE = 0x113a, // Security cookie information + S_FRAMECOOKIE = 0x113A, // Security cookie information - S_DISCARDED = 0x113b, // Discarded by LINK /OPT:REF (experimental, see richards) + S_DISCARDED = 0x113B, // Discarded by LINK /OPT:REF (experimental, see richards) - S_COMPILE3 = 0x113c, // Replacement for S_COMPILE2 - S_ENVBLOCK = 0x113d, // Environment block split off from S_COMPILE2 + S_COMPILE3 = 0x113C, // Replacement for S_COMPILE2 + S_ENVBLOCK = 0x113D, // Environment block split off from S_COMPILE2 - S_LOCAL = 0x113e, // defines a local symbol in optimized code - S_DEFRANGE = 0x113f, // defines a single range of addresses in which symbol can be evaluated + S_LOCAL = 0x113E, // defines a local symbol in optimized code + S_DEFRANGE = 0x113F, // defines a single range of addresses in which symbol can be evaluated S_DEFRANGE_SUBFIELD = 0x1140, // ranges for a subfield S_DEFRANGE_REGISTER = 0x1141, // ranges for en-registered symbol @@ -2327,13 +2327,13 @@ public enum CodeViewSymbolDefinition : ushort S_GPROC32_ID = 0x1147, S_LPROCMIPS_ID = 0x1148, S_GPROCMIPS_ID = 0x1149, - S_LPROCIA64_ID = 0x114a, - S_GPROCIA64_ID = 0x114b, + S_LPROCIA64_ID = 0x114A, + S_GPROCIA64_ID = 0x114B, - S_BUILDINFO = 0x114c, // build information. - S_INLINESITE = 0x114d, // inlined function callsite. - S_INLINESITE_END = 0x114e, - S_PROC_ID_END = 0x114f, + S_BUILDINFO = 0x114C, // build information. + S_INLINESITE = 0x114D, // inlined function callsite. + S_INLINESITE_END = 0x114E, + S_PROC_ID_END = 0x114F, S_DEFRANGE_HLSL = 0x1150, S_GDATA_HLSL = 0x1151, @@ -2342,14 +2342,14 @@ public enum CodeViewSymbolDefinition : ushort S_FILESTATIC = 0x1153, S_ARMSWITCHTABLE = 0x1159, - S_CALLEES = 0x115a, - S_CALLERS = 0x115b, - S_POGODATA = 0x115c, - S_INLINESITE2 = 0x115d, // extended inline site information + S_CALLEES = 0x115A, + S_CALLERS = 0x115B, + S_POGODATA = 0x115C, + S_INLINESITE2 = 0x115D, // extended inline site information - S_HEAPALLOCSITE = 0x115e, // heap allocation site + S_HEAPALLOCSITE = 0x115E, // heap allocation site - S_MOD_TYPEREF = 0x115f, // only generated at link time + S_MOD_TYPEREF = 0x115F, // only generated at link time S_REF_MINIPDB = 0x1160, // only generated at link time for mini PDB S_PDBMAP = 0x1161, // only generated at link time for mini PDB diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs index da5340d8b1db41..1f18dfc83d33de 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CoffObjectWriter.cs @@ -655,8 +655,8 @@ private struct CoffHeader private static ReadOnlySpan BigObjMagic => new byte[] { - 0xc7, 0xa1, 0xba, 0xd1, 0xee, 0xba, 0xa9, 0x4b, - 0xaf, 0x20, 0xfa, 0xf6, 0x6a, 0xa4, 0xdc, 0xb8, + 0xC7, 0xA1, 0xBA, 0xD1, 0xEE, 0xBA, 0xA9, 0x4B, + 0xAF, 0x20, 0xFA, 0xF6, 0x6A, 0xA4, 0xDC, 0xB8, }; private const int RegularSize = @@ -670,7 +670,7 @@ private struct CoffHeader private const int BigObjSize = sizeof(ushort) + // Signature 1 (Machine = Unknown) - sizeof(ushort) + // Signature 2 (NumberOfSections = 0xffff) + sizeof(ushort) + // Signature 2 (NumberOfSections = 0xFFFF) sizeof(ushort) + // Version (2) sizeof(ushort) + // Machine sizeof(uint) + // TimeDateStamp @@ -706,7 +706,7 @@ public void Write(FileStream stream) Span buffer = stackalloc byte[BigObjSize]; buffer.Clear(); - BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), 0xffff); + BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(2), 0xFFFF); BinaryPrimitives.WriteUInt16LittleEndian(buffer.Slice(4), 2); BinaryPrimitives.WriteInt16LittleEndian(buffer.Slice(6), (short)Machine); BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(8), TimeDateStamp); @@ -1035,49 +1035,49 @@ public static uint CalculateChecksum(Stream stream) // We embed the pre-generated version since it's small. ReadOnlySpan table = [ - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, + 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, + 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, + 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D ]; uint crc = 0; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index 4e2a9613c02839..8e9d56dbfdcebe 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -9,7 +9,7 @@ internal sealed class DwarfAbbrev { private readonly ushort[] _definition; - public static ushort DW_FORM_size = 0xdead; // Dummy value + public static ushort DW_FORM_size = 0xDEAD; // Dummy value public DwarfAbbrev(ushort[] definition) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index ef098581385c39..5d38e30c934f92 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -88,7 +88,7 @@ private void WriteCie(DwarfCie cie) BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); _sectionWriter.Write(tempBuffer); - _sectionWriter.WriteByte(cie.ReturnAddressRegister < 0x7f ? (byte)1u : (byte)3u); // Version + _sectionWriter.WriteByte(cie.ReturnAddressRegister < 0x7F ? (byte)1u : (byte)3u); // Version _sectionWriter.Write(augmentationString.UnderlyingArray); _sectionWriter.WriteULEB128(cie.CodeAlignFactor); @@ -160,7 +160,7 @@ private void WriteFde(DwarfFde fde, uint cieOffset) private uint AddressSize(byte encoding) { - switch (encoding & 0xf) + switch (encoding & 0xF) { case DW_EH_PE_ptr: return _is64Bit ? 8u : 4u; case DW_EH_PE_sdata4: return 4u; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index d42571c4167f3b..4239c383a2f401 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -57,13 +57,13 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) { // Advance int diff = (int)((codeOffset - lastCodeOffset) / cie.CodeAlignFactor); - if (diff <= 0x3f) + if (diff <= 0x3F) { cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_advance_loc | diff); } else { - Debug.Assert(diff <= 0xff); + Debug.Assert(diff <= 0xFF); cfiCode[cfiCodeOffset++] = (byte)DW_CFA_advance_loc1; cfiCode[cfiCodeOffset++] = (byte)diff; } @@ -78,7 +78,7 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) break; case CFI_OPCODE.CFI_REL_OFFSET: - if (dwarfReg <= 0x3f) + if (dwarfReg <= 0x3F) { cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_offset | (byte)dwarfReg); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs index 0a53f38fab7268..c595781222bfb5 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfHelper.cs @@ -33,7 +33,7 @@ public static int WriteULEB128(Span buffer, ulong value) int pos = 0; do { - buffer[pos++] = (byte)((value & 0x7f) | ((value >= 0x80) ? 0x80u : 0)); + buffer[pos++] = (byte)((value & 0x7F) | ((value >= 0x80) ? 0x80u : 0)); value >>= 7; } while (value > 0); @@ -58,7 +58,7 @@ public static int WriteSLEB128(Span buffer, long value) int pos = 0; while (cont) { - var b = (byte)((byte)value & 0x7f); + var b = (byte)((byte)value & 0x7F); value >>= 7; bool isSignBitSet = (b & 0x40) != 0; if ((value == 0 && !isSignBitSet) || (value == -1 && isSignBitSet)) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs index 964beb16d0d0b5..d8e0c36ca685c8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfNative.cs @@ -6,16 +6,16 @@ namespace ILCompiler.ObjectWriter internal static class DwarfNative { public const byte DW_EH_PE_absptr = 0x00; - public const byte DW_EH_PE_omit = 0xff; + public const byte DW_EH_PE_omit = 0xFF; public const byte DW_EH_PE_ptr = 0x00; public const byte DW_EH_PE_uleb128 = 0x01; public const byte DW_EH_PE_udata2 = 0x02; public const byte DW_EH_PE_udata4 = 0x03; public const byte DW_EH_PE_udata8 = 0x04; public const byte DW_EH_PE_sleb128 = 0x09; - public const byte DW_EH_PE_sdata2 = 0x0a; - public const byte DW_EH_PE_sdata4 = 0x0b; - public const byte DW_EH_PE_sdata8 = 0x0c; + public const byte DW_EH_PE_sdata2 = 0x0A; + public const byte DW_EH_PE_sdata4 = 0x0B; + public const byte DW_EH_PE_sdata8 = 0x0C; public const byte DW_EH_PE_signed = 0x08; public const byte DW_EH_PE_pcrel = 0x10; public const byte DW_EH_PE_textrel = 0x20; @@ -34,12 +34,12 @@ internal static class DwarfNative public const byte DW_CFA_undefined = 0x7; public const byte DW_CFA_same_value = 0x8; public const byte DW_CFA_register = 0x9; - public const byte DW_CFA_remember_state = 0xa; - public const byte DW_CFA_restore_state = 0xb; - public const byte DW_CFA_def_cfa = 0xc; - public const byte DW_CFA_def_cfa_register = 0xd; - public const byte DW_CFA_def_cfa_offset = 0xe; - public const byte DW_CFA_def_cfa_expression = 0xf; + public const byte DW_CFA_remember_state = 0xA; + public const byte DW_CFA_restore_state = 0xB; + public const byte DW_CFA_def_cfa = 0xC; + public const byte DW_CFA_def_cfa_register = 0xD; + public const byte DW_CFA_def_cfa_offset = 0xE; + public const byte DW_CFA_def_cfa_expression = 0xF; public const byte DW_CFA_expression = 0x10; public const byte DW_CFA_offset_extended_sf = 0x11; public const byte DW_CFA_def_cfa_sf = 0x12; @@ -49,11 +49,11 @@ internal static class DwarfNative public const byte DW_CFA_val_expression = 0x16; public const byte DW_CFA_advance_loc = 0x40; public const byte DW_CFA_offset = 0x80; - public const byte DW_CFA_restore = 0xc0; - public const byte DW_CFA_GNU_window_save = 0x2d; - public const byte DW_CFA_GNU_args_size = 0x2e; - public const byte DW_CFA_GNU_negative_offset_extended = 0x2f; - public const byte DW_CFA_AARCH64_negate_ra_state = 0x2d; + public const byte DW_CFA_restore = 0xC0; + public const byte DW_CFA_GNU_window_save = 0x2D; + public const byte DW_CFA_GNU_args_size = 0x2E; + public const byte DW_CFA_GNU_negative_offset_extended = 0x2F; + public const byte DW_CFA_AARCH64_negate_ra_state = 0x2D; public const byte DW_ATE_address = 0x01; public const byte DW_ATE_boolean = 0x02; @@ -64,12 +64,12 @@ internal static class DwarfNative public const byte DW_ATE_unsigned = 0x07; public const byte DW_ATE_unsigned_char = 0x08; public const byte DW_ATE_imaginary_float = 0x09; /* DWARF3 */ - public const byte DW_ATE_packed_decimal = 0x0a; /* DWARF3f */ - public const byte DW_ATE_numeric_string = 0x0b; /* DWARF3f */ - public const byte DW_ATE_edited = 0x0c; /* DWARF3f */ - public const byte DW_ATE_signed_fixed = 0x0d; /* DWARF3f */ - public const byte DW_ATE_unsigned_fixed = 0x0e; /* DWARF3f */ - public const byte DW_ATE_decimal_float = 0x0f; /* DWARF3f */ + public const byte DW_ATE_packed_decimal = 0x0A; /* DWARF3f */ + public const byte DW_ATE_numeric_string = 0x0B; /* DWARF3f */ + public const byte DW_ATE_edited = 0x0C; /* DWARF3f */ + public const byte DW_ATE_signed_fixed = 0x0D; /* DWARF3f */ + public const byte DW_ATE_unsigned_fixed = 0x0E; /* DWARF3f */ + public const byte DW_ATE_decimal_float = 0x0F; /* DWARF3f */ public const byte DW_ATE_UTF = 0x10; /* DWARF4 */ public const byte DW_ATE_UCS = 0x11; /* DWARF5 */ public const byte DW_ATE_ASCII = 0x12; /* DWARF5 */ diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index 7c2d3653248d73..f310b8c59b344f 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -583,7 +583,7 @@ private void EmitObjectFile(FileStream outputFileStream) symbolTableSectionHeader.Write(outputFileStream); // If the symbol table has references to sections with indexes higher than - // SHN_LORESERVE (0xff00) we need to write them down in a separate table + // SHN_LORESERVE (0xFF00) we need to write them down in a separate table // in the .symtab_shndx section. if (hasSymTabExtendedIndices) { @@ -616,7 +616,7 @@ private sealed class ElfSectionDefinition private sealed class ElfHeader { - private static ReadOnlySpan Magic => new byte[] { 0x7f, 0x45, 0x4c, 0x46 }; + private static ReadOnlySpan Magic => new byte[] { 0x7F, 0x45, 0x4C, 0x46 }; public ushort Type { get; set; } public ushort Machine { get; set; } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs index dec6a7cc2171d6..9c4f07c866cfc7 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachNative.cs @@ -7,7 +7,7 @@ namespace ILCompiler.ObjectWriter /// internal static class MachNative { - public const uint MH_MAGIC_64 = 0xfeedfacf; + public const uint MH_MAGIC_64 = 0xFEEDFACF; // File type public const uint MH_OBJECT = 0x1; @@ -23,7 +23,7 @@ internal static class MachNative // Load command types public const uint LC_SYMTAB = 0x2; - public const uint LC_DYSYMTAB = 0xb; + public const uint LC_DYSYMTAB = 0xB; public const uint LC_SEGMENT_64 = 0x19; public const uint LC_BUILD_VERSION = 0x32; @@ -93,9 +93,9 @@ internal static class MachNative public const byte N_UNDF = 0; public const byte N_EXT = 1; public const byte N_ABS = 2; - public const byte N_INDR = 0xa; - public const byte N_SECT = 0xe; - public const byte N_PBUD = 0xc; + public const byte N_INDR = 0xA; + public const byte N_SECT = 0xE; + public const byte N_PBUD = 0xC; // Symbol descriptor flags public const ushort REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs index d3186021698a71..86ac433262f990 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/MachObjectWriter.cs @@ -244,15 +244,15 @@ private protected override void EmitObjectFile(string objectFilePath) { case TargetOS.OSX: buildVersion.Platform = PLATFORM_MACOS; - buildVersion.MinimumPlatformVersion = 0x0a_0c_00; // 10.12.0 + buildVersion.MinimumPlatformVersion = 0x0A_0C_00; // 10.12.0 break; case TargetOS.MacCatalyst: buildVersion.Platform = PLATFORM_MACCATALYST; buildVersion.MinimumPlatformVersion = _cpuType switch { - CPU_TYPE_X86_64 => 0x0d_05_00u, // 13.5.0 - _ => 0x0e_02_00u, // 14.2.0 + CPU_TYPE_X86_64 => 0x0D_05_00u, // 13.5.0 + _ => 0x0E_02_00u, // 14.2.0 }; break; @@ -268,7 +268,7 @@ private protected override void EmitObjectFile(string objectFilePath) TargetOS.tvOSSimulator => PLATFORM_TVOSSIMULATOR, _ => 0, }; - buildVersion.MinimumPlatformVersion = 0x0b_00_00; // 11.0.0 + buildVersion.MinimumPlatformVersion = 0x0B_00_00; // 11.0.0 break; } buildVersion.Write(outputFileStream); @@ -880,7 +880,7 @@ private sealed class MachSection public uint NumberOfRelocationEntries => relocationCollection is null ? 0u : (uint)relocationCollection.Count; public uint Flags { get; set; } - public uint Type => Flags & 0xff; + public uint Type => Flags & 0xFF; public bool IsInFile => Size > 0 && Type != S_ZEROFILL && Type != S_GB_ZEROFILL && Type != S_THREAD_LOCAL_ZEROFILL; public bool IsDwarfSection { get; } From a64485ea39285ddbcf550839c3100446e3379966 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:15:57 +0100 Subject: [PATCH 135/144] Move AbbreviationCode out of DwarfAbbrev --- .../Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs | 7 ++----- .../Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs | 14 ++++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index 8e9d56dbfdcebe..a2f6e69d1b4972 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -9,9 +9,9 @@ internal sealed class DwarfAbbrev { private readonly ushort[] _definition; - public static ushort DW_FORM_size = 0xDEAD; // Dummy value + public const ushort DW_FORM_size = 0xDEAD; // Dummy value - public DwarfAbbrev(ushort[] definition) + private DwarfAbbrev(ushort[] definition) { _definition = definition; } @@ -20,11 +20,8 @@ public DwarfAbbrev(ushort[] definition) public bool HasChildren => _definition[1] == DW_CHILDREN_yes; - public int AbbreviationCode { get; set; } - public void Write(SectionWriter writer, int targetPointerSize) { - writer.WriteULEB128((ulong)AbbreviationCode); writer.WriteULEB128(Tag); writer.WriteULEB128(HasChildren ? DW_CHILDREN_yes : DW_CHILDREN_no); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index a2bda448429532..9b3abb1dac2ef0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -23,7 +23,7 @@ private sealed record InfoReference(uint TypeIndex, int Position, byte[] Data); private readonly RelocType _codeRelocType; private readonly List _lateBoundReferences = new(); private readonly Stack _dieStack = new(); - private readonly List _usedAbbrevs = new(); + private readonly Dictionary _usedAbbrevs = new(); private readonly ArrayBufferWriter _expressionBufferWriter = new(); public DwarfInfoWriter( @@ -56,14 +56,15 @@ public void WriteStartDIE(DwarfAbbrev abbrev) throw new InvalidOperationException($"Trying to write a children into DIE (Tag {_dieStack.Peek().Tag}) with DW_CHILDREN_no"); } - if (abbrev.AbbreviationCode == 0) + if (!_usedAbbrevs.TryGetValue(abbrev, out int abbreviationCode)) { - _usedAbbrevs.Add(abbrev); - abbrev.AbbreviationCode = _usedAbbrevs.Count; + abbreviationCode = _usedAbbrevs.Count + 1; + _usedAbbrevs.Add(abbrev, abbreviationCode); } + _dieStack.Push(abbrev); - WriteULEB128((ulong)abbrev.AbbreviationCode); + WriteULEB128((ulong)abbreviationCode); } public void WriteEndDIE() @@ -208,8 +209,9 @@ public void Dispose() } // Write abbreviation section - foreach (var abbrev in _usedAbbrevs) + foreach ((DwarfAbbrev abbrev, int abbreviationCode) in _usedAbbrevs) { + _abbrevSectionWriter.WriteULEB128((ulong)abbreviationCode); abbrev.Write(_abbrevSectionWriter, TargetPointerSize); } _abbrevSectionWriter.Write([0, 0]); From c07a3d75da0e29799816c685a1cc68de168d72e5 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:19:12 +0100 Subject: [PATCH 136/144] More readonly treatment --- .../ObjectWriter/Dwarf/DwarfAbbrev.cs | 80 +++++++++---------- .../Compiler/ObjectWriter/Dwarf/DwarfInfo.cs | 4 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs index a2f6e69d1b4972..4475b239aad3c9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfAbbrev.cs @@ -47,7 +47,7 @@ public void Write(SectionWriter writer, int targetPointerSize) writer.Write([0, 0]); } - public static DwarfAbbrev CompileUnit = new([ + public static readonly DwarfAbbrev CompileUnit = new([ DW_TAG_compile_unit, DW_CHILDREN_yes, DW_AT_producer, DW_FORM_strp, DW_AT_language, DW_FORM_data2, @@ -57,50 +57,50 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_ranges, DW_FORM_sec_offset, DW_AT_stmt_list, DW_FORM_sec_offset]); - public static DwarfAbbrev BaseType = new([ + public static readonly DwarfAbbrev BaseType = new([ DW_TAG_base_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_encoding, DW_FORM_data1, DW_AT_byte_size, DW_FORM_data1]); - public static DwarfAbbrev EnumerationType = new([ + public static readonly DwarfAbbrev EnumerationType = new([ DW_TAG_enumeration_type, DW_CHILDREN_yes, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_byte_size, DW_FORM_data1]); - public static DwarfAbbrev EnumerationTypeNoChildren = new([ + public static readonly DwarfAbbrev EnumerationTypeNoChildren = new([ DW_TAG_enumeration_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_byte_size, DW_FORM_data1]); - public static DwarfAbbrev Enumerator1 = new([ + public static readonly DwarfAbbrev Enumerator1 = new([ DW_TAG_enumerator, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_const_value, DW_FORM_data1]); - public static DwarfAbbrev Enumerator2 = new([ + public static readonly DwarfAbbrev Enumerator2 = new([ DW_TAG_enumerator, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_const_value, DW_FORM_data2]); - public static DwarfAbbrev Enumerator4 = new([ + public static readonly DwarfAbbrev Enumerator4 = new([ DW_TAG_enumerator, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_const_value, DW_FORM_data4]); - public static DwarfAbbrev Enumerator8 = new([ + public static readonly DwarfAbbrev Enumerator8 = new([ DW_TAG_enumerator, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_const_value, DW_FORM_data8]); - public static DwarfAbbrev TypeDef = new([ + public static readonly DwarfAbbrev TypeDef = new([ DW_TAG_typedef, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4]); - public static DwarfAbbrev Subprogram = new([ + public static readonly DwarfAbbrev Subprogram = new([ DW_TAG_subprogram, DW_CHILDREN_yes, DW_AT_specification, DW_FORM_ref4, DW_AT_low_pc, DW_FORM_addr, @@ -108,7 +108,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_frame_base, DW_FORM_exprloc, DW_AT_object_pointer, DW_FORM_ref4]); - public static DwarfAbbrev SubprogramNoChildren = new([ + public static readonly DwarfAbbrev SubprogramNoChildren = new([ DW_TAG_subprogram, DW_CHILDREN_no, DW_AT_specification, DW_FORM_ref4, DW_AT_low_pc, DW_FORM_addr, @@ -116,21 +116,21 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_frame_base, DW_FORM_exprloc, DW_AT_object_pointer, DW_FORM_ref4]); - public static DwarfAbbrev SubprogramStatic = new([ + public static readonly DwarfAbbrev SubprogramStatic = new([ DW_TAG_subprogram, DW_CHILDREN_yes, DW_AT_specification, DW_FORM_ref4, DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size, DW_AT_frame_base, DW_FORM_exprloc]); - public static DwarfAbbrev SubprogramStaticNoChildren = new([ + public static readonly DwarfAbbrev SubprogramStaticNoChildren = new([ DW_TAG_subprogram, DW_CHILDREN_no, DW_AT_specification, DW_FORM_ref4, DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size, DW_AT_frame_base, DW_FORM_exprloc]); - public static DwarfAbbrev SubprogramSpec = new([ + public static readonly DwarfAbbrev SubprogramSpec = new([ DW_TAG_subprogram, DW_CHILDREN_yes, DW_AT_name, DW_FORM_strp, DW_AT_linkage_name, DW_FORM_strp, @@ -141,7 +141,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_declaration, DW_FORM_flag_present, DW_AT_object_pointer, DW_FORM_ref4]); - public static DwarfAbbrev SubprogramStaticSpec = new([ + public static readonly DwarfAbbrev SubprogramStaticSpec = new([ DW_TAG_subprogram, DW_CHILDREN_yes, DW_AT_name, DW_FORM_strp, DW_AT_linkage_name, DW_FORM_strp, @@ -151,7 +151,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_external, DW_FORM_flag_present, DW_AT_declaration, DW_FORM_flag_present]); - public static DwarfAbbrev SubprogramStaticNoChildrenSpec = new([ + public static readonly DwarfAbbrev SubprogramStaticNoChildrenSpec = new([ DW_TAG_subprogram, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_linkage_name, DW_FORM_strp, @@ -161,7 +161,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_external, DW_FORM_flag_present, DW_AT_declaration, DW_FORM_flag_present]); - public static DwarfAbbrev Variable = new([ + public static readonly DwarfAbbrev Variable = new([ DW_TAG_variable, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -169,7 +169,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_type, DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc]); - public static DwarfAbbrev VariableLoc = new([ + public static readonly DwarfAbbrev VariableLoc = new([ DW_TAG_variable, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -177,12 +177,12 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_type, DW_FORM_ref4, DW_AT_location, DW_FORM_sec_offset]); - public static DwarfAbbrev VariableStatic = new([ + public static readonly DwarfAbbrev VariableStatic = new([ DW_TAG_variable, DW_CHILDREN_no, DW_AT_specification, DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc]); - public static DwarfAbbrev FormalParameter = new([ + public static readonly DwarfAbbrev FormalParameter = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -190,7 +190,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_type, DW_FORM_ref4, DW_AT_location, DW_FORM_exprloc]); - public static DwarfAbbrev FormalParameterThis = new([ + public static readonly DwarfAbbrev FormalParameterThis = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -199,7 +199,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_location, DW_FORM_exprloc, DW_AT_artificial, DW_FORM_flag_present]); - public static DwarfAbbrev FormalParameterLoc = new([ + public static readonly DwarfAbbrev FormalParameterLoc = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -207,7 +207,7 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_type, DW_FORM_ref4, DW_AT_location, DW_FORM_sec_offset]); - public static DwarfAbbrev FormalParameterThisLoc = new([ + public static readonly DwarfAbbrev FormalParameterThisLoc = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, @@ -216,86 +216,86 @@ public void Write(SectionWriter writer, int targetPointerSize) DW_AT_location, DW_FORM_sec_offset, DW_AT_artificial, DW_FORM_flag_present]); - public static DwarfAbbrev FormalParameterSpec = new([ + public static readonly DwarfAbbrev FormalParameterSpec = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4]); - public static DwarfAbbrev FormalParameterThisSpec = new([ + public static readonly DwarfAbbrev FormalParameterThisSpec = new([ DW_TAG_formal_parameter, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4, DW_AT_artificial, DW_FORM_flag_present]); - public static DwarfAbbrev ClassType = new([ + public static readonly DwarfAbbrev ClassType = new([ DW_TAG_class_type, DW_CHILDREN_yes, DW_AT_name, DW_FORM_strp, DW_AT_byte_size, DW_FORM_data4]); - public static DwarfAbbrev ClassTypeNoChildren = new([ + public static readonly DwarfAbbrev ClassTypeNoChildren = new([ DW_TAG_class_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_byte_size, DW_FORM_data4]); - public static DwarfAbbrev ClassTypeDecl = new([ + public static readonly DwarfAbbrev ClassTypeDecl = new([ DW_TAG_class_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_declaration, DW_FORM_flag_present]); - public static DwarfAbbrev ClassMember = new([ + public static readonly DwarfAbbrev ClassMember = new([ DW_TAG_member, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_data_member_location, DW_FORM_data4]); - public static DwarfAbbrev ClassMemberStatic = new([ + public static readonly DwarfAbbrev ClassMemberStatic = new([ DW_TAG_member, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, DW_AT_external, DW_FORM_flag_present, DW_AT_declaration, DW_FORM_flag_present]); - public static DwarfAbbrev PointerType = new([ + public static readonly DwarfAbbrev PointerType = new([ DW_TAG_pointer_type, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4, DW_AT_byte_size, DW_FORM_data1]); - public static DwarfAbbrev ReferenceType = new([ + public static readonly DwarfAbbrev ReferenceType = new([ DW_TAG_reference_type, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4, DW_AT_byte_size, DW_FORM_data1]); - public static DwarfAbbrev ArrayType = new([ + public static readonly DwarfAbbrev ArrayType = new([ DW_TAG_array_type, DW_CHILDREN_yes, DW_AT_type, DW_FORM_ref4]); - public static DwarfAbbrev SubrangeType = new([ + public static readonly DwarfAbbrev SubrangeType = new([ DW_TAG_subrange_type, DW_CHILDREN_no, DW_AT_upper_bound, DW_FORM_udata]); - public static DwarfAbbrev ClassInheritance = new([ + public static readonly DwarfAbbrev ClassInheritance = new([ DW_TAG_inheritance, DW_CHILDREN_no, DW_AT_type, DW_FORM_ref4, DW_AT_data_member_location, DW_FORM_data1]); - public static DwarfAbbrev LexicalBlock = new([ + public static readonly DwarfAbbrev LexicalBlock = new([ DW_TAG_lexical_block, DW_CHILDREN_yes, DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size]); - public static DwarfAbbrev TryBlock = new([ + public static readonly DwarfAbbrev TryBlock = new([ DW_TAG_try_block, DW_CHILDREN_no, DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size]); - public static DwarfAbbrev CatchBlock = new([ + public static readonly DwarfAbbrev CatchBlock = new([ DW_TAG_catch_block, DW_CHILDREN_no, DW_AT_low_pc, DW_FORM_addr, DW_AT_high_pc, DW_FORM_size]); - public static DwarfAbbrev VoidType = new([ + public static readonly DwarfAbbrev VoidType = new([ DW_TAG_unspecified_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp]); - public static DwarfAbbrev VoidPointerType = new([ + public static readonly DwarfAbbrev VoidPointerType = new([ DW_TAG_pointer_type, DW_CHILDREN_no]); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs index f796dc8ac8d288..b1408e3eae3bb0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfo.cs @@ -20,8 +20,8 @@ internal abstract class DwarfInfo internal sealed class DwarfPrimitiveTypeInfo : DwarfInfo { - private TypeFlags _typeFlags; - private int _targetPointerSize; + private readonly TypeFlags _typeFlags; + private readonly int _targetPointerSize; public DwarfPrimitiveTypeInfo(TypeFlags typeFlags, int targetPointerSize) { From a1ad9761f0706c501716dc2b7117a1daee8f0142 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:26:01 +0100 Subject: [PATCH 137/144] Update comment --- .../Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs index 25da10934675c1..e5fc700e78361e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs @@ -342,7 +342,10 @@ public uint GetArrayTypeIndex( Name = "m_Data", }); - // TODO: Verify that this makes sense + // We currently don't encode the size of the variable length data. The DWARF5 + // specification allows encoding variable length arrays through DW_AT_lower_bound, + // DW_AT_upper_bound, and DW_AT_count expressions. There's potentially room + // to improve the debugging information by a more substential restructuring. arrayClassDescriptor.InstanceSize = fieldOffset; ClassFieldsTypeDescriptor fieldsTypeDesc = new ClassFieldsTypeDescriptor From eb143fdd9936b1d14239d7553df34070b140ae63 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:28:05 +0100 Subject: [PATCH 138/144] Consistently throw exception for unsupported architectures --- .../Compiler/ObjectWriter/Dwarf/DwarfCie.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs index 57054a1186e618..64ec8dce601b9b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs @@ -52,8 +52,6 @@ public DwarfCie(TargetArchitecture targetArchitecture) InitialCFAOffset = 0; break; - //case TargetArchitecture.ARM: - case TargetArchitecture.X64: CodeAlignFactor = 1; DataAlignFactor = -8; @@ -69,10 +67,8 @@ public DwarfCie(TargetArchitecture targetArchitecture) InitialCFAOffset = 8; break; - //case TargetArchitecture.X86: - default: - throw new NotSupportedException(); + throw new NotSupportedException("Unsupported architecture"); } } } From a182ea76327ec0297b5e6682d89ae2e3c6885cfb Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:31:24 +0100 Subject: [PATCH 139/144] Use the WriteLittleEndian helper method where appropriate --- .../Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 5d38e30c934f92..5ea5a7afc86a54 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -47,7 +47,6 @@ private void WriteCie(DwarfCie cie) { Utf8StringBuilder augmentationString = new Utf8StringBuilder(); uint augmentationLength = 0; - Span tempBuffer = stackalloc byte[8]; if (cie.FdesHaveAugmentationData) { @@ -85,8 +84,7 @@ private void WriteCie(DwarfCie cie) (uint)cie.Instructions.Length; uint padding = ((length + 7u) & ~7u) - length; - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - _sectionWriter.Write(tempBuffer); + _sectionWriter.WriteLittleEndian(length + padding - 4u); _sectionWriter.WriteByte(cie.ReturnAddressRegister < 0x7F ? (byte)1u : (byte)3u); // Version _sectionWriter.Write(augmentationString.UnderlyingArray); @@ -117,8 +115,6 @@ private void WriteCie(DwarfCie cie) private void WriteFde(DwarfFde fde, uint cieOffset) { - Span tempBuffer = stackalloc byte[8]; - uint augmentationLength = fde.Cie.FdesHaveAugmentationData ? 1u + // Length @@ -134,10 +130,8 @@ private void WriteFde(DwarfFde fde, uint cieOffset) (uint)fde.Instructions.Length; uint padding = ((length + 7u) & ~7u) - length; - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, length + padding - 4u); - _sectionWriter.Write(tempBuffer.Slice(0, 4)); - BinaryPrimitives.WriteUInt32LittleEndian(tempBuffer, (uint)(_sectionWriter.Position - cieOffset)); - _sectionWriter.Write(tempBuffer.Slice(0, 4)); + _sectionWriter.WriteLittleEndian(length + padding - 4u); + _sectionWriter.WriteLittleEndian((uint)(_sectionWriter.Position - cieOffset)); WriteAddress(fde.Cie.PointerEncoding, fde.PcStartSymbolName, fde.PcStartSymbolOffset); WriteSize(fde.Cie.PointerEncoding, fde.PcLength); From 939fa83e2776e8aa3d580180c9ff0e47473f49a3 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:45:39 +0100 Subject: [PATCH 140/144] Refactor how DwarfFde/DwarfCie are constructed and make them readonly structs --- .../Compiler/ObjectWriter/Dwarf/DwarfCie.cs | 24 +++++------ .../ObjectWriter/Dwarf/DwarfEhFrame.cs | 4 +- .../Compiler/ObjectWriter/Dwarf/DwarfFde.cs | 43 ++++++++++++------- .../Compiler/ObjectWriter/UnixObjectWriter.cs | 16 +++---- 4 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs index 64ec8dce601b9b..d6bb68908f892e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs @@ -7,19 +7,19 @@ namespace ILCompiler.ObjectWriter { - internal sealed class DwarfCie + internal readonly struct DwarfCie { - public byte PointerEncoding; - public byte LsdaEncoding; - public byte PersonalityEncoding; - public string PersonalitySymbolName; - public uint CodeAlignFactor; - public int DataAlignFactor; - public bool IsSignalFrame; - public bool FdesHaveAugmentationData; - public byte ReturnAddressRegister; - public byte[] Instructions; - public byte InitialCFAOffset; + public readonly byte PointerEncoding; + public readonly byte LsdaEncoding; + public readonly byte PersonalityEncoding; + public readonly string PersonalitySymbolName; + public readonly uint CodeAlignFactor; + public readonly int DataAlignFactor; + public readonly bool IsSignalFrame; + public readonly bool FdesHaveAugmentationData; + public readonly byte ReturnAddressRegister; + public readonly byte[] Instructions; + public readonly byte InitialCFAOffset; public DwarfCie(TargetArchitecture targetArchitecture) { diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 5ea5a7afc86a54..76843ae3bb0e65 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -24,13 +24,13 @@ public DwarfEhFrame(SectionWriter sectionWriter, bool is64Bit) _is64Bit = is64Bit; } - public void AddCie(DwarfCie cie) + public void AddCie(in DwarfCie cie) { _cieOffset.Add(cie, (uint)_sectionWriter.Position); WriteCie(cie); } - public void AddFde(DwarfFde fde) + public void AddFde(in DwarfFde fde) { uint cieOffset; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs index 4239c383a2f401..ea3bcdc740ec0d 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfFde.cs @@ -8,21 +8,32 @@ namespace ILCompiler.ObjectWriter { - internal sealed class DwarfFde + internal readonly struct DwarfFde { public readonly DwarfCie Cie; - public string PcStartSymbolName; - public long PcStartSymbolOffset; - public ulong PcLength; - public string LsdaSymbolName; - public string PersonalitySymbolName; public readonly byte[] Instructions; + public readonly string PcStartSymbolName; + public readonly long PcStartSymbolOffset; + public readonly ulong PcLength; + public readonly string LsdaSymbolName; + public readonly string PersonalitySymbolName; - public DwarfFde(DwarfCie cie, byte[] instructions) + public DwarfFde( + DwarfCie cie, + byte[] blobData, + string pcStartSymbolName, + long pcStartSymbolOffset, + ulong pcLength, + string lsdaSymbolName, + string personalitySymbolName) { Cie = cie; - Instructions = instructions; - PersonalitySymbolName = null; + Instructions = CfiCodeToInstructions(cie, blobData); + PcStartSymbolName = pcStartSymbolName; + PcStartSymbolOffset = pcStartSymbolOffset; + PcLength = pcLength; + LsdaSymbolName = lsdaSymbolName; + PersonalitySymbolName = personalitySymbolName; } private enum CFI_OPCODE @@ -36,7 +47,7 @@ private enum CFI_OPCODE /// /// Convert JIT version of CFI blob into the the DWARF byte code form. /// - public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) + private static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) { int cfaOffset = cie.InitialCFAOffset; var cfiCode = ArrayPool.Shared.Rent(4096); @@ -59,12 +70,12 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) int diff = (int)((codeOffset - lastCodeOffset) / cie.CodeAlignFactor); if (diff <= 0x3F) { - cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_advance_loc | diff); + cfiCode[cfiCodeOffset++] = (byte)(DW_CFA_advance_loc | diff); } else { Debug.Assert(diff <= 0xFF); - cfiCode[cfiCodeOffset++] = (byte)DW_CFA_advance_loc1; + cfiCode[cfiCodeOffset++] = DW_CFA_advance_loc1; cfiCode[cfiCodeOffset++] = (byte)diff; } lastCodeOffset = codeOffset; @@ -73,14 +84,14 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) switch (opcode) { case CFI_OPCODE.CFI_DEF_CFA_REGISTER: - cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa_register; + cfiCode[cfiCodeOffset++] = DW_CFA_def_cfa_register; cfiCode[cfiCodeOffset++] = (byte)dwarfReg; break; case CFI_OPCODE.CFI_REL_OFFSET: if (dwarfReg <= 0x3F) { - cfiCode[cfiCodeOffset++] = (byte)((byte)DW_CFA_offset | (byte)dwarfReg); + cfiCode[cfiCodeOffset++] = (byte)(DW_CFA_offset | (byte)dwarfReg); } else { @@ -91,13 +102,13 @@ public static byte[] CfiCodeToInstructions(DwarfCie cie, byte[] blobData) break; case CFI_OPCODE.CFI_ADJUST_CFA_OFFSET: - cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa_offset; + cfiCode[cfiCodeOffset++] = DW_CFA_def_cfa_offset; cfaOffset += cfiOffset; cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)cfaOffset); break; case CFI_OPCODE.CFI_DEF_CFA: - cfiCode[cfiCodeOffset++] = (byte)DW_CFA_def_cfa; + cfiCode[cfiCodeOffset++] = DW_CFA_def_cfa; cfiCode[cfiCodeOffset++] = (byte)dwarfReg; cfaOffset = cfiOffset; cfiCodeOffset += DwarfHelper.WriteULEB128(cfiCode.AsSpan(cfiCodeOffset), (uint)cfaOffset); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs index a76db546ff00ed..37d274b7946497 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/UnixObjectWriter.cs @@ -146,14 +146,14 @@ private protected override void EmitUnwindInfo( ulong length = (ulong)(end - start); if (!EmitCompactUnwinding(startSymbolName, length, lsdaSymbolName, blob)) { - var fde = new DwarfFde(_dwarfCie, DwarfFde.CfiCodeToInstructions(_dwarfCie, blob)) - { - PcStartSymbolName = startSymbolName, - PcStartSymbolOffset = useFrameNames ? 0 : start, - PcLength = (ulong)(end - start), - LsdaSymbolName = lsdaSymbolName, - }; - + var fde = new DwarfFde( + _dwarfCie, + blob, + pcStartSymbolName: startSymbolName, + pcStartSymbolOffset: useFrameNames ? 0 : start, + pcLength: (ulong)(end - start), + lsdaSymbolName, + personalitySymbolName: null); _dwarfEhFrame.AddFde(fde); } } From 47e8094ba36ce11a58a090260caeb82e09e4afdf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 10:54:20 +0100 Subject: [PATCH 141/144] Add WritePadding method and use it instead of Write(stackalloc byte[...]) --- .../Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs | 4 ++-- .../Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs | 2 +- .../Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs | 7 +++---- .../Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs | 4 ++-- .../Compiler/ObjectWriter/SectionWriter.cs | 2 ++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs index ba600a349d4b89..c5aa7f8b4ee2bc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/CodeView/CodeViewTypesBuilder.cs @@ -416,7 +416,7 @@ public void Dispose() BinaryPrimitives.WriteUInt16LittleEndian(lengthBuffer, (ushort)(length + padding - sizeof(ushort))); _debugTypesBuilder._sectionWriter.Write(lengthBuffer); _debugTypesBuilder._sectionWriter.Write(_bufferWriter.WrittenSpan); - _debugTypesBuilder._sectionWriter.Write(stackalloc byte[padding]); + _debugTypesBuilder._sectionWriter.WritePadding(padding); _bufferWriter.Clear(); } @@ -515,7 +515,7 @@ public void EndListEntry() int padding = ((length + 3) & ~3) - length; _debugTypesBuilder._sectionWriter.WriteLittleEndian((ushort)(length + padding - sizeof(ushort))); _debugTypesBuilder._sectionWriter.Write(_bufferWriter.WrittenSpan.Slice(0, _lastListMemberStart)); - _debugTypesBuilder._sectionWriter.Write(stackalloc byte[padding]); + _debugTypesBuilder._sectionWriter.WritePadding(padding); byte[] overflow = _bufferWriter.WrittenSpan.Slice(_lastListMemberStart).ToArray(); _bufferWriter.Clear(); diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs index e5fc700e78361e..d79abeea30c5d8 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfBuilder.cs @@ -244,7 +244,7 @@ private void WriteAddressRangeTable(SectionWriter arangeSectionWriter) default: throw new NotSupportedException(); } } - arangeSectionWriter.Write(stackalloc byte[_targetPointerSize * 2]); + arangeSectionWriter.WritePadding(_targetPointerSize * 2); // Update the size BinaryPrimitives.WriteUInt32LittleEndian(sizeBuffer, (uint)(arangeSectionWriter.Position - sizeof(uint))); } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index 76843ae3bb0e65..bfcaf66e5a0fa9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -110,7 +110,7 @@ private void WriteCie(DwarfCie cie) _sectionWriter.Write(cie.Instructions); - _sectionWriter.Write(stackalloc byte[(int)padding]); + _sectionWriter.WritePadding((int)padding); } private void WriteFde(DwarfFde fde, uint cieOffset) @@ -149,7 +149,7 @@ private void WriteFde(DwarfFde fde, uint cieOffset) } _sectionWriter.Write(fde.Instructions); - _sectionWriter.Write(stackalloc byte[(int)padding]); + _sectionWriter.WritePadding((int)padding); } private uint AddressSize(byte encoding) @@ -177,8 +177,7 @@ private void WriteAddress(byte encoding, string symbolName, long symbolOffset = } else { - Span address = stackalloc byte[(int)AddressSize(encoding)]; - _sectionWriter.Write(address); + _sectionWriter.WritePadding((int)AddressSize(encoding)); } } diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs index 9b3abb1dac2ef0..3a2290fb6d5312 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfInfoWriter.cs @@ -169,7 +169,7 @@ public void WriteLocationListExpression(string methodName, long startOffset, lon public void WriteEndLocationList() { - _locSectionWriter.Write(stackalloc byte[TargetPointerSize * 2]); + _locSectionWriter.WritePadding(TargetPointerSize * 2); } public void WriteStartRangeList() @@ -187,7 +187,7 @@ public void WriteRangeListEntry(string symbolName, long startOffset, long endOff public void WriteEndRangeList() { - _rangeSectionWriter.Write(stackalloc byte[TargetPointerSize * 2]); + _rangeSectionWriter.WritePadding(TargetPointerSize * 2); } public void Dispose() diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index 957582ce310668..c7a52e6bf46a96 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -125,6 +125,8 @@ public readonly void WriteUtf8String(string value) bufferWriter.Advance(size); } + public readonly void WritePadding(int size) => _sectionData.AppendPadding(size); + public readonly long Position => _sectionData.Length; } } From 96a9e7cc311a4e4d44c997b1c80eb4bfc9aad367 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 13:31:26 +0100 Subject: [PATCH 142/144] Fix DWARF EH frame building --- .../Compiler/ObjectWriter/Dwarf/DwarfCie.cs | 2 +- .../Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs | 5 +++-- .../Compiler/ObjectWriter/SectionWriter.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs index d6bb68908f892e..f0bc413e2c6e70 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfCie.cs @@ -7,7 +7,7 @@ namespace ILCompiler.ObjectWriter { - internal readonly struct DwarfCie + internal sealed class DwarfCie { public readonly byte PointerEncoding; public readonly byte LsdaEncoding; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs index bfcaf66e5a0fa9..d0e147b28eb0d4 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/Dwarf/DwarfEhFrame.cs @@ -24,7 +24,7 @@ public DwarfEhFrame(SectionWriter sectionWriter, bool is64Bit) _is64Bit = is64Bit; } - public void AddCie(in DwarfCie cie) + public void AddCie(DwarfCie cie) { _cieOffset.Add(cie, (uint)_sectionWriter.Position); WriteCie(cie); @@ -85,6 +85,7 @@ private void WriteCie(DwarfCie cie) uint padding = ((length + 7u) & ~7u) - length; _sectionWriter.WriteLittleEndian(length + padding - 4u); + _sectionWriter.WriteLittleEndian(0); _sectionWriter.WriteByte(cie.ReturnAddressRegister < 0x7F ? (byte)1u : (byte)3u); // Version _sectionWriter.Write(augmentationString.UnderlyingArray); @@ -113,7 +114,7 @@ private void WriteCie(DwarfCie cie) _sectionWriter.WritePadding((int)padding); } - private void WriteFde(DwarfFde fde, uint cieOffset) + private void WriteFde(in DwarfFde fde, uint cieOffset) { uint augmentationLength = fde.Cie.FdesHaveAugmentationData ? diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index c7a52e6bf46a96..ee85c343ddce93 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -125,7 +125,7 @@ public readonly void WriteUtf8String(string value) bufferWriter.Advance(size); } - public readonly void WritePadding(int size) => _sectionData.AppendPadding(size); + public readonly void WritePadding(int size) => Write(stackalloc byte[size]);//_sectionData.AppendPadding(size); public readonly long Position => _sectionData.Length; } From 1fa507494b5b6a61ffe82adbe894fd203be0f00d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 5 Jan 2024 13:35:48 +0100 Subject: [PATCH 143/144] Revert accidental change --- .../ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs index ee85c343ddce93..c7a52e6bf46a96 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/SectionWriter.cs @@ -125,7 +125,7 @@ public readonly void WriteUtf8String(string value) bufferWriter.Advance(size); } - public readonly void WritePadding(int size) => Write(stackalloc byte[size]);//_sectionData.AppendPadding(size); + public readonly void WritePadding(int size) => _sectionData.AppendPadding(size); public readonly long Position => _sectionData.Length; } From e716e3d5d4c0e4e49f22804dc4a7f8ef2d225c32 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 6 Jan 2024 19:07:23 +0100 Subject: [PATCH 144/144] Add code paths for ARM32 to ELF object writer This only serves as a testbed for the 32-bit ELF support, rest of the NativeAOT runtime is still largely broken. We also try to emit DWARF exception handling instead of the ARM EHABI. --- .../Compiler/ObjectWriter/ElfNative.cs | 129 ++++++++++++++++++ .../Compiler/ObjectWriter/ElfObjectWriter.cs | 49 ++++++- 2 files changed, 177 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs index 5f6d0eea5d7636..b39253a02e8545 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfNative.cs @@ -22,6 +22,7 @@ internal static class ElfNative // Architecture public const ushort EM_386 = 3; + public const ushort EM_ARM = 40; public const ushort EM_X86_64 = 62; public const ushort EM_AARCH64 = 183; @@ -170,6 +171,134 @@ internal static class ElfNative public const uint R_X86_64_IRELATIVE = 37; public const uint R_X86_64_RELATIVE64 = 38; + // Relocations (arm32) + public const uint R_ARM_NONE = 0; + public const uint R_ARM_PC24 = 1; + public const uint R_ARM_ABS32 = 2; + public const uint R_ARM_REL32 = 3; + public const uint R_ARM_PC13 = 4; + public const uint R_ARM_ABS16 = 5; + public const uint R_ARM_ABS12 = 6; + public const uint R_ARM_THM_ABS5 = 7; + public const uint R_ARM_ABS8 = 8; + public const uint R_ARM_SBREL32 = 9; + public const uint R_ARM_THM_PC22 = 10; + public const uint R_ARM_THM_PC8 = 11; + public const uint R_ARM_AMP_VCALL9 = 12; + public const uint R_ARM_SWI24 = 13; + public const uint R_ARM_TLS_DESC = 13; + public const uint R_ARM_THM_SWI8 = 14; + public const uint R_ARM_XPC25 = 15; + public const uint R_ARM_THM_XPC22 = 16; + public const uint R_ARM_TLS_DTPMOD32 = 17; + public const uint R_ARM_TLS_DTPOFF32 = 18; + public const uint R_ARM_TLS_TPOFF32 = 19; + public const uint R_ARM_COPY = 20; + public const uint R_ARM_GLOB_DAT = 21; + public const uint R_ARM_JUMP_SLOT = 22; + public const uint R_ARM_RELATIVE = 23; + public const uint R_ARM_GOTOFF = 24; + public const uint R_ARM_GOTPC = 25; + public const uint R_ARM_GOT32 = 26; + public const uint R_ARM_PLT32 = 27; + public const uint R_ARM_CALL = 28; + public const uint R_ARM_JUMP24 = 29; + public const uint R_ARM_THM_JUMP24 = 30; + public const uint R_ARM_BASE_ABS = 31; + public const uint R_ARM_ALU_PCREL_7_0 = 32; + public const uint R_ARM_ALU_PCREL_15_8 = 33; + public const uint R_ARM_ALU_PCREL_23_15 = 34; + public const uint R_ARM_LDR_SBREL_11_0 = 35; + public const uint R_ARM_ALU_SBREL_19_12 = 36; + public const uint R_ARM_ALU_SBREL_27_20 = 37; + public const uint R_ARM_TARGET1 = 38; + public const uint R_ARM_SBREL31 = 39; + public const uint R_ARM_V4BX = 40; + public const uint R_ARM_TARGET2 = 41; + public const uint R_ARM_PREL31 = 42; + public const uint R_ARM_MOVW_ABS_NC = 43; + public const uint R_ARM_MOVT_ABS = 44; + public const uint R_ARM_MOVW_PREL_NC = 45; + public const uint R_ARM_MOVT_PREL = 46; + public const uint R_ARM_THM_MOVW_ABS_NC = 47; + public const uint R_ARM_THM_MOVT_ABS = 48; + public const uint R_ARM_THM_MOVW_PREL_NC = 49; + public const uint R_ARM_THM_MOVT_PREL = 50; + public const uint R_ARM_THM_JUMP19 = 51; + public const uint R_ARM_THM_JUMP6 = 52; + public const uint R_ARM_THM_ALU_PREL_11_0 = 53; + public const uint R_ARM_THM_PC12 = 54; + public const uint R_ARM_ABS32_NOI = 55; + public const uint R_ARM_REL32_NOI = 56; + public const uint R_ARM_ALU_PC_G0_NC = 57; + public const uint R_ARM_ALU_PC_G0 = 58; + public const uint R_ARM_ALU_PC_G1_NC = 59; + public const uint R_ARM_ALU_PC_G1 = 60; + public const uint R_ARM_ALU_PC_G2 = 61; + public const uint R_ARM_LDR_PC_G1 = 62; + public const uint R_ARM_LDR_PC_G2 = 63; + public const uint R_ARM_LDRS_PC_G0 = 64; + public const uint R_ARM_LDRS_PC_G1 = 65; + public const uint R_ARM_LDRS_PC_G2 = 66; + public const uint R_ARM_LDC_PC_G0 = 67; + public const uint R_ARM_LDC_PC_G1 = 68; + public const uint R_ARM_LDC_PC_G2 = 69; + public const uint R_ARM_ALU_SB_G0_NC = 70; + public const uint R_ARM_ALU_SB_G0 = 71; + public const uint R_ARM_ALU_SB_G1_NC = 72; + public const uint R_ARM_ALU_SB_G1 = 73; + public const uint R_ARM_ALU_SB_G2 = 74; + public const uint R_ARM_LDR_SB_G0 = 75; + public const uint R_ARM_LDR_SB_G1 = 76; + public const uint R_ARM_LDR_SB_G2 = 77; + public const uint R_ARM_LDRS_SB_G0 = 78; + public const uint R_ARM_LDRS_SB_G1 = 79; + public const uint R_ARM_LDRS_SB_G2 = 80; + public const uint R_ARM_LDC_SB_G0 = 81; + public const uint R_ARM_LDC_SB_G1 = 82; + public const uint R_ARM_LDC_SB_G2 = 83; + public const uint R_ARM_MOVW_BREL_NC = 84; + public const uint R_ARM_MOVT_BREL = 85; + public const uint R_ARM_MOVW_BREL = 86; + public const uint R_ARM_THM_MOVW_BREL_NC = 87; + public const uint R_ARM_THM_MOVT_BREL = 88; + public const uint R_ARM_THM_MOVW_BREL = 89; + public const uint R_ARM_TLS_GOTDESC = 90; + public const uint R_ARM_TLS_CALL = 91; + public const uint R_ARM_TLS_DESCSEQ = 92; + public const uint R_ARM_THM_TLS_CALL = 93; + public const uint R_ARM_PLT32_ABS = 94; + public const uint R_ARM_GOT_ABS = 95; + public const uint R_ARM_GOT_PREL = 96; + public const uint R_ARM_GOT_BREL12 = 97; + public const uint R_ARM_GOTOFF12 = 98; + public const uint R_ARM_GOTRELAX = 99; + public const uint R_ARM_GNU_VTENTRY = 100; + public const uint R_ARM_GNU_VTINHERIT = 101; + public const uint R_ARM_THM_PC11 = 102; + public const uint R_ARM_THM_PC9 = 103; + public const uint R_ARM_TLS_GD32 = 104; + public const uint R_ARM_TLS_LDM32 = 105; + public const uint R_ARM_TLS_LDO32 = 106; + public const uint R_ARM_TLS_IE32 = 107; + public const uint R_ARM_TLS_LE32 = 108; + public const uint R_ARM_TLS_LDO12 = 109; + public const uint R_ARM_TLS_LE12 = 110; + public const uint R_ARM_TLS_IE12GP = 111; + public const uint R_ARM_ME_TOO = 128; + public const uint R_ARM_THM_TLS_DESCSEQ = 129; + public const uint R_ARM_THM_TLS_DESCSEQ16 = 129; + public const uint R_ARM_THM_TLS_DESCSEQ32 = 130; + public const uint R_ARM_THM_GOT_BREL12 = 131; + public const uint R_ARM_IRELATIVE = 160; + public const uint R_ARM_RXPC25 = 249; + public const uint R_ARM_RSBREL32 = 250; + public const uint R_ARM_THM_RPC22 = 251; + public const uint R_ARM_RREL32 = 252; + public const uint R_ARM_RABS22 = 253; + public const uint R_ARM_RPC24 = 254; + public const uint R_ARM_RBASE = 255; + // Relocations (arm64) public const uint R_AARCH64_NONE = 0; public const uint R_AARCH64_P32_ABS32 = 1; diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs index f310b8c59b344f..00648d5d7b897a 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ElfObjectWriter.cs @@ -48,6 +48,7 @@ public ElfObjectWriter(NodeFactory factory, ObjectWritingOptions options) { TargetArchitecture.X86 => EM_386, TargetArchitecture.X64 => EM_X86_64, + TargetArchitecture.ARM => EM_ARM, TargetArchitecture.ARM64 => EM_AARCH64, _ => throw new NotSupportedException("Unsupported architecture") }; @@ -231,6 +232,9 @@ private protected override void EmitRelocations(int sectionIndex, List reloc } } + private void EmitRelocationsARM(int sectionIndex, List relocationList) + { + if (relocationList.Count > 0) + { + Span relocationEntry = stackalloc byte[12]; + var relocationStream = new MemoryStream(12 * relocationList.Count); + _sections[sectionIndex].RelocationStream = relocationStream; + foreach (SymbolicRelocation symbolicRelocation in relocationList) + { + uint symbolIndex = _symbolNameToIndex[symbolicRelocation.SymbolName]; + uint type = symbolicRelocation.Type switch + { + IMAGE_REL_BASED_HIGHLOW => R_ARM_ABS32, + IMAGE_REL_BASED_RELPTR32 => R_ARM_REL32, + IMAGE_REL_BASED_REL32 => R_ARM_REL32, + IMAGE_REL_BASED_THUMB_MOV32 => R_ARM_THM_MOVW_ABS_NC, + IMAGE_REL_BASED_THUMB_MOV32_PCREL => R_ARM_THM_MOVW_PREL_NC, + IMAGE_REL_BASED_THUMB_BRANCH24 => R_ARM_THM_PC22, + _ => throw new NotSupportedException("Unknown relocation type: " + symbolicRelocation.Type) + }; + + long addend = symbolicRelocation.Addend; + if (symbolicRelocation.Type == IMAGE_REL_BASED_REL32) + { + addend -= 4; + } + + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry, (uint)symbolicRelocation.Offset); + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry.Slice(4), ((uint)symbolIndex << 8) | type); + BinaryPrimitives.WriteInt32LittleEndian(relocationEntry.Slice(8), (int)addend); + relocationStream.Write(relocationEntry); + + if (symbolicRelocation.Type is IMAGE_REL_BASED_THUMB_MOV32 or IMAGE_REL_BASED_THUMB_MOV32_PCREL) + { + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry, (uint)(symbolicRelocation.Offset + 4)); + BinaryPrimitives.WriteUInt32LittleEndian(relocationEntry.Slice(4), ((uint)symbolIndex << 8) | (type + 1)); + relocationStream.Write(relocationEntry); + } + } + } + } + private void EmitRelocationsARM64(int sectionIndex, List relocationList) { if (relocationList.Count > 0) @@ -353,6 +399,7 @@ private protected override void EmitObjectFile(string objectFilePath) switch (_machine) { case EM_386: + case EM_ARM: EmitObjectFile(outputFileStream); break; default: @@ -544,7 +591,7 @@ private void EmitObjectFile(FileStream outputFileStream) Link = symTabSectionIndex, Info = section.SectionIndex, Alignment = 8u, - EntrySize = 24u, + EntrySize = (ulong)default(TSize).GetByteCount() * 3u, }; relaSectionHeader.Write(outputFileStream); }